cursor: Simplify node_at_coords with scene_descriptor_find

This commit is contained in:
Alexander Orzechowski 2024-08-26 16:09:42 -04:00
parent 3e7306489f
commit 4a3c13f1ba

View file

@ -76,42 +76,30 @@ struct sway_node *node_at_coords(
} }
} }
// determine what container we clicked on struct sway_container *con =
struct wlr_scene_node *current = scene_node; scene_descriptor_find(scene_node, SWAY_SCENE_DESC_CONTAINER);
while (true) {
struct sway_container *con = scene_descriptor_try_get(current,
SWAY_SCENE_DESC_CONTAINER);
if (!con) { if (con) {
struct sway_popup_desc *popup = // If this condition succeeds, the container is currently in the
scene_descriptor_try_get(current, SWAY_SCENE_DESC_POPUP); // process of being destroyed. In this case, ignore the container
if (popup && popup->view) { if (con->view && !con->view->surface) {
con = popup->view->container; return NULL;
}
} }
if (con && (!con->view || con->view->surface)) {
return &con->node; return &con->node;
} }
if (scene_descriptor_try_get(current, SWAY_SCENE_DESC_LAYER_SHELL)) { // if we clicked on a layer shell or unmanaged xwayland we don't
// We don't want to feed through the current workspace on // want to return the workspace node.
// layer shells if (scene_descriptor_find(scene_node, SWAY_SCENE_DESC_LAYER_SHELL)) {
return NULL; return NULL;
} }
#if WLR_HAS_XWAYLAND #if WLR_HAS_XWAYLAND
if (scene_descriptor_try_get(current, SWAY_SCENE_DESC_XWAYLAND_UNMANAGED)) { if (scene_descriptor_find(scene_node, SWAY_SCENE_DESC_XWAYLAND_UNMANAGED)) {
return NULL; return NULL;
} }
#endif #endif
if (!current->parent) {
break;
}
current = &current->parent->node;
}
} }
// if we aren't on a container, determine what workspace we are on // if we aren't on a container, determine what workspace we are on