diff options
author | Ronan Pigott <rpigott@berkeley.edu> | 2021-08-11 15:18:46 -0700 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-08-12 10:05:12 +0200 |
commit | f67ed6772c27d7ba163e8caa3c9eb8481712a716 (patch) | |
tree | 9ba3d046cf7cb82f759a11b732bb459a8a78e5fe | |
parent | xdg-decoration: let floating clients set borders (diff) | |
download | sway-f67ed6772c27d7ba163e8caa3c9eb8481712a716.tar.gz sway-f67ed6772c27d7ba163e8caa3c9eb8481712a716.tar.zst sway-f67ed6772c27d7ba163e8caa3c9eb8481712a716.zip |
layer_shell: damage previous area when a surface shrinks
When a layer surface shrinks we need to damage the area it previously
occupied, but we don't know the location of all its subsurfaces in the
previous state, so instead damage a rectangle that encloses the entire
previous extent.
-rw-r--r-- | include/sway/layers.h | 1 | ||||
-rw-r--r-- | sway/desktop/layer_shell.c | 14 |
2 files changed, 9 insertions, 6 deletions
diff --git a/include/sway/layers.h b/include/sway/layers.h index 82ac5368..3c33c748 100644 --- a/include/sway/layers.h +++ b/include/sway/layers.h | |||
@@ -22,6 +22,7 @@ struct sway_layer_surface { | |||
22 | struct wl_listener new_subsurface; | 22 | struct wl_listener new_subsurface; |
23 | 23 | ||
24 | struct wlr_box geo; | 24 | struct wlr_box geo; |
25 | struct wlr_box extent; | ||
25 | enum zwlr_layer_shell_v1_layer layer; | 26 | enum zwlr_layer_shell_v1_layer layer; |
26 | }; | 27 | }; |
27 | 28 | ||
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index cadc702a..8a41e705 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -169,6 +169,9 @@ static void arrange_layer(struct sway_output *output, struct wl_list *list, | |||
169 | } | 169 | } |
170 | // Apply | 170 | // Apply |
171 | sway_layer->geo = box; | 171 | sway_layer->geo = box; |
172 | wlr_surface_get_extends(layer->surface, &sway_layer->extent); | ||
173 | sway_layer->extent.x += box.x; | ||
174 | sway_layer->extent.y += box.y; | ||
172 | apply_exclusive(usable_area, state->anchor, state->exclusive_zone, | 175 | apply_exclusive(usable_area, state->anchor, state->exclusive_zone, |
173 | state->margin.top, state->margin.right, | 176 | state->margin.top, state->margin.right, |
174 | state->margin.bottom, state->margin.left); | 177 | state->margin.bottom, state->margin.left); |
@@ -297,11 +300,11 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { | |||
297 | } | 300 | } |
298 | 301 | ||
299 | struct sway_output *output = wlr_output->data; | 302 | struct sway_output *output = wlr_output->data; |
300 | struct wlr_box old_geo = layer->geo; | 303 | struct wlr_box old_extent = layer->extent; |
301 | arrange_layers(output); | 304 | arrange_layers(output); |
302 | 305 | ||
303 | bool geo_changed = | 306 | bool extent_changed = |
304 | memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0; | 307 | memcmp(&old_extent, &layer->extent, sizeof(struct wlr_box)) != 0; |
305 | bool layer_changed = layer->layer != layer_surface->current.layer; | 308 | bool layer_changed = layer->layer != layer_surface->current.layer; |
306 | if (layer_changed) { | 309 | if (layer_changed) { |
307 | wl_list_remove(&layer->link); | 310 | wl_list_remove(&layer->link); |
@@ -309,9 +312,8 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { | |||
309 | &layer->link); | 312 | &layer->link); |
310 | layer->layer = layer_surface->current.layer; | 313 | layer->layer = layer_surface->current.layer; |
311 | } | 314 | } |
312 | if (geo_changed || layer_changed) { | 315 | if (extent_changed || layer_changed) { |
313 | output_damage_surface(output, old_geo.x, old_geo.y, | 316 | output_damage_box(output, &old_extent); |
314 | layer_surface->surface, true); | ||
315 | output_damage_surface(output, layer->geo.x, layer->geo.y, | 317 | output_damage_surface(output, layer->geo.x, layer->geo.y, |
316 | layer_surface->surface, true); | 318 | layer_surface->surface, true); |
317 | } else { | 319 | } else { |