mirror of
https://github.com/labwc/labwc.git
synced 2026-04-07 08:21:20 -04:00
Merge branch 'labwc:master' into osd-on-nearest-output
This commit is contained in:
commit
73ceba0fd9
3 changed files with 26 additions and 31 deletions
|
|
@ -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>
|
||||
|
|
@ -81,19 +82,19 @@ 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;
|
||||
|
||||
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;
|
||||
int h = wl_array_len(views) * switcher_theme->item_height + 2 * padding;
|
||||
if (show_workspace) {
|
||||
/* workspace indicator */
|
||||
h += switcher_theme->item_height;
|
||||
|
|
@ -115,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) {
|
||||
|
|
@ -143,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) {
|
||||
|
|
@ -174,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 =
|
||||
|
|
@ -188,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);
|
||||
|
|
@ -214,10 +210,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
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
#include <assert.h>
|
||||
#include <wlr/render/swapchain.h>
|
||||
#include <wlr/types/wlr_scene.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 "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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue