desktop.c: handle layer-subsurfaces in get_cursor_context()

...to allow these surfaces to receive pointer button events

Test by running `gtk-layer-demo --keyboard exclusive`, then open the
'set margin' dialog and try setting the margin with the pointer.
This commit is contained in:
Johan Malm 2022-12-29 20:16:32 +00:00 committed by Consolatis
parent 15781a394c
commit 86fa0c0a65

View file

@ -310,6 +310,21 @@ get_surface_from_layer_node(struct wlr_scene_node *node)
return NULL; return NULL;
} }
static bool
is_layer_descendant(struct wlr_scene_node *node)
{
goto start;
while (node) {
struct node_descriptor *desc = node->data;
if (desc && desc->type == LAB_NODE_DESC_LAYER_SURFACE) {
return true;
}
start:
node = node->parent ? &node->parent->node : NULL;
}
return false;
}
/* TODO: make this less big and scary */ /* TODO: make this less big and scary */
struct cursor_context struct cursor_context
get_cursor_context(struct server *server) get_cursor_context(struct server *server)
@ -389,6 +404,27 @@ get_cursor_context(struct server *server)
break; break;
} }
} }
/* Edge-case nodes without node-descriptors */
if (node->type == WLR_SCENE_NODE_BUFFER) {
struct wlr_surface *surface = lab_wlr_surface_from_node(node);
if (surface) {
if (is_layer_descendant(node)) {
/*
* layer-shell subsurfaces need to be
* able to receive pointer actions.
*
* Test by running
* `gtk-layer-demo -k exclusive`, then
* open the 'set margin' dialog and try
* setting the margin with the pointer.
*/
ret.surface = surface;
return ret;
}
}
}
/* node->parent is always a *wlr_scene_tree */ /* node->parent is always a *wlr_scene_tree */
node = node->parent ? &node->parent->node : NULL; node = node->parent ? &node->parent->node : NULL;
} }