OSD: Use separate OSD texture for each output

This commit is contained in:
ARDiDo 2022-02-09 16:38:07 -05:00 committed by Johan Malm
parent 049b84409e
commit 7c437eac2f
3 changed files with 105 additions and 109 deletions

View file

@ -144,7 +144,6 @@ struct server {
double grab_x, grab_y; double grab_x, grab_y;
struct wlr_box grab_box; struct wlr_box grab_box;
uint32_t resize_edges; uint32_t resize_edges;
struct wlr_texture *osd;
struct wl_list outputs; struct wl_list outputs;
struct wl_listener new_output; struct wl_listener new_output;
@ -154,7 +153,6 @@ struct server {
struct wlr_output_manager_v1 *output_manager; struct wlr_output_manager_v1 *output_manager;
struct wl_listener output_manager_apply; struct wl_listener output_manager_apply;
struct wlr_output_configuration_v1 *pending_output_config; struct wlr_output_configuration_v1 *pending_output_config;
float greatest_scale;
struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager;
@ -177,6 +175,7 @@ struct output {
struct wlr_output_damage *damage; struct wlr_output_damage *damage;
struct wl_list layers[4]; struct wl_list layers[4];
struct wlr_box usable_area; struct wlr_box usable_area;
struct wlr_texture *osd;
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener damage_frame; struct wl_listener damage_frame;

View file

@ -79,7 +79,9 @@ osd_update(struct server *server)
struct wlr_renderer *renderer = server->renderer; struct wlr_renderer *renderer = server->renderer;
struct theme *theme = server->theme; struct theme *theme = server->theme;
float scale = server->greatest_scale; struct output *output;
wl_list_for_each(output, &server->outputs, link) {
float scale = output->wlr_output->scale;
int w = (OSD_ITEM_WIDTH + (2 * OSD_BORDER_WIDTH)) * scale; int w = (OSD_ITEM_WIDTH + (2 * OSD_BORDER_WIDTH)) * scale;
int h = get_osd_height(&server->views) * scale; int h = get_osd_height(&server->views) * scale;
@ -186,8 +188,9 @@ osd_update(struct server *server)
cairo_destroy(cairo); cairo_destroy(cairo);
cairo_surface_destroy(surf); cairo_surface_destroy(surf);
if (server->osd) { if (output->osd) {
wlr_texture_destroy(server->osd); wlr_texture_destroy(output->osd);
}
output->osd = texture;
} }
server->osd = texture;
} }

View file

@ -516,10 +516,6 @@ static void
render_osd(struct output *output, pixman_region32_t *damage, render_osd(struct output *output, pixman_region32_t *damage,
struct server *server) struct server *server)
{ {
if (!server->osd) {
return;
}
/* show on screen display (osd) on all outputs */ /* show on screen display (osd) on all outputs */
struct output *o; struct output *o;
struct wlr_output_layout *layout = server->output_layout; struct wlr_output_layout *layout = server->output_layout;
@ -530,15 +526,16 @@ render_osd(struct output *output, pixman_region32_t *damage,
continue; continue;
} }
if (!output->osd) {
continue;
}
struct wlr_box box = { struct wlr_box box = {
.x = ol_output->x + o->wlr_output->width .x = ol_output->x + o->wlr_output->width
/ 2, / 2,
.y = ol_output->y + o->wlr_output->height .y = ol_output->y + o->wlr_output->height
/ 2, / 2,
.width = server->osd->width * o->wlr_output->scale .width = output->osd->width,
/ server->greatest_scale, .height = output->osd->height,
.height = server->osd->height * o->wlr_output->scale
/ server->greatest_scale,
}; };
box.x -= box.width / 2; box.x -= box.width / 2;
box.y -= box.height / 2; box.y -= box.height / 2;
@ -551,7 +548,7 @@ render_osd(struct output *output, pixman_region32_t *damage,
float matrix[9]; float matrix[9];
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
0, output->wlr_output->transform_matrix); 0, output->wlr_output->transform_matrix);
render_texture(o->wlr_output, damage, server->osd, NULL, &box, render_texture(o->wlr_output, damage, output->osd, NULL, &box,
matrix); matrix);
} }
} }
@ -1046,6 +1043,9 @@ new_output_notify(struct wl_listener *listener, void *data)
wlr_output->name); wlr_output->name);
wlr_output_enable_adaptive_sync(wlr_output, true); wlr_output_enable_adaptive_sync(wlr_output, true);
} }
output->osd = NULL;
wlr_output_layout_add_auto(server->output_layout, wlr_output); wlr_output_layout_add_auto(server->output_layout, wlr_output);
} }
@ -1071,8 +1071,6 @@ output_init(struct server *server)
wl_list_init(&server->outputs); wl_list_init(&server->outputs);
server->greatest_scale = 1;
output_manager_init(server); output_manager_init(server);
} }
@ -1167,11 +1165,7 @@ handle_output_manager_apply(struct wl_listener *listener, void *data)
} }
wlr_output_configuration_v1_destroy(config); wlr_output_configuration_v1_destroy(config);
struct output *output; struct output *output;
server->greatest_scale = 0;
wl_list_for_each(output, &server->outputs, link) { wl_list_for_each(output, &server->outputs, link) {
if (output->wlr_output->scale > server->greatest_scale) {
server->greatest_scale = output->wlr_output->scale;
}
wlr_xcursor_manager_load(server->seat.xcursor_manager, wlr_xcursor_manager_load(server->seat.xcursor_manager,
output->wlr_output->scale); output->wlr_output->scale);
} }