diff options
author | Simon Ser <contact@emersion.fr> | 2022-10-18 14:31:05 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-10-19 09:26:03 +0000 |
commit | 2ee59e1a08ba7b2e50a5122f074014111d8d7556 (patch) | |
tree | ac795c8fd7bd3ee6cfcff31f0e7f8d4a87dab704 /xwayland | |
parent | c6d8a11d2c438d514473b1cbe20e5550e7227472 (diff) |
xwyland/xwm: simplify unpaired_link handling
Always keep it initialized, so that we don't have to check for
xsurface->surface_id.
Will help with WL_SURFACE_SERIAL support, which adds a new way for
a surface to be unpaired.
Diffstat (limited to 'xwayland')
-rw-r--r-- | xwayland/xwm.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 95ef4194..f0d5bff4 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -159,6 +159,7 @@ static struct wlr_xwayland_surface *xwayland_surface_create( wl_list_init(&surface->children); wl_list_init(&surface->stack_link); wl_list_init(&surface->parent_link); + wl_list_init(&surface->unpaired_link); wl_signal_init(&surface->events.destroy); wl_signal_init(&surface->events.request_configure); wl_signal_init(&surface->events.request_move); @@ -406,9 +407,7 @@ static void xwayland_surface_destroy( child->parent = NULL; } - if (xsurface->surface_id) { - wl_list_remove(&xsurface->unpaired_link); - } + wl_list_remove(&xsurface->unpaired_link); if (xsurface->surface) { wl_list_remove(&xsurface->surface_destroy.link); @@ -879,6 +878,10 @@ static void xwm_map_shell_surface(struct wlr_xwm *xwm, return; } + wl_list_remove(&xsurface->unpaired_link); + wl_list_init(&xsurface->unpaired_link); + xsurface->surface_id = 0; + xsurface->surface = surface; // read all surface properties @@ -913,13 +916,12 @@ static void xsurface_unmap(struct wlr_xwayland_surface *surface) { xwm_set_net_client_list(surface->xwm); } - if (surface->surface_id) { - // Make sure we're not on the unpaired surface list or we - // could be assigned a surface during surface creation that - // was mapped before this unmap request. - wl_list_remove(&surface->unpaired_link); - surface->surface_id = 0; - } + // Make sure we're not on the unpaired surface list or we + // could be assigned a surface during surface creation that + // was mapped before this unmap request. + wl_list_remove(&surface->unpaired_link); + wl_list_init(&surface->unpaired_link); + surface->surface_id = 0; if (surface->surface) { wl_list_remove(&surface->surface_destroy.link); @@ -1129,6 +1131,7 @@ static void xwm_handle_surface_id_message(struct wlr_xwm *xwm, xwm_map_shell_surface(xwm, xsurface, surface); } else { xsurface->surface_id = id; + wl_list_remove(&xsurface->unpaired_link); wl_list_insert(&xwm->unpaired_surfaces, &xsurface->unpaired_link); } } @@ -1655,8 +1658,6 @@ static void handle_compositor_new_surface(struct wl_listener *listener, wl_list_for_each(xsurface, &xwm->unpaired_surfaces, unpaired_link) { if (xsurface->surface_id == surface_id) { xwm_map_shell_surface(xwm, xsurface, surface); - xsurface->surface_id = 0; - wl_list_remove(&xsurface->unpaired_link); xcb_flush(xwm->xcb_conn); return; } |