From 9b6e2b71e687293c25b3465c76c10cdf1a7bd8b5 Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Sun, 2 Nov 2025 11:29:50 +0900 Subject: [PATCH] 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); }