mirror of
https://github.com/labwc/labwc.git
synced 2026-04-12 08:21:13 -04:00
[wip] move more button related things into ssd_button.c
This commit is contained in:
parent
bfacfc107f
commit
2ff6d23e56
3 changed files with 59 additions and 60 deletions
|
|
@ -62,15 +62,6 @@ ssd_max_extents(struct view *view)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
ssd_is_button(enum ssd_part_type type)
|
|
||||||
{
|
|
||||||
return type == LAB_SSD_BUTTON_CLOSE
|
|
||||||
|| type == LAB_SSD_BUTTON_MAXIMIZE
|
|
||||||
|| type == LAB_SSD_BUTTON_ICONIFY
|
|
||||||
|| type == LAB_SSD_BUTTON_WINDOW_MENU;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ssd_part_type
|
enum ssd_part_type
|
||||||
ssd_get_part_type(const struct ssd *ssd, struct wlr_scene_node *node)
|
ssd_get_part_type(const struct ssd *ssd, struct wlr_scene_node *node)
|
||||||
{
|
{
|
||||||
|
|
@ -246,8 +237,7 @@ ssd_destroy(struct ssd *ssd)
|
||||||
|
|
||||||
/* Maybe reset hover view */
|
/* Maybe reset hover view */
|
||||||
struct view *view = ssd->view;
|
struct view *view = ssd->view;
|
||||||
struct ssd_hover_state *hover_state;
|
struct ssd_hover_state *hover_state = view->server->ssd_hover_state;
|
||||||
hover_state = view->server->ssd_hover_state;
|
|
||||||
if (hover_state->view == view) {
|
if (hover_state->view == view) {
|
||||||
hover_state->view = NULL;
|
hover_state->view = NULL;
|
||||||
hover_state->node = NULL;
|
hover_state->node = NULL;
|
||||||
|
|
@ -328,24 +318,6 @@ ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable)
|
||||||
wlr_scene_rect_set_color(rect, color);
|
wlr_scene_rect_set_color(rect, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ssd_hover_state *
|
|
||||||
ssd_hover_state_new(void)
|
|
||||||
{
|
|
||||||
return znew(struct ssd_hover_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ssd_part_type
|
|
||||||
ssd_button_get_type(const struct ssd_button *button)
|
|
||||||
{
|
|
||||||
return button ? button->type : LAB_SSD_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct view *
|
|
||||||
ssd_button_get_view(const struct ssd_button *button)
|
|
||||||
{
|
|
||||||
return button ? button->view : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ssd_debug_is_root_node(const struct ssd *ssd, struct wlr_scene_node *node)
|
ssd_debug_is_root_node(const struct ssd *ssd, struct wlr_scene_node *node)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -185,3 +185,61 @@ ssd_button_enable_rounded_corner(struct ssd_part *corner_tree, float *bg_color,
|
||||||
/* Toggle rounded corner image itself */
|
/* Toggle rounded corner image itself */
|
||||||
wlr_scene_node_set_enabled(rounded->node, enable);
|
wlr_scene_node_set_enabled(rounded->node, enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ssd_is_button(enum ssd_part_type type)
|
||||||
|
{
|
||||||
|
return type == LAB_SSD_BUTTON_CLOSE
|
||||||
|
|| type == LAB_SSD_BUTTON_MAXIMIZE
|
||||||
|
|| type == LAB_SSD_BUTTON_ICONIFY
|
||||||
|
|| type == LAB_SSD_BUTTON_WINDOW_MENU;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ssd_part_type
|
||||||
|
ssd_button_get_type(const struct ssd_button *button)
|
||||||
|
{
|
||||||
|
return button ? button->type : LAB_SSD_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct view *
|
||||||
|
ssd_button_get_view(const struct ssd_button *button)
|
||||||
|
{
|
||||||
|
return button ? button->view : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ssd_hover_state *
|
||||||
|
ssd_hover_state_new(void)
|
||||||
|
{
|
||||||
|
return znew(struct ssd_hover_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ssd_update_button_hover(struct wlr_scene_node *node,
|
||||||
|
struct ssd_hover_state *hover_state)
|
||||||
|
{
|
||||||
|
struct ssd_button *button = NULL;
|
||||||
|
if (!node || !node->data) {
|
||||||
|
goto disable_old_hover;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct node_descriptor *desc = node->data;
|
||||||
|
if (desc->type == LAB_NODE_DESC_SSD_BUTTON) {
|
||||||
|
button = node_ssd_button_from_node(node);
|
||||||
|
if (button->hover == hover_state->node) {
|
||||||
|
/* Cursor is still on the same button */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
disable_old_hover:
|
||||||
|
if (hover_state->node) {
|
||||||
|
wlr_scene_node_set_enabled(hover_state->node, false);
|
||||||
|
hover_state->view = NULL;
|
||||||
|
hover_state->node = NULL;
|
||||||
|
}
|
||||||
|
if (button) {
|
||||||
|
wlr_scene_node_set_enabled(button->hover, true);
|
||||||
|
hover_state->view = button->view;
|
||||||
|
hover_state->node = button->hover;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -330,35 +330,4 @@ ssd_update_title(struct ssd *ssd)
|
||||||
ssd_update_title_positions(ssd);
|
ssd_update_title_positions(ssd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ssd_update_button_hover(struct wlr_scene_node *node,
|
|
||||||
struct ssd_hover_state *hover_state)
|
|
||||||
{
|
|
||||||
struct ssd_button *button = NULL;
|
|
||||||
if (!node || !node->data) {
|
|
||||||
goto disable_old_hover;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct node_descriptor *desc = node->data;
|
|
||||||
if (desc->type == LAB_NODE_DESC_SSD_BUTTON) {
|
|
||||||
button = node_ssd_button_from_node(node);
|
|
||||||
if (button->hover == hover_state->node) {
|
|
||||||
/* Cursor is still on the same button */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
disable_old_hover:
|
|
||||||
if (hover_state->node) {
|
|
||||||
wlr_scene_node_set_enabled(hover_state->node, false);
|
|
||||||
hover_state->view = NULL;
|
|
||||||
hover_state->node = NULL;
|
|
||||||
}
|
|
||||||
if (button) {
|
|
||||||
wlr_scene_node_set_enabled(button->hover, true);
|
|
||||||
hover_state->view = button->view;
|
|
||||||
hover_state->node = button->hover;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef FOR_EACH_STATE
|
#undef FOR_EACH_STATE
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue