2022-02-21 03:18:38 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
|
|
|
|
|
#include "labwc.h"
|
|
|
|
|
#include "ssd.h"
|
|
|
|
|
#include "theme.h"
|
|
|
|
|
#include "common/scene-helpers.h"
|
|
|
|
|
|
|
|
|
|
#define FOR_EACH_STATE(view, tmp) FOR_EACH(tmp, \
|
|
|
|
|
&(view)->ssd.border.active, \
|
|
|
|
|
&(view)->ssd.border.inactive)
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ssd_border_create(struct view *view)
|
|
|
|
|
{
|
|
|
|
|
struct theme *theme = view->server->theme;
|
2022-02-24 01:27:29 +01:00
|
|
|
int width = view->w;
|
|
|
|
|
int height = view->h;
|
2022-02-21 03:18:38 +01:00
|
|
|
int full_width = width + 2 * theme->border_width;
|
|
|
|
|
|
|
|
|
|
float *color;
|
2022-06-05 15:17:35 +02:00
|
|
|
struct wlr_scene_tree *parent;
|
2022-02-21 03:18:38 +01:00
|
|
|
struct ssd_sub_tree *subtree;
|
|
|
|
|
|
|
|
|
|
FOR_EACH_STATE(view, subtree) {
|
2022-06-05 15:17:35 +02:00
|
|
|
subtree->tree = wlr_scene_tree_create(view->ssd.tree);
|
|
|
|
|
parent = subtree->tree;
|
|
|
|
|
wlr_scene_node_set_position(&parent->node, -theme->border_width, 0);
|
2022-02-21 03:18:38 +01:00
|
|
|
if (subtree == &view->ssd.border.active) {
|
|
|
|
|
color = theme->window_active_border_color;
|
|
|
|
|
} else {
|
|
|
|
|
color = theme->window_inactive_border_color;
|
2022-06-05 15:17:35 +02:00
|
|
|
wlr_scene_node_set_enabled(&parent->node, false);
|
2022-02-21 03:18:38 +01:00
|
|
|
}
|
|
|
|
|
wl_list_init(&subtree->parts);
|
|
|
|
|
add_scene_rect(&subtree->parts, LAB_SSD_PART_LEFT, parent,
|
|
|
|
|
theme->border_width, height, 0, 0, color);
|
|
|
|
|
add_scene_rect(&subtree->parts, LAB_SSD_PART_RIGHT, parent,
|
|
|
|
|
theme->border_width, height,
|
|
|
|
|
theme->border_width + width, 0, color);
|
|
|
|
|
add_scene_rect(&subtree->parts, LAB_SSD_PART_BOTTOM, parent,
|
2022-03-09 08:52:33 +01:00
|
|
|
full_width, theme->border_width, 0, height, color);
|
2022-03-06 17:06:14 +00:00
|
|
|
add_scene_rect(&subtree->parts, LAB_SSD_PART_TOP, parent,
|
2022-03-09 08:52:33 +01:00
|
|
|
width - 2 * BUTTON_WIDTH, theme->border_width,
|
|
|
|
|
theme->border_width + BUTTON_WIDTH,
|
|
|
|
|
-(theme->title_height + theme->border_width), color);
|
2022-02-21 03:18:38 +01:00
|
|
|
} FOR_EACH_END
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ssd_border_update(struct view *view)
|
|
|
|
|
{
|
|
|
|
|
struct theme *theme = view->server->theme;
|
|
|
|
|
|
2022-02-24 01:27:29 +01:00
|
|
|
int width = view->w;
|
|
|
|
|
int height = view->h;
|
2022-02-21 03:18:38 +01:00
|
|
|
int full_width = width + 2 * theme->border_width;
|
|
|
|
|
|
|
|
|
|
struct ssd_part *part;
|
|
|
|
|
struct wlr_scene_rect *rect;
|
|
|
|
|
struct ssd_sub_tree *subtree;
|
|
|
|
|
FOR_EACH_STATE(view, subtree) {
|
|
|
|
|
wl_list_for_each(part, &subtree->parts, link) {
|
|
|
|
|
rect = lab_wlr_scene_get_rect(part->node);
|
|
|
|
|
switch (part->type) {
|
|
|
|
|
case LAB_SSD_PART_LEFT:
|
2022-04-04 20:53:36 +01:00
|
|
|
wlr_scene_rect_set_size(rect,
|
|
|
|
|
theme->border_width, height);
|
2022-02-21 03:18:38 +01:00
|
|
|
continue;
|
|
|
|
|
case LAB_SSD_PART_RIGHT:
|
2022-04-04 20:53:36 +01:00
|
|
|
wlr_scene_rect_set_size(rect,
|
|
|
|
|
theme->border_width, height);
|
|
|
|
|
wlr_scene_node_set_position(part->node,
|
|
|
|
|
theme->border_width + width, 0);
|
2022-02-21 03:18:38 +01:00
|
|
|
continue;
|
|
|
|
|
case LAB_SSD_PART_BOTTOM:
|
2022-04-04 20:53:36 +01:00
|
|
|
wlr_scene_rect_set_size(rect,
|
|
|
|
|
full_width, theme->border_width);
|
|
|
|
|
wlr_scene_node_set_position(part->node,
|
|
|
|
|
0, height);
|
2022-02-21 03:18:38 +01:00
|
|
|
continue;
|
2022-03-06 17:06:14 +00:00
|
|
|
case LAB_SSD_PART_TOP:
|
|
|
|
|
wlr_scene_rect_set_size(rect,
|
2022-04-04 20:53:36 +01:00
|
|
|
width - 2 * BUTTON_WIDTH,
|
|
|
|
|
theme->border_width);
|
2022-03-06 17:06:14 +00:00
|
|
|
continue;
|
2022-02-21 03:18:38 +01:00
|
|
|
default:
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} FOR_EACH_END
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ssd_border_destroy(struct view *view)
|
|
|
|
|
{
|
|
|
|
|
if (!view->ssd.border.active.tree) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ssd_sub_tree *subtree;
|
|
|
|
|
FOR_EACH_STATE(view, subtree) {
|
|
|
|
|
ssd_destroy_parts(&subtree->parts);
|
|
|
|
|
wlr_scene_node_destroy(&subtree->tree->node);
|
|
|
|
|
subtree->tree = NULL;
|
|
|
|
|
} FOR_EACH_END
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef FOR_EACH_STATE
|