mirror of
https://github.com/labwc/labwc.git
synced 2025-10-31 22:25:34 -04:00
struct ssd_part and struct node_descriptor seem to have essentially the same purpose: tag a wlr_scene_node with some extra data indicating what we're using it for. Also, as with enum ssd_part_type (now lab_node_type), ssd_part is used for several types of nodes that are not part of SSD. So instead of the current chaining (node_descriptor -> ssd_part), let's flatten/unify the two structs. In detail: - First, merge node_descriptor_type into lab_node_type. - Add a separate view pointer in node_descriptor, since in the case of SSD buttons we need separate view and button data pointers. - Rename ssd_part_button to simply ssd_button. It no longer contains an ssd_part as base. - Add node_try_ssd_button_from_node() which replaces node_ssd_part_from_node() + button_try_from_ssd_part(). - Factor out ssd_button_free() to be called in node descriptor destroy. - Finally, get_cursor_context() needs a little reorganization to handle the unified structs. Overall, this simplifies the code a bit, and in my opinion makes it easier to understand. No functional change intended.
73 lines
2.3 KiB
C
73 lines
2.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#ifndef LABWC_NODE_DESCRIPTOR_H
|
|
#define LABWC_NODE_DESCRIPTOR_H
|
|
#include <wlr/types/wlr_scene.h>
|
|
#include "common/node-type.h"
|
|
|
|
struct node_descriptor {
|
|
enum lab_node_type type;
|
|
struct view *view;
|
|
void *data;
|
|
struct wl_listener destroy;
|
|
};
|
|
|
|
/**
|
|
* node_descriptor_create - create node descriptor for wlr_scene_node user_data
|
|
*
|
|
* The node_descriptor will be destroyed automatically
|
|
* once the scene_node it is attached to is destroyed.
|
|
*
|
|
* @scene_node: wlr_scene_node to attached node_descriptor to
|
|
* @type: node descriptor type
|
|
* @view: associated view
|
|
* @data: struct to point to as follows:
|
|
* - LAB_NODE_LAYER_SURFACE struct lab_layer_surface
|
|
* - LAB_NODE_LAYER_POPUP struct lab_layer_popup
|
|
* - LAB_NODE_MENUITEM struct menuitem
|
|
* - LAB_NODE_BUTTON_* struct ssd_button
|
|
*/
|
|
void node_descriptor_create(struct wlr_scene_node *scene_node,
|
|
enum lab_node_type type, struct view *view, void *data);
|
|
|
|
/**
|
|
* node_view_from_node - return view struct from node
|
|
* @wlr_scene_node: wlr_scene_node from which to return data
|
|
*/
|
|
struct view *node_view_from_node(struct wlr_scene_node *wlr_scene_node);
|
|
|
|
/**
|
|
* node_lab_surface_from_node - return lab_layer_surface struct from node
|
|
* @wlr_scene_node: wlr_scene_node from which to return data
|
|
*/
|
|
struct lab_layer_surface *node_layer_surface_from_node(
|
|
struct wlr_scene_node *wlr_scene_node);
|
|
|
|
/**
|
|
* node_layer_popup_from_node - return lab_layer_popup struct from node
|
|
* @wlr_scene_node: wlr_scene_node from which to return data
|
|
*/
|
|
struct lab_layer_popup *node_layer_popup_from_node(
|
|
struct wlr_scene_node *wlr_scene_node);
|
|
|
|
/**
|
|
* node_menuitem_from_node - return menuitem struct from node
|
|
* @wlr_scene_node: wlr_scene_node from which to return data
|
|
*/
|
|
struct menuitem *node_menuitem_from_node(
|
|
struct wlr_scene_node *wlr_scene_node);
|
|
|
|
/**
|
|
* node_scaled_buffer_from_node - return scaled_buffer from node
|
|
* @wlr_scene_node: wlr_scene_node from which to return data
|
|
*/
|
|
struct scaled_buffer *node_scaled_buffer_from_node(
|
|
struct wlr_scene_node *wlr_scene_node);
|
|
|
|
/**
|
|
* node_try_ssd_button_from_node - return ssd_button or NULL from node
|
|
* @wlr_scene_node: wlr_scene_node from which to return data
|
|
*/
|
|
struct ssd_button *node_try_ssd_button_from_node(
|
|
struct wlr_scene_node *wlr_scene_node);
|
|
|
|
#endif /* LABWC_NODE_DESCRIPTOR_H */
|