2021-09-24 21:45:48 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2020-12-30 10:29:21 +00:00
|
|
|
#include "config.h"
|
2022-04-26 23:56:27 +02:00
|
|
|
#include <assert.h>
|
2021-08-16 07:16:56 +01:00
|
|
|
#include <cairo.h>
|
|
|
|
|
#include <drm_fourcc.h>
|
|
|
|
|
#include <pango/pangocairo.h>
|
2021-07-23 21:15:55 +01:00
|
|
|
#include <wlr/util/log.h>
|
2022-02-11 23:12:45 +00:00
|
|
|
#include "buffer.h"
|
2021-08-16 07:16:56 +01:00
|
|
|
#include "common/buf.h"
|
|
|
|
|
#include "common/font.h"
|
2022-08-20 20:11:58 +02:00
|
|
|
#include "common/graphic-helpers.h"
|
2022-04-26 23:56:27 +02:00
|
|
|
#include "common/scene-helpers.h"
|
2020-09-28 20:41:41 +01:00
|
|
|
#include "config/rcxml.h"
|
|
|
|
|
#include "labwc.h"
|
2021-10-13 21:29:32 +01:00
|
|
|
#include "theme.h"
|
2022-06-15 02:02:50 +02:00
|
|
|
#include "node.h"
|
|
|
|
|
#include "workspaces.h"
|
2020-08-20 21:13:04 +01:00
|
|
|
|
2021-08-16 07:16:56 +01:00
|
|
|
#define OSD_ITEM_HEIGHT (20)
|
|
|
|
|
#define OSD_ITEM_WIDTH (600)
|
|
|
|
|
#define OSD_ITEM_PADDING (10)
|
|
|
|
|
#define OSD_BORDER_WIDTH (6)
|
|
|
|
|
#define OSD_TAB1 (120)
|
|
|
|
|
#define OSD_TAB2 (300)
|
|
|
|
|
|
|
|
|
|
/* is title different from app_id/class? */
|
|
|
|
|
static int
|
|
|
|
|
is_title_different(struct view *view)
|
|
|
|
|
{
|
|
|
|
|
switch (view->type) {
|
|
|
|
|
case LAB_XDG_SHELL_VIEW:
|
2021-12-16 16:24:13 +00:00
|
|
|
return g_strcmp0(view_get_string_prop(view, "title"),
|
2021-10-18 20:01:10 +01:00
|
|
|
view_get_string_prop(view, "app_id"));
|
2021-08-16 07:16:56 +01:00
|
|
|
#if HAVE_XWAYLAND
|
|
|
|
|
case LAB_XWAYLAND_VIEW:
|
2021-12-16 16:24:13 +00:00
|
|
|
return g_strcmp0(view_get_string_prop(view, "title"),
|
2021-08-16 07:16:56 +01:00
|
|
|
view->xwayland_surface->class);
|
|
|
|
|
#endif
|
2020-08-20 21:13:04 +01:00
|
|
|
}
|
2021-08-16 07:16:56 +01:00
|
|
|
return 1;
|
2020-08-20 21:13:04 +01:00
|
|
|
}
|
2019-12-27 21:45:00 +00:00
|
|
|
|
2021-08-16 07:16:56 +01:00
|
|
|
static const char *
|
|
|
|
|
get_formatted_app_id(struct view *view)
|
2019-12-27 21:45:00 +00:00
|
|
|
{
|
2021-10-18 20:01:10 +01:00
|
|
|
char *s = (char *)view_get_string_prop(view, "app_id");
|
2022-04-04 20:53:36 +01:00
|
|
|
if (!s) {
|
2021-12-03 16:16:59 -05:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2021-08-16 07:16:56 +01:00
|
|
|
/* remove the first two nodes of 'org.' strings */
|
|
|
|
|
if (!strncmp(s, "org.", 4)) {
|
|
|
|
|
char *p = s + 4;
|
|
|
|
|
p = strchr(p, '.');
|
|
|
|
|
if (p) {
|
|
|
|
|
return ++p;
|
|
|
|
|
}
|
2019-12-27 21:45:00 +00:00
|
|
|
}
|
2021-08-16 07:16:56 +01:00
|
|
|
return s;
|
2019-12-27 21:45:00 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 07:16:56 +01:00
|
|
|
static int
|
2022-06-15 02:02:50 +02:00
|
|
|
get_osd_height(struct wl_list *node_list)
|
2019-12-27 21:45:00 +00:00
|
|
|
{
|
2021-08-16 07:16:56 +01:00
|
|
|
int height = 0;
|
|
|
|
|
struct view *view;
|
2022-06-15 02:02:50 +02:00
|
|
|
struct wlr_scene_node *node;
|
|
|
|
|
wl_list_for_each(node, node_list, link) {
|
|
|
|
|
view = node_view_from_node(node);
|
2021-08-16 07:16:56 +01:00
|
|
|
if (!isfocusable(view)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
height += OSD_ITEM_HEIGHT;
|
2019-12-27 21:45:00 +00:00
|
|
|
}
|
2021-08-16 07:16:56 +01:00
|
|
|
height += 2 * OSD_BORDER_WIDTH;
|
|
|
|
|
return height;
|
2019-12-27 21:45:00 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-12 22:04:27 +00:00
|
|
|
static void
|
2022-04-20 17:45:10 +01:00
|
|
|
destroy_osd_nodes(struct output *output)
|
2022-02-12 22:04:27 +00:00
|
|
|
{
|
|
|
|
|
struct wlr_scene_node *child, *next;
|
2022-06-05 17:12:55 +02:00
|
|
|
struct wl_list *children = &output->osd_tree->children;
|
2022-06-05 15:55:18 +02:00
|
|
|
wl_list_for_each_safe(child, next, children, link) {
|
2022-02-12 22:04:27 +00:00
|
|
|
wlr_scene_node_destroy(child);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 20:15:03 +02:00
|
|
|
static void
|
|
|
|
|
osd_update_preview_outlines(struct view *view)
|
|
|
|
|
{
|
|
|
|
|
/* Create / Update preview outline tree */
|
|
|
|
|
struct server *server = view->server;
|
2022-08-22 00:42:01 +02:00
|
|
|
struct multi_rect *rect = view->server->osd_state.preview_outline;
|
2022-07-04 20:15:03 +02:00
|
|
|
if (!rect) {
|
|
|
|
|
int line_width = server->theme->osd_border_width;
|
|
|
|
|
float *colors[] = {
|
|
|
|
|
server->theme->osd_bg_color,
|
|
|
|
|
server->theme->osd_label_text_color,
|
|
|
|
|
server->theme->osd_bg_color
|
|
|
|
|
};
|
|
|
|
|
rect = multi_rect_create(&server->scene->tree, colors, line_width);
|
|
|
|
|
wlr_scene_node_place_above(&rect->tree->node, &server->menu_tree->node);
|
2022-08-22 00:42:01 +02:00
|
|
|
server->osd_state.preview_outline = rect;
|
2022-07-04 20:15:03 +02:00
|
|
|
}
|
2022-08-27 13:26:30 +01:00
|
|
|
|
2022-07-04 20:15:03 +02:00
|
|
|
struct wlr_box geo = ssd_max_extents(view);
|
2022-08-27 13:26:30 +01:00
|
|
|
multi_rect_set_size(rect, geo.width, geo.height);
|
|
|
|
|
wlr_scene_node_set_position(&rect->tree->node, geo.x, geo.y);
|
2022-07-04 20:15:03 +02:00
|
|
|
}
|
|
|
|
|
|
2022-08-22 02:54:40 +02:00
|
|
|
void
|
|
|
|
|
osd_on_view_destroy(struct view *view)
|
|
|
|
|
{
|
|
|
|
|
assert(view);
|
|
|
|
|
struct osd_state *osd_state = &view->server->osd_state;
|
|
|
|
|
|
|
|
|
|
if (!osd_state->cycle_view) {
|
|
|
|
|
/* OSD not active, no need for clean up */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (osd_state->cycle_view == view) {
|
|
|
|
|
/*
|
|
|
|
|
* If we are the current OSD selected view, cycle
|
|
|
|
|
* to the next because we are dying.
|
|
|
|
|
*/
|
|
|
|
|
osd_state->cycle_view = desktop_cycle_view(view->server,
|
|
|
|
|
osd_state->cycle_view, LAB_CYCLE_DIR_BACKWARD);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If we cycled back to ourselves, then we have no more windows.
|
|
|
|
|
* Just close the OSD for good.
|
|
|
|
|
*/
|
|
|
|
|
if (osd_state->cycle_view == view || !osd_state->cycle_view) {
|
|
|
|
|
/* osd_finish() additionally resets cycle_view to NULL */
|
|
|
|
|
osd_finish(view->server);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (view->scene_tree) {
|
|
|
|
|
struct wlr_scene_node *node = &view->scene_tree->node;
|
|
|
|
|
if (osd_state->preview_anchor == node) {
|
|
|
|
|
/*
|
|
|
|
|
* If we are the anchor for the current OSD selected view,
|
|
|
|
|
* replace the anchor with the node before us.
|
|
|
|
|
*/
|
|
|
|
|
osd_state->preview_anchor = lab_wlr_scene_get_prev_node(node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (osd_state->cycle_view) {
|
|
|
|
|
/* Update the OSD to reflect the view has now gone. */
|
|
|
|
|
osd_update(view->server);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-12 22:04:27 +00:00
|
|
|
void
|
|
|
|
|
osd_finish(struct server *server)
|
|
|
|
|
{
|
2022-04-26 22:06:22 +02:00
|
|
|
server->osd_state.cycle_view = NULL;
|
2022-04-26 23:56:27 +02:00
|
|
|
server->osd_state.preview_node = NULL;
|
|
|
|
|
server->osd_state.preview_anchor = NULL;
|
2022-04-26 22:06:22 +02:00
|
|
|
|
2022-04-20 17:45:10 +01:00
|
|
|
struct output *output;
|
|
|
|
|
wl_list_for_each(output, &server->outputs, link) {
|
|
|
|
|
destroy_osd_nodes(output);
|
|
|
|
|
wlr_scene_node_set_enabled(&output->osd_tree->node, false);
|
|
|
|
|
}
|
2022-08-22 00:42:01 +02:00
|
|
|
if (server->osd_state.preview_outline) {
|
2022-07-04 20:15:03 +02:00
|
|
|
/* Destroy the whole multi_rect so we can easily react to new themes */
|
2022-08-22 00:42:01 +02:00
|
|
|
wlr_scene_node_destroy(&server->osd_state.preview_outline->tree->node);
|
|
|
|
|
server->osd_state.preview_outline = NULL;
|
2022-07-04 20:15:03 +02:00
|
|
|
}
|
2022-02-12 22:04:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-04-26 23:56:27 +02:00
|
|
|
void
|
|
|
|
|
osd_preview_restore(struct server *server)
|
|
|
|
|
{
|
|
|
|
|
struct osd_state *osd_state = &server->osd_state;
|
|
|
|
|
if (osd_state->preview_node) {
|
|
|
|
|
if (osd_state->preview_anchor) {
|
|
|
|
|
wlr_scene_node_place_above(osd_state->preview_node,
|
|
|
|
|
osd_state->preview_anchor);
|
|
|
|
|
} else {
|
|
|
|
|
/* Selected view was the first node */
|
|
|
|
|
wlr_scene_node_lower_to_bottom(osd_state->preview_node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Node was disabled / minimized before, disable again */
|
|
|
|
|
if (!osd_state->preview_was_enabled) {
|
|
|
|
|
wlr_scene_node_set_enabled(osd_state->preview_node, false);
|
|
|
|
|
}
|
|
|
|
|
osd_state->preview_node = NULL;
|
|
|
|
|
osd_state->preview_anchor = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
preview_cycled_view(struct view *view)
|
|
|
|
|
{
|
|
|
|
|
assert(view);
|
|
|
|
|
assert(view->scene_tree);
|
|
|
|
|
struct osd_state *osd_state = &view->server->osd_state;
|
|
|
|
|
|
|
|
|
|
/* Move previous selected node back to its original place */
|
|
|
|
|
osd_preview_restore(view->server);
|
|
|
|
|
|
|
|
|
|
/* Remember the sibling right before the selected node */
|
|
|
|
|
osd_state->preview_node = &view->scene_tree->node;
|
|
|
|
|
osd_state->preview_anchor = lab_wlr_scene_get_prev_node(
|
|
|
|
|
osd_state->preview_node);
|
|
|
|
|
|
|
|
|
|
/* Store node enabled / minimized state and force-enable if disabled */
|
|
|
|
|
osd_state->preview_was_enabled = osd_state->preview_node->enabled;
|
|
|
|
|
if (!osd_state->preview_was_enabled) {
|
|
|
|
|
wlr_scene_node_set_enabled(osd_state->preview_node, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Finally raise selected node to the top */
|
|
|
|
|
wlr_scene_node_raise_to_top(osd_state->preview_node);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-28 20:41:41 +01:00
|
|
|
void
|
2021-08-16 07:16:56 +01:00
|
|
|
osd_update(struct server *server)
|
2019-12-27 21:45:00 +00:00
|
|
|
{
|
2022-06-15 02:02:50 +02:00
|
|
|
struct wl_list *node_list =
|
|
|
|
|
&server->workspace_current->tree->children;
|
|
|
|
|
|
|
|
|
|
if (wl_list_empty(node_list)) {
|
2022-06-15 03:28:08 +02:00
|
|
|
osd_finish(server);
|
2022-04-20 17:45:10 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 21:29:32 +01:00
|
|
|
struct theme *theme = server->theme;
|
2022-06-15 02:02:50 +02:00
|
|
|
bool show_workspace = wl_list_length(&rc.workspace_config.workspaces) > 1;
|
2021-10-13 21:29:32 +01:00
|
|
|
|
2022-05-26 15:39:51 +02:00
|
|
|
struct buf buf;
|
|
|
|
|
buf_init(&buf);
|
2022-06-15 02:02:50 +02:00
|
|
|
|
|
|
|
|
struct view *view;
|
2022-02-09 16:38:07 -05:00
|
|
|
struct output *output;
|
2022-06-15 02:02:50 +02:00
|
|
|
struct wlr_scene_node *node;
|
2022-02-09 16:38:07 -05:00
|
|
|
wl_list_for_each(output, &server->outputs, link) {
|
2022-04-20 17:45:10 +01:00
|
|
|
destroy_osd_nodes(output);
|
2022-08-21 15:01:32 -04:00
|
|
|
if (!output->wlr_output->enabled) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-09 16:38:07 -05:00
|
|
|
float scale = output->wlr_output->scale;
|
2022-06-15 02:02:50 +02:00
|
|
|
int w = OSD_ITEM_WIDTH + (2 * OSD_BORDER_WIDTH);
|
|
|
|
|
int h = get_osd_height(node_list);
|
|
|
|
|
if (show_workspace) {
|
|
|
|
|
/* workspace indicator */
|
|
|
|
|
h += OSD_ITEM_HEIGHT;
|
|
|
|
|
}
|
2022-02-09 16:38:07 -05:00
|
|
|
|
2022-02-13 13:00:26 +00:00
|
|
|
if (output->osd_buffer) {
|
|
|
|
|
wlr_buffer_drop(&output->osd_buffer->base);
|
|
|
|
|
}
|
2022-06-12 21:11:25 +02:00
|
|
|
output->osd_buffer = buffer_create_cairo(w, h, scale, true);
|
2022-02-13 13:00:26 +00:00
|
|
|
|
|
|
|
|
cairo_t *cairo = output->osd_buffer->cairo;
|
|
|
|
|
cairo_surface_t *surf = cairo_get_target(cairo);
|
2022-02-09 16:38:07 -05:00
|
|
|
|
|
|
|
|
/* background */
|
2022-08-20 20:11:58 +02:00
|
|
|
set_cairo_color(cairo, theme->osd_bg_color);
|
2022-02-09 16:38:07 -05:00
|
|
|
cairo_rectangle(cairo, 0, 0, w, h);
|
|
|
|
|
cairo_fill(cairo);
|
|
|
|
|
|
2022-05-31 19:14:58 +02:00
|
|
|
/* Border */
|
2022-08-20 20:11:58 +02:00
|
|
|
set_cairo_color(cairo, theme->osd_border_color);
|
|
|
|
|
draw_cairo_border(cairo, w, h, theme->osd_border_width);
|
2022-02-09 16:38:07 -05:00
|
|
|
|
|
|
|
|
int y = OSD_BORDER_WIDTH;
|
2022-06-15 02:02:50 +02:00
|
|
|
|
|
|
|
|
if (show_workspace) {
|
|
|
|
|
/* workspace indicator */
|
|
|
|
|
y += OSD_ITEM_HEIGHT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* highlight current window */
|
|
|
|
|
wl_list_for_each_reverse(node, node_list, link) {
|
|
|
|
|
view = node_view_from_node(node);
|
2022-02-09 16:38:07 -05:00
|
|
|
if (!isfocusable(view)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2022-04-26 22:06:22 +02:00
|
|
|
if (view == server->osd_state.cycle_view) {
|
2022-08-20 20:11:58 +02:00
|
|
|
set_cairo_color(cairo, theme->osd_label_text_color);
|
2022-02-09 16:38:07 -05:00
|
|
|
cairo_rectangle(cairo, OSD_BORDER_WIDTH, y,
|
|
|
|
|
OSD_ITEM_WIDTH, OSD_ITEM_HEIGHT);
|
|
|
|
|
cairo_stroke(cairo);
|
2022-08-24 20:27:08 +02:00
|
|
|
if (rc.cycle_preview_outlines) {
|
|
|
|
|
osd_update_preview_outlines(view);
|
|
|
|
|
}
|
2022-02-09 16:38:07 -05:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
y += OSD_ITEM_HEIGHT;
|
2021-08-16 07:16:56 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-09 16:38:07 -05:00
|
|
|
/* text */
|
2022-08-20 20:11:58 +02:00
|
|
|
set_cairo_color(cairo, theme->osd_label_text_color);
|
2022-02-09 16:38:07 -05:00
|
|
|
PangoLayout *layout = pango_cairo_create_layout(cairo);
|
2022-06-19 21:10:03 +02:00
|
|
|
pango_layout_set_width(layout,
|
|
|
|
|
(OSD_ITEM_WIDTH - 2 * OSD_ITEM_PADDING) * PANGO_SCALE);
|
2022-02-09 16:38:07 -05:00
|
|
|
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
|
|
|
|
|
2022-09-15 10:53:49 -04:00
|
|
|
PangoFontDescription *desc = font_to_pango_desc(&rc.font_osd);
|
2022-02-09 16:38:07 -05:00
|
|
|
pango_layout_set_font_description(layout, desc);
|
|
|
|
|
|
|
|
|
|
PangoTabArray *tabs = pango_tab_array_new_with_positions(2, TRUE,
|
|
|
|
|
PANGO_TAB_LEFT, OSD_TAB1, PANGO_TAB_LEFT, OSD_TAB2);
|
|
|
|
|
pango_layout_set_tabs(layout, tabs);
|
|
|
|
|
pango_tab_array_free(tabs);
|
|
|
|
|
|
|
|
|
|
pango_cairo_update_layout(cairo, layout);
|
|
|
|
|
|
|
|
|
|
y = OSD_BORDER_WIDTH;
|
|
|
|
|
|
2022-06-15 02:02:50 +02:00
|
|
|
/* Center text entries on the y axis */
|
2022-09-15 10:53:49 -04:00
|
|
|
int y_offset = (OSD_ITEM_HEIGHT - font_height(&rc.font_osd)) / 2;
|
2022-06-15 02:02:50 +02:00
|
|
|
y += y_offset;
|
|
|
|
|
|
|
|
|
|
if (show_workspace) {
|
|
|
|
|
/* Center workspace indicator on the x axis */
|
2022-09-15 10:53:49 -04:00
|
|
|
int x = font_width(&rc.font_osd, server->workspace_current->name);
|
2022-06-15 02:02:50 +02:00
|
|
|
x = (OSD_ITEM_WIDTH - x) / 2;
|
|
|
|
|
cairo_move_to(cairo, x, y);
|
2022-09-15 10:53:49 -04:00
|
|
|
PangoWeight weight = pango_font_description_get_weight(desc);
|
2022-06-15 02:02:50 +02:00
|
|
|
pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
|
|
|
|
|
pango_layout_set_font_description(layout, desc);
|
2022-09-17 12:31:07 +01:00
|
|
|
pango_layout_set_text(layout,
|
|
|
|
|
server->workspace_current->name, -1);
|
2022-06-15 02:02:50 +02:00
|
|
|
pango_cairo_show_layout(cairo, layout);
|
2022-09-15 10:53:49 -04:00
|
|
|
pango_font_description_set_weight(desc, weight);
|
2022-06-15 02:02:50 +02:00
|
|
|
pango_layout_set_font_description(layout, desc);
|
|
|
|
|
y += OSD_ITEM_HEIGHT;
|
|
|
|
|
}
|
|
|
|
|
pango_font_description_free(desc);
|
|
|
|
|
|
|
|
|
|
wl_list_for_each_reverse(node, node_list, link) {
|
|
|
|
|
view = node_view_from_node(node);
|
2022-02-09 16:38:07 -05:00
|
|
|
if (!isfocusable(view)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
buf.len = 0;
|
|
|
|
|
cairo_move_to(cairo, OSD_BORDER_WIDTH + OSD_ITEM_PADDING, y);
|
|
|
|
|
|
|
|
|
|
switch (view->type) {
|
|
|
|
|
case LAB_XDG_SHELL_VIEW:
|
|
|
|
|
buf_add(&buf, "[xdg-shell]\t");
|
|
|
|
|
buf_add(&buf, get_formatted_app_id(view));
|
|
|
|
|
buf_add(&buf, "\t");
|
|
|
|
|
break;
|
2020-12-30 10:29:21 +00:00
|
|
|
#if HAVE_XWAYLAND
|
2022-02-09 16:38:07 -05:00
|
|
|
case LAB_XWAYLAND_VIEW:
|
|
|
|
|
buf_add(&buf, "[xwayland]\t");
|
|
|
|
|
buf_add(&buf, view_get_string_prop(view, "class"));
|
|
|
|
|
buf_add(&buf, "\t");
|
|
|
|
|
break;
|
2020-12-30 10:29:21 +00:00
|
|
|
#endif
|
2022-02-09 16:38:07 -05:00
|
|
|
}
|
2019-12-27 21:45:00 +00:00
|
|
|
|
2022-02-09 16:38:07 -05:00
|
|
|
if (is_title_different(view)) {
|
|
|
|
|
buf_add(&buf, view_get_string_prop(view, "title"));
|
|
|
|
|
}
|
2019-12-27 21:45:00 +00:00
|
|
|
|
2022-02-09 16:38:07 -05:00
|
|
|
pango_layout_set_text(layout, buf.buf, -1);
|
|
|
|
|
pango_cairo_show_layout(cairo, layout);
|
|
|
|
|
y += OSD_ITEM_HEIGHT;
|
|
|
|
|
}
|
|
|
|
|
g_object_unref(layout);
|
|
|
|
|
cairo_surface_flush(surf);
|
2022-02-11 23:12:45 +00:00
|
|
|
|
|
|
|
|
struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_create(
|
2022-06-05 15:17:35 +02:00
|
|
|
output->osd_tree, &output->osd_buffer->base);
|
2022-06-11 13:38:09 +00:00
|
|
|
wlr_scene_buffer_set_dest_size(scene_buffer, w, h);
|
2022-04-20 17:45:10 +01:00
|
|
|
|
|
|
|
|
/* Center OSD */
|
|
|
|
|
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 / 2
|
|
|
|
|
- w / 2 + output_box.x;
|
|
|
|
|
int ly = output->usable_area.y + output->usable_area.height / 2
|
|
|
|
|
- h / 2 + output_box.y;
|
2022-04-20 18:08:10 +01:00
|
|
|
wlr_scene_node_set_position(&scene_buffer->node, lx, ly);
|
2022-04-20 17:45:10 +01:00
|
|
|
wlr_scene_node_set_enabled(&output->osd_tree->node, true);
|
2020-06-18 20:39:55 +01:00
|
|
|
}
|
2022-05-26 15:39:51 +02:00
|
|
|
free(buf.buf);
|
2022-04-26 23:56:27 +02:00
|
|
|
|
|
|
|
|
if (rc.cycle_preview_contents) {
|
|
|
|
|
preview_cycled_view(server->osd_state.cycle_view);
|
|
|
|
|
}
|
2020-06-18 20:39:55 +01:00
|
|
|
}
|