mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
scene: unify intersection logic in wlr_scene_node_at
Let's extract the common bits.
This commit is contained in:
parent
b25759cd20
commit
f6f0e010d1
1 changed files with 13 additions and 18 deletions
|
@ -445,36 +445,31 @@ struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool intersects = false;
|
||||||
switch (node->type) {
|
switch (node->type) {
|
||||||
case WLR_SCENE_NODE_ROOT:
|
case WLR_SCENE_NODE_ROOT:
|
||||||
case WLR_SCENE_NODE_TREE:
|
case WLR_SCENE_NODE_TREE:
|
||||||
break;
|
break;
|
||||||
case WLR_SCENE_NODE_SURFACE:;
|
case WLR_SCENE_NODE_SURFACE:;
|
||||||
struct wlr_scene_surface *scene_surface = wlr_scene_surface_from_node(node);
|
struct wlr_scene_surface *scene_surface = wlr_scene_surface_from_node(node);
|
||||||
if (wlr_surface_point_accepts_input(scene_surface->surface, lx, ly)) {
|
intersects = wlr_surface_point_accepts_input(scene_surface->surface, lx, ly);
|
||||||
if (nx != NULL) {
|
|
||||||
*nx = lx;
|
|
||||||
}
|
|
||||||
if (ny != NULL) {
|
|
||||||
*ny = ly;
|
|
||||||
}
|
|
||||||
return &scene_surface->node;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WLR_SCENE_NODE_RECT:;
|
case WLR_SCENE_NODE_RECT:;
|
||||||
struct wlr_scene_rect *rect = scene_rect_from_node(node);
|
struct wlr_scene_rect *rect = scene_rect_from_node(node);
|
||||||
if (lx >= 0 && lx < rect->width && ly >= 0 && ly < rect->height) {
|
intersects = lx >= 0 && lx < rect->width && ly >= 0 && ly < rect->height;
|
||||||
if (nx != NULL) {
|
|
||||||
*nx = lx;
|
|
||||||
}
|
|
||||||
if (ny != NULL) {
|
|
||||||
*ny = ly;
|
|
||||||
}
|
|
||||||
return &rect->node;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (intersects) {
|
||||||
|
if (nx != NULL) {
|
||||||
|
*nx = lx;
|
||||||
|
}
|
||||||
|
if (ny != NULL) {
|
||||||
|
*ny = ly;
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue