aboutsummaryrefslogtreecommitdiff
path: root/include/wlr
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-11-13 10:31:00 +0100
committerSimon Ser <contact@emersion.fr>2023-11-13 10:31:00 +0100
commit319e4125ab699c2346c7d1b66ff8d06064ec6ac2 (patch)
treeeb9a317402d5f0f221aaf1f7989df679ff8deed9 /include/wlr
parent5de9e1a99d6642c2d09d589aa37ff0a8945dcee1 (diff)
xdg-shell: add wlr_xdg_{toplevel,popup}_try_from_wlr_surface()
Convenience helpers for compositors. Saves them the trouble of manually checking the role (and if they forget to do so, prevents an invalid cast).
Diffstat (limited to 'include/wlr')
-rw-r--r--include/wlr/types/wlr_xdg_shell.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h
index b81b7a3b..29ced596 100644
--- a/include/wlr/types/wlr_xdg_shell.h
+++ b/include/wlr/types/wlr_xdg_shell.h
@@ -486,6 +486,24 @@ struct wlr_surface *wlr_xdg_surface_popup_surface_at(
struct wlr_xdg_surface *wlr_xdg_surface_try_from_wlr_surface(struct wlr_surface *surface);
/**
+ * Get a struct wlr_xdg_toplevel from a struct wlr_surface.
+ *
+ * Returns NULL if the surface doesn't have the xdg_surface role, the
+ * xdg_surface is not a toplevel, or the xdg_surface/xdg_toplevel objects have
+ * been destroyed.
+ */
+struct wlr_xdg_toplevel *wlr_xdg_toplevel_try_from_wlr_surface(struct wlr_surface *surface);
+
+/**
+ * Get a struct wlr_xdg_popup from a struct wlr_surface.
+ *
+ * Returns NULL if the surface doesn't have the xdg_surface role, the
+ * xdg_surface is not a popup, or the xdg_surface/xdg_popup objects have
+ * been destroyed.
+ */
+struct wlr_xdg_popup *wlr_xdg_popup_try_from_wlr_surface(struct wlr_surface *surface);
+
+/**
* Get the surface geometry.
*
* This is either the geometry as set by the client, or defaulted to the bounds