From d75e8146c414bfd512ba5dbd4a83acb334bbe19b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 12 Jul 2010 16:01:34 -0700 Subject: Unwrap/rewrap EnterVT/LeaveVT completely, Fixes 28998 Because some EnterVT code needs to remove it self from the call chain, we need to fix all of the wrappers to correctly unwrap/rewrap during the call chain. This is a follow-on to the fix for bug 27114 in commit 68a9ee8370e6f9b38218376ac92d5130a5b0ef1e. Signed-off-by: Keith Packard Tested-by: Jesse Barnes Reviewed-by: Daniel Stone Reviewed-by: Tiago Vignatti --- glx/glxdri.c | 17 +++++++++++++++-- glx/glxdri2.c | 17 +++++++++++++++-- hw/xfree86/common/xf86VGAarbiter.c | 10 +++++++++- hw/xfree86/common/xf86cmap.c | 8 +++++++- hw/xfree86/common/xf86xv.c | 8 ++++++++ hw/xfree86/shadowfb/shadow.c | 11 ++++++++++- hw/xfree86/xaa/xaaInit.c | 12 +++++++++++- 7 files changed, 75 insertions(+), 8 deletions(-) diff --git a/glx/glxdri.c b/glx/glxdri.c index 32b35db4c..41482c913 100644 --- a/glx/glxdri.c +++ b/glx/glxdri.c @@ -866,12 +866,21 @@ static const char dri_driver_path[] = DRI_DRIVER_PATH; static Bool glxDRIEnterVT (int index, int flags) { + ScrnInfoPtr scrn = xf86Screens[index]; + Bool ret; __GLXDRIscreen *screen = (__GLXDRIscreen *) glxGetScreen(screenInfo.screens[index]); LogMessage(X_INFO, "AIGLX: Resuming AIGLX clients after VT switch\n"); - if (!(*screen->enterVT) (index, flags)) + scrn->EnterVT = screen->enterVT; + + ret = scrn->EnterVT (index, flags); + + screen->enterVT = scrn->EnterVT; + scrn->EnterVT = glxDRIEnterVT; + + if (!ret) return FALSE; glxResumeClients(); @@ -882,6 +891,7 @@ glxDRIEnterVT (int index, int flags) static void glxDRILeaveVT (int index, int flags) { + ScrnInfoPtr scrn = xf86Screens[index]; __GLXDRIscreen *screen = (__GLXDRIscreen *) glxGetScreen(screenInfo.screens[index]); @@ -889,7 +899,10 @@ glxDRILeaveVT (int index, int flags) glxSuspendClients(); - return (*screen->leaveVT) (index, flags); + scrn->LeaveVT = screen->leaveVT; + (*screen->leaveVT) (index, flags); + screen->leaveVT = scrn->LeaveVT; + scrn->LeaveVT = glxDRILeaveVT; } static void diff --git a/glx/glxdri2.c b/glx/glxdri2.c index 970a51ae3..c2305ad90 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -605,12 +605,21 @@ static const char dri_driver_path[] = DRI_DRIVER_PATH; static Bool glxDRIEnterVT (int index, int flags) { + ScrnInfoPtr scrn = xf86Screens[index]; + Bool ret; __GLXDRIscreen *screen = (__GLXDRIscreen *) glxGetScreen(screenInfo.screens[index]); LogMessage(X_INFO, "AIGLX: Resuming AIGLX clients after VT switch\n"); - if (!(*screen->enterVT) (index, flags)) + scrn->EnterVT = screen->enterVT; + + ret = scrn->EnterVT (index, flags); + + screen->enterVT = scrn->EnterVT; + scrn->EnterVT = glxDRIEnterVT; + + if (!ret) return FALSE; glxResumeClients(); @@ -621,6 +630,7 @@ glxDRIEnterVT (int index, int flags) static void glxDRILeaveVT (int index, int flags) { + ScrnInfoPtr scrn = xf86Screens[index]; __GLXDRIscreen *screen = (__GLXDRIscreen *) glxGetScreen(screenInfo.screens[index]); @@ -628,7 +638,10 @@ glxDRILeaveVT (int index, int flags) glxSuspendClients(); - return (*screen->leaveVT) (index, flags); + scrn->LeaveVT = screen->leaveVT; + (*screen->leaveVT) (index, flags); + screen->leaveVT = scrn->LeaveVT; + scrn->LeaveVT = glxDRILeaveVT; } static void diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c index a58d21a2d..05cf24502 100644 --- a/hw/xfree86/common/xf86VGAarbiter.c +++ b/hw/xfree86/common/xf86VGAarbiter.c @@ -523,12 +523,16 @@ static Bool VGAarbiterEnterVT(int index, int flags) { Bool val; + ScrnInfoPtr pScrn = xf86Screens[index]; ScreenPtr pScreen = screenInfo.screens[index]; VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate( &pScreen->devPrivates, VGAarbiterScreenKey); VGAGet(); - val = (*pScreenPriv->EnterVT)(index, flags); + pScrn->EnterVT = pScreenPriv->EnterVT; + val = (*pScrn->EnterVT)(index, flags); + pScreenPriv->EnterVT = pScrn->EnterVT; + pScrn->EnterVT = VGAarbiterEnterVT; VGAPut(); return val; } @@ -536,12 +540,16 @@ VGAarbiterEnterVT(int index, int flags) static void VGAarbiterLeaveVT(int index, int flags) { + ScrnInfoPtr pScrn = xf86Screens[index]; ScreenPtr pScreen = screenInfo.screens[index]; VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate( &pScreen->devPrivates, VGAarbiterScreenKey); VGAGet(); + pScrn->LeaveVT = pScreenPriv->LeaveVT; (*pScreenPriv->LeaveVT)(index, flags); + pScreenPriv->LeaveVT = pScrn->LeaveVT; + pScrn->LeaveVT = VGAarbiterLeaveVT; VGAPut(); } diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c index d2a8f12b8..8b27b8418 100644 --- a/hw/xfree86/common/xf86cmap.c +++ b/hw/xfree86/common/xf86cmap.c @@ -466,11 +466,17 @@ CMapInstallColormap(ColormapPtr pmap) static Bool CMapEnterVT(int index, int flags) { + ScrnInfoPtr pScrn = xf86Screens[index]; ScreenPtr pScreen = screenInfo.screens[index]; + Bool ret; CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( &pScreen->devPrivates, CMapScreenKey); - if((*pScreenPriv->EnterVT)(index, flags)) { + pScrn->EnterVT = pScreenPriv->EnterVT; + ret = (*pScreenPriv->EnterVT)(index, flags); + pScreenPriv->EnterVT = pScrn->EnterVT; + pScrn->EnterVT = CMapEnterVT; + if(ret) { if(GetInstalledmiColormap(pScreen)) CMapReinstallMap(GetInstalledmiColormap(pScreen)); return TRUE; diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 948f82d8f..c1d319976 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -1229,11 +1229,15 @@ xf86XVQueryAdaptors( static Bool xf86XVEnterVT(int index, int flags) { + ScrnInfoPtr pScrn = xf86Screens[index]; ScreenPtr pScreen = screenInfo.screens[index]; XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); Bool ret; + pScrn->EnterVT = ScreenPriv->EnterVT; ret = (*ScreenPriv->EnterVT)(index, flags); + ScreenPriv->EnterVT = pScrn->EnterVT; + pScrn->EnterVT = xf86XVEnterVT; if(ret) WalkTree(pScreen, xf86XVReputAllVideo, 0); @@ -1243,6 +1247,7 @@ xf86XVEnterVT(int index, int flags) static void xf86XVLeaveVT(int index, int flags) { + ScrnInfoPtr pScrn = xf86Screens[index]; ScreenPtr pScreen = screenInfo.screens[index]; XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); @@ -1274,7 +1279,10 @@ xf86XVLeaveVT(int index, int flags) } } + pScrn->LeaveVT = ScreenPriv->LeaveVT; (*ScreenPriv->LeaveVT)(index, flags); + ScreenPriv->LeaveVT = pScrn->LeaveVT; + pScrn->LeaveVT = xf86XVLeaveVT; } static void diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c index 977398177..344f1abf7 100644 --- a/hw/xfree86/shadowfb/shadow.c +++ b/hw/xfree86/shadowfb/shadow.c @@ -216,9 +216,14 @@ static Bool ShadowEnterVT(int index, int flags) { ScrnInfoPtr pScrn = xf86Screens[index]; + Bool ret; ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScrn->pScreen); - if((*pPriv->EnterVT)(index, flags)) { + pScrn->EnterVT = pPriv->EnterVT; + ret = (*pPriv->EnterVT)(index, flags); + pPriv->EnterVT = pScrn->EnterVT; + pScrn->EnterVT = ShadowEnterVT; + if(ret) { pPriv->vtSema = TRUE; return TRUE; } @@ -229,11 +234,15 @@ ShadowEnterVT(int index, int flags) static void ShadowLeaveVT(int index, int flags) { + ScrnInfoPtr pScrn = xf86Screens[index]; ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(xf86Screens[index]->pScreen); pPriv->vtSema = FALSE; + pScrn->LeaveVT = pPriv->LeaveVT; (*pPriv->LeaveVT)(index, flags); + pPriv->LeaveVT = pScrn->LeaveVT; + pScrn->LeaveVT = ShadowLeaveVT; } /**********************************************************/ diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c index ec55632e9..11443a60e 100644 --- a/hw/xfree86/xaa/xaaInit.c +++ b/hw/xfree86/xaa/xaaInit.c @@ -508,16 +508,23 @@ XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask) static Bool XAAEnterVT(int index, int flags) { + ScrnInfoPtr pScrn = xf86Screens[index]; + Bool ret; ScreenPtr pScreen = screenInfo.screens[index]; XAAScreenPtr pScreenPriv = (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); - return((*pScreenPriv->EnterVT)(index, flags)); + pScrn->EnterVT = pScreenPriv->EnterVT; + ret = ((*pScreenPriv->EnterVT)(index, flags)); + pScreenPriv->EnterVT = pScrn->EnterVT; + pScrn->EnterVT = XAAEnterVT; + return ret; } static void XAALeaveVT(int index, int flags) { + ScrnInfoPtr pScrn = xf86Screens[index]; ScreenPtr pScreen = screenInfo.screens[index]; XAAScreenPtr pScreenPriv = (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); @@ -528,7 +535,10 @@ XAALeaveVT(int index, int flags) infoRec->NeedToSync = FALSE; } + pScrn->LeaveVT = pScreenPriv->LeaveVT; (*pScreenPriv->LeaveVT)(index, flags); + pScreenPriv->LeaveVT = pScrn->LeaveVT; + pScrn->LeaveVT = XAALeaveVT; } typedef struct { -- cgit v1.2.3