mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
ssd: attach LAB_NODE_SSD_ROOT to ssd->tree
This doesn't change any behaviors. Attaching LAB_NODE_NONE node-descriptor to ssd->tree looks strange, this patch uses new LAB_NODE_SSD_ROOT instead. The node-descriptor attached to ssd->tree is needed for get_cursor_context() to detect cursor hovering on borders/extents. I also updated get_cursor_context() to make my intent clearer.
This commit is contained in:
parent
b9b23f5931
commit
574b20fbff
4 changed files with 43 additions and 16 deletions
|
|
@ -59,6 +59,12 @@ enum lab_node_type {
|
||||||
LAB_NODE_LAYER_POPUP,
|
LAB_NODE_LAYER_POPUP,
|
||||||
LAB_NODE_SESSION_LOCK_SURFACE,
|
LAB_NODE_SESSION_LOCK_SURFACE,
|
||||||
LAB_NODE_IME_POPUP,
|
LAB_NODE_IME_POPUP,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* translated to LAB_CORNER_* or LAB_BORDER* by
|
||||||
|
* ssd_get_resizing_type()
|
||||||
|
*/
|
||||||
|
LAB_NODE_SSD_ROOT,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum lab_node_type node_type_parse(const char *context);
|
enum lab_node_type node_type_parse(const char *context);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ struct ssd_state_title_width {
|
||||||
* type of each node (enum lab_node_type, stored in the node_descriptor
|
* type of each node (enum lab_node_type, stored in the node_descriptor
|
||||||
* attached to the wlr_scene_node).
|
* attached to the wlr_scene_node).
|
||||||
*
|
*
|
||||||
* ssd->tree (LAB_NODE_NONE)
|
* ssd->tree (LAB_NODE_SSD_ROOT)
|
||||||
* +--titlebar (LAB_NODE_TITLEBAR)
|
* +--titlebar (LAB_NODE_TITLEBAR)
|
||||||
* | +--inactive
|
* | +--inactive
|
||||||
* | | +--background bar
|
* | | +--background bar
|
||||||
|
|
|
||||||
|
|
@ -331,31 +331,46 @@ get_cursor_context(struct server *server)
|
||||||
ret.node = node;
|
ret.node = node;
|
||||||
ret.type = LAB_NODE_MENUITEM;
|
ret.type = LAB_NODE_MENUITEM;
|
||||||
return ret;
|
return ret;
|
||||||
default:
|
case LAB_NODE_BUTTON_FIRST...LAB_NODE_BUTTON_LAST:
|
||||||
/*
|
case LAB_NODE_SSD_ROOT:
|
||||||
* All other node descriptors (buttons, title,
|
case LAB_NODE_TITLE:
|
||||||
* etc.) should have an associated view.
|
case LAB_NODE_TITLEBAR:
|
||||||
*/
|
|
||||||
if (!desc->view) {
|
|
||||||
wlr_log(WLR_ERROR, "cursor not on any view "
|
|
||||||
"(node type %d)", desc->type);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret.node = node;
|
ret.node = node;
|
||||||
ret.view = desc->view;
|
ret.view = desc->view;
|
||||||
|
/*
|
||||||
|
* A node_descriptor attached to a ssd part
|
||||||
|
* must have an associated view.
|
||||||
|
*/
|
||||||
|
assert(ret.view);
|
||||||
|
|
||||||
/* Detect mouse contexts like Top, Left and TRCorner */
|
/*
|
||||||
|
* When cursor is on the ssd border or extents,
|
||||||
|
* desc->type is usually LAB_NODE_SSD_ROOT.
|
||||||
|
* But desc->type can also be LAB_NODE_TITLEBAR
|
||||||
|
* when cursor is on the curved border at the
|
||||||
|
* titlebar.
|
||||||
|
*
|
||||||
|
* ssd_get_resizing_type() overwrites both of
|
||||||
|
* them with LAB_NODE_{BORDER,CORNER}_* node
|
||||||
|
* types, which are mapped to mouse contexts
|
||||||
|
* like Left and TLCorner.
|
||||||
|
*/
|
||||||
ret.type = ssd_get_resizing_type(ret.view->ssd, cursor);
|
ret.type = ssd_get_resizing_type(ret.view->ssd, cursor);
|
||||||
if (ret.type == LAB_NODE_NONE) {
|
if (ret.type == LAB_NODE_NONE) {
|
||||||
/*
|
/*
|
||||||
* Otherwise, detect mouse contexts like
|
* If cursor is not on border/extents,
|
||||||
* Title, Titlebar and Iconify
|
* just use desc->type which should be
|
||||||
|
* mapped to mouse contexts like Title,
|
||||||
|
* Titlebar and Iconify.
|
||||||
*/
|
*/
|
||||||
ret.type = desc->type;
|
ret.type = desc->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
default:
|
||||||
|
/* Other node types are not attached a scene node */
|
||||||
|
wlr_log(WLR_ERROR, "unexpected node type: %d", desc->type);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,8 +146,14 @@ ssd_create(struct view *view, bool active)
|
||||||
|
|
||||||
ssd->view = view;
|
ssd->view = view;
|
||||||
ssd->tree = wlr_scene_tree_create(view->scene_tree);
|
ssd->tree = wlr_scene_tree_create(view->scene_tree);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Attach node_descriptor to the root node so that get_cursor_context()
|
||||||
|
* detect cursor hovering on borders and extents.
|
||||||
|
*/
|
||||||
node_descriptor_create(&ssd->tree->node,
|
node_descriptor_create(&ssd->tree->node,
|
||||||
LAB_NODE_NONE, view, /*data*/ NULL);
|
LAB_NODE_SSD_ROOT, view, /*data*/ NULL);
|
||||||
|
|
||||||
wlr_scene_node_lower_to_bottom(&ssd->tree->node);
|
wlr_scene_node_lower_to_bottom(&ssd->tree->node);
|
||||||
ssd->titlebar.height = view->server->theme->titlebar_height;
|
ssd->titlebar.height = view->server->theme->titlebar_height;
|
||||||
ssd_shadow_create(ssd);
|
ssd_shadow_create(ssd);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue