mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
osd: place osd at the center of output rather than usable area
This commit is contained in:
parent
0f62648d39
commit
9b6e2b71e6
2 changed files with 17 additions and 13 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <wlr/types/wlr_output_layout.h>
|
||||||
#include <wlr/types/wlr_scene.h>
|
#include <wlr/types/wlr_scene.h>
|
||||||
#include <wlr/util/box.h>
|
#include <wlr/util/box.h>
|
||||||
#include <wlr/util/log.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;
|
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;
|
||||||
|
|
||||||
int output_width, output_height;
|
struct wlr_box output_box;
|
||||||
wlr_output_effective_resolution(output->wlr_output,
|
wlr_output_layout_get_box(server->output_layout, output->wlr_output,
|
||||||
&output_width, &output_height);
|
&output_box);
|
||||||
|
|
||||||
int w = switcher_theme->width;
|
int w = switcher_theme->width;
|
||||||
if (switcher_theme->width_is_percent) {
|
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
|
int h = wl_array_len(views) * switcher_theme->item_height
|
||||||
+ 2 * rc.theme->osd_border_width + 2 * switcher_theme->padding;
|
+ 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:;
|
error:;
|
||||||
/* Center OSD */
|
/* Center OSD */
|
||||||
struct wlr_box usable = output_usable_area_in_layout_coords(output);
|
|
||||||
wlr_scene_node_set_position(&output->osd_scene.tree->node,
|
wlr_scene_node_set_position(&output->osd_scene.tree->node,
|
||||||
usable.x + usable.width / 2 - w / 2,
|
output_box.x + (output_box.width - w) / 2,
|
||||||
usable.y + usable.height / 2 - h / 2);
|
output_box.y + (output_box.height - h) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <wlr/render/swapchain.h>
|
|
||||||
#include <wlr/types/wlr_scene.h>
|
|
||||||
#include <wlr/render/allocator.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 "config/rcxml.h"
|
#include "config/rcxml.h"
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
#include "common/box.h"
|
#include "common/box.h"
|
||||||
|
|
@ -211,7 +212,8 @@ osd_thumbnail_create(struct output *output, struct wl_array *views)
|
||||||
{
|
{
|
||||||
assert(!output->osd_scene.tree);
|
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 =
|
struct window_switcher_thumbnail_theme *switcher_theme =
|
||||||
&theme->osd_window_switcher_thumbnail;
|
&theme->osd_window_switcher_thumbnail;
|
||||||
int padding = theme->osd_border_width + switcher_theme->padding;
|
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);
|
wlr_scene_node_lower_to_bottom(&bg->tree->node);
|
||||||
|
|
||||||
/* center */
|
/* center */
|
||||||
struct wlr_box usable = output_usable_area_in_layout_coords(output);
|
struct wlr_box output_box;
|
||||||
int lx = usable.x + (usable.width - bg_opts.width) / 2;
|
wlr_output_layout_get_box(server->output_layout, output->wlr_output,
|
||||||
int ly = usable.y + (usable.height - bg_opts.height) / 2;
|
&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);
|
wlr_scene_node_set_position(&output->osd_scene.tree->node, lx, ly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue