]> git.mdlowis.com Git - proto/labwc.git/commitdiff
osd: place osd at the center of output rather than usable area
authortokyo4j <hrak1529@gmail.com>
Sun, 2 Nov 2025 02:29:50 +0000 (11:29 +0900)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 2 Nov 2025 03:27:39 +0000 (04:27 +0100)
src/osd/osd-classic.c
src/osd/osd-thumbnail.c

index 7af728233519cb88003a5eba218b27d53271c6cf..cbe0519db83ea95b5b49477d403658f0838c7d11 100644 (file)
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include <assert.h>
+#include <wlr/types/wlr_output_layout.h>
 #include <wlr/types/wlr_scene.h>
 #include <wlr/util/box.h>
 #include <wlr/util/log.h>
@@ -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
index 1ba65a79ca7f4fc1697f7427e75f3e41dcdd8f97..0b300a2344a19b1ed1463b1ddead8b3301add28d 100644 (file)
@@ -1,8 +1,9 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include <assert.h>
+#include <wlr/render/allocator.h>
 #include <wlr/render/swapchain.h>
+#include <wlr/types/wlr_output_layout.h>
 #include <wlr/types/wlr_scene.h>
-#include <wlr/render/allocator.h>
 #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);
 }