diff options
author | Kirill Primak <vyivel@eclair.cafe> | 2022-11-06 13:39:34 +0300 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2022-11-06 17:00:00 +0300 |
commit | 32daa43a454bcea1306ad0976fd4161ce8c7e86f (patch) | |
tree | 7aa01e16938a12f848d4c33f8856db4c3a74aa16 /xwayland | |
parent | acd5a64fd128bc1efbad0bfca3e8d8088123c439 (diff) |
xwayland/xwm: use role object destroy handler
Diffstat (limited to 'xwayland')
-rw-r--r-- | xwayland/xwm.c | 69 |
1 files changed, 30 insertions, 39 deletions
diff --git a/xwayland/xwm.c b/xwayland/xwm.c index f0d5bff4..8f4c0ebb 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -384,11 +384,11 @@ static void xsurface_set_net_wm_state(struct wlr_xwayland_surface *xsurface) { i, property); } -static void xsurface_unmap(struct wlr_xwayland_surface *surface); - static void xwayland_surface_destroy( struct wlr_xwayland_surface *xsurface) { - xsurface_unmap(xsurface); + if (xsurface->surface != NULL) { + wlr_surface_destroy_role_object(xsurface->surface); + } wl_signal_emit_mutable(&xsurface->events.destroy, xsurface); @@ -409,11 +409,6 @@ static void xwayland_surface_destroy( wl_list_remove(&xsurface->unpaired_link); - if (xsurface->surface) { - wl_list_remove(&xsurface->surface_destroy.link); - xsurface->surface->role_data = NULL; - } - wl_event_source_remove(xsurface->ping_timer); free(xsurface->title); @@ -858,18 +853,35 @@ static void xwayland_surface_role_precommit(struct wlr_surface *wlr_surface, } } +static void xwayland_surface_role_destroy(struct wlr_surface *wlr_surface) { + assert(wlr_surface->role == &xwayland_surface_role); + struct wlr_xwayland_surface *surface = wlr_surface->role_data; + if (surface == NULL) { + return; + } + + if (surface->mapped) { + wl_signal_emit_mutable(&surface->events.unmap, surface); + surface->mapped = false; + xwm_set_net_client_list(surface->xwm); + } + + // 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; + surface->surface = NULL; +} + static const struct wlr_surface_role xwayland_surface_role = { .name = "wlr_xwayland_surface", .commit = xwayland_surface_role_commit, .precommit = xwayland_surface_role_precommit, + .destroy = xwayland_surface_role_destroy, }; -static void handle_surface_destroy(struct wl_listener *listener, void *data) { - struct wlr_xwayland_surface *surface = - wl_container_of(listener, surface, surface_destroy); - xsurface_unmap(surface); -} - static void xwm_map_shell_surface(struct wlr_xwm *xwm, struct wlr_xwayland_surface *xsurface, struct wlr_surface *surface) { if (!wlr_surface_set_role(surface, &xwayland_surface_role, xsurface, @@ -904,30 +916,6 @@ static void xwm_map_shell_surface(struct wlr_xwm *xwm, if (xwm->xres) { read_surface_client_id(xwm, xsurface); } - - xsurface->surface_destroy.notify = handle_surface_destroy; - wl_signal_add(&surface->events.destroy, &xsurface->surface_destroy); -} - -static void xsurface_unmap(struct wlr_xwayland_surface *surface) { - if (surface->mapped) { - wl_signal_emit_mutable(&surface->events.unmap, surface); - surface->mapped = false; - xwm_set_net_client_list(surface->xwm); - } - - // 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); - surface->surface->role_data = NULL; - surface->surface = NULL; - } } static void xwm_handle_create_notify(struct wlr_xwm *xwm, @@ -1098,7 +1086,10 @@ static void xwm_handle_unmap_notify(struct wlr_xwm *xwm, return; } - xsurface_unmap(xsurface); + if (xsurface->surface != NULL) { + wlr_surface_destroy_role_object(xsurface->surface); + } + xsurface_set_wm_state(xsurface, XCB_ICCCM_WM_STATE_WITHDRAWN); } |