aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2021-01-07 15:11:29 +0100
committerSimon Ser <contact@emersion.fr>2021-01-08 12:05:13 +0100
commit4ee4a36c0cc961c93e48a7994dbe55173f827d25 (patch)
tree87e3db0d8e3450b7af8f622b8112691fd2e89f13
parent8f63557ed7695a8ae5a4acb85a2693dc36be85bb (diff)
layer shell: add wlr_layer_surface_v1_popup_surface_at()
This function will allow compositors to implement input handling in a way consistent with rendering more easily. Calling wlr_layer_surface_v1_surface_at() and checking if the result is a wlr_xdg_popup is flawed as there may be subsurfaces in the popup tree.
-rw-r--r--include/wlr/types/wlr_layer_shell_v1.h9
-rw-r--r--types/wlr_layer_shell_v1.c13
2 files changed, 21 insertions, 1 deletions
diff --git a/include/wlr/types/wlr_layer_shell_v1.h b/include/wlr/types/wlr_layer_shell_v1.h
index f13eadb7..007c612b 100644
--- a/include/wlr/types/wlr_layer_shell_v1.h
+++ b/include/wlr/types/wlr_layer_shell_v1.h
@@ -151,4 +151,13 @@ struct wlr_surface *wlr_layer_surface_v1_surface_at(
struct wlr_layer_surface_v1 *surface, double sx, double sy,
double *sub_x, double *sub_y);
+/**
+ * Find a surface within this layer-surface's popup tree at the given
+ * surface-local coordinates. Returns the surface and coordinates in the leaf
+ * surface coordinate system or NULL if no surface is found at that location.
+ */
+struct wlr_surface *wlr_layer_surface_v1_popup_surface_at(
+ struct wlr_layer_surface_v1 *surface, double sx, double sy,
+ double *sub_x, double *sub_y);
+
#endif
diff --git a/types/wlr_layer_shell_v1.c b/types/wlr_layer_shell_v1.c
index 4914b9b1..443ac9c7 100644
--- a/types/wlr_layer_shell_v1.c
+++ b/types/wlr_layer_shell_v1.c
@@ -590,6 +590,17 @@ void wlr_layer_surface_v1_for_each_popup(struct wlr_layer_surface_v1 *surface,
struct wlr_surface *wlr_layer_surface_v1_surface_at(
struct wlr_layer_surface_v1 *surface, double sx, double sy,
double *sub_x, double *sub_y) {
+ struct wlr_surface *sub = wlr_layer_surface_v1_popup_surface_at(surface,
+ sx, sy, sub_x, sub_y);
+ if (sub != NULL) {
+ return sub;
+ }
+ return wlr_surface_surface_at(surface->surface, sx, sy, sub_x, sub_y);
+}
+
+struct wlr_surface *wlr_layer_surface_v1_popup_surface_at(
+ struct wlr_layer_surface_v1 *surface, double sx, double sy,
+ double *sub_x, double *sub_y) {
struct wlr_xdg_popup *popup_state;
wl_list_for_each(popup_state, &surface->popups, link) {
struct wlr_xdg_surface *popup = popup_state->base;
@@ -606,5 +617,5 @@ struct wlr_surface *wlr_layer_surface_v1_surface_at(
}
}
- return wlr_surface_surface_at(surface->surface, sx, sy, sub_x, sub_y);
+ return NULL;
}