summaryrefslogtreecommitdiff
path: root/src/gx_randr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gx_randr.c')
-rw-r--r--src/gx_randr.c242
1 files changed, 122 insertions, 120 deletions
diff --git a/src/gx_randr.c b/src/gx_randr.c
index 116678d..2176019 100644
--- a/src/gx_randr.c
+++ b/src/gx_randr.c
@@ -48,16 +48,15 @@
static int GXRandRGeneration;
-typedef struct _GXRandRInfo
-{
+typedef struct _GXRandRInfo {
int virtualX;
int virtualY;
int mmWidth;
int mmHeight;
int maxX;
int maxY;
- Rotation rotation; /* current mode */
- Rotation supported_rotations; /* driver supported */
+ Rotation rotation; /* current mode */
+ Rotation supported_rotations; /* driver supported */
} XF86RandRInfoRec, *XF86RandRInfoPtr;
#if HAS_DEVPRIVATEKEYREC
@@ -81,10 +80,9 @@ static int
GXRandRModeRefresh(DisplayModePtr mode)
{
if (mode->VRefresh)
- return (int)(mode->VRefresh + 0.5);
+ return (int) (mode->VRefresh + 0.5);
else
- return (int)(mode->Clock * 1000.0 / mode->HTotal / mode->VTotal +
- 0.5);
+ return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
}
static Bool
@@ -100,59 +98,59 @@ GXRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
*rotations = pRandr->supported_rotations;
if (pRandr->virtualX == -1 || pRandr->virtualY == -1) {
- pRandr->virtualX = pScrni->virtualX;
- pRandr->virtualY = pScrni->virtualY;
+ pRandr->virtualX = pScrni->virtualX;
+ pRandr->virtualY = pScrni->virtualY;
}
for (mode = pScrni->modes;; mode = mode->next) {
- int refresh = GXRandRModeRefresh(mode);
-
- if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- if (maxX < mode->HDisplay)
- maxX = mode->HDisplay;
- if (maxY < mode->VDisplay)
- maxY = mode->VDisplay;
- }
-
- if (mode == pScrni->modes)
- refresh0 = refresh;
-
- pSize = RRRegisterSize(pScreen,
- mode->HDisplay, mode->VDisplay,
- pRandr->mmWidth, pRandr->mmHeight);
- if (!pSize)
- return FALSE;
-
- RRRegisterRate(pScreen, pSize, refresh);
-
- if (mode == pScrni->currentMode &&
- mode->HDisplay == pScrni->virtualX
- && mode->VDisplay == pScrni->virtualY)
- RRSetCurrentConfig(pScreen, pRandr->rotation, refresh, pSize);
- if (mode->next == pScrni->modes)
- break;
+ int refresh = GXRandRModeRefresh(mode);
+
+ if (pRandr->maxX == 0 || pRandr->maxY == 0) {
+ if (maxX < mode->HDisplay)
+ maxX = mode->HDisplay;
+ if (maxY < mode->VDisplay)
+ maxY = mode->VDisplay;
+ }
+
+ if (mode == pScrni->modes)
+ refresh0 = refresh;
+
+ pSize = RRRegisterSize(pScreen,
+ mode->HDisplay, mode->VDisplay,
+ pRandr->mmWidth, pRandr->mmHeight);
+ if (!pSize)
+ return FALSE;
+
+ RRRegisterRate(pScreen, pSize, refresh);
+
+ if (mode == pScrni->currentMode &&
+ mode->HDisplay == pScrni->virtualX
+ && mode->VDisplay == pScrni->virtualY)
+ RRSetCurrentConfig(pScreen, pRandr->rotation, refresh, pSize);
+ if (mode->next == pScrni->modes)
+ break;
}
if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- pRandr->maxX = maxX;
- pRandr->maxY = maxY;
+ pRandr->maxX = maxX;
+ pRandr->maxY = maxY;
}
if (pScrni->currentMode->HDisplay != pScrni->virtualX ||
- pScrni->currentMode->VDisplay != pScrni->virtualY) {
-
- mode = pScrni->modes;
- pSize = RRRegisterSize(pScreen,
- pRandr->virtualX, pRandr->virtualY,
- pRandr->mmWidth, pRandr->mmHeight);
- if (!pSize)
- return FALSE;
-
- RRRegisterRate(pScreen, pSize, refresh0);
- if (pScrni->virtualX == pRandr->virtualX &&
- pScrni->virtualY == pRandr->virtualY) {
- RRSetCurrentConfig(pScreen, pRandr->rotation, refresh0, pSize);
- }
+ pScrni->currentMode->VDisplay != pScrni->virtualY) {
+
+ mode = pScrni->modes;
+ pSize = RRRegisterSize(pScreen,
+ pRandr->virtualX, pRandr->virtualY,
+ pRandr->mmWidth, pRandr->mmHeight);
+ if (!pSize)
+ return FALSE;
+
+ RRRegisterRate(pScreen, pSize, refresh0);
+ if (pScrni->virtualX == pRandr->virtualX &&
+ pScrni->virtualY == pRandr->virtualY) {
+ RRSetCurrentConfig(pScreen, pRandr->rotation, refresh0, pSize);
+ }
}
return TRUE;
@@ -160,7 +158,7 @@ GXRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
static Bool
GXRandRSetMode(ScreenPtr pScreen,
- DisplayModePtr mode, Bool useVirtual, int mmWidth, int mmHeight)
+ DisplayModePtr mode, Bool useVirtual, int mmWidth, int mmHeight)
{
ScrnInfoPtr pScrni = XF86SCRNINFO(pScreen);
XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
@@ -169,6 +167,7 @@ GXRandRSetMode(ScreenPtr pScreen,
int oldHeight = pScreen->height;
int oldmmWidth = pScreen->mmWidth;
int oldmmHeight = pScreen->mmHeight;
+
#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 8
WindowPtr pRoot = WindowTable[pScreen->myNum];
#else
@@ -176,45 +175,48 @@ GXRandRSetMode(ScreenPtr pScreen,
#endif
DisplayModePtr currentMode = NULL;
Bool ret = TRUE;
+
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,9,99,1,0)
PixmapPtr pspix = NULL;
- #endif
+#endif
if (pRoot)
- (*pScrni->EnableDisableFBAccess) (pScreen->myNum, FALSE);
+ (*pScrni->EnableDisableFBAccess) (pScreen->myNum, FALSE);
if (useVirtual) {
- pScrni->virtualX = pRandr->virtualX;
- pScrni->virtualY = pRandr->virtualY;
- } else {
- pScrni->virtualX = mode->HDisplay;
- pScrni->virtualY = mode->VDisplay;
+ pScrni->virtualX = pRandr->virtualX;
+ pScrni->virtualY = pRandr->virtualY;
+ }
+ else {
+ pScrni->virtualX = mode->HDisplay;
+ pScrni->virtualY = mode->VDisplay;
}
if (pRandr->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
- pScreen->width = pScrni->virtualY;
- pScreen->height = pScrni->virtualX;
- pScreen->mmWidth = mmHeight;
- pScreen->mmHeight = mmWidth;
- } else {
- pScreen->width = pScrni->virtualX;
- pScreen->height = pScrni->virtualY;
- pScreen->mmWidth = mmWidth;
- pScreen->mmHeight = mmHeight;
+ pScreen->width = pScrni->virtualY;
+ pScreen->height = pScrni->virtualX;
+ pScreen->mmWidth = mmHeight;
+ pScreen->mmHeight = mmWidth;
+ }
+ else {
+ pScreen->width = pScrni->virtualX;
+ pScreen->height = pScrni->virtualY;
+ pScreen->mmWidth = mmWidth;
+ pScreen->mmHeight = mmHeight;
}
if (pScrni->currentMode == mode) {
- currentMode = pScrni->currentMode;
- pScrni->currentMode = NULL;
+ currentMode = pScrni->currentMode;
+ pScrni->currentMode = NULL;
}
if (!xf86SwitchMode(pScreen, mode)) {
- ret = FALSE;
- pScrni->virtualX = pScreen->width = oldWidth;
- pScrni->virtualY = pScreen->height = oldHeight;
- pScreen->mmWidth = oldmmWidth;
- pScreen->mmHeight = oldmmHeight;
- pScrni->currentMode = currentMode;
+ ret = FALSE;
+ pScrni->virtualX = pScreen->width = oldWidth;
+ pScrni->virtualY = pScreen->height = oldHeight;
+ pScreen->mmWidth = oldmmWidth;
+ pScreen->mmHeight = oldmmHeight;
+ pScrni->currentMode = currentMode;
}
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,9,99,1,0)
@@ -225,7 +227,7 @@ GXRandRSetMode(ScreenPtr pScreen,
*/
pspix = (*pScreen->GetScreenPixmap) (pScreen);
if (pspix->devPrivate.ptr)
- pScrni->pixmapPrivate = pspix->devPrivate;
+ pScrni->pixmapPrivate = pspix->devPrivate;
#endif
xf86ReconfigureLayout();
@@ -234,14 +236,14 @@ GXRandRSetMode(ScreenPtr pScreen,
xf86SetViewport(pScreen, 0, 0);
if (pRoot)
- (*pScrni->EnableDisableFBAccess) (pScreen->myNum, TRUE);
+ (*pScrni->EnableDisableFBAccess) (pScreen->myNum, TRUE);
return ret;
}
Bool
GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
- int rate, RRScreenSizePtr pSize)
+ int rate, RRScreenSizePtr pSize)
{
ScrnInfoPtr pScrni = XF86SCRNINFO(pScreen);
XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
@@ -255,8 +257,8 @@ GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
pRandr->rotation = rotation;
if (pRandr->virtualX == -1 || pRandr->virtualY == -1) {
- pRandr->virtualX = pScrni->virtualX;
- pRandr->virtualY = pScrni->virtualY;
+ pRandr->virtualX = pScrni->virtualX;
+ pRandr->virtualY = pScrni->virtualY;
}
/* FIXME: we don't have a new video ABI yet */
@@ -267,40 +269,40 @@ GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
#endif
for (mode = pScrni->modes;; mode = mode->next) {
- if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- if (maxX < mode->HDisplay)
- maxX = mode->HDisplay;
- if (maxY < mode->VDisplay)
- maxY = mode->VDisplay;
- }
- if (mode->HDisplay == pSize->width &&
- mode->VDisplay == pSize->height &&
- (rate == 0 || GXRandRModeRefresh(mode) == rate))
- break;
- if (mode->next == pScrni->modes) {
- if (pSize->width == pRandr->virtualX &&
- pSize->height == pRandr->virtualY) {
- mode = pScrni->modes;
- useVirtual = TRUE;
- break;
- }
- if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- pRandr->maxX = maxX;
- pRandr->maxY = maxY;
- }
- return FALSE;
- }
+ if (pRandr->maxX == 0 || pRandr->maxY == 0) {
+ if (maxX < mode->HDisplay)
+ maxX = mode->HDisplay;
+ if (maxY < mode->VDisplay)
+ maxY = mode->VDisplay;
+ }
+ if (mode->HDisplay == pSize->width &&
+ mode->VDisplay == pSize->height &&
+ (rate == 0 || GXRandRModeRefresh(mode) == rate))
+ break;
+ if (mode->next == pScrni->modes) {
+ if (pSize->width == pRandr->virtualX &&
+ pSize->height == pRandr->virtualY) {
+ mode = pScrni->modes;
+ useVirtual = TRUE;
+ break;
+ }
+ if (pRandr->maxX == 0 || pRandr->maxY == 0) {
+ pRandr->maxX = maxX;
+ pRandr->maxY = maxY;
+ }
+ return FALSE;
+ }
}
if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- pRandr->maxX = maxX;
- pRandr->maxY = maxY;
+ pRandr->maxX = maxX;
+ pRandr->maxY = maxY;
}
if (!GXRandRSetMode(pScreen, mode, useVirtual, pSize->mmWidth,
- pSize->mmHeight)) {
- pRandr->rotation = oldRotation;
- return FALSE;
+ pSize->mmHeight)) {
+ pRandr->rotation = oldRotation;
+ return FALSE;
}
/* FIXME: we don't have a new video ABI yet */
@@ -310,17 +312,17 @@ GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
if (pScreen == miPointerCurrentScreen())
#endif
{
- px = (px >= pScreen->width ? (pScreen->width - 1) : px);
- py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+ px = (px >= pScreen->width ? (pScreen->width - 1) : px);
+ py = (py >= pScreen->height ? (pScreen->height - 1) : py);
- xf86SetViewport(pScreen, px, py);
+ xf86SetViewport(pScreen, px, py);
/* FIXME: we don't have a new video ABI yet */
- (*pScreen->SetCursorPosition) (
+ (*pScreen->SetCursorPosition) (
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
- inputInfo.pointer,
+ inputInfo.pointer,
#endif
- pScreen, px, py, FALSE);
+ pScreen, px, py, FALSE);
}
return TRUE;
@@ -341,23 +343,23 @@ GXRandRInit(ScreenPtr pScreen, int rotation)
rrScrPrivPtr rp;
if (GXRandRGeneration != serverGeneration) {
- GXRandRGeneration = serverGeneration;
+ GXRandRGeneration = serverGeneration;
}
#if OLD_VIDEODRV_INTERFACE
GXRandRIndex = AllocateScreenPrivateIndex();
#endif
#if HAS_DIXREGISTERPRIVATEKEY
if (!dixRegisterPrivateKey(&GXRandRIndex, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
#endif
pRandr = calloc(1, sizeof(XF86RandRInfoRec));
if (pRandr == NULL)
- return FALSE;
+ return FALSE;
if (!RRScreenInit(pScreen)) {
- free(pRandr);
- return FALSE;
+ free(pRandr);
+ return FALSE;
}
rp = rrGetScrPriv(pScreen);