From 9b6e2b71e687293c25b3465c76c10cdf1a7bd8b5 Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Sun, 2 Nov 2025 11:29:50 +0900 Subject: [PATCH 1/3] osd: place osd at the center of output rather than usable area --- src/osd/osd-classic.c | 14 +++++++------- src/osd/osd-thumbnail.c | 16 ++++++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/osd/osd-classic.c b/src/osd/osd-classic.c index 7af72823..cbe0519d 100644 --- a/src/osd/osd-classic.c +++ b/src/osd/osd-classic.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only #include +#include #include #include #include @@ -84,13 +85,13 @@ osd_classic_create(struct output *output, struct wl_array *views) bool show_workspace = wl_list_length(&rc.workspace_config.workspaces) > 1; const char *workspace_name = server->workspaces.current->name; - int output_width, output_height; - wlr_output_effective_resolution(output->wlr_output, - &output_width, &output_height); + struct wlr_box output_box; + wlr_output_layout_get_box(server->output_layout, output->wlr_output, + &output_box); int w = switcher_theme->width; if (switcher_theme->width_is_percent) { - w = output_width * switcher_theme->width / 100; + w = output_box.width * switcher_theme->width / 100; } int h = wl_array_len(views) * switcher_theme->item_height + 2 * rc.theme->osd_border_width + 2 * switcher_theme->padding; @@ -214,10 +215,9 @@ osd_classic_create(struct output *output, struct wl_array *views) error:; /* Center OSD */ - struct wlr_box usable = output_usable_area_in_layout_coords(output); wlr_scene_node_set_position(&output->osd_scene.tree->node, - usable.x + usable.width / 2 - w / 2, - usable.y + usable.height / 2 - h / 2); + output_box.x + (output_box.width - w) / 2, + output_box.y + (output_box.height - h) / 2); } static void diff --git a/src/osd/osd-thumbnail.c b/src/osd/osd-thumbnail.c index 1ba65a79..0b300a23 100644 --- a/src/osd/osd-thumbnail.c +++ b/src/osd/osd-thumbnail.c @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-2.0-only #include -#include -#include #include +#include +#include +#include #include "config/rcxml.h" #include "common/array.h" #include "common/box.h" @@ -211,7 +212,8 @@ osd_thumbnail_create(struct output *output, struct wl_array *views) { assert(!output->osd_scene.tree); - struct theme *theme = output->server->theme; + struct server *server = output->server; + struct theme *theme = server->theme; struct window_switcher_thumbnail_theme *switcher_theme = &theme->osd_window_switcher_thumbnail; int padding = theme->osd_border_width + switcher_theme->padding; @@ -252,9 +254,11 @@ osd_thumbnail_create(struct output *output, struct wl_array *views) wlr_scene_node_lower_to_bottom(&bg->tree->node); /* center */ - struct wlr_box usable = output_usable_area_in_layout_coords(output); - int lx = usable.x + (usable.width - bg_opts.width) / 2; - int ly = usable.y + (usable.height - bg_opts.height) / 2; + struct wlr_box output_box; + wlr_output_layout_get_box(server->output_layout, output->wlr_output, + &output_box); + int lx = output_box.x + (output_box.width - bg_opts.width) / 2; + int ly = output_box.y + (output_box.height - bg_opts.height) / 2; wlr_scene_node_set_position(&output->osd_scene.tree->node, lx, ly); } From 9ce57c5f36f680b1f47e6e42d4dd4b975c58985b Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Sun, 2 Nov 2025 11:37:57 +0900 Subject: [PATCH 2/3] workspaces: place osd at the center of output rather than usable area --- src/workspaces.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/workspaces.c b/src/workspaces.c index 43f19b18..f56d170a 100644 --- a/src/workspaces.c +++ b/src/workspaces.c @@ -170,12 +170,8 @@ _osd_update(struct server *server) struct wlr_box output_box; wlr_output_layout_get_box(output->server->output_layout, output->wlr_output, &output_box); - int lx = output->usable_area.x - + (output->usable_area.width - width) / 2 - + output_box.x; - int ly = output->usable_area.y - + (output->usable_area.height - height) / 2 - + output_box.y; + int lx = output_box.x + (output_box.width - width) / 2; + int ly = output_box.y + (output_box.height - height) / 2; wlr_scene_node_set_position(&output->workspace_osd->node, lx, ly); wlr_scene_buffer_set_buffer(output->workspace_osd, &buffer->base); wlr_scene_buffer_set_dest_size(output->workspace_osd, From 7223056ffc5f242d98c195e2cb1b60a28d092c64 Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Sun, 2 Nov 2025 12:18:11 +0900 Subject: [PATCH 3/3] osd-classic: substitute `theme->osd_border_width+switcher_theme->padding` --- src/osd/osd-classic.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/osd/osd-classic.c b/src/osd/osd-classic.c index cbe0519d..27c58e17 100644 --- a/src/osd/osd-classic.c +++ b/src/osd/osd-classic.c @@ -82,6 +82,7 @@ osd_classic_create(struct output *output, struct wl_array *views) struct theme *theme = server->theme; struct window_switcher_classic_theme *switcher_theme = &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; 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) { w = output_box.width * switcher_theme->width / 100; } - int h = wl_array_len(views) * switcher_theme->item_height - + 2 * rc.theme->osd_border_width + 2 * switcher_theme->padding; + int h = wl_array_len(views) * switcher_theme->item_height + 2 * padding; if (show_workspace) { /* workspace indicator */ 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); - int y = theme->osd_border_width + switcher_theme->padding; + int y = padding; /* Draw workspace indicator */ 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); /* This is the width of the area available for text fields */ - int field_widths_sum = w - 2 * theme->osd_border_width - - 2 * switcher_theme->padding + int field_widths_sum = w - 2 * padding - 2 * switcher_theme->item_active_border_width - (nr_fields + 1) * switcher_theme->item_padding_x; 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 - + switcher_theme->padding + int x = padding + switcher_theme->item_active_border_width + switcher_theme->item_padding_x; 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; /* Highlight around selected window's item */ - int highlight_x = theme->osd_border_width - + switcher_theme->padding; struct lab_scene_rect_options highlight_opts = { .border_colors = (float *[1]) {active_border_color}, .bg_color = active_bg_color, .nr_borders = 1, .border_width = switcher_theme->item_active_border_width, - .width = w - 2 * theme->osd_border_width - - 2 * switcher_theme->padding, + .width = w - 2 * padding, .height = switcher_theme->item_height, }; struct lab_scene_rect *highlight_rect = lab_scene_rect_create( 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, text_color, bg_color, field_widths_sum, x, y);