aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorKirill Primak <vyivel@posteo.net>2021-09-24 18:07:37 +0300
committerKirill Primak <vyivel@posteo.net>2021-09-25 22:21:51 +0300
commit5fd5d6434e9ebbc453dde33bf58fea931ea2975a (patch)
treef398ab0c564c42314fd8c648e5fc49dcb3ed10fd /sway
parentc11b5db4d6c1b9ce658405d92a23dd2993efca8e (diff)
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.
Diffstat (limited to 'sway')
-rw-r--r--sway/desktop/layer_shell.c33
1 files changed, 18 insertions, 15 deletions
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,
}
// Apply
sway_layer->geo = box;
- wlr_surface_get_extends(layer->surface, &sway_layer->extent);
- sway_layer->extent.x += box.x;
- sway_layer->extent.y += box.y;
apply_exclusive(usable_area, state->anchor, state->exclusive_zone,
state->margin.top, state->margin.right,
state->margin.bottom, state->margin.left);
@@ -297,24 +294,30 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
if (wlr_output == NULL) {
return;
}
- if (layer_surface->current.committed == 0) {
- // The layer surface state didn't change
- return;
- }
struct sway_output *output = wlr_output->data;
struct wlr_box old_extent = layer->extent;
- arrange_layers(output);
+
+ bool layer_changed = false;
+ if (layer_surface->current.committed != 0
+ || layer->mapped != layer_surface->mapped) {
+ layer->mapped = layer_surface->mapped;
+ layer_changed = layer->layer != layer_surface->current.layer;
+ if (layer_changed) {
+ wl_list_remove(&layer->link);
+ wl_list_insert(&output->layers[layer_surface->current.layer],
+ &layer->link);
+ layer->layer = layer_surface->current.layer;
+ }
+ arrange_layers(output);
+ }
+
+ wlr_surface_get_extends(layer_surface->surface, &layer->extent);
+ layer->extent.x += layer->geo.x;
+ layer->extent.y += layer->geo.y;
bool extent_changed =
memcmp(&old_extent, &layer->extent, sizeof(struct wlr_box)) != 0;
- bool layer_changed = layer->layer != layer_surface->current.layer;
- if (layer_changed) {
- wl_list_remove(&layer->link);
- wl_list_insert(&output->layers[layer_surface->current.layer],
- &layer->link);
- layer->layer = layer_surface->current.layer;
- }
if (extent_changed || layer_changed) {
output_damage_box(output, &old_extent);
output_damage_surface(output, layer->geo.x, layer->geo.y,