diff options
author | Alexander Orzechowski <orzechowski.alexander@gmail.com> | 2022-05-19 14:24:05 -0400 |
---|---|---|
committer | Alexander Orzechowski <orzechowski.alexander@gmail.com> | 2022-05-19 14:24:05 -0400 |
commit | 34be5da072ed452be50b6d3664a97cfa5bb62521 (patch) | |
tree | b97fd8a5199c7ba7f58d7cc9bcd15e611d2dc3b7 | |
parent | 09c7fe0f904d4e91cce2a9414e2bcfe050f0c8d4 (diff) |
wlr_scene: Add a way to choose when input interactions happen on a buffer
-rw-r--r-- | include/wlr/types/wlr_scene.h | 8 | ||||
-rw-r--r-- | types/scene/wlr_scene.c | 14 |
2 files changed, 20 insertions, 2 deletions
diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index 6e7b3440..4c1f5ea9 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -28,6 +28,11 @@ struct wlr_output_layout; struct wlr_xdg_surface; struct wlr_layer_surface_v1; +struct wlr_scene_buffer; + +typedef bool (*wlr_scene_buffer_point_accepts_input_func_t)( + struct wlr_scene_buffer *buffer, int sx, int sy); + enum wlr_scene_node_type { WLR_SCENE_NODE_ROOT, WLR_SCENE_NODE_TREE, @@ -118,6 +123,9 @@ struct wlr_scene_buffer { struct wl_signal frame_done; // struct timespec } events; + // May be NULL + wlr_scene_buffer_point_accepts_input_func_t point_accepts_input; + /** * The output that the largest area of this buffer is displayed on. * This may be NULL if the buffer is not currently displayed on any diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 87f571d9..5c110c3a 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -771,12 +771,22 @@ struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node, struct wlr_scene_surface *scene_surface = wlr_scene_surface_from_node(node); intersects = wlr_surface_point_accepts_input(scene_surface->surface, lx, ly); break; - case WLR_SCENE_NODE_RECT: - case WLR_SCENE_NODE_BUFFER:; + case WLR_SCENE_NODE_RECT:; int width, height; scene_node_get_size(node, &width, &height); intersects = lx >= 0 && lx < width && ly >= 0 && ly < height; break; + case WLR_SCENE_NODE_BUFFER:; + struct wlr_scene_buffer *scene_buffer = scene_buffer_from_node(node); + + if (scene_buffer->point_accepts_input) { + intersects = scene_buffer->point_accepts_input(scene_buffer, lx, ly); + } else { + int width, height; + scene_node_get_size(node, &width, &height); + intersects = lx >= 0 && lx < width && ly >= 0 && ly < height; + } + break; } if (intersects) { |