commit d4f2c6bfd638d45736512691f06081cf314370bd
parent 25db04539216fa6bf05ad39cdeeeca6df6b69e60
Author: Leonardo Hernández Hernández <leohdz172@proton.me>
Date: Mon, 21 Aug 2023 17:53:24 -0600
chase wlroots!4288
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4288
Diffstat:
| M | client.h | | | 39 | +++++++++++++++++++++------------------ |
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/client.h b/client.h
@@ -54,7 +54,7 @@ client_surface(Client *c)
static inline int
toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl)
{
- struct wlr_xdg_surface *xdg_surface;
+ struct wlr_xdg_surface *xdg_surface, *tmp_xdg_surface;
struct wlr_surface *root_surface;
struct wlr_layer_surface_v1 *layer_surface;
Client *c = NULL;
@@ -82,24 +82,27 @@ toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl)
goto end;
}
- if ((xdg_surface = wlr_xdg_surface_try_from_wlr_surface(root_surface))) {
- while (1) {
- switch (xdg_surface->role) {
- case WLR_XDG_SURFACE_ROLE_POPUP:
- if (!xdg_surface->popup->parent)
- return -1;
- else if (!wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent))
- return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
-
- xdg_surface = wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
- break;
- case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
- c = xdg_surface->data;
- type = c->type;
- goto end;
- case WLR_XDG_SURFACE_ROLE_NONE:
+ xdg_surface = wlr_xdg_surface_try_from_wlr_surface(root_surface);
+ while (xdg_surface) {
+ tmp_xdg_surface = NULL;
+ switch (xdg_surface->role) {
+ case WLR_XDG_SURFACE_ROLE_POPUP:
+ if (!xdg_surface->popup || !xdg_surface->popup->parent)
return -1;
- }
+
+ tmp_xdg_surface = wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
+
+ if (!tmp_xdg_surface)
+ return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
+
+ xdg_surface = tmp_xdg_surface;
+ break;
+ case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
+ c = xdg_surface->data;
+ type = c->type;
+ goto end;
+ case WLR_XDG_SURFACE_ROLE_NONE:
+ return -1;
}
}