aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-09-20 18:32:44 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-09-22 10:45:39 -0600
commitf6f0e010d182e5a24b7e540fcc0567ebcafcca24 (patch)
tree07558ea6d26c99a2848bbc53ffbb42707b8f1ad5
parentb25759cd20262f59e6144b00e9bc9d132549cc94 (diff)
scene: unify intersection logic in wlr_scene_node_at
Let's extract the common bits.
-rw-r--r--types/scene/wlr_scene.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c
index 31e0fd98..7f8f8e76 100644
--- a/types/scene/wlr_scene.c
+++ b/types/scene/wlr_scene.c
@@ -445,36 +445,31 @@ struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
}
}
+ bool intersects = false;
switch (node->type) {
case WLR_SCENE_NODE_ROOT:
case WLR_SCENE_NODE_TREE:
break;
case WLR_SCENE_NODE_SURFACE:;
struct wlr_scene_surface *scene_surface = wlr_scene_surface_from_node(node);
- if (wlr_surface_point_accepts_input(scene_surface->surface, lx, ly)) {
- if (nx != NULL) {
- *nx = lx;
- }
- if (ny != NULL) {
- *ny = ly;
- }
- return &scene_surface->node;
- }
+ intersects = wlr_surface_point_accepts_input(scene_surface->surface, lx, ly);
break;
case WLR_SCENE_NODE_RECT:;
struct wlr_scene_rect *rect = scene_rect_from_node(node);
- if (lx >= 0 && lx < rect->width && ly >= 0 && ly < rect->height) {
- if (nx != NULL) {
- *nx = lx;
- }
- if (ny != NULL) {
- *ny = ly;
- }
- return &rect->node;
- }
+ intersects = lx >= 0 && lx < rect->width && ly >= 0 && ly < rect->height;
break;
}
+ if (intersects) {
+ if (nx != NULL) {
+ *nx = lx;
+ }
+ if (ny != NULL) {
+ *ny = ly;
+ }
+ return node;
+ }
+
return NULL;
}