]> git.mdlowis.com Git - proto/labwc.git/commitdiff
desktop.c: handle layer-subsurfaces in get_cursor_context()
authorJohan Malm <jgm323@gmail.com>
Thu, 29 Dec 2022 20:16:32 +0000 (20:16 +0000)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Thu, 29 Dec 2022 22:18:08 +0000 (23:18 +0100)
...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.

src/desktop.c

index deb551fe81c6ed362e0f36769aaae3aa4358a5cb..9abea27bb78b228eb125be16496dba9bb9eab65a 100644 (file)
@@ -310,6 +310,21 @@ get_surface_from_layer_node(struct wlr_scene_node *node)
        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 */
 struct cursor_context
 get_cursor_context(struct server *server)
@@ -389,6 +404,27 @@ get_cursor_context(struct server *server)
                                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 = node->parent ? &node->parent->node : NULL;
        }