From 9580caf8f82e26d1e827adfcc9b8554ec3031547 Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Tue, 12 Nov 2024 12:37:26 +0900 Subject: [PATCH] theme: rename title_height to titlebar_height Also removed the redundant initialization of title_height in theme_builtin(). --- include/theme.h | 2 +- src/ssd/ssd-titlebar.c | 16 ++++++++-------- src/ssd/ssd.c | 10 +++++----- src/theme.c | 13 ++++++------- src/view.c | 2 +- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/include/theme.h b/include/theme.h index d1657ea9..779b9499 100644 --- a/include/theme.h +++ b/include/theme.h @@ -44,7 +44,7 @@ struct theme { int window_titlebar_padding_width; int window_titlebar_padding_height; - int title_height; + int titlebar_height; float window_toggled_keybinds_color[4]; enum lab_justification window_label_text_justify; diff --git a/src/ssd/ssd-titlebar.c b/src/ssd/ssd-titlebar.c index 3c1c92b9..373dd1c4 100644 --- a/src/ssd/ssd-titlebar.c +++ b/src/ssd/ssd-titlebar.c @@ -52,12 +52,12 @@ ssd_titlebar_create(struct ssd *ssd) corner_top_left = &theme->window[active].corner_top_left_normal->base; corner_top_right = &theme->window[active].corner_top_right_normal->base; wlr_scene_node_set_enabled(&parent->node, active); - wlr_scene_node_set_position(&parent->node, 0, -theme->title_height); + wlr_scene_node_set_position(&parent->node, 0, -theme->titlebar_height); wl_list_init(&subtree->parts); /* Background */ add_scene_rect(&subtree->parts, LAB_SSD_PART_TITLEBAR, parent, - width - corner_width * 2, theme->title_height, + width - corner_width * 2, theme->titlebar_height, corner_width, 0, color); add_scene_buffer(&subtree->parts, LAB_SSD_PART_TITLEBAR_CORNER_LEFT, parent, corner_top_left, -rc.theme->border_width, -rc.theme->border_width); @@ -70,7 +70,7 @@ ssd_titlebar_create(struct ssd *ssd) int x = theme->window_titlebar_padding_width; /* Center vertically within titlebar */ - int y = (theme->title_height - theme->window_button_height) / 2; + int y = (theme->titlebar_height - theme->window_button_height) / 2; wl_list_for_each(b, &rc.title_buttons_left, link) { struct lab_data_buffer **buffers = @@ -152,8 +152,8 @@ set_squared_corners(struct ssd *ssd, bool enable) FOR_EACH_STATE(ssd, subtree) { part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR); wlr_scene_node_set_position(part->node, x, 0); - wlr_scene_rect_set_size( - wlr_scene_rect_from_node(part->node), width - 2 * x, theme->title_height); + wlr_scene_rect_set_size(wlr_scene_rect_from_node(part->node), + width - 2 * x, theme->titlebar_height); part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR_CORNER_LEFT); wlr_scene_node_set_enabled(part->node, !enable); @@ -291,7 +291,7 @@ ssd_titlebar_update(struct ssd *ssd) update_visible_buttons(ssd); /* Center buttons vertically within titlebar */ - int y = (theme->title_height - theme->window_button_height) / 2; + int y = (theme->titlebar_height - theme->window_button_height) / 2; int x; struct ssd_part *part; struct ssd_sub_tree *subtree; @@ -301,7 +301,7 @@ ssd_titlebar_update(struct ssd *ssd) part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR); wlr_scene_rect_set_size( wlr_scene_rect_from_node(part->node), - width - bg_offset * 2, theme->title_height); + width - bg_offset * 2, theme->titlebar_height); x = theme->window_titlebar_padding_width; wl_list_for_each(b, &rc.title_buttons_left, link) { @@ -386,7 +386,7 @@ ssd_update_title_positions(struct ssd *ssd, int offset_left, int offset_right) buffer_width = part->buffer ? part->buffer->width : 0; buffer_height = part->buffer ? part->buffer->height : 0; x = offset_left; - y = (theme->title_height - buffer_height) / 2; + y = (theme->titlebar_height - buffer_height) / 2; if (title_bg_width <= 0) { wlr_scene_node_set_enabled(part->node, false); diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index 149bf586..49f088b7 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -39,20 +39,20 @@ ssd_thickness(struct view *view) if (view->maximized == VIEW_AXIS_BOTH) { struct border thickness = { 0 }; if (!view->ssd_titlebar_hidden) { - thickness.top += theme->title_height; + thickness.top += theme->titlebar_height; } return thickness; } struct border thickness = { - .top = theme->title_height + theme->border_width, + .top = theme->titlebar_height + theme->border_width, .bottom = theme->border_width, .left = theme->border_width, .right = theme->border_width, }; if (view->ssd_titlebar_hidden) { - thickness.top -= theme->title_height; + thickness.top -= theme->titlebar_height; } return thickness; } @@ -176,7 +176,7 @@ ssd_create(struct view *view, bool active) ssd->view = view; ssd->tree = wlr_scene_tree_create(view->scene_tree); wlr_scene_node_lower_to_bottom(&ssd->tree->node); - ssd->titlebar.height = view->server->theme->title_height; + ssd->titlebar.height = view->server->theme->titlebar_height; ssd_shadow_create(ssd); ssd_extents_create(ssd); /* @@ -271,7 +271,7 @@ ssd_set_titlebar(struct ssd *ssd, bool enabled) return; } wlr_scene_node_set_enabled(&ssd->titlebar.tree->node, enabled); - ssd->titlebar.height = enabled ? ssd->view->server->theme->title_height : 0; + ssd->titlebar.height = enabled ? ssd->view->server->theme->titlebar_height : 0; ssd_border_update(ssd); ssd_extents_update(ssd); ssd_shadow_update(ssd); diff --git a/src/theme.c b/src/theme.c index 0e503ce1..56d10ebd 100644 --- a/src/theme.c +++ b/src/theme.c @@ -179,7 +179,7 @@ create_rounded_buffer(struct theme *theme, enum corner corner, * border. See the picture in #2189 for reference. */ int margin_x = theme->window_titlebar_padding_width; - int margin_y = (theme->title_height - theme->window_button_height) / 2; + int margin_y = (theme->titlebar_height - theme->window_button_height) / 2; float white[4] = {1, 1, 1, 1}; struct rounded_corner_ctx rounded_ctx = { .box = &(struct wlr_box){ @@ -562,7 +562,6 @@ theme_builtin(struct theme *theme, struct server *server) theme->border_width = 1; theme->window_titlebar_padding_height = 0; theme->window_titlebar_padding_width = 0; - theme->title_height = INT_MIN; parse_hexstr("#e1dedb", theme->window[THEME_ACTIVE].border_color); parse_hexstr("#f6f5f4", theme->window[THEME_INACTIVE].border_color); @@ -1243,7 +1242,7 @@ create_corners(struct theme *theme) .x = 0, .y = 0, .width = corner_width + theme->border_width, - .height = theme->title_height + theme->border_width, + .height = theme->titlebar_height + theme->border_width, }; for (int active = THEME_INACTIVE; active <= THEME_ACTIVE; active++) { @@ -1409,7 +1408,7 @@ create_shadow(struct theme *theme, int active) total_size, theme->window[active].shadow_color); shadow_corner_gradient(theme->window[active].shadow_corner_top, visible_size, total_size, - theme->title_height, theme->window[active].shadow_color); + theme->titlebar_height, theme->window[active].shadow_color); shadow_corner_gradient(theme->window[active].shadow_corner_bottom, visible_size, total_size, 0, theme->window[active].shadow_color); @@ -1445,7 +1444,7 @@ get_titlebar_height(struct theme *theme) static void post_processing(struct theme *theme) { - theme->title_height = get_titlebar_height(theme); + theme->titlebar_height = get_titlebar_height(theme); theme->menu_item_height = font_height(&rc.font_menuitem) + 2 * theme->menu_items_padding_y; @@ -1457,8 +1456,8 @@ post_processing(struct theme *theme) + 2 * theme->osd_window_switcher_item_padding_y + 2 * theme->osd_window_switcher_item_active_border_width; - if (rc.corner_radius >= theme->title_height) { - rc.corner_radius = theme->title_height - 1; + if (rc.corner_radius >= theme->titlebar_height) { + rc.corner_radius = theme->titlebar_height - 1; } int min_button_hover_radius = diff --git a/src/view.c b/src/view.c index 51b335a7..c8ff0275 100644 --- a/src/view.c +++ b/src/view.c @@ -980,7 +980,7 @@ view_cascade(struct view *view) int offset_x = rc.placement_cascade_offset_x; int offset_y = rc.placement_cascade_offset_y; struct theme *theme = view->server->theme; - int default_offset = theme->title_height + theme->border_width + 5; + int default_offset = theme->titlebar_height + theme->border_width + 5; if (offset_x <= 0) { offset_x = default_offset; }