diff options
| author | gnidorah <gnidorah@users.noreply.github.com> | 2017-11-22 01:47:05 +0300 |
|---|---|---|
| committer | Calvin Lee <cyrus296@gmail.com> | 2017-12-29 12:11:51 -0700 |
| commit | 87a55dfe5cd6805906fc08f3f03083a2649e84a0 (patch) | |
| tree | a5e09e32b8016931f663425437dcac376858e1bf | |
| parent | cbd0c49a8cf5a11d1bcc27629a7a71f7fb9d9df2 (diff) | |
Fix icon updating on secondary outputs
| -rw-r--r-- | include/swaybar/bar.h | 1 | ||||
| -rw-r--r-- | swaybar/bar.c | 3 | ||||
| -rw-r--r-- | swaybar/tray/tray.c | 23 |
3 files changed, 26 insertions, 1 deletions
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 6f2a7083..96c4365c 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -29,6 +29,7 @@ struct output { char *name; int idx; bool focused; + bool active; }; struct workspace { diff --git a/swaybar/bar.c b/swaybar/bar.c index 9cd17303..49a698b7 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -295,9 +295,12 @@ void bar_run(struct bar *bar) { for (i = 0; i < bar->outputs->length; ++i) { struct output *output = bar->outputs->items[i]; if (window_prerender(output->window) && output->window->cairo) { + output->active = true; render(output, bar->config, bar->status); window_render(output->window); wl_display_flush(output->registry->display); + } else { + output->active = false; } } } 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) { return tray_width; } + bool clean_item = false; + // Clean item if only one output has tray or this is the last output + if (swaybar.outputs->length == 1 || config->tray_output || output->idx == swaybar.outputs->length-1) { + clean_item = true; + // More trickery is needed in case you plug off secondary outputs on live + } else { + int active_outputs = 0; + for (int i = 0; i < swaybar.outputs->length; i++) { + struct output *output = swaybar.outputs->items[i]; + if (output->active) { + active_outputs++; + } + } + if (active_outputs == 1) { + clean_item = true; + } + } + for (int i = 0; i < tray->items->length; ++i) { struct StatusNotifierItem *item = tray->items->items[i]; @@ -398,6 +416,7 @@ uint32_t tray_render(struct output *output, struct config *config) { list_add(output->items, render_item); } else if (item->dirty) { // item needs re-render + sway_log(L_DEBUG, "Redrawing item %d for output %d", i, output->idx); sni_icon_ref_free(render_item); output->items->items[j] = render_item = sni_icon_ref_create(item, item_size); @@ -413,7 +432,9 @@ uint32_t tray_render(struct output *output, struct config *config) { cairo_fill(cairo); cairo_set_operator(cairo, op); - item->dirty = false; + if (clean_item) { + item->dirty = false; + } } |
