RandR: Fix failure handling (Closes #4635; Thomas Winischhofer)
This commit is contained in:
parent
4608a2b654
commit
b5ce065a5e
@ -46,7 +46,7 @@ typedef struct _xf86RandRInfo {
|
|||||||
int mmHeight;
|
int mmHeight;
|
||||||
Rotation rotation;
|
Rotation rotation;
|
||||||
} XF86RandRInfoRec, *XF86RandRInfoPtr;
|
} XF86RandRInfoRec, *XF86RandRInfoPtr;
|
||||||
|
|
||||||
static int xf86RandRIndex;
|
static int xf86RandRIndex;
|
||||||
static int xf86RandRGeneration;
|
static int xf86RandRGeneration;
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
|
|||||||
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
|
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
|
||||||
DisplayModePtr mode;
|
DisplayModePtr mode;
|
||||||
int refresh0 = 60;
|
int refresh0 = 60;
|
||||||
|
|
||||||
*rotations = RR_Rotate_0;
|
*rotations = RR_Rotate_0;
|
||||||
|
|
||||||
for (mode = scrp->modes; ; mode = mode->next)
|
for (mode = scrp->modes; ; mode = mode->next)
|
||||||
@ -100,7 +100,7 @@ xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
|
|||||||
if (!pSize)
|
if (!pSize)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
RRRegisterRate (pScreen, pSize, refresh0);
|
RRRegisterRate (pScreen, pSize, refresh0);
|
||||||
if (scrp->virtualX == randrp->virtualX &&
|
if (scrp->virtualX == randrp->virtualX &&
|
||||||
scrp->virtualY == randrp->virtualY)
|
scrp->virtualY == randrp->virtualY)
|
||||||
{
|
{
|
||||||
RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize);
|
RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize);
|
||||||
@ -110,13 +110,13 @@ xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
|
|||||||
/* If there is driver support for randr, let it set our supported rotations */
|
/* If there is driver support for randr, let it set our supported rotations */
|
||||||
if(scrp->DriverFunc) {
|
if(scrp->DriverFunc) {
|
||||||
xorgRRRotation RRRotation;
|
xorgRRRotation RRRotation;
|
||||||
|
|
||||||
RRRotation.RRRotations = *rotations;
|
RRRotation.RRRotations = *rotations;
|
||||||
if (!(*scrp->DriverFunc)(scrp, RR_GET_INFO, &RRRotation))
|
if (!(*scrp->DriverFunc)(scrp, RR_GET_INFO, &RRRotation))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
*rotations = RRRotation.RRRotations;
|
*rotations = RRRotation.RRRotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,8 @@ xf86RandRSetMode (ScreenPtr pScreen,
|
|||||||
int oldmmWidth = pScreen->mmWidth;
|
int oldmmWidth = pScreen->mmWidth;
|
||||||
int oldmmHeight = pScreen->mmHeight;
|
int oldmmHeight = pScreen->mmHeight;
|
||||||
WindowPtr pRoot = WindowTable[pScreen->myNum];
|
WindowPtr pRoot = WindowTable[pScreen->myNum];
|
||||||
|
Bool ret = TRUE;
|
||||||
|
|
||||||
if (pRoot)
|
if (pRoot)
|
||||||
(*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
|
(*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
|
||||||
if (useVirtual)
|
if (useVirtual)
|
||||||
@ -168,7 +169,7 @@ xf86RandRSetMode (ScreenPtr pScreen,
|
|||||||
scrp->virtualY = pScreen->height = oldHeight;
|
scrp->virtualY = pScreen->height = oldHeight;
|
||||||
pScreen->mmWidth = oldmmWidth;
|
pScreen->mmWidth = oldmmWidth;
|
||||||
pScreen->mmHeight = oldmmHeight;
|
pScreen->mmHeight = oldmmHeight;
|
||||||
return FALSE;
|
ret = FALSE;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Make sure the layout is correct
|
* Make sure the layout is correct
|
||||||
@ -182,7 +183,7 @@ xf86RandRSetMode (ScreenPtr pScreen,
|
|||||||
xf86SetViewport (pScreen, 0, 0);
|
xf86SetViewport (pScreen, 0, 0);
|
||||||
if (pRoot)
|
if (pRoot)
|
||||||
(*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
|
(*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
|
||||||
return TRUE;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
@ -196,11 +197,12 @@ xf86RandRSetConfig (ScreenPtr pScreen,
|
|||||||
DisplayModePtr mode;
|
DisplayModePtr mode;
|
||||||
int px, py;
|
int px, py;
|
||||||
Bool useVirtual = FALSE;
|
Bool useVirtual = FALSE;
|
||||||
|
Rotation oldRotation = randrp->rotation;
|
||||||
|
|
||||||
miPointerPosition (&px, &py);
|
miPointerPosition (&px, &py);
|
||||||
for (mode = scrp->modes; ; mode = mode->next)
|
for (mode = scrp->modes; ; mode = mode->next)
|
||||||
{
|
{
|
||||||
if (mode->HDisplay == pSize->width &&
|
if (mode->HDisplay == pSize->width &&
|
||||||
mode->VDisplay == pSize->height &&
|
mode->VDisplay == pSize->height &&
|
||||||
(rate == 0 || xf86RandRModeRefresh (mode) == rate))
|
(rate == 0 || xf86RandRModeRefresh (mode) == rate))
|
||||||
break;
|
break;
|
||||||
@ -219,7 +221,7 @@ xf86RandRSetConfig (ScreenPtr pScreen,
|
|||||||
|
|
||||||
if (randrp->rotation != rotation) {
|
if (randrp->rotation != rotation) {
|
||||||
|
|
||||||
/* Have the driver do its thing. */
|
/* Have the driver do its thing. */
|
||||||
if (scrp->DriverFunc) {
|
if (scrp->DriverFunc) {
|
||||||
xorgRRRotation RRRotation;
|
xorgRRRotation RRRotation;
|
||||||
RRRotation.RRConfig.rotation = rotation;
|
RRRotation.RRConfig.rotation = rotation;
|
||||||
@ -234,12 +236,26 @@ xf86RandRSetConfig (ScreenPtr pScreen,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
} else
|
} else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
randrp->rotation = rotation;
|
randrp->rotation = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xf86RandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight))
|
if (!xf86RandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) {
|
||||||
|
if(randrp->rotation != oldRotation) {
|
||||||
|
/* Have the driver undo its thing. */
|
||||||
|
if (scrp->DriverFunc) {
|
||||||
|
xorgRRRotation RRRotation;
|
||||||
|
RRRotation.RRConfig.rotation = oldRotation;
|
||||||
|
RRRotation.RRConfig.rate = xf86RandRModeRefresh (scrp->currentMode);
|
||||||
|
RRRotation.RRConfig.width = pScreen->width;
|
||||||
|
RRRotation.RRConfig.height = pScreen->height;
|
||||||
|
(*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
randrp->rotation = oldRotation;
|
||||||
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Move the cursor back where it belongs; SwitchMode repositions it
|
* Move the cursor back where it belongs; SwitchMode repositions it
|
||||||
*/
|
*/
|
||||||
@ -269,13 +285,13 @@ xf86RandRCreateScreenResources (ScreenPtr pScreen)
|
|||||||
pScreen->CreateScreenResources = randrp->CreateScreenResources;
|
pScreen->CreateScreenResources = randrp->CreateScreenResources;
|
||||||
if (!(*pScreen->CreateScreenResources) (pScreen))
|
if (!(*pScreen->CreateScreenResources) (pScreen))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
mode = scrp->currentMode;
|
mode = scrp->currentMode;
|
||||||
if (mode)
|
if (mode)
|
||||||
xf86RandRSetMode (pScreen, mode, TRUE);
|
xf86RandRSetMode (pScreen, mode, TRUE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +303,7 @@ xf86RandRCloseScreen (int index, ScreenPtr pScreen)
|
|||||||
{
|
{
|
||||||
ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
|
ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
|
||||||
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
|
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
|
||||||
|
|
||||||
scrp->virtualX = pScreen->width = randrp->virtualX;
|
scrp->virtualX = pScreen->width = randrp->virtualX;
|
||||||
scrp->virtualY = pScreen->height = randrp->virtualY;
|
scrp->virtualY = pScreen->height = randrp->virtualY;
|
||||||
scrp->currentMode = scrp->modes;
|
scrp->currentMode = scrp->modes;
|
||||||
@ -303,7 +319,7 @@ xf86RandRInit (ScreenPtr pScreen)
|
|||||||
rrScrPrivPtr rp;
|
rrScrPrivPtr rp;
|
||||||
XF86RandRInfoPtr randrp;
|
XF86RandRInfoPtr randrp;
|
||||||
ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
|
ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
|
||||||
|
|
||||||
#ifdef PANORAMIX
|
#ifdef PANORAMIX
|
||||||
/* XXX disable RandR when using Xinerama */
|
/* XXX disable RandR when using Xinerama */
|
||||||
if (!noPanoramiXExtension)
|
if (!noPanoramiXExtension)
|
||||||
@ -314,11 +330,11 @@ xf86RandRInit (ScreenPtr pScreen)
|
|||||||
xf86RandRIndex = AllocateScreenPrivateIndex();
|
xf86RandRIndex = AllocateScreenPrivateIndex();
|
||||||
xf86RandRGeneration = serverGeneration;
|
xf86RandRGeneration = serverGeneration;
|
||||||
}
|
}
|
||||||
|
|
||||||
randrp = xalloc (sizeof (XF86RandRInfoRec));
|
randrp = xalloc (sizeof (XF86RandRInfoRec));
|
||||||
if (!randrp)
|
if (!randrp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!RRScreenInit (pScreen))
|
if (!RRScreenInit (pScreen))
|
||||||
{
|
{
|
||||||
xfree (randrp);
|
xfree (randrp);
|
||||||
@ -332,10 +348,10 @@ xf86RandRInit (ScreenPtr pScreen)
|
|||||||
randrp->virtualY = scrp->virtualY;
|
randrp->virtualY = scrp->virtualY;
|
||||||
randrp->mmWidth = pScreen->mmWidth;
|
randrp->mmWidth = pScreen->mmWidth;
|
||||||
randrp->mmHeight = pScreen->mmHeight;
|
randrp->mmHeight = pScreen->mmHeight;
|
||||||
|
|
||||||
randrp->CreateScreenResources = pScreen->CreateScreenResources;
|
randrp->CreateScreenResources = pScreen->CreateScreenResources;
|
||||||
pScreen->CreateScreenResources = xf86RandRCreateScreenResources;
|
pScreen->CreateScreenResources = xf86RandRCreateScreenResources;
|
||||||
|
|
||||||
randrp->CloseScreen = pScreen->CloseScreen;
|
randrp->CloseScreen = pScreen->CloseScreen;
|
||||||
pScreen->CloseScreen = xf86RandRCloseScreen;
|
pScreen->CloseScreen = xf86RandRCloseScreen;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user