backend/wayland: Fix HiDPI support for nested compositors

When running a wlroots-based compositor nested under another Wayland
compositor with HiDPI scaling, the nested window appears blurry and
incorrectly sized. This is because the Wayland backend does not:

1. Detect and track the parent compositor's output scale
2. Set wl_surface_set_buffer_scale() to match the parent's scale
3. Multiply output dimensions by the scale factor when handling
   configure events

This patch fixes all three issues by:

- Adding wlr_wl_parent_output structure to track parent outputs
- Listening to wl_output.scale events from the parent compositor
- Setting buffer_scale on all backend surfaces (output and layers)
- Scaling output dimensions to account for buffer scale
- Setting wlr_output.scale so nested clients render at correct DPI

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/854
This commit is contained in:
Anatolii Smolianinov 2025-10-30 11:13:32 +01:00
parent 604fcdb1db
commit f758cd1115
No known key found for this signature in database
GPG key ID: 2DFC2826A71FE8A0
3 changed files with 134 additions and 1 deletions

View file

@ -16,6 +16,14 @@
#include <wlr/render/drm_format_set.h>
#include <wlr/render/drm_syncobj.h>
struct wlr_wl_parent_output {
struct wlr_wl_backend *backend;
struct wl_output *wl_output;
uint32_t global_name;
int32_t scale;
struct wl_list link;
};
struct wlr_wl_backend {
struct wlr_backend backend;
@ -30,6 +38,9 @@ struct wlr_wl_backend {
struct wl_listener event_loop_destroy;
char *activation_token;
struct wl_list parent_outputs; // wlr_wl_parent_output.link
int32_t max_parent_scale;
/* remote state */
struct wl_display *remote_display;
bool own_remote_display;