aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2023-12-05 17:04:12 +0100
committerLibravatar Simon Ser <contact@emersion.fr>2023-12-14 10:48:56 +0100
commit79f82b3e6ace5db980c2934fdd6f47b7e55067c7 (patch)
tree7c2789f0c763f22498872d624508d5143783ef14
parentUpdate sway.5.scd (diff)
downloadsway-79f82b3e6ace5db980c2934fdd6f47b7e55067c7.tar.gz
sway-79f82b3e6ace5db980c2934fdd6f47b7e55067c7.tar.zst
sway-79f82b3e6ace5db980c2934fdd6f47b7e55067c7.zip
desktop/xwayland: correctly handle association on o-r change
When override-redirect changes, we need to setup/teardown listeners, just like we do for map. References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3773 (cherry picked from commit bf2b79b2845a070d84aafaf95e6cfcf9af7eeb9b)
-rw-r--r--sway/desktop/xwayland.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index a52cf4ad..2c6184fd 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -170,6 +170,7 @@ static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
170} 170}
171 171
172static void handle_map(struct wl_listener *listener, void *data); 172static void handle_map(struct wl_listener *listener, void *data);
173static void handle_associate(struct wl_listener *listener, void *data);
173 174
174struct sway_xwayland_view *create_xwayland_view(struct wlr_xwayland_surface *xsurface); 175struct sway_xwayland_view *create_xwayland_view(struct wlr_xwayland_surface *xsurface);
175 176
@@ -178,14 +179,22 @@ static void unmanaged_handle_override_redirect(struct wl_listener *listener, voi
178 wl_container_of(listener, surface, override_redirect); 179 wl_container_of(listener, surface, override_redirect);
179 struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; 180 struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface;
180 181
181 bool mapped = xsurface->surface != NULL && xsurface->surface->mapped; 182 bool associated = xsurface->surface != NULL;
183 bool mapped = associated && xsurface->surface->mapped;
182 if (mapped) { 184 if (mapped) {
183 unmanaged_handle_unmap(&surface->unmap, NULL); 185 unmanaged_handle_unmap(&surface->unmap, NULL);
184 } 186 }
187 if (associated) {
188 unmanaged_handle_dissociate(&surface->dissociate, NULL);
189 }
185 190
186 unmanaged_handle_destroy(&surface->destroy, NULL); 191 unmanaged_handle_destroy(&surface->destroy, NULL);
187 xsurface->data = NULL; 192 xsurface->data = NULL;
193
188 struct sway_xwayland_view *xwayland_view = create_xwayland_view(xsurface); 194 struct sway_xwayland_view *xwayland_view = create_xwayland_view(xsurface);
195 if (associated) {
196 handle_associate(&xwayland_view->associate, NULL);
197 }
189 if (mapped) { 198 if (mapped) {
190 handle_map(&xwayland_view->map, xsurface); 199 handle_map(&xwayland_view->map, xsurface);
191 } 200 }
@@ -531,20 +540,30 @@ static void handle_map(struct wl_listener *listener, void *data) {
531 transaction_commit_dirty(); 540 transaction_commit_dirty();
532} 541}
533 542
543static void handle_dissociate(struct wl_listener *listener, void *data);
544
534static void handle_override_redirect(struct wl_listener *listener, void *data) { 545static void handle_override_redirect(struct wl_listener *listener, void *data) {
535 struct sway_xwayland_view *xwayland_view = 546 struct sway_xwayland_view *xwayland_view =
536 wl_container_of(listener, xwayland_view, override_redirect); 547 wl_container_of(listener, xwayland_view, override_redirect);
537 struct sway_view *view = &xwayland_view->view; 548 struct sway_view *view = &xwayland_view->view;
538 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; 549 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
539 550
540 bool mapped = xsurface->surface != NULL && xsurface->surface->mapped; 551 bool associated = xsurface->surface != NULL;
552 bool mapped = associated && xsurface->surface->mapped;
541 if (mapped) { 553 if (mapped) {
542 handle_unmap(&xwayland_view->unmap, NULL); 554 handle_unmap(&xwayland_view->unmap, NULL);
543 } 555 }
556 if (associated) {
557 handle_dissociate(&xwayland_view->dissociate, NULL);
558 }
544 559
545 handle_destroy(&xwayland_view->destroy, view); 560 handle_destroy(&xwayland_view->destroy, view);
546 xsurface->data = NULL; 561 xsurface->data = NULL;
562
547 struct sway_xwayland_unmanaged *unmanaged = create_unmanaged(xsurface); 563 struct sway_xwayland_unmanaged *unmanaged = create_unmanaged(xsurface);
564 if (associated) {
565 unmanaged_handle_associate(&unmanaged->associate, NULL);
566 }
548 if (mapped) { 567 if (mapped) {
549 unmanaged_handle_map(&unmanaged->map, xsurface); 568 unmanaged_handle_map(&unmanaged->map, xsurface);
550 } 569 }