aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kirill Primak <vyivel@posteo.net>2021-09-24 18:07:37 +0300
committerLibravatar Kirill Primak <vyivel@posteo.net>2021-09-25 22:21:51 +0300
commit5fd5d6434e9ebbc453dde33bf58fea931ea2975a (patch)
treef398ab0c564c42314fd8c648e5fc49dcb3ed10fd
parentlayer-shell: check `committed` bitmask (diff)
downloadsway-5fd5d6434e9ebbc453dde33bf58fea931ea2975a.tar.gz
sway-5fd5d6434e9ebbc453dde33bf58fea931ea2975a.tar.zst
sway-5fd5d6434e9ebbc453dde33bf58fea931ea2975a.zip
layer-shell: fix commit handler
This commit makes sure the extents are kept up-to-date, fixes not damaging the surface if its layer shell-specific state didn't change, and adds a check if the layer shell-specific state didn't change but the surface got mapped/unmapped, which could affect keyboard focus.
-rw-r--r--include/sway/layers.h1
-rw-r--r--sway/desktop/layer_shell.c33
2 files changed, 19 insertions, 15 deletions
diff --git a/include/sway/layers.h b/include/sway/layers.h
index 3c33c748..224dc5e6 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 bool mapped;
25 struct wlr_box extent; 26 struct wlr_box extent;
26 enum zwlr_layer_shell_v1_layer layer; 27 enum zwlr_layer_shell_v1_layer layer;
27}; 28};
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index 2b4b2027..7b249be3 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -168,9 +168,6 @@ static void arrange_layer(struct sway_output *output, struct wl_list *list,
168 } 168 }
169 // Apply 169 // Apply
170 sway_layer->geo = box; 170 sway_layer->geo = box;
171 wlr_surface_get_extends(layer->surface, &sway_layer->extent);
172 sway_layer->extent.x += box.x;
173 sway_layer->extent.y += box.y;
174 apply_exclusive(usable_area, state->anchor, state->exclusive_zone, 171 apply_exclusive(usable_area, state->anchor, state->exclusive_zone,
175 state->margin.top, state->margin.right, 172 state->margin.top, state->margin.right,
176 state->margin.bottom, state->margin.left); 173 state->margin.bottom, state->margin.left);
@@ -297,24 +294,30 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
297 if (wlr_output == NULL) { 294 if (wlr_output == NULL) {
298 return; 295 return;
299 } 296 }
300 if (layer_surface->current.committed == 0) {
301 // The layer surface state didn't change
302 return;
303 }
304 297
305 struct sway_output *output = wlr_output->data; 298 struct sway_output *output = wlr_output->data;
306 struct wlr_box old_extent = layer->extent; 299 struct wlr_box old_extent = layer->extent;
307 arrange_layers(output); 300
301 bool layer_changed = false;
302 if (layer_surface->current.committed != 0
303 || layer->mapped != layer_surface->mapped) {
304 layer->mapped = layer_surface->mapped;
305 layer_changed = layer->layer != layer_surface->current.layer;
306 if (layer_changed) {
307 wl_list_remove(&layer->link);
308 wl_list_insert(&output->layers[layer_surface->current.layer],
309 &layer->link);
310 layer->layer = layer_surface->current.layer;
311 }
312 arrange_layers(output);
313 }
314
315 wlr_surface_get_extends(layer_surface->surface, &layer->extent);
316 layer->extent.x += layer->geo.x;
317 layer->extent.y += layer->geo.y;
308 318
309 bool extent_changed = 319 bool extent_changed =
310 memcmp(&old_extent, &layer->extent, sizeof(struct wlr_box)) != 0; 320 memcmp(&old_extent, &layer->extent, sizeof(struct wlr_box)) != 0;
311 bool layer_changed = layer->layer != layer_surface->current.layer;
312 if (layer_changed) {
313 wl_list_remove(&layer->link);
314 wl_list_insert(&output->layers[layer_surface->current.layer],
315 &layer->link);
316 layer->layer = layer_surface->current.layer;
317 }
318 if (extent_changed || layer_changed) { 321 if (extent_changed || layer_changed) {
319 output_damage_box(output, &old_extent); 322 output_damage_box(output, &old_extent);
320 output_damage_surface(output, layer->geo.x, layer->geo.y, 323 output_damage_surface(output, layer->geo.x, layer->geo.y,