From e086f6f5e00ef5466739bff107fb252be0b13705 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Wed, 9 Mar 2022 08:52:33 +0100 Subject: [PATCH] ssd: move top border above titlebar --- src/ssd/ssd.c | 2 +- src/ssd/ssd_border.c | 13 +++++-------- src/ssd/ssd_extents.c | 10 +++++----- src/ssd/ssd_part.c | 19 ++++++++++++++----- src/ssd/ssd_titlebar.c | 23 ++++++++++------------- src/theme.c | 4 ++-- 6 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index f42f06ec..902fd2d7 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -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, diff --git a/src/ssd/ssd_border.c b/src/ssd/ssd_border.c index 7425eff0..b87c4770 100644 --- a/src/ssd/ssd_border.c +++ b/src/ssd/ssd_border.c @@ -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; diff --git a/src/ssd/ssd_extents.c b/src/ssd/ssd_extents.c index 13d55fed..85f6e7ff 100644 --- a/src/ssd/ssd_extents.c +++ b/src/ssd/ssd_extents.c @@ -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; diff --git a/src/ssd/ssd_part.c b/src/ssd/ssd_part.c index 1dce341a..95eac508 100644 --- a/src/ssd/ssd_part.c +++ b/src/ssd/ssd_part.c @@ -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; } diff --git a/src/ssd/ssd_titlebar.c b/src/ssd/ssd_titlebar.c index b59e6f84..996b8a4e 100644 --- a/src/ssd/ssd_titlebar.c +++ b/src/ssd/ssd_titlebar.c @@ -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: diff --git a/src/theme.c b/src/theme.c index 1bf6dba0..1a745f17 100644 --- a/src/theme.c +++ b/src/theme.c @@ -421,8 +421,8 @@ create_corners(struct theme *theme) struct wlr_box box = { .x = 0, .y = 0, - .width = BUTTON_WIDTH, - .height = theme->title_height, + .width = BUTTON_WIDTH + theme->border_width, + .height = theme->title_height + theme->border_width, }; struct rounded_corner_ctx ctx = {