ssd: move top border above titlebar

This commit is contained in:
Consolatis 2022-03-09 08:52:33 +01:00 committed by Johan Malm
parent e4f1f9a975
commit e086f6f5e0
6 changed files with 37 additions and 34 deletions

View file

@ -18,7 +18,7 @@ ssd_thickness(struct view *view)
{
struct theme *theme = view->server->theme;
struct border border = {
.top = theme->title_height,
.top = theme->title_height + theme->border_width,
.bottom = theme->border_width,
.left = theme->border_width,
.right = theme->border_width,

View file

@ -38,11 +38,11 @@ ssd_border_create(struct view *view)
theme->border_width, height,
theme->border_width + width, 0, color);
add_scene_rect(&subtree->parts, LAB_SSD_PART_BOTTOM, parent,
full_width, theme->border_width,
0, height, color);
full_width, theme->border_width, 0, height, color);
add_scene_rect(&subtree->parts, LAB_SSD_PART_TOP, parent,
full_width - 2 * BUTTON_WIDTH, theme->border_width,
BUTTON_WIDTH, -theme->title_height, color);
width - 2 * BUTTON_WIDTH, theme->border_width,
theme->border_width + BUTTON_WIDTH,
-(theme->title_height + theme->border_width), color);
} FOR_EACH_END
}
@ -76,10 +76,7 @@ ssd_border_update(struct view *view)
continue;
case LAB_SSD_PART_TOP:
wlr_scene_rect_set_size(rect,
full_width - 2 * BUTTON_WIDTH,
theme->border_width);
wlr_scene_node_set_position(part->node,
BUTTON_WIDTH, -theme->title_height);
width - 2 * BUTTON_WIDTH, theme->border_width);
continue;
default:
continue;

View file

@ -13,8 +13,8 @@ ssd_extents_create(struct view *view)
struct wl_list *part_list = &view->ssd.extents.parts;
int width = view->w;
int height = view->h;
int full_height = height + theme->border_width + theme->title_height;
int full_width = width + 2 * theme->border_width;
int full_height = height + theme->border_width * 2 + theme->title_height;
int full_width = width + theme->border_width * 2;
int extended_area = EXTENDED_AREA;
int corner_size = extended_area + theme->border_width + BUTTON_WIDTH / 2;
int side_width = full_width + extended_area * 2 - corner_size * 2;
@ -27,7 +27,7 @@ ssd_extents_create(struct view *view)
}
wl_list_init(&view->ssd.extents.parts);
wlr_scene_node_set_position(parent, -(theme->border_width + extended_area),
-(theme->title_height + extended_area));
-(theme->title_height + theme->border_width + extended_area));
/* Top */
add_scene_rect(part_list, LAB_SSD_PART_CORNER_TOP_LEFT, parent,
@ -54,7 +54,7 @@ ssd_extents_create(struct view *view)
0, corner_size + side_height, invisible);
add_scene_rect(part_list, LAB_SSD_PART_BOTTOM, parent,
side_width, extended_area,
extended_area, extended_area + full_height, invisible);
corner_size, extended_area + full_height, invisible);
add_scene_rect(part_list, LAB_SSD_PART_CORNER_BOTTOM_RIGHT, parent,
corner_size, corner_size,
corner_size + side_width, corner_size + side_height, invisible);
@ -75,7 +75,7 @@ ssd_extents_update(struct view *view)
int width = view->w;
int height = view->h;
int full_height = height + theme->border_width + theme->title_height;
int full_height = height + theme->border_width * 2 + theme->title_height;
int full_width = width + 2 * theme->border_width;
int extended_area = EXTENDED_AREA;
int corner_size = extended_area + theme->border_width + BUTTON_WIDTH / 2;

View file

@ -52,14 +52,22 @@ finish_scene_button(struct wl_list *part_list, enum ssd_part_type type,
float hover_bg[4] = {0.15f, 0.15f, 0.15f, 0.3f};
/* Icon */
int offset_y = 0;
int offset_x = 0;
if (type == LAB_SSD_BUTTON_WINDOW_MENU) {
offset_y = rc.theme->border_width;
offset_x = rc.theme->border_width;
} else if (type == LAB_SSD_BUTTON_CLOSE) {
offset_y = rc.theme->border_width;
}
add_scene_buffer(part_list, type, parent, icon_buffer,
(BUTTON_WIDTH - icon_buffer->width) / 2,
(rc.theme->title_height - icon_buffer->height) / 2);
offset_x + (BUTTON_WIDTH - icon_buffer->width) / 2,
offset_y + (rc.theme->title_height - icon_buffer->height) / 2);
/* Hover overlay */
struct ssd_part *hover_part;
hover_part = add_scene_rect(part_list, type, parent,
BUTTON_WIDTH, rc.theme->title_height, 0, 0, hover_bg);
BUTTON_WIDTH, rc.theme->title_height, offset_x, offset_y, hover_bg);
wlr_scene_node_set_enabled(hover_part->node, false);
}
@ -69,8 +77,9 @@ add_scene_button_corner(struct wl_list *part_list, enum ssd_part_type type,
struct wlr_buffer *icon_buffer, int x)
{
struct ssd_part *part;
/* Background */
part = add_scene_buffer(part_list, type, parent, corner_buffer, x, 0);
/* Background, y adjusted for border_width */
part = add_scene_buffer(part_list, type, parent, corner_buffer,
x, -rc.theme->border_width);
finish_scene_button(part_list, type, part->node, icon_buffer);
return part;
}

View file

@ -18,7 +18,6 @@ ssd_titlebar_create(struct view *view)
{
struct theme *theme = view->server->theme;
int width = view->w;
int full_width = width + 2 * theme->border_width;
float *color;
struct wlr_scene_node *parent;
@ -29,8 +28,7 @@ ssd_titlebar_create(struct view *view)
FOR_EACH_STATE(view, subtree) {
subtree->tree = wlr_scene_tree_create(&view->ssd.tree->node);
parent = &subtree->tree->node;
wlr_scene_node_set_position(parent,
-theme->border_width, -theme->title_height);
wlr_scene_node_set_position(parent, 0, -theme->title_height);
if (subtree == &view->ssd.titlebar.active) {
color = theme->window_active_title_bg_color;
corner_top_left = &theme->corner_top_left_active_normal->base;
@ -45,21 +43,21 @@ ssd_titlebar_create(struct view *view)
/* Title */
add_scene_rect(&subtree->parts, LAB_SSD_PART_TITLEBAR, parent,
full_width - BUTTON_WIDTH * BUTTON_COUNT, theme->title_height,
width - BUTTON_WIDTH * BUTTON_COUNT, theme->title_height,
BUTTON_WIDTH, 0, color);
/* Buttons */
add_scene_button_corner(&subtree->parts, LAB_SSD_BUTTON_WINDOW_MENU,
parent, corner_top_left,
&theme->xbm_menu_active_unpressed->base, 0);
&theme->xbm_menu_active_unpressed->base, -theme->border_width);
add_scene_button(&subtree->parts, LAB_SSD_BUTTON_ICONIFY, parent,
color, &theme->xbm_iconify_active_unpressed->base,
full_width - BUTTON_WIDTH * 3);
width - BUTTON_WIDTH * 3);
add_scene_button(&subtree->parts, LAB_SSD_BUTTON_MAXIMIZE, parent,
color, &theme->xbm_maximize_active_unpressed->base,
full_width - BUTTON_WIDTH * 2);
width - BUTTON_WIDTH * 2);
add_scene_button_corner(&subtree->parts, LAB_SSD_BUTTON_CLOSE, parent,
corner_top_right, &theme->xbm_close_active_unpressed->base,
full_width - BUTTON_WIDTH * 1);
width - BUTTON_WIDTH * 1);
} FOR_EACH_END
ssd_update_title(view);
}
@ -78,7 +76,6 @@ ssd_titlebar_update(struct view *view)
return;
}
struct theme *theme = view->server->theme;
int full_width = width + 2 * theme->border_width;
struct ssd_part *part;
struct ssd_sub_tree *subtree;
@ -87,25 +84,25 @@ ssd_titlebar_update(struct view *view)
switch (part->type) {
case LAB_SSD_PART_TITLEBAR:
wlr_scene_rect_set_size(lab_wlr_scene_get_rect(part->node),
full_width - BUTTON_WIDTH * BUTTON_COUNT,
width - BUTTON_WIDTH * BUTTON_COUNT,
theme->title_height);
continue;
case LAB_SSD_BUTTON_ICONIFY:
if (is_direct_child(part->node, subtree)) {
wlr_scene_node_set_position(part->node,
full_width - BUTTON_WIDTH * 3, 0);
width - BUTTON_WIDTH * 3, 0);
}
continue;
case LAB_SSD_BUTTON_MAXIMIZE:
if (is_direct_child(part->node, subtree)) {
wlr_scene_node_set_position(part->node,
full_width - BUTTON_WIDTH * 2, 0);
width - BUTTON_WIDTH * 2, 0);
}
continue;
case LAB_SSD_BUTTON_CLOSE:
if (is_direct_child(part->node, subtree)) {
wlr_scene_node_set_position(part->node,
full_width - BUTTON_WIDTH * 1, 0);
width - BUTTON_WIDTH * 1, -theme->border_width);
}
continue;
default: