From 3cbb9fcf839827f36b4f80821bc9aabef488e867 Mon Sep 17 00:00:00 2001 From: Icenowy Zheng Date: Tue, 13 May 2025 21:34:04 +0800 Subject: [PATCH] randr: do full transform when checking SetScreenSize size When validating the size passed to SetScreenSize, the CRTC mode size needs to be applied the full CRTC transform, otherwise the check may bogusly fail. Do a full transform on the CRTC mode size when checking the SetScreenSize request size instead of the current code that only manually handles rotation. Signed-off-by: Icenowy Zheng Part-of: --- randr/rrscreen.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/randr/rrscreen.c b/randr/rrscreen.c index c120dcc1c..3e3088d7b 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -273,17 +273,14 @@ ProcRRSetScreenSize(ClientPtr client) RRModePtr mode = crtc->mode; if (!RRCrtcIsLeased(crtc) && mode) { - int source_width = mode->mode.width; - int source_height = mode->mode.height; - Rotation rotation = crtc->rotation; + struct pixman_box16 display_box = { + crtc->x, crtc->y, + crtc->x + mode->mode.width, + crtc->y + mode->mode.height + }; + pixman_f_transform_bounds(&crtc->f_transform, &display_box); - if (rotation & (RR_Rotate_90 | RR_Rotate_270)) { - source_width = mode->mode.height; - source_height = mode->mode.width; - } - - if (crtc->x + source_width > stuff->width || - crtc->y + source_height > stuff->height) + if (display_box.x2 > stuff->width || display_box.y2 > stuff->height) return BadMatch; } }