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
|
// 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>
|
||||||
|
|
@ -81,19 +82,19 @@ osd_classic_create(struct output *output, struct wl_array *views)
|
||||||
struct theme *theme = server->theme;
|
struct theme *theme = server->theme;
|
||||||
struct window_switcher_classic_theme *switcher_theme =
|
struct window_switcher_classic_theme *switcher_theme =
|
||||||
&theme->osd_window_switcher_classic;
|
&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;
|
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 * padding;
|
||||||
+ 2 * rc.theme->osd_border_width + 2 * switcher_theme->padding;
|
|
||||||
if (show_workspace) {
|
if (show_workspace) {
|
||||||
/* workspace indicator */
|
/* workspace indicator */
|
||||||
h += switcher_theme->item_height;
|
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);
|
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 */
|
/* Draw workspace indicator */
|
||||||
if (show_workspace) {
|
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);
|
int nr_fields = wl_list_length(&rc.window_switcher.fields);
|
||||||
|
|
||||||
/* This is the width of the area available for text fields */
|
/* This is the width of the area available for text fields */
|
||||||
int field_widths_sum = w - 2 * theme->osd_border_width
|
int field_widths_sum = w - 2 * padding
|
||||||
- 2 * switcher_theme->padding
|
|
||||||
- 2 * switcher_theme->item_active_border_width
|
- 2 * switcher_theme->item_active_border_width
|
||||||
- (nr_fields + 1) * switcher_theme->item_padding_x;
|
- (nr_fields + 1) * switcher_theme->item_padding_x;
|
||||||
if (field_widths_sum <= 0) {
|
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
|
int x = padding
|
||||||
+ switcher_theme->padding
|
|
||||||
+ switcher_theme->item_active_border_width
|
+ switcher_theme->item_active_border_width
|
||||||
+ switcher_theme->item_padding_x;
|
+ switcher_theme->item_padding_x;
|
||||||
struct wlr_scene_tree *item_root =
|
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;
|
float *active_border_color = switcher_theme->item_active_border_color;
|
||||||
|
|
||||||
/* Highlight around selected window's item */
|
/* Highlight around selected window's item */
|
||||||
int highlight_x = theme->osd_border_width
|
|
||||||
+ switcher_theme->padding;
|
|
||||||
struct lab_scene_rect_options highlight_opts = {
|
struct lab_scene_rect_options highlight_opts = {
|
||||||
.border_colors = (float *[1]) {active_border_color},
|
.border_colors = (float *[1]) {active_border_color},
|
||||||
.bg_color = active_bg_color,
|
.bg_color = active_bg_color,
|
||||||
.nr_borders = 1,
|
.nr_borders = 1,
|
||||||
.border_width = switcher_theme->item_active_border_width,
|
.border_width = switcher_theme->item_active_border_width,
|
||||||
.width = w - 2 * theme->osd_border_width
|
.width = w - 2 * padding,
|
||||||
- 2 * switcher_theme->padding,
|
|
||||||
.height = switcher_theme->item_height,
|
.height = switcher_theme->item_height,
|
||||||
};
|
};
|
||||||
struct lab_scene_rect *highlight_rect = lab_scene_rect_create(
|
struct lab_scene_rect *highlight_rect = lab_scene_rect_create(
|
||||||
item->active_tree, &highlight_opts);
|
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,
|
create_fields_scene(server, *view, item->normal_tree,
|
||||||
text_color, bg_color, field_widths_sum, x, y);
|
text_color, bg_color, field_widths_sum, x, y);
|
||||||
|
|
@ -214,10 +210,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,12 +170,8 @@ _osd_update(struct server *server)
|
||||||
struct wlr_box output_box;
|
struct wlr_box output_box;
|
||||||
wlr_output_layout_get_box(output->server->output_layout,
|
wlr_output_layout_get_box(output->server->output_layout,
|
||||||
output->wlr_output, &output_box);
|
output->wlr_output, &output_box);
|
||||||
int lx = output->usable_area.x
|
int lx = output_box.x + (output_box.width - width) / 2;
|
||||||
+ (output->usable_area.width - width) / 2
|
int ly = output_box.y + (output_box.height - height) / 2;
|
||||||
+ output_box.x;
|
|
||||||
int ly = output->usable_area.y
|
|
||||||
+ (output->usable_area.height - height) / 2
|
|
||||||
+ output_box.y;
|
|
||||||
wlr_scene_node_set_position(&output->workspace_osd->node, lx, ly);
|
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_buffer(output->workspace_osd, &buffer->base);
|
||||||
wlr_scene_buffer_set_dest_size(output->workspace_osd,
|
wlr_scene_buffer_set_dest_size(output->workspace_osd,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue