diff options
author | 2017-11-22 01:47:05 +0300 | |
---|---|---|
committer | 2017-12-29 12:11:51 -0700 | |
commit | 87a55dfe5cd6805906fc08f3f03083a2649e84a0 (patch) | |
tree | a5e09e32b8016931f663425437dcac376858e1bf /swaybar/tray/tray.c | |
parent | Allow correct item to get icon updates for both kde and gtk implementation (diff) | |
download | sway-87a55dfe5cd6805906fc08f3f03083a2649e84a0.tar.gz sway-87a55dfe5cd6805906fc08f3f03083a2649e84a0.tar.zst sway-87a55dfe5cd6805906fc08f3f03083a2649e84a0.zip |
Fix icon updating on secondary outputs
Diffstat (limited to 'swaybar/tray/tray.c')
-rw-r--r-- | swaybar/tray/tray.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/swaybar/tray/tray.c b/swaybar/tray/tray.c index 3c5492f7..a5248f6c 100644 --- a/swaybar/tray/tray.c +++ b/swaybar/tray/tray.c | |||
@@ -372,6 +372,24 @@ uint32_t tray_render(struct output *output, struct config *config) { | |||
372 | return tray_width; | 372 | return tray_width; |
373 | } | 373 | } |
374 | 374 | ||
375 | bool clean_item = false; | ||
376 | // Clean item if only one output has tray or this is the last output | ||
377 | if (swaybar.outputs->length == 1 || config->tray_output || output->idx == swaybar.outputs->length-1) { | ||
378 | clean_item = true; | ||
379 | // More trickery is needed in case you plug off secondary outputs on live | ||
380 | } else { | ||
381 | int active_outputs = 0; | ||
382 | for (int i = 0; i < swaybar.outputs->length; i++) { | ||
383 | struct output *output = swaybar.outputs->items[i]; | ||
384 | if (output->active) { | ||
385 | active_outputs++; | ||
386 | } | ||
387 | } | ||
388 | if (active_outputs == 1) { | ||
389 | clean_item = true; | ||
390 | } | ||
391 | } | ||
392 | |||
375 | for (int i = 0; i < tray->items->length; ++i) { | 393 | for (int i = 0; i < tray->items->length; ++i) { |
376 | struct StatusNotifierItem *item = | 394 | struct StatusNotifierItem *item = |
377 | tray->items->items[i]; | 395 | tray->items->items[i]; |
@@ -398,6 +416,7 @@ uint32_t tray_render(struct output *output, struct config *config) { | |||
398 | list_add(output->items, render_item); | 416 | list_add(output->items, render_item); |
399 | } else if (item->dirty) { | 417 | } else if (item->dirty) { |
400 | // item needs re-render | 418 | // item needs re-render |
419 | sway_log(L_DEBUG, "Redrawing item %d for output %d", i, output->idx); | ||
401 | sni_icon_ref_free(render_item); | 420 | sni_icon_ref_free(render_item); |
402 | output->items->items[j] = render_item = | 421 | output->items->items[j] = render_item = |
403 | sni_icon_ref_create(item, item_size); | 422 | sni_icon_ref_create(item, item_size); |
@@ -413,7 +432,9 @@ uint32_t tray_render(struct output *output, struct config *config) { | |||
413 | cairo_fill(cairo); | 432 | cairo_fill(cairo); |
414 | cairo_set_operator(cairo, op); | 433 | cairo_set_operator(cairo, op); |
415 | 434 | ||
416 | item->dirty = false; | 435 | if (clean_item) { |
436 | item->dirty = false; | ||
437 | } | ||
417 | } | 438 | } |
418 | 439 | ||
419 | 440 | ||