From a2bc6f3bfd35c9785b8b3bb1a788587f298edef6 Mon Sep 17 00:00:00 2001 From: Mykyta Holubakha Date: Thu, 21 Jul 2016 22:47:35 +0300 Subject: [PATCH] Arrange backgrounds only when required --- include/layout.h | 1 + sway/focus.c | 1 + sway/layout.c | 5 ++++- sway/workspace.c | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/layout.h b/include/layout.h index c05e9e69..b982365c 100644 --- a/include/layout.h +++ b/include/layout.h @@ -59,6 +59,7 @@ void move_workspace_to(swayc_t* workspace, swayc_t* destination); void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout); void update_geometry(swayc_t *view); void arrange_windows(swayc_t *container, double width, double height); +void arrange_backgrounds(void); swayc_t *get_focused_container(swayc_t *parent); swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir); diff --git a/sway/focus.c b/sway/focus.c index 97fa4b98..9974ba6a 100644 --- a/sway/focus.c +++ b/sway/focus.c @@ -158,6 +158,7 @@ bool set_focused_container(swayc_t *c) { // rearrange if parent container is tabbed/stacked swayc_t *parent = swayc_tabbed_stacked_ancestor(p); if (parent != NULL) { + arrange_backgrounds(); arrange_windows(parent, -1, -1); } } else if (p->type == C_WORKSPACE) { diff --git a/sway/layout.c b/sway/layout.c index d32b4139..faa108a1 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -961,9 +961,12 @@ void arrange_windows(swayc_t *container, double width, double height) { update_visibility(container); arrange_windows_r(container, width, height); layout_log(&root_container, 0); +} +void arrange_backgrounds(void) { + struct background_config *bg; for (int i = 0; i < desktop_shell.backgrounds->length; ++i) { - struct background_config *bg = desktop_shell.backgrounds->items[i]; + bg = desktop_shell.backgrounds->items[i]; wlc_view_send_to_back(bg->handle); } } diff --git a/sway/workspace.c b/sway/workspace.c index 913a412c..9c3e69a9 100644 --- a/sway/workspace.c +++ b/sway/workspace.c @@ -308,6 +308,7 @@ bool workspace_switch(swayc_t *workspace) { return false; } swayc_t *output = swayc_parent_by_type(workspace, C_OUTPUT); + arrange_backgrounds(); arrange_windows(output, -1, -1); return true; }