]> git.mdlowis.com Git - proto/labwc.git/commitdiff
ssd: move top border above titlebar
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 9 Mar 2022 07:52:33 +0000 (08:52 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 12 Mar 2022 15:32:44 +0000 (15:32 +0000)
src/ssd/ssd.c
src/ssd/ssd_border.c
src/ssd/ssd_extents.c
src/ssd/ssd_part.c
src/ssd/ssd_titlebar.c
src/theme.c

index f42f06ecb7b541c90ebdc0292c3c18c1d27802fc..902fd2d72b5ebfe4583a61422f1b8c031574a4ab 100644 (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,
index 7425eff0918cee78930115f04448b8245b87df23..b87c477096ca63ac756e8171647596e6c9f9e8eb 100644 (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;
index 13d55fedd2bf92e5aeccc42523045e4f13b8339e..85f6e7ffd8f808bb86b78dea1f55c3f15c72cf5f 100644 (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;
index 1dce341a94413c7a028f596cfb1b0a16cc3b1f64..95eac508f5cad5837b09f2f5577595cb77364554 100644 (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;
 }
index b59e6f8492ba28eb6d1676d4b7d29a0bf3734512..996b8a4e4b5cfc9f8ebdb6c4e1bd0b5f77d92564 100644 (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:
index 1bf6dba00e010ef8ebd27d13ff2a8a2a0e72ee1f..1a745f17dc685d09df8f46b672cd30f3427ae6ef 100644 (file)
@@ -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 = {