aboutsummaryrefslogtreecommitdiff
path: root/client.h
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-03-16 23:08:17 -0600
committerLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-03-16 23:08:17 -0600
commit294fb324d8f67c33552b15d3f1f79fe524d5f8fd (patch)
tree3f279bf3efb9af7da0fc7bfa28c66de1b4951d03 /client.h
parent2768af5a9bfd7cb5f874a8d61f4bc9a1188b82fd (diff)
constraint popups to its parent client
Closes: #146 Closes: #155
Diffstat (limited to 'client.h')
-rw-r--r--client.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/client.h b/client.h
index 191dcc5..22454a5 100644
--- a/client.h
+++ b/client.h
@@ -179,3 +179,24 @@ client_surface_at(Client *c, double cx, double cy, double *sx, double *sy)
#endif
return wlr_xdg_surface_surface_at(c->surface.xdg, cx, cy, sx, sy);
}
+
+static inline Client *
+client_from_popup(struct wlr_xdg_popup *popup)
+{
+ struct wlr_xdg_surface *surface = popup->base;
+
+ while (1) {
+ switch (surface->role) {
+ case WLR_XDG_SURFACE_ROLE_POPUP:
+ if (!wlr_surface_is_xdg_surface(surface->popup->parent))
+ return NULL;
+
+ surface = wlr_xdg_surface_from_wlr_surface(surface->popup->parent);
+ break;
+ case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
+ return surface->data;
+ case WLR_XDG_SURFACE_ROLE_NONE:
+ return NULL;
+ }
+ }
+}