From c7a2da7b994cdf829d805944c80f9fefd9246109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Spintzyk?= Date: Fri, 18 Sep 2020 14:31:34 +0200 Subject: [PATCH] present: fix msc offset calculation in screen mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of getting the current msc value from the window crtc, which not exist take the last saved msc value saved in the window_priv struct Signed-off-by: Ɓukasz Spintzyk (cherry picked from commit d2dce22b6775c772282ac2c0e224ef9685ab34fa) --- configure.ac | 2 +- hw/dmx/dmxextension.c | 3 --- hw/dmx/dmxinit.c | 2 -- present/present_scmd.c | 5 +++-- randr/randrstr.h | 5 +++++ randr/rrcrtc.c | 43 +++++++++++++++++++++++++++++++++++++++++- randr/rrprovider.c | 2 +- 7 files changed, 52 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 7ba6d05ba..91fc5fdbf 100644 --- a/configure.ac +++ b/configure.ac @@ -2236,7 +2236,7 @@ if test "x$DMX" = xyes; then fi DMX_INCLUDES="$XEXT_INC $RENDER_INC $RECORD_INC" XDMX_CFLAGS="$DMXMODULES_CFLAGS" - XDMX_LIBS="$FB_LIB $MI_LIB $XEXT_LIB $RENDER_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB $COMPOSITE_LIB $DAMAGE_LIB $MAIN_LIB $DIX_LIB $RANDR_LIB $CONFIG_LIB $OS_LIB $FIXES_LIB" + XDMX_LIBS="$FB_LIB $MI_LIB $XEXT_LIB $RENDER_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB $COMPOSITE_LIB $DAMAGE_LIB $MAIN_LIB $DIX_LIB $RANDR_LIB $RENDER_LIB $CONFIG_LIB $OS_LIB $FIXES_LIB" XDMX_SYS_LIBS="$DMXMODULES_LIBS" AC_SUBST([XDMX_CFLAGS]) AC_SUBST([XDMX_LIBS]) diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c index 4f5ca7252..e5ec7fa54 100644 --- a/hw/dmx/dmxextension.c +++ b/hw/dmx/dmxextension.c @@ -68,9 +68,6 @@ * _any_ header files. */ extern FontPtr defaultFont; -/* Hack to get Present to build (present requires RandR) */ -RESTYPE RRCrtcType; - /** This routine provides information to the DMX protocol extension * about a particular screen. */ Bool diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c index ddb331090..eae40413c 100644 --- a/hw/dmx/dmxinit.c +++ b/hw/dmx/dmxinit.c @@ -109,8 +109,6 @@ Bool dmxGLXSyncSwap = FALSE; Bool dmxGLXFinishSwap = FALSE; #endif -RESTYPE RRProviderType = 0; - Bool dmxIgnoreBadFontPaths = FALSE; Bool dmxAddRemoveScreens = FALSE; diff --git a/present/present_scmd.c b/present/present_scmd.c index 72a4026ea..3c68e690b 100644 --- a/present/present_scmd.c +++ b/present/present_scmd.c @@ -239,11 +239,12 @@ present_window_to_crtc_msc(WindowPtr window, RRCrtcPtr crtc, uint64_t window_msc if (window_priv->crtc == PresentCrtcNeverSet) { window_priv->msc_offset = 0; } else { - /* The old CRTC may have been turned off, in which case + /* The old CRTC may have been turned off or be destroyed, in which case * we'll just use whatever previous MSC we'd seen from this CRTC */ - if (present_get_ust_msc(window->drawable.pScreen, window_priv->crtc, &old_ust, &old_msc) != Success) + if (!RRCrtcExists(window->drawable.pScreen, window_priv->crtc) || + present_get_ust_msc(window->drawable.pScreen, window_priv->crtc, &old_ust, &old_msc) != Success) old_msc = window_priv->msc; window_priv->msc_offset += new_msc - old_msc; diff --git a/randr/randrstr.h b/randr/randrstr.h index 2cede92e3..0b95d6e25 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -642,6 +642,11 @@ extern _X_EXPORT void */ extern _X_EXPORT RRCrtcPtr RRCrtcCreate(ScreenPtr pScreen, void *devPrivate); +/* + * Tests if findCrtc belongs to pScreen or slave screens + */ +extern _X_EXPORT Bool RRCrtcExists(ScreenPtr pScreen, RRCrtcPtr findCrtc); + /* * Set the allowed rotations on a CRTC */ diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 7839a0eda..027a31a9e 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -27,7 +27,7 @@ #include -RESTYPE RRCrtcType; +RESTYPE RRCrtcType = 0; /* * Notify the CRTC of some change @@ -960,6 +960,47 @@ RRCrtcGammaGet(RRCrtcPtr crtc) return ret; } +static Bool RRCrtcInScreen(ScreenPtr pScreen, RRCrtcPtr findCrtc) +{ + rrScrPrivPtr pScrPriv; + int c; + + if (pScreen == NULL) + return FALSE; + + if (findCrtc == NULL) + return FALSE; + + if (!dixPrivateKeyRegistered(rrPrivKey)) + return FALSE; + + pScrPriv = rrGetScrPriv(pScreen); + for (c = 0; c < pScrPriv->numCrtcs; c++) { + if (pScrPriv->crtcs[c] == findCrtc) + return TRUE; + } + + return FALSE; +} + +Bool RRCrtcExists(ScreenPtr pScreen, RRCrtcPtr findCrtc) +{ + ScreenPtr slave= NULL; + + if (RRCrtcInScreen(pScreen, findCrtc)) + return TRUE; + + xorg_list_for_each_entry(slave, &pScreen->slave_list, slave_head) { + if (!slave->is_output_slave) + continue; + if (RRCrtcInScreen(slave, findCrtc)) + return TRUE; + } + + return FALSE; +} + + /* * Notify the extension that the Crtc gamma has been changed * The driver calls this whenever it has changed the gamma values diff --git a/randr/rrprovider.c b/randr/rrprovider.c index c430f7477..d90477235 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -27,7 +27,7 @@ #include -RESTYPE RRProviderType; +RESTYPE RRProviderType = 0; /* * Initialize provider type error value