From c6484574a6351d44d08f8ef91222ed7a7d18c971 Mon Sep 17 00:00:00 2001 From: Kurt Kanzenbach Date: Wed, 9 Jul 2025 15:07:44 +0200 Subject: [PATCH] frontend: Fix VNC mirror screen rotation The following config allows to mirror the LVDS output to VNC: |[output] |name=LVDS-1 |transform=rotate-270 | |[output] |name=vnc |mirror-of=LVDS-1 However, the current code only takes the scale into account, not the relative transformation. In case of rotate 90 or 270 the width and height have to be swapped. Add it. Closes: https://gitlab.freedesktop.org/wayland/weston/-/issues/1076 Signed-off-by: Kurt Kanzenbach --- frontend/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/main.c b/frontend/main.c index 626d1e88e..4dca72314 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -3331,6 +3331,21 @@ wet_output_compute_output_from_mirror(struct weston_output *output, mode->height = output->native_mode_copy.height / mirror->current_scale; + /* Switch width and height for transform 90 or 270 */ + switch (output->transform) { + case WL_OUTPUT_TRANSFORM_90: + case WL_OUTPUT_TRANSFORM_270: + case WL_OUTPUT_TRANSFORM_FLIPPED_90: + case WL_OUTPUT_TRANSFORM_FLIPPED_270: { + int32_t tmp = mode->width; + mode->width = mode->height; + mode->height = tmp; + break; + } + default: + break; + } + mode->refresh = output->native_mode_copy.refresh; *scale = output->current_scale; }