From 814a04927d54586ea478ba6ac14eb4fca5667239 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Mon, 15 May 2023 09:23:57 +0200 Subject: [PATCH] xwayland: Keep the CVT timings for non-standard modes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current code, as changed by commit ad2d461de „Do not round non-standard modes“ is reported to be logically incongruent. We should either drop libxcvt entirely or simply fix the size, keeping the CVT timings unchanged. For backward compatibility and simplicity, I'd rather simply fix the hdisplay/vdisplay to match the given size. Signed-off-by: Olivier Fourdan Fixes: ad2d461de - xwayland: Do not round non-standard modes Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1549 --- hw/xwayland/xwayland-cvt.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/hw/xwayland/xwayland-cvt.c b/hw/xwayland/xwayland-cvt.c index d052471eb..4248d3869 100644 --- a/hw/xwayland/xwayland-cvt.c +++ b/hw/xwayland/xwayland-cvt.c @@ -53,17 +53,6 @@ xwayland_modeinfo_from_cvt(xRRModeInfo *modeinfo, free(libxcvt_mode_info); } -static void -xwayland_modeinfo_from_values(xRRModeInfo *modeinfo, - int hdisplay, int vdisplay, float vrefresh) -{ - modeinfo->width = hdisplay; - modeinfo->height = vdisplay; - modeinfo->hTotal = hdisplay; - modeinfo->vTotal = vdisplay; - modeinfo->dotClock = hdisplay * vdisplay * vrefresh; -} - RRModePtr xwayland_cvt(int hdisplay, int vdisplay, float vrefresh, Bool reduced, Bool interlaced) @@ -75,14 +64,13 @@ xwayland_cvt(int hdisplay, int vdisplay, float vrefresh, Bool reduced, hdisplay, vdisplay, vrefresh, reduced, interlaced); /* Horizontal granularity in libxcvt is 8, so if our horizontal size is not - * divisible by 8, libxcvt will round it down, and we will advertise a wrong - * size to our XRandR clients. Fallback to a simpler method in that case. + * divisible by 8, libxcvt will round it up, and we will advertise a wrong + * size to our XRandR clients. + * Force the width/height (i.e. simply increase blanking which should not + * hurt anything), keeping the rest of the CVT mode timings unchanged. */ - if (modeinfo.width != hdisplay || modeinfo.height != vdisplay) { - memset(&modeinfo, 0, sizeof(xRRModeInfo)); - xwayland_modeinfo_from_values(&modeinfo, - hdisplay, vdisplay, vrefresh); - } + modeinfo.width = hdisplay; + modeinfo.height = vdisplay; snprintf(name, sizeof name, "%dx%d", modeinfo.width, modeinfo.height);