mirror of
https://github.com/labwc/labwc.git
synced 2025-10-31 22:25:34 -04:00
ssd: clean up scene management
Our codebase for ssd scenes has grown with a lot of technical debts: - We needed to call `ssd_get_part()` everywhere to get the scene node of a ssd part. We then needed to cast it to `wlr_scene_rect` and `wlr_scene_buffer`. This bloated our codebase and even blocked duplicated button types in `<titlebar><layout>`. - `ssd_get_part_type()` was a dirty hack. It compared parent, grandparent and grandgrandparent of a node with each subtree in the ssd to get the part type of the node. To resolve this issues, this commit changes how ssd scenes are managed: - Access scene rects and scene buffers just as a member of `struct ssd`. - `ssd_part` is now a attachment to a scene node that can be accessed via node_descriptor->data, with a new node-descriptor type `LAB_NODE_DESC_SSD_PART`. `LAB_NODE_DESC_SSD_BUTTON` is unified into it. Now the scene graph under ssd->tree looks like below. The parentheses indicate the type of ssd_part attached to the node: ssd->tree (LAB_SSD_NONE) +--titlebar (LAB_SSD_PART_TITLEBAR) | +--inactive | | +--background bar | | +--left corner | | +--right corner | | +--title (LAB_SSD_PART_TITLE) | | +--iconify button (LAB_SSD_BUTTON_ICONIFY) | | | +--normal close icon image | | | +--hovered close icon image | | | +--... | | +--window icon (LAB_SSD_BUTTON_WINDOW_ICON) | | | +--window icon image | | +--... | +--active | +--... +--border | +--inactive | | +--top | | +--... | +--active | +--top | +--... +--shadow | +--inactive | | +--top | | +--... | +--active | +--top | +--... +--extents +--top +--... When hovering on SSD, `get_cursor_context()` traverses this scene node from the leaf. If it finds a `ssd_part` attached to the node, it returns `ssd_part_type` that represents the resizing direction, button types or `Title`/`Titlebar`.
This commit is contained in:
parent
aa3dbb4f85
commit
f347a818e3
13 changed files with 516 additions and 726 deletions
|
|
@ -302,22 +302,30 @@ get_cursor_context(struct server *server)
|
|||
case LAB_NODE_DESC_VIEW:
|
||||
case LAB_NODE_DESC_XDG_POPUP:
|
||||
ret.view = desc->data;
|
||||
ret.type = ssd_get_part_type(
|
||||
ret.view->ssd, ret.node, cursor);
|
||||
if (ret.type == LAB_SSD_CLIENT) {
|
||||
if (ret.node->type == WLR_SCENE_NODE_BUFFER
|
||||
&& lab_wlr_surface_from_node(ret.node)) {
|
||||
ret.type = LAB_SSD_CLIENT;
|
||||
ret.surface = lab_wlr_surface_from_node(ret.node);
|
||||
} else {
|
||||
/* should never be reached */
|
||||
wlr_log(WLR_ERROR, "cursor not on client or ssd");
|
||||
}
|
||||
return ret;
|
||||
case LAB_NODE_DESC_SSD_BUTTON: {
|
||||
/*
|
||||
* Always return the top scene node for SSD
|
||||
* buttons
|
||||
*/
|
||||
struct ssd_button *button =
|
||||
node_ssd_button_from_node(node);
|
||||
case LAB_NODE_DESC_SSD_PART: {
|
||||
struct ssd_part *part = node_ssd_part_from_node(node);
|
||||
ret.node = node;
|
||||
ret.type = ssd_button_get_type(button);
|
||||
ret.view = ssd_button_get_view(button);
|
||||
ret.view = ssd_part_get_view(part);
|
||||
|
||||
/* Detect mouse contexts like Top, Left and TRCorner */
|
||||
ret.type = ssd_get_resizing_type(ret.view->ssd, cursor);
|
||||
if (ret.type == LAB_SSD_NONE) {
|
||||
/*
|
||||
* Otherwise, detect mouse contexts like
|
||||
* Title, Titlebar and Iconify
|
||||
*/
|
||||
ret.type = ssd_part_get_type(part);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
case LAB_NODE_DESC_LAYER_SURFACE:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue