aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Alexander Orzechowski <alex@ozal.ski>2024-01-23 10:17:37 -0500
committerLibravatar Kirill Primak <vyivel@eclair.cafe>2024-02-12 19:19:22 +0300
commit09c360d503eb7309de46af3745001df7dd911438 (patch)
treed69bb2e93c2a241b14f5a2140420535a15b4e75d /sway
parentxdg_shell: Extract struct for popup descriptor (diff)
downloadsway-09c360d503eb7309de46af3745001df7dd911438.tar.gz
sway-09c360d503eb7309de46af3745001df7dd911438.tar.zst
sway-09c360d503eb7309de46af3745001df7dd911438.zip
layer_shell: Handle popups through popup descriptor
We tried to synchronize layer shell popups with the parent layer shell on commits, but this is subtly wrong because we would only update the position for one layer shell that was committed, but not any other layer that might be affected. By moving handling to the scene descriptor we can iterate all popups and ensure they are synchronized.
Diffstat (limited to 'sway')
-rw-r--r--sway/desktop/layer_shell.c14
-rw-r--r--sway/desktop/transaction.c10
-rw-r--r--sway/input/cursor.c2
3 files changed, 14 insertions, 12 deletions
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index 9a35ef95..769d3a86 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -122,6 +122,16 @@ static struct sway_layer_surface *sway_layer_surface_create(
122 return NULL; 122 return NULL;
123 } 123 }
124 124
125 surface->desc.relative = &scene->tree->node;
126
127 if (!scene_descriptor_assign(&popups->node,
128 SWAY_SCENE_DESC_POPUP, &surface->desc)) {
129 sway_log(SWAY_ERROR, "Failed to allocate a popup scene descriptor");
130 wlr_scene_node_destroy(&popups->node);
131 free(surface);
132 return NULL;
133 }
134
125 surface->tree = scene->tree; 135 surface->tree = scene->tree;
126 surface->scene = scene; 136 surface->scene = scene;
127 surface->layer_surface = scene->layer_surface; 137 surface->layer_surface = scene->layer_surface;
@@ -224,10 +234,6 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
224 arrange_layers(surface->output); 234 arrange_layers(surface->output);
225 transaction_commit_dirty(); 235 transaction_commit_dirty();
226 } 236 }
227
228 int lx, ly;
229 wlr_scene_node_coords(&surface->scene->tree->node, &lx, &ly);
230 wlr_scene_node_set_position(&surface->popups->node, lx, ly);
231} 237}
232 238
233static void handle_map(struct wl_listener *listener, void *data) { 239static void handle_map(struct wl_listener *listener, void *data) {
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index e3196e3a..fd1c3d3a 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -612,13 +612,9 @@ void arrange_popups(struct wlr_scene_tree *popups) {
612 struct sway_popup_desc *popup = scene_descriptor_try_get(node, 612 struct sway_popup_desc *popup = scene_descriptor_try_get(node,
613 SWAY_SCENE_DESC_POPUP); 613 SWAY_SCENE_DESC_POPUP);
614 614
615 // the popup layer may have popups from layer_shell surfaces, in this 615 int lx, ly;
616 // case those don't have a scene descriptor, so lets skip those here. 616 wlr_scene_node_coords(popup->relative, &lx, &ly);
617 if (popup) { 617 wlr_scene_node_set_position(node, lx, ly);
618 int lx, ly;
619 wlr_scene_node_coords(popup->relative, &lx, &ly);
620 wlr_scene_node_set_position(node, lx, ly);
621 }
622 } 618 }
623} 619}
624 620
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index f25439cb..25fa603e 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -92,7 +92,7 @@ struct sway_node *node_at_coords(
92 if (!con) { 92 if (!con) {
93 struct sway_popup_desc *popup = 93 struct sway_popup_desc *popup =
94 scene_descriptor_try_get(current, SWAY_SCENE_DESC_POPUP); 94 scene_descriptor_try_get(current, SWAY_SCENE_DESC_POPUP);
95 if (popup) { 95 if (popup && popup->view) {
96 con = popup->view->container; 96 con = popup->view->container;
97 } 97 }
98 } 98 }