From 5c8dc9cb73be8b3fde25475dbc3e5f931f73f642 Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Tue, 31 Oct 2017 12:42:08 -0600 Subject: Correct context menu placement if bar is bottom Originally the context menu would draw at the top of the screen, which is incorrect. --- include/swaybar/bar.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/swaybar/bar.h') diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 50d36e76..6f2a7083 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -21,6 +21,7 @@ struct bar { struct output { struct window *window; struct registry *registry; + struct output_state *state; list_t *workspaces; #ifdef ENABLE_TRAY list_t *items; -- cgit v1.2.3 From 87a55dfe5cd6805906fc08f3f03083a2649e84a0 Mon Sep 17 00:00:00 2001 From: gnidorah Date: Wed, 22 Nov 2017 01:47:05 +0300 Subject: Fix icon updating on secondary outputs --- include/swaybar/bar.h | 1 + swaybar/bar.c | 3 +++ swaybar/tray/tray.c | 23 ++++++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'include/swaybar/bar.h') 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; + } } -- cgit v1.2.3 From 4d34bc393e7b144fbc105537f17bee329c44814d Mon Sep 17 00:00:00 2001 From: gnidorah Date: Wed, 22 Nov 2017 09:04:46 +0300 Subject: Keep tray separate --- include/swaybar/bar.h | 2 ++ swaybar/bar.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'include/swaybar/bar.h') diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 96c4365c..7ec09e3e 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -29,7 +29,9 @@ struct output { char *name; int idx; bool focused; +#ifdef ENABLE_TRAY bool active; +#endif }; struct workspace { diff --git a/swaybar/bar.c b/swaybar/bar.c index 49a698b7..f1b42d2c 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -295,12 +295,14 @@ 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); +#ifdef ENABLE_TRAY + output->active = true; } else { output->active = false; +#endif } } } -- cgit v1.2.3