From a9086518219c0ace4a5d81c2f7219dae3b6aa20c Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Wed, 26 Jul 2023 20:32:33 +0300 Subject: [PATCH] chore: chase wlroots xdg-surface role rework --- sway/desktop/layer_shell.c | 10 +++++----- sway/input/cursor.c | 3 ++- sway/tree/container.c | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index d990d92a..8c6cedfe 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -35,13 +35,13 @@ struct wlr_layer_surface_v1 *toplevel_layer_surface_from_surface( } // Layer surface popup - struct wlr_xdg_surface * xdg_popup = NULL; - if ((xdg_popup = wlr_xdg_surface_try_from_wlr_surface(surface)) && - xdg_popup->role == WLR_XDG_SURFACE_ROLE_POPUP) { - if (!xdg_popup->popup->parent) { + struct wlr_xdg_surface *xdg_surface = NULL; + if ((xdg_surface = wlr_xdg_surface_try_from_wlr_surface(surface)) && + xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP && xdg_surface->popup != NULL) { + if (!xdg_surface->popup->parent) { return NULL; } - surface = wlr_surface_get_root_surface(xdg_popup->popup->parent); + surface = wlr_surface_get_root_surface(xdg_surface->popup->parent); continue; } diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 62c74d04..44a5d6f7 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -56,7 +56,8 @@ static struct wlr_surface *layer_surface_at(struct sway_output *output, static bool surface_is_xdg_popup(struct wlr_surface *surface) { struct wlr_xdg_surface *xdg_surface = wlr_xdg_surface_try_from_wlr_surface(surface); - return xdg_surface != NULL && xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP; + return xdg_surface != NULL && xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP && + xdg_surface->popup != NULL; } static struct wlr_surface *layer_surface_popup_at(struct sway_output *output, diff --git a/sway/tree/container.c b/sway/tree/container.c index d2c4ffc4..8c344a6d 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -394,7 +394,7 @@ static bool surface_is_popup(struct wlr_surface *surface) { } struct wlr_xdg_surface *xdg_surface = wlr_xdg_surface_try_from_wlr_surface(surface); - return xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP; + return xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP && xdg_surface->popup != NULL; } struct sway_container *container_at(struct sway_workspace *workspace,