diff options
author | Kirill Primak <vyivel@eclair.cafe> | 2023-03-05 23:49:45 +0300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-06-02 20:11:42 +0200 |
commit | c9e1dab3187d22ada0232d699e759a628e0ed185 (patch) | |
tree | 2838a14e3144fca71a7c693cd36ced33bf622bf7 | |
parent | xwayland: don't rely on event source being data (diff) | |
download | sway-c9e1dab3187d22ada0232d699e759a628e0ed185.tar.gz sway-c9e1dab3187d22ada0232d699e759a628e0ed185.tar.zst sway-c9e1dab3187d22ada0232d699e759a628e0ed185.zip |
chore: chase wlroots map logic unification
-rw-r--r-- | include/sway/tree/view.h | 4 | ||||
-rw-r--r-- | sway/desktop/layer_shell.c | 22 | ||||
-rw-r--r-- | sway/desktop/output.c | 4 | ||||
-rw-r--r-- | sway/desktop/render.c | 2 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 10 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 87 | ||||
-rw-r--r-- | sway/input/seat.c | 8 | ||||
-rw-r--r-- | sway/lock.c | 2 | ||||
-rw-r--r-- | sway/xdg_activation_v1.c | 2 |
9 files changed, 90 insertions, 51 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 7fc2d95d..960f9d71 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -160,6 +160,8 @@ struct sway_xwayland_view { | |||
160 | struct wl_listener set_window_type; | 160 | struct wl_listener set_window_type; |
161 | struct wl_listener set_hints; | 161 | struct wl_listener set_hints; |
162 | struct wl_listener set_decorations; | 162 | struct wl_listener set_decorations; |
163 | struct wl_listener associate; | ||
164 | struct wl_listener dissociate; | ||
163 | struct wl_listener map; | 165 | struct wl_listener map; |
164 | struct wl_listener unmap; | 166 | struct wl_listener unmap; |
165 | struct wl_listener destroy; | 167 | struct wl_listener destroy; |
@@ -177,6 +179,8 @@ struct sway_xwayland_unmanaged { | |||
177 | struct wl_listener request_fullscreen; | 179 | struct wl_listener request_fullscreen; |
178 | struct wl_listener commit; | 180 | struct wl_listener commit; |
179 | struct wl_listener set_geometry; | 181 | struct wl_listener set_geometry; |
182 | struct wl_listener associate; | ||
183 | struct wl_listener dissociate; | ||
180 | struct wl_listener map; | 184 | struct wl_listener map; |
181 | struct wl_listener unmap; | 185 | struct wl_listener unmap; |
182 | struct wl_listener destroy; | 186 | struct wl_listener destroy; |
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index cf795dc7..50aa6938 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -219,7 +219,7 @@ void arrange_layers(struct sway_output *output) { | |||
219 | wl_list_for_each_reverse(layer, | 219 | wl_list_for_each_reverse(layer, |
220 | &output->layers[layers_above_shell[i]], link) { | 220 | &output->layers[layers_above_shell[i]], link) { |
221 | if (layer->layer_surface->current.keyboard_interactive && | 221 | if (layer->layer_surface->current.keyboard_interactive && |
222 | layer->layer_surface->mapped) { | 222 | layer->layer_surface->surface->mapped) { |
223 | topmost = layer; | 223 | topmost = layer; |
224 | break; | 224 | break; |
225 | } | 225 | } |
@@ -253,7 +253,7 @@ static struct sway_layer_surface *find_mapped_layer_by_client( | |||
253 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], link) { | 253 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], link) { |
254 | struct wl_resource *resource = lsurface->layer_surface->resource; | 254 | struct wl_resource *resource = lsurface->layer_surface->resource; |
255 | if (wl_resource_get_client(resource) == client | 255 | if (wl_resource_get_client(resource) == client |
256 | && lsurface->layer_surface->mapped) { | 256 | && lsurface->layer_surface->surface->mapped) { |
257 | return lsurface; | 257 | return lsurface; |
258 | } | 258 | } |
259 | } | 259 | } |
@@ -293,8 +293,8 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { | |||
293 | 293 | ||
294 | bool layer_changed = false; | 294 | bool layer_changed = false; |
295 | if (layer_surface->current.committed != 0 | 295 | if (layer_surface->current.committed != 0 |
296 | || layer->mapped != layer_surface->mapped) { | 296 | || layer->mapped != layer_surface->surface->mapped) { |
297 | layer->mapped = layer_surface->mapped; | 297 | layer->mapped = layer_surface->surface->mapped; |
298 | layer_changed = layer->layer != layer_surface->current.layer; | 298 | layer_changed = layer->layer != layer_surface->current.layer; |
299 | if (layer_changed) { | 299 | if (layer_changed) { |
300 | wl_list_remove(&layer->link); | 300 | wl_list_remove(&layer->link); |
@@ -349,7 +349,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
349 | wl_container_of(listener, sway_layer, destroy); | 349 | wl_container_of(listener, sway_layer, destroy); |
350 | sway_log(SWAY_DEBUG, "Layer surface destroyed (%s)", | 350 | sway_log(SWAY_DEBUG, "Layer surface destroyed (%s)", |
351 | sway_layer->layer_surface->namespace); | 351 | sway_layer->layer_surface->namespace); |
352 | if (sway_layer->layer_surface->mapped) { | 352 | if (sway_layer->layer_surface->surface->mapped) { |
353 | unmap(sway_layer); | 353 | unmap(sway_layer); |
354 | } | 354 | } |
355 | 355 | ||
@@ -454,9 +454,9 @@ static struct sway_layer_subsurface *create_subsurface( | |||
454 | wl_list_insert(&layer_surface->subsurfaces, &subsurface->link); | 454 | wl_list_insert(&layer_surface->subsurfaces, &subsurface->link); |
455 | 455 | ||
456 | subsurface->map.notify = subsurface_handle_map; | 456 | subsurface->map.notify = subsurface_handle_map; |
457 | wl_signal_add(&wlr_subsurface->events.map, &subsurface->map); | 457 | wl_signal_add(&wlr_subsurface->surface->events.map, &subsurface->map); |
458 | subsurface->unmap.notify = subsurface_handle_unmap; | 458 | subsurface->unmap.notify = subsurface_handle_unmap; |
459 | wl_signal_add(&wlr_subsurface->events.unmap, &subsurface->unmap); | 459 | wl_signal_add(&wlr_subsurface->surface->events.unmap, &subsurface->unmap); |
460 | subsurface->destroy.notify = subsurface_handle_destroy; | 460 | subsurface->destroy.notify = subsurface_handle_destroy; |
461 | wl_signal_add(&wlr_subsurface->events.destroy, &subsurface->destroy); | 461 | wl_signal_add(&wlr_subsurface->events.destroy, &subsurface->destroy); |
462 | subsurface->commit.notify = subsurface_handle_commit; | 462 | subsurface->commit.notify = subsurface_handle_commit; |
@@ -571,9 +571,9 @@ static struct sway_layer_popup *create_popup(struct wlr_xdg_popup *wlr_popup, | |||
571 | popup->parent_layer = parent; | 571 | popup->parent_layer = parent; |
572 | 572 | ||
573 | popup->map.notify = popup_handle_map; | 573 | popup->map.notify = popup_handle_map; |
574 | wl_signal_add(&wlr_popup->base->events.map, &popup->map); | 574 | wl_signal_add(&wlr_popup->base->surface->events.map, &popup->map); |
575 | popup->unmap.notify = popup_handle_unmap; | 575 | popup->unmap.notify = popup_handle_unmap; |
576 | wl_signal_add(&wlr_popup->base->events.unmap, &popup->unmap); | 576 | wl_signal_add(&wlr_popup->base->surface->events.unmap, &popup->unmap); |
577 | popup->destroy.notify = popup_handle_destroy; | 577 | popup->destroy.notify = popup_handle_destroy; |
578 | wl_signal_add(&wlr_popup->base->events.destroy, &popup->destroy); | 578 | wl_signal_add(&wlr_popup->base->events.destroy, &popup->destroy); |
579 | popup->commit.notify = popup_handle_commit; | 579 | popup->commit.notify = popup_handle_commit; |
@@ -661,9 +661,9 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { | |||
661 | sway_layer->destroy.notify = handle_destroy; | 661 | sway_layer->destroy.notify = handle_destroy; |
662 | wl_signal_add(&layer_surface->events.destroy, &sway_layer->destroy); | 662 | wl_signal_add(&layer_surface->events.destroy, &sway_layer->destroy); |
663 | sway_layer->map.notify = handle_map; | 663 | sway_layer->map.notify = handle_map; |
664 | wl_signal_add(&layer_surface->events.map, &sway_layer->map); | 664 | wl_signal_add(&layer_surface->surface->events.map, &sway_layer->map); |
665 | sway_layer->unmap.notify = handle_unmap; | 665 | sway_layer->unmap.notify = handle_unmap; |
666 | wl_signal_add(&layer_surface->events.unmap, &sway_layer->unmap); | 666 | wl_signal_add(&layer_surface->surface->events.unmap, &sway_layer->unmap); |
667 | sway_layer->new_popup.notify = handle_new_popup; | 667 | sway_layer->new_popup.notify = handle_new_popup; |
668 | wl_signal_add(&layer_surface->events.new_popup, &sway_layer->new_popup); | 668 | wl_signal_add(&layer_surface->events.new_popup, &sway_layer->new_popup); |
669 | sway_layer->new_subsurface.notify = handle_new_subsurface; | 669 | sway_layer->new_subsurface.notify = handle_new_subsurface; |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 01bc87bb..fe1fa8af 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -265,7 +265,7 @@ void output_drag_icons_for_each_surface(struct sway_output *output, | |||
265 | double ox = drag_icon->x - output->lx; | 265 | double ox = drag_icon->x - output->lx; |
266 | double oy = drag_icon->y - output->ly; | 266 | double oy = drag_icon->y - output->ly; |
267 | 267 | ||
268 | if (drag_icon->wlr_drag_icon->mapped) { | 268 | if (drag_icon->wlr_drag_icon->surface->mapped) { |
269 | output_surface_for_each_surface(output, | 269 | output_surface_for_each_surface(output, |
270 | drag_icon->wlr_drag_icon->surface, ox, oy, | 270 | drag_icon->wlr_drag_icon->surface, ox, oy, |
271 | iterator, user_data); | 271 | iterator, user_data); |
@@ -295,7 +295,7 @@ static void output_for_each_surface(struct sway_output *output, | |||
295 | if (lock_surface->output != output->wlr_output) { | 295 | if (lock_surface->output != output->wlr_output) { |
296 | continue; | 296 | continue; |
297 | } | 297 | } |
298 | if (!lock_surface->mapped) { | 298 | if (!lock_surface->surface->mapped) { |
299 | continue; | 299 | continue; |
300 | } | 300 | } |
301 | 301 | ||
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 223457b2..21014042 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -1065,7 +1065,7 @@ void output_render(struct render_context *ctx) { | |||
1065 | if (lock_surface->output != wlr_output) { | 1065 | if (lock_surface->output != wlr_output) { |
1066 | continue; | 1066 | continue; |
1067 | } | 1067 | } |
1068 | if (!lock_surface->mapped) { | 1068 | if (!lock_surface->surface->mapped) { |
1069 | continue; | 1069 | continue; |
1070 | } | 1070 | } |
1071 | 1071 | ||
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 9b6456da..377a0f1c 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -104,8 +104,8 @@ static struct sway_xdg_popup *popup_create( | |||
104 | wl_signal_add(&xdg_surface->events.destroy, &popup->destroy); | 104 | wl_signal_add(&xdg_surface->events.destroy, &popup->destroy); |
105 | popup->destroy.notify = popup_handle_destroy; | 105 | popup->destroy.notify = popup_handle_destroy; |
106 | 106 | ||
107 | wl_signal_add(&xdg_surface->events.map, &popup->child.surface_map); | 107 | wl_signal_add(&xdg_surface->surface->events.map, &popup->child.surface_map); |
108 | wl_signal_add(&xdg_surface->events.unmap, &popup->child.surface_unmap); | 108 | wl_signal_add(&xdg_surface->surface->events.unmap, &popup->child.surface_unmap); |
109 | 109 | ||
110 | popup_unconstrain(popup); | 110 | popup_unconstrain(popup); |
111 | 111 | ||
@@ -344,7 +344,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data) | |||
344 | struct wlr_xdg_toplevel *toplevel = xdg_shell_view->view.wlr_xdg_toplevel; | 344 | struct wlr_xdg_toplevel *toplevel = xdg_shell_view->view.wlr_xdg_toplevel; |
345 | struct sway_view *view = &xdg_shell_view->view; | 345 | struct sway_view *view = &xdg_shell_view->view; |
346 | 346 | ||
347 | if (!toplevel->base->mapped) { | 347 | if (!toplevel->base->surface->mapped) { |
348 | return; | 348 | return; |
349 | } | 349 | } |
350 | 350 | ||
@@ -529,10 +529,10 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) { | |||
529 | xdg_shell_view->view.wlr_xdg_toplevel = xdg_surface->toplevel; | 529 | xdg_shell_view->view.wlr_xdg_toplevel = xdg_surface->toplevel; |
530 | 530 | ||
531 | xdg_shell_view->map.notify = handle_map; | 531 | xdg_shell_view->map.notify = handle_map; |
532 | wl_signal_add(&xdg_surface->events.map, &xdg_shell_view->map); | 532 | wl_signal_add(&xdg_surface->surface->events.map, &xdg_shell_view->map); |
533 | 533 | ||
534 | xdg_shell_view->unmap.notify = handle_unmap; | 534 | xdg_shell_view->unmap.notify = handle_unmap; |
535 | wl_signal_add(&xdg_surface->events.unmap, &xdg_shell_view->unmap); | 535 | wl_signal_add(&xdg_surface->surface->events.unmap, &xdg_shell_view->unmap); |
536 | 536 | ||
537 | xdg_shell_view->destroy.notify = handle_destroy; | 537 | xdg_shell_view->destroy.notify = handle_destroy; |
538 | wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_view->destroy); | 538 | wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_view->destroy); |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index bcefc4fd..bb4340f1 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -128,7 +128,7 @@ static void unmanaged_handle_request_activate(struct wl_listener *listener, void | |||
128 | struct sway_xwayland_unmanaged *surface = | 128 | struct sway_xwayland_unmanaged *surface = |
129 | wl_container_of(listener, surface, request_activate); | 129 | wl_container_of(listener, surface, request_activate); |
130 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; | 130 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; |
131 | if (!xsurface->mapped) { | 131 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
132 | return; | 132 | return; |
133 | } | 133 | } |
134 | struct sway_seat *seat = input_manager_current_seat(); | 134 | struct sway_seat *seat = input_manager_current_seat(); |
@@ -140,12 +140,29 @@ static void unmanaged_handle_request_activate(struct wl_listener *listener, void | |||
140 | seat_set_focus_surface(seat, xsurface->surface, false); | 140 | seat_set_focus_surface(seat, xsurface->surface, false); |
141 | } | 141 | } |
142 | 142 | ||
143 | static void unmanaged_handle_associate(struct wl_listener *listener, void *data) { | ||
144 | struct sway_xwayland_unmanaged *surface = | ||
145 | wl_container_of(listener, surface, associate); | ||
146 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; | ||
147 | wl_signal_add(&xsurface->surface->events.map, &surface->map); | ||
148 | surface->map.notify = unmanaged_handle_map; | ||
149 | wl_signal_add(&xsurface->surface->events.unmap, &surface->unmap); | ||
150 | surface->unmap.notify = unmanaged_handle_unmap; | ||
151 | } | ||
152 | |||
153 | static void unmanaged_handle_dissociate(struct wl_listener *listener, void *data) { | ||
154 | struct sway_xwayland_unmanaged *surface = | ||
155 | wl_container_of(listener, surface, dissociate); | ||
156 | wl_list_remove(&surface->map.link); | ||
157 | wl_list_remove(&surface->unmap.link); | ||
158 | } | ||
159 | |||
143 | static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) { | 160 | static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) { |
144 | struct sway_xwayland_unmanaged *surface = | 161 | struct sway_xwayland_unmanaged *surface = |
145 | wl_container_of(listener, surface, destroy); | 162 | wl_container_of(listener, surface, destroy); |
146 | wl_list_remove(&surface->request_configure.link); | 163 | wl_list_remove(&surface->request_configure.link); |
147 | wl_list_remove(&surface->map.link); | 164 | wl_list_remove(&surface->associate.link); |
148 | wl_list_remove(&surface->unmap.link); | 165 | wl_list_remove(&surface->dissociate.link); |
149 | wl_list_remove(&surface->destroy.link); | 166 | wl_list_remove(&surface->destroy.link); |
150 | wl_list_remove(&surface->override_redirect.link); | 167 | wl_list_remove(&surface->override_redirect.link); |
151 | wl_list_remove(&surface->request_activate.link); | 168 | wl_list_remove(&surface->request_activate.link); |
@@ -161,7 +178,7 @@ static void unmanaged_handle_override_redirect(struct wl_listener *listener, voi | |||
161 | wl_container_of(listener, surface, override_redirect); | 178 | wl_container_of(listener, surface, override_redirect); |
162 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; | 179 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; |
163 | 180 | ||
164 | bool mapped = xsurface->mapped; | 181 | bool mapped = xsurface->surface != NULL || xsurface->surface->mapped; |
165 | if (mapped) { | 182 | if (mapped) { |
166 | unmanaged_handle_unmap(&surface->unmap, NULL); | 183 | unmanaged_handle_unmap(&surface->unmap, NULL); |
167 | } | 184 | } |
@@ -188,10 +205,10 @@ static struct sway_xwayland_unmanaged *create_unmanaged( | |||
188 | wl_signal_add(&xsurface->events.request_configure, | 205 | wl_signal_add(&xsurface->events.request_configure, |
189 | &surface->request_configure); | 206 | &surface->request_configure); |
190 | surface->request_configure.notify = unmanaged_handle_request_configure; | 207 | surface->request_configure.notify = unmanaged_handle_request_configure; |
191 | wl_signal_add(&xsurface->events.map, &surface->map); | 208 | wl_signal_add(&xsurface->events.associate, &surface->associate); |
192 | surface->map.notify = unmanaged_handle_map; | 209 | surface->associate.notify = unmanaged_handle_associate; |
193 | wl_signal_add(&xsurface->events.unmap, &surface->unmap); | 210 | wl_signal_add(&xsurface->events.dissociate, &surface->dissociate); |
194 | surface->unmap.notify = unmanaged_handle_unmap; | 211 | surface->dissociate.notify = unmanaged_handle_dissociate; |
195 | wl_signal_add(&xsurface->events.destroy, &surface->destroy); | 212 | wl_signal_add(&xsurface->events.destroy, &surface->destroy); |
196 | surface->destroy.notify = unmanaged_handle_destroy; | 213 | surface->destroy.notify = unmanaged_handle_destroy; |
197 | wl_signal_add(&xsurface->events.set_override_redirect, &surface->override_redirect); | 214 | wl_signal_add(&xsurface->events.set_override_redirect, &surface->override_redirect); |
@@ -474,8 +491,8 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
474 | wl_list_remove(&xwayland_view->set_window_type.link); | 491 | wl_list_remove(&xwayland_view->set_window_type.link); |
475 | wl_list_remove(&xwayland_view->set_hints.link); | 492 | wl_list_remove(&xwayland_view->set_hints.link); |
476 | wl_list_remove(&xwayland_view->set_decorations.link); | 493 | wl_list_remove(&xwayland_view->set_decorations.link); |
477 | wl_list_remove(&xwayland_view->map.link); | 494 | wl_list_remove(&xwayland_view->associate.link); |
478 | wl_list_remove(&xwayland_view->unmap.link); | 495 | wl_list_remove(&xwayland_view->dissociate.link); |
479 | wl_list_remove(&xwayland_view->override_redirect.link); | 496 | wl_list_remove(&xwayland_view->override_redirect.link); |
480 | view_begin_destroy(&xwayland_view->view); | 497 | view_begin_destroy(&xwayland_view->view); |
481 | } | 498 | } |
@@ -520,7 +537,7 @@ static void handle_override_redirect(struct wl_listener *listener, void *data) { | |||
520 | struct sway_view *view = &xwayland_view->view; | 537 | struct sway_view *view = &xwayland_view->view; |
521 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 538 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
522 | 539 | ||
523 | bool mapped = xsurface->mapped; | 540 | bool mapped = xsurface->surface != NULL || xsurface->surface->mapped; |
524 | if (mapped) { | 541 | if (mapped) { |
525 | handle_unmap(&xwayland_view->unmap, NULL); | 542 | handle_unmap(&xwayland_view->unmap, NULL); |
526 | } | 543 | } |
@@ -539,7 +556,7 @@ static void handle_request_configure(struct wl_listener *listener, void *data) { | |||
539 | struct wlr_xwayland_surface_configure_event *ev = data; | 556 | struct wlr_xwayland_surface_configure_event *ev = data; |
540 | struct sway_view *view = &xwayland_view->view; | 557 | struct sway_view *view = &xwayland_view->view; |
541 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 558 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
542 | if (!xsurface->mapped) { | 559 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
543 | wlr_xwayland_surface_configure(xsurface, ev->x, ev->y, | 560 | wlr_xwayland_surface_configure(xsurface, ev->x, ev->y, |
544 | ev->width, ev->height); | 561 | ev->width, ev->height); |
545 | return; | 562 | return; |
@@ -568,7 +585,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data) | |||
568 | wl_container_of(listener, xwayland_view, request_fullscreen); | 585 | wl_container_of(listener, xwayland_view, request_fullscreen); |
569 | struct sway_view *view = &xwayland_view->view; | 586 | struct sway_view *view = &xwayland_view->view; |
570 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 587 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
571 | if (!xsurface->mapped) { | 588 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
572 | return; | 589 | return; |
573 | } | 590 | } |
574 | container_set_fullscreen(view->container, xsurface->fullscreen); | 591 | container_set_fullscreen(view->container, xsurface->fullscreen); |
@@ -582,7 +599,7 @@ static void handle_request_minimize(struct wl_listener *listener, void *data) { | |||
582 | wl_container_of(listener, xwayland_view, request_minimize); | 599 | wl_container_of(listener, xwayland_view, request_minimize); |
583 | struct sway_view *view = &xwayland_view->view; | 600 | struct sway_view *view = &xwayland_view->view; |
584 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 601 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
585 | if (!xsurface->mapped) { | 602 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
586 | return; | 603 | return; |
587 | } | 604 | } |
588 | 605 | ||
@@ -597,7 +614,7 @@ static void handle_request_move(struct wl_listener *listener, void *data) { | |||
597 | wl_container_of(listener, xwayland_view, request_move); | 614 | wl_container_of(listener, xwayland_view, request_move); |
598 | struct sway_view *view = &xwayland_view->view; | 615 | struct sway_view *view = &xwayland_view->view; |
599 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 616 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
600 | if (!xsurface->mapped) { | 617 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
601 | return; | 618 | return; |
602 | } | 619 | } |
603 | if (!container_is_floating(view->container) || | 620 | if (!container_is_floating(view->container) || |
@@ -613,7 +630,7 @@ static void handle_request_resize(struct wl_listener *listener, void *data) { | |||
613 | wl_container_of(listener, xwayland_view, request_resize); | 630 | wl_container_of(listener, xwayland_view, request_resize); |
614 | struct sway_view *view = &xwayland_view->view; | 631 | struct sway_view *view = &xwayland_view->view; |
615 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 632 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
616 | if (!xsurface->mapped) { | 633 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
617 | return; | 634 | return; |
618 | } | 635 | } |
619 | if (!container_is_floating(view->container)) { | 636 | if (!container_is_floating(view->container)) { |
@@ -629,7 +646,7 @@ static void handle_request_activate(struct wl_listener *listener, void *data) { | |||
629 | wl_container_of(listener, xwayland_view, request_activate); | 646 | wl_container_of(listener, xwayland_view, request_activate); |
630 | struct sway_view *view = &xwayland_view->view; | 647 | struct sway_view *view = &xwayland_view->view; |
631 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 648 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
632 | if (!xsurface->mapped) { | 649 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
633 | return; | 650 | return; |
634 | } | 651 | } |
635 | view_request_activate(view, NULL); | 652 | view_request_activate(view, NULL); |
@@ -642,7 +659,7 @@ static void handle_set_title(struct wl_listener *listener, void *data) { | |||
642 | wl_container_of(listener, xwayland_view, set_title); | 659 | wl_container_of(listener, xwayland_view, set_title); |
643 | struct sway_view *view = &xwayland_view->view; | 660 | struct sway_view *view = &xwayland_view->view; |
644 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 661 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
645 | if (!xsurface->mapped) { | 662 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
646 | return; | 663 | return; |
647 | } | 664 | } |
648 | view_update_title(view, false); | 665 | view_update_title(view, false); |
@@ -654,7 +671,7 @@ static void handle_set_class(struct wl_listener *listener, void *data) { | |||
654 | wl_container_of(listener, xwayland_view, set_class); | 671 | wl_container_of(listener, xwayland_view, set_class); |
655 | struct sway_view *view = &xwayland_view->view; | 672 | struct sway_view *view = &xwayland_view->view; |
656 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 673 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
657 | if (!xsurface->mapped) { | 674 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
658 | return; | 675 | return; |
659 | } | 676 | } |
660 | view_execute_criteria(view); | 677 | view_execute_criteria(view); |
@@ -665,7 +682,7 @@ static void handle_set_role(struct wl_listener *listener, void *data) { | |||
665 | wl_container_of(listener, xwayland_view, set_role); | 682 | wl_container_of(listener, xwayland_view, set_role); |
666 | struct sway_view *view = &xwayland_view->view; | 683 | struct sway_view *view = &xwayland_view->view; |
667 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 684 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
668 | if (!xsurface->mapped) { | 685 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
669 | return; | 686 | return; |
670 | } | 687 | } |
671 | view_execute_criteria(view); | 688 | view_execute_criteria(view); |
@@ -701,7 +718,7 @@ static void handle_set_window_type(struct wl_listener *listener, void *data) { | |||
701 | wl_container_of(listener, xwayland_view, set_window_type); | 718 | wl_container_of(listener, xwayland_view, set_window_type); |
702 | struct sway_view *view = &xwayland_view->view; | 719 | struct sway_view *view = &xwayland_view->view; |
703 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 720 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
704 | if (!xsurface->mapped) { | 721 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
705 | return; | 722 | return; |
706 | } | 723 | } |
707 | view_execute_criteria(view); | 724 | view_execute_criteria(view); |
@@ -712,7 +729,7 @@ static void handle_set_hints(struct wl_listener *listener, void *data) { | |||
712 | wl_container_of(listener, xwayland_view, set_hints); | 729 | wl_container_of(listener, xwayland_view, set_hints); |
713 | struct sway_view *view = &xwayland_view->view; | 730 | struct sway_view *view = &xwayland_view->view; |
714 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 731 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
715 | if (!xsurface->mapped) { | 732 | if (xsurface->surface == NULL || !xsurface->surface->mapped) { |
716 | return; | 733 | return; |
717 | } | 734 | } |
718 | const bool hints_urgency = xcb_icccm_wm_hints_get_urgency(xsurface->hints); | 735 | const bool hints_urgency = xcb_icccm_wm_hints_get_urgency(xsurface->hints); |
@@ -727,6 +744,24 @@ static void handle_set_hints(struct wl_listener *listener, void *data) { | |||
727 | } | 744 | } |
728 | } | 745 | } |
729 | 746 | ||
747 | static void handle_associate(struct wl_listener *listener, void *data) { | ||
748 | struct sway_xwayland_view *xwayland_view = | ||
749 | wl_container_of(listener, xwayland_view, associate); | ||
750 | struct wlr_xwayland_surface *xsurface = | ||
751 | xwayland_view->view.wlr_xwayland_surface; | ||
752 | wl_signal_add(&xsurface->surface->events.unmap, &xwayland_view->unmap); | ||
753 | xwayland_view->unmap.notify = handle_unmap; | ||
754 | wl_signal_add(&xsurface->surface->events.map, &xwayland_view->map); | ||
755 | xwayland_view->map.notify = handle_map; | ||
756 | } | ||
757 | |||
758 | static void handle_dissociate(struct wl_listener *listener, void *data) { | ||
759 | struct sway_xwayland_view *xwayland_view = | ||
760 | wl_container_of(listener, xwayland_view, dissociate); | ||
761 | wl_list_remove(&xwayland_view->map.link); | ||
762 | wl_list_remove(&xwayland_view->unmap.link); | ||
763 | } | ||
764 | |||
730 | struct sway_view *view_from_wlr_xwayland_surface( | 765 | struct sway_view *view_from_wlr_xwayland_surface( |
731 | struct wlr_xwayland_surface *xsurface) { | 766 | struct wlr_xwayland_surface *xsurface) { |
732 | return xsurface->data; | 767 | return xsurface->data; |
@@ -796,11 +831,11 @@ struct sway_xwayland_view *create_xwayland_view(struct wlr_xwayland_surface *xsu | |||
796 | &xwayland_view->set_decorations); | 831 | &xwayland_view->set_decorations); |
797 | xwayland_view->set_decorations.notify = handle_set_decorations; | 832 | xwayland_view->set_decorations.notify = handle_set_decorations; |
798 | 833 | ||
799 | wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap); | 834 | wl_signal_add(&xsurface->events.associate, &xwayland_view->associate); |
800 | xwayland_view->unmap.notify = handle_unmap; | 835 | xwayland_view->associate.notify = handle_associate; |
801 | 836 | ||
802 | wl_signal_add(&xsurface->events.map, &xwayland_view->map); | 837 | wl_signal_add(&xsurface->events.dissociate, &xwayland_view->dissociate); |
803 | xwayland_view->map.notify = handle_map; | 838 | xwayland_view->dissociate.notify = handle_dissociate; |
804 | 839 | ||
805 | wl_signal_add(&xsurface->events.set_override_redirect, | 840 | wl_signal_add(&xsurface->events.set_override_redirect, |
806 | &xwayland_view->override_redirect); | 841 | &xwayland_view->override_redirect); |
diff --git a/sway/input/seat.c b/sway/input/seat.c index bcb89b48..5795f40f 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -367,7 +367,7 @@ static void handle_new_node(struct wl_listener *listener, void *data) { | |||
367 | } | 367 | } |
368 | 368 | ||
369 | static void drag_icon_damage_whole(struct sway_drag_icon *icon) { | 369 | static void drag_icon_damage_whole(struct sway_drag_icon *icon) { |
370 | if (!icon->wlr_drag_icon->mapped) { | 370 | if (!icon->wlr_drag_icon->surface->mapped) { |
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | desktop_damage_surface(icon->wlr_drag_icon->surface, icon->x, icon->y, true); | 373 | desktop_damage_surface(icon->wlr_drag_icon->surface, icon->x, icon->y, true); |
@@ -511,9 +511,9 @@ static void handle_start_drag(struct wl_listener *listener, void *data) { | |||
511 | icon->surface_commit.notify = drag_icon_handle_surface_commit; | 511 | icon->surface_commit.notify = drag_icon_handle_surface_commit; |
512 | wl_signal_add(&wlr_drag_icon->surface->events.commit, &icon->surface_commit); | 512 | wl_signal_add(&wlr_drag_icon->surface->events.commit, &icon->surface_commit); |
513 | icon->unmap.notify = drag_icon_handle_unmap; | 513 | icon->unmap.notify = drag_icon_handle_unmap; |
514 | wl_signal_add(&wlr_drag_icon->events.unmap, &icon->unmap); | 514 | wl_signal_add(&wlr_drag_icon->surface->events.unmap, &icon->unmap); |
515 | icon->map.notify = drag_icon_handle_map; | 515 | icon->map.notify = drag_icon_handle_map; |
516 | wl_signal_add(&wlr_drag_icon->events.map, &icon->map); | 516 | wl_signal_add(&wlr_drag_icon->surface->events.map, &icon->map); |
517 | icon->destroy.notify = drag_icon_handle_destroy; | 517 | icon->destroy.notify = drag_icon_handle_destroy; |
518 | wl_signal_add(&wlr_drag_icon->events.destroy, &icon->destroy); | 518 | wl_signal_add(&wlr_drag_icon->events.destroy, &icon->destroy); |
519 | 519 | ||
@@ -1350,7 +1350,7 @@ void seat_set_focus_layer(struct sway_seat *seat, | |||
1350 | } else if (!layer || seat->focused_layer == layer) { | 1350 | } else if (!layer || seat->focused_layer == layer) { |
1351 | return; | 1351 | return; |
1352 | } | 1352 | } |
1353 | assert(layer->mapped); | 1353 | assert(layer->surface->mapped); |
1354 | seat_set_focus_surface(seat, layer->surface, true); | 1354 | seat_set_focus_surface(seat, layer->surface, true); |
1355 | if (layer->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) { | 1355 | if (layer->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) { |
1356 | seat->focused_layer = layer; | 1356 | seat->focused_layer = layer; |
diff --git a/sway/lock.c b/sway/lock.c index 6d9e991b..ae44aa40 100644 --- a/sway/lock.c +++ b/sway/lock.c | |||
@@ -60,7 +60,7 @@ static void destroy_lock_surface(struct sway_session_lock_surface *surf) { | |||
60 | 60 | ||
61 | struct wlr_session_lock_surface_v1 *other; | 61 | struct wlr_session_lock_surface_v1 *other; |
62 | wl_list_for_each(other, &server.session_lock.lock->surfaces, link) { | 62 | wl_list_for_each(other, &server.session_lock.lock->surfaces, link) { |
63 | if (other != surf->lock_surface && other->mapped) { | 63 | if (other != surf->lock_surface && other->surface->mapped) { |
64 | next_focus = other->surface; | 64 | next_focus = other->surface; |
65 | break; | 65 | break; |
66 | } | 66 | } |
diff --git a/sway/xdg_activation_v1.c b/sway/xdg_activation_v1.c index e97989c8..c26ee19a 100644 --- a/sway/xdg_activation_v1.c +++ b/sway/xdg_activation_v1.c | |||
@@ -17,7 +17,7 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | |||
17 | return; | 17 | return; |
18 | } | 18 | } |
19 | 19 | ||
20 | if (!xdg_surface->mapped) { | 20 | if (!xdg_surface->surface->mapped) { |
21 | // This is a startup notification. If we are tracking it, the data | 21 | // This is a startup notification. If we are tracking it, the data |
22 | // field is a launcher_ctx. | 22 | // field is a launcher_ctx. |
23 | struct launcher_ctx *ctx = event->token->data; | 23 | struct launcher_ctx *ctx = event->token->data; |