diff options
Diffstat (limited to 'hw/xfree86/modes/xf86RandR12.c')
-rw-r--r-- | hw/xfree86/modes/xf86RandR12.c | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 48e7efe00..1c20082ce 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -60,11 +60,11 @@ static Bool xf86RandR12Init12 (ScreenPtr pScreen); static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen); #endif -static int xf86RandR12Index; -static int xf86RandR12Generation; +static int xf86RandR12Generation; +static DevPrivateKey xf86RandR12Key; -#define XF86RANDRINFO(p) \ - ((XF86RandRInfoPtr)(p)->devPrivates[xf86RandR12Index].ptr) +#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \ + dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key)) static int xf86RandR12ModeRefresh (DisplayModePtr mode) @@ -341,10 +341,12 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen, PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen); Bool ret = FALSE; - if (randrp->virtualX == -1 || randrp->virtualY == -1) - { - randrp->virtualX = pScrn->virtualX; - randrp->virtualY = pScrn->virtualY; + if (xf86RandR12Key) { + if (randrp->virtualX == -1 || randrp->virtualY == -1) + { + randrp->virtualX = pScrn->virtualX; + randrp->virtualY = pScrn->virtualY; + } } if (pRoot && pScrn->vtSema) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE); @@ -367,7 +369,7 @@ finish: if (pRoot && pScrn->vtSema) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE); #if RANDR_12_INTERFACE - if (WindowTable[pScreen->myNum] && ret) + if (xf86RandR12Key && WindowTable[pScreen->myNum] && ret) RRScreenSizeNotify (pScreen); #endif return ret; @@ -451,10 +453,10 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen) else { /* - * Otherwise, just set the screen to 96dpi + * Otherwise, just set the screen to DEFAULT_DPI */ - mmWidth = width * 25.4 / 96; - mmHeight = height * 25.4 / 96; + mmWidth = width * 25.4 / DEFAULT_DPI; + mmHeight = height * 25.4 / DEFAULT_DPI; } } xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -467,6 +469,9 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen) mmHeight); } + if (xf86RandR12Key == NULL) + return TRUE; + if (randrp->virtualX == -1 || randrp->virtualY == -1) { randrp->virtualX = pScrn->virtualX; @@ -492,11 +497,11 @@ xf86RandR12Init (ScreenPtr pScreen) if (!noPanoramiXExtension) return TRUE; #endif + if (xf86RandR12Generation != serverGeneration) - { - xf86RandR12Index = AllocateScreenPrivateIndex(); xf86RandR12Generation = serverGeneration; - } + + xf86RandR12Key = &xf86RandR12Key; randrp = xalloc (sizeof (XF86RandRInfoRec)); if (!randrp) @@ -522,7 +527,7 @@ xf86RandR12Init (ScreenPtr pScreen) randrp->maxX = randrp->maxY = 0; - pScreen->devPrivates[xf86RandR12Index].ptr = randrp; + dixSetPrivate(&pScreen->devPrivates, xf86RandR12Key, randrp); #if RANDR_12_INTERFACE if (!xf86RandR12Init12 (pScreen)) @@ -534,12 +539,18 @@ xf86RandR12Init (ScreenPtr pScreen) _X_EXPORT void xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations) { - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + XF86RandRInfoPtr randrp; #if RANDR_12_INTERFACE ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; int c; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); +#endif + + if (xf86RandR12Key == NULL) + return; + randrp = XF86RANDRINFO(pScreen); +#if RANDR_12_INTERFACE for (c = 0; c < config->num_crtc; c++) { xf86CrtcPtr crtc = config->crtc[c]; @@ -684,11 +695,8 @@ xf86RandRModeConvert (ScrnInfoPtr scrn, RRModePtr randr_mode, DisplayModePtr mode) { - mode->prev = NULL; - mode->next = NULL; - mode->name = NULL; + memset(mode, 0, sizeof(DisplayModeRec)); mode->status = MODE_OK; - mode->type = 0; mode->Clock = randr_mode->mode.dotClock / 1000; @@ -1069,9 +1077,11 @@ xf86RandR12CreateScreenResources12 (ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + if (xf86RandR12Key == NULL) + return TRUE; + for (c = 0; c < config->num_crtc; c++) - xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc); - + xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc); RRScreenSetSizeRange (pScreen, config->minWidth, config->minHeight, config->maxWidth, config->maxHeight); @@ -1088,11 +1098,11 @@ xf86RandR12TellChanged (ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); int c; - if (!randrp) + if (xf86RandR12Key == NULL) return; + xf86RandR12SetInfo12 (pScreen); for (c = 0; c < config->num_crtc; c++) xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc); |