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

Implements: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/854
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/5186
Co-Authored-By: Hugo Osvaldo Barrera <hugo@whynothugo.nl>
This commit is contained in:
Anatolii Smolianinov 2025-10-30 11:13:32 +01:00 committed by Hugo Osvaldo Barrera
parent a94cd29eb1
commit 514eeebd3c
6 changed files with 171 additions and 15 deletions

View file

@ -534,8 +534,9 @@ static void handle_tablet_tool_motion(void *data, struct zwp_tablet_tool_v2 *id,
struct wlr_wl_output *output = tool->output;
assert(output);
tool->x = wl_fixed_to_double(x) / output->wlr_output.width;
tool->y = wl_fixed_to_double(y) / output->wlr_output.height;
// Parent compositor sends coordinates in logical (unscaled) space.
tool->x = wl_fixed_to_double(x) / output->logical_width;
tool->y = wl_fixed_to_double(y) / output->logical_height;
}
static void handle_tablet_tool_pressure(void *data,