mirror of
https://github.com/swaywm/sway.git
synced 2026-03-30 11:10:59 -04:00
Fix icon updating on secondary outputs
This commit is contained in:
parent
cbd0c49a8c
commit
87a55dfe5c
3 changed files with 26 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue