osd-classic: substitute theme->osd_border_width+switcher_theme->padding

This commit is contained in:
tokyo4j 2025-11-02 12:18:11 +09:00 committed by Consolatis
parent 9ce57c5f36
commit 7223056ffc

View file

@ -82,6 +82,7 @@ osd_classic_create(struct output *output, struct wl_array *views)
struct theme *theme = server->theme; struct theme *theme = server->theme;
struct window_switcher_classic_theme *switcher_theme = struct window_switcher_classic_theme *switcher_theme =
&theme->osd_window_switcher_classic; &theme->osd_window_switcher_classic;
int padding = theme->osd_border_width + switcher_theme->padding;
bool show_workspace = wl_list_length(&rc.workspace_config.workspaces) > 1; bool show_workspace = wl_list_length(&rc.workspace_config.workspaces) > 1;
const char *workspace_name = server->workspaces.current->name; const char *workspace_name = server->workspaces.current->name;
@ -93,8 +94,7 @@ osd_classic_create(struct output *output, struct wl_array *views)
if (switcher_theme->width_is_percent) { if (switcher_theme->width_is_percent) {
w = output_box.width * switcher_theme->width / 100; w = output_box.width * switcher_theme->width / 100;
} }
int h = wl_array_len(views) * switcher_theme->item_height int h = wl_array_len(views) * switcher_theme->item_height + 2 * padding;
+ 2 * rc.theme->osd_border_width + 2 * switcher_theme->padding;
if (show_workspace) { if (show_workspace) {
/* workspace indicator */ /* workspace indicator */
h += switcher_theme->item_height; h += switcher_theme->item_height;
@ -116,7 +116,7 @@ osd_classic_create(struct output *output, struct wl_array *views)
}; };
lab_scene_rect_create(output->osd_scene.tree, &bg_opts); lab_scene_rect_create(output->osd_scene.tree, &bg_opts);
int y = theme->osd_border_width + switcher_theme->padding; int y = padding;
/* Draw workspace indicator */ /* Draw workspace indicator */
if (show_workspace) { if (show_workspace) {
@ -144,8 +144,7 @@ osd_classic_create(struct output *output, struct wl_array *views)
int nr_fields = wl_list_length(&rc.window_switcher.fields); int nr_fields = wl_list_length(&rc.window_switcher.fields);
/* This is the width of the area available for text fields */ /* This is the width of the area available for text fields */
int field_widths_sum = w - 2 * theme->osd_border_width int field_widths_sum = w - 2 * padding
- 2 * switcher_theme->padding
- 2 * switcher_theme->item_active_border_width - 2 * switcher_theme->item_active_border_width
- (nr_fields + 1) * switcher_theme->item_padding_x; - (nr_fields + 1) * switcher_theme->item_padding_x;
if (field_widths_sum <= 0) { if (field_widths_sum <= 0) {
@ -175,8 +174,7 @@ osd_classic_create(struct output *output, struct wl_array *views)
* | | * | |
* +---------------------------------+ * +---------------------------------+
*/ */
int x = theme->osd_border_width int x = padding
+ switcher_theme->padding
+ switcher_theme->item_active_border_width + switcher_theme->item_active_border_width
+ switcher_theme->item_padding_x; + switcher_theme->item_padding_x;
struct wlr_scene_tree *item_root = struct wlr_scene_tree *item_root =
@ -189,20 +187,17 @@ osd_classic_create(struct output *output, struct wl_array *views)
float *active_border_color = switcher_theme->item_active_border_color; float *active_border_color = switcher_theme->item_active_border_color;
/* Highlight around selected window's item */ /* Highlight around selected window's item */
int highlight_x = theme->osd_border_width
+ switcher_theme->padding;
struct lab_scene_rect_options highlight_opts = { struct lab_scene_rect_options highlight_opts = {
.border_colors = (float *[1]) {active_border_color}, .border_colors = (float *[1]) {active_border_color},
.bg_color = active_bg_color, .bg_color = active_bg_color,
.nr_borders = 1, .nr_borders = 1,
.border_width = switcher_theme->item_active_border_width, .border_width = switcher_theme->item_active_border_width,
.width = w - 2 * theme->osd_border_width .width = w - 2 * padding,
- 2 * switcher_theme->padding,
.height = switcher_theme->item_height, .height = switcher_theme->item_height,
}; };
struct lab_scene_rect *highlight_rect = lab_scene_rect_create( struct lab_scene_rect *highlight_rect = lab_scene_rect_create(
item->active_tree, &highlight_opts); item->active_tree, &highlight_opts);
wlr_scene_node_set_position(&highlight_rect->tree->node, highlight_x, y); wlr_scene_node_set_position(&highlight_rect->tree->node, padding, y);
create_fields_scene(server, *view, item->normal_tree, create_fields_scene(server, *view, item->normal_tree,
text_color, bg_color, field_widths_sum, x, y); text_color, bg_color, field_widths_sum, x, y);