node.c: add helpers for returning structs from node data

Support returning the following structs:
  - view from LAB_NODE_DESC_VIEW or LAB_NODE_DESC_XDG_POPUP
  - lab_layer_surface form LAB_NODE_DESC_LAYER_SURFACE
  - lab_layer_popup from LAB_NODE_DESC_LAYER_POPUP
This commit is contained in:
Johan Malm 2022-03-02 22:05:41 +00:00
parent 30298228e3
commit b4cbc20e8c
3 changed files with 66 additions and 13 deletions

View file

@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <assert.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_scene.h>
#include "buffer.h"
@ -113,10 +112,7 @@ get_special(struct server *server, struct wlr_scene_node *node,
return "server->view_tree";
}
if (node->parent == &server->view_tree->node) {
struct node_descriptor *desc = node->data;
assert(desc->type == LAB_NODE_DESC_VIEW
|| desc->type == LAB_NODE_DESC_XDG_POPUP);
*last_view = desc->data;
*last_view = node_view_from_node(node->data);
}
const char *view_part = get_view_part(*last_view, node);
if (view_part) {