void xf86SetViewport(ScreenPtr pScreen, int x, int y) { ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); (*pScr->PointerMoved)(pScreen->myNum, x, y); }
/* Function to change RandR's idea of the virtual screen size */ Bool xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen, int newvirtX, int newvirtY, int newmmWidth, int newmmHeight, Bool resetMode) { XF86RandRInfoPtr randrp; if (xf86RandRKey == NULL) return FALSE; randrp = XF86RANDRINFO(pScreen); if (randrp == NULL) return FALSE; if (newvirtX > 0) randrp->virtualX = newvirtX; if (newvirtY > 0) randrp->virtualY = newvirtY; if (newmmWidth > 0) randrp->mmWidth = newmmWidth; if (newmmHeight > 0) randrp->mmHeight = newmmHeight; /* This is only for during server start */ if (resetMode) { return (xf86RandRSetMode(pScreen, XF86SCRNINFO(pScreen)->currentMode, TRUE, pScreen->mmWidth, pScreen->mmHeight)); } return TRUE; }
static Bool xf86RandR12GetInfo (ScreenPtr pScreen, Rotation *rotations) { RRScreenSizePtr pSize; ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); DisplayModePtr mode; int refresh0 = 60; int maxX = 0, maxY = 0; *rotations = randrp->supported_rotations; if (randrp->virtualX == -1 || randrp->virtualY == -1) { randrp->virtualX = scrp->virtualX; randrp->virtualY = scrp->virtualY; } /* Re-probe the outputs for new monitors or modes */ if (scrp->vtSema) { xf86ProbeOutputModes (scrp, 0, 0); xf86SetScrnInfoModes (scrp); } for (mode = scrp->modes; ; mode = mode->next) { int refresh = xf86RandR12ModeRefresh (mode); if (randrp->maxX == 0 || randrp->maxY == 0) { if (maxX < mode->HDisplay) maxX = mode->HDisplay; if (maxY < mode->VDisplay) maxY = mode->VDisplay; } if (mode == scrp->modes) refresh0 = refresh; pSize = RRRegisterSize (pScreen, mode->HDisplay, mode->VDisplay, randrp->mmWidth, randrp->mmHeight); if (!pSize) return FALSE; RRRegisterRate (pScreen, pSize, refresh); if (xf86ModesEqual(mode, scrp->currentMode)) { RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize); } if (mode->next == scrp->modes) break; } if (randrp->maxX == 0 || randrp->maxY == 0) { randrp->maxX = maxX; randrp->maxY = maxY; } return TRUE; }
static Bool xf86RandRSetConfig (ScreenPtr pScreen, Rotation rotation, int rate, RRScreenSizePtr pSize) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); DisplayModePtr mode; int px, py; Bool useVirtual = FALSE; randrp->rotation = rotation; miPointerPosition (&px, &py); for (mode = scrp->modes; ; mode = mode->next) { if (mode->HDisplay == pSize->width && mode->VDisplay == pSize->height && (rate == 0 || xf86RandRModeRefresh (mode) == rate)) break; if (mode->next == scrp->modes) { if (pSize->width == randrp->virtualX && pSize->height == randrp->virtualY) { mode = scrp->modes; useVirtual = TRUE; break; } return FALSE; } } /* Have the driver do its thing. */ if (scrp->RRFunc) { xorgRRRotation RRRotation; RRRotation.RRConfig.rotation = rotation; RRRotation.RRConfig.rate = rate; RRRotation.RRConfig.width = pSize->width; RRRotation.RRConfig.height = pSize->height; if (!(*scrp->RRFunc)(scrp, RR_SET_CONFIG, &RRRotation)) return FALSE; } if (!xf86RandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) return FALSE; /* * Move the cursor back where it belongs; SwitchMode repositions it */ if (pScreen == miPointerCurrentScreen ()) { if (px < pSize->width && py < pSize->height) (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE); } return TRUE; }
static Bool xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations) { RRScreenSizePtr pSize; ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); DisplayModePtr mode; int refresh0 = 60; *rotations = RR_Rotate_0; for (mode = scrp->modes; ; mode = mode->next) { int refresh = xf86RandRModeRefresh (mode); if (mode == scrp->modes) refresh0 = refresh; pSize = RRRegisterSize (pScreen, mode->HDisplay, mode->VDisplay, randrp->mmWidth, randrp->mmHeight); if (!pSize) return FALSE; RRRegisterRate (pScreen, pSize, refresh); if (mode == scrp->currentMode && mode->HDisplay == scrp->virtualX && mode->VDisplay == scrp->virtualY) RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize); if (mode->next == scrp->modes) break; } if (scrp->currentMode->HDisplay != randrp->virtualX || scrp->currentMode->VDisplay != randrp->virtualY) { mode = scrp->modes; pSize = RRRegisterSize (pScreen, randrp->virtualX, randrp->virtualY, randrp->mmWidth, randrp->mmHeight); if (!pSize) return FALSE; RRRegisterRate (pScreen, pSize, refresh0); if (scrp->virtualX == randrp->virtualX && scrp->virtualY == randrp->virtualY) { RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize); } } /* If there is driver support for randr, let it set our supported rotations */ if(scrp->RRFunc) { xorgRRRotation RRRotation; RRRotation.RRRotations = *rotations; if (!(*scrp->RRFunc)(scrp, RR_GET_INFO, &RRRotation)) return FALSE; *rotations = RRRotation.RRRotations; } return TRUE; }
static void xf86RandR12PointerMoved (int scrnIndex, int x, int y) { ScreenPtr pScreen = screenInfo.screens[scrnIndex]; ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); int c; randrp->pointerX = x; randrp->pointerY = y; for (c = 0; c < config->num_crtc; c++) xf86RandR13Pan (config->crtc[c], x, y); }
/* * Reset size back to original */ static Bool xf86RandRCloseScreen (int index, ScreenPtr pScreen) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); scrp->virtualX = pScreen->width = randrp->virtualX; scrp->virtualY = pScreen->height = randrp->virtualY; scrp->currentMode = scrp->modes; pScreen->CloseScreen = randrp->CloseScreen; free(randrp); dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, NULL); return (*pScreen->CloseScreen) (index, pScreen); }
static Bool exaXorgCloseScreen (int i, ScreenPtr pScreen) { ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr) dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey); pScreen->CloseScreen = pScreenPriv->SavedCloseScreen; pScrn->EnableDisableFBAccess = pScreenPriv->SavedEnableDisableFBAccess; xfree (pScreenPriv->options); xfree (pScreenPriv); return pScreen->CloseScreen (i, pScreen); }
Bool xf86RandRInit (ScreenPtr pScreen) { rrScrPrivPtr rp; XF86RandRInfoPtr randrp; ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); #ifdef PANORAMIX /* XXX disable RandR when using Xinerama */ if (!noPanoramiXExtension) return TRUE; #endif if (xf86RandRGeneration != serverGeneration) { xf86RandRIndex = AllocateScreenPrivateIndex(); xf86RandRGeneration = serverGeneration; } randrp = xalloc (sizeof (XF86RandRInfoRec)); if (!randrp) return FALSE; if (!RRScreenInit (pScreen)) { xfree (randrp); return FALSE; } rp = rrGetScrPriv(pScreen); rp->rrGetInfo = xf86RandRGetInfo; rp->rrSetConfig = xf86RandRSetConfig; randrp->virtualX = scrp->virtualX; randrp->virtualY = scrp->virtualY; randrp->mmWidth = pScreen->mmWidth; randrp->mmHeight = pScreen->mmHeight; randrp->CreateScreenResources = pScreen->CreateScreenResources; pScreen->CreateScreenResources = xf86RandRCreateScreenResources; randrp->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xf86RandRCloseScreen; randrp->rotation = RR_Rotate_0; pScreen->devPrivates[xf86RandRIndex].ptr = randrp; return TRUE; }
Bool xf86RandRInit (ScreenPtr pScreen) { rrScrPrivPtr rp; XF86RandRInfoPtr randrp; ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); #ifdef PANORAMIX /* XXX disable RandR when using Xinerama */ if (!noPanoramiXExtension) return TRUE; #endif xf86RandRKey = &xf86RandRKeyRec; if (!dixRegisterPrivateKey(&xf86RandRKeyRec, PRIVATE_SCREEN, 0)) return FALSE; randrp = malloc(sizeof (XF86RandRInfoRec)); if (!randrp) return FALSE; if (!RRScreenInit (pScreen)) { free(randrp); return FALSE; } rp = rrGetScrPriv(pScreen); rp->rrGetInfo = xf86RandRGetInfo; rp->rrSetConfig = xf86RandRSetConfig; randrp->virtualX = scrp->virtualX; randrp->virtualY = scrp->virtualY; randrp->mmWidth = pScreen->mmWidth; randrp->mmHeight = pScreen->mmHeight; randrp->CreateScreenResources = pScreen->CreateScreenResources; pScreen->CreateScreenResources = xf86RandRCreateScreenResources; randrp->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xf86RandRCloseScreen; randrp->rotation = RR_Rotate_0; dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, randrp); return TRUE; }
static Bool xf86RandR12ScreenSetSize (ScreenPtr pScreen, CARD16 width, CARD16 height, CARD32 mmWidth, CARD32 mmHeight) { XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); WindowPtr pRoot = WindowTable[pScreen->myNum]; PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen); Bool ret = FALSE; if (randrp->virtualX == -1 || randrp->virtualY == -1) { randrp->virtualX = pScrn->virtualX; randrp->virtualY = pScrn->virtualY; } if (pRoot) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE); /* Let the driver update virtualX and virtualY */ if (!(*config->funcs->resize)(pScrn, width, height)) goto finish; ret = TRUE; pScreen->width = pScrnPix->drawable.width = width; pScreen->height = pScrnPix->drawable.height = height; pScreen->mmWidth = mmWidth; pScreen->mmHeight = mmHeight; xf86SetViewport (pScreen, pScreen->width-1, pScreen->height-1); xf86SetViewport (pScreen, 0, 0); finish: if (pRoot) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE); #if RANDR_12_INTERFACE if (WindowTable[pScreen->myNum] && ret) RRScreenSizeNotify (pScreen); #endif return ret; }
void xf86ZoomViewport(ScreenPtr pScreen, int zoom) { ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); DisplayModePtr mode; if (pScr->zoomLocked || !(mode = pScr->currentMode)) return; do { if (zoom > 0) mode = mode->next; else mode = mode->prev; } while (mode != pScr->currentMode && !(mode->type & M_T_USERDEF)); (void)xf86SwitchMode(pScreen, mode); }
/* * Wait until the screen is initialized before whacking the * sizes around; otherwise the screen pixmap will be allocated * at the current mode size rather than the maximum size */ static Bool xf86RandRCreateScreenResources (ScreenPtr pScreen) { XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); #if 0 ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); DisplayModePtr mode; #endif pScreen->CreateScreenResources = randrp->CreateScreenResources; if (!(*pScreen->CreateScreenResources) (pScreen)) return FALSE; #if 0 mode = scrp->currentMode; if (mode) xf86RandRSetMode (pScreen, mode, TRUE); #endif return TRUE; }
static void TsengSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) { int xorigin, yorigin; TsengPtr pTseng = TsengPTR(pScrn); /* * If the cursor is partly out of screen at the left or top, * we need to modify the origin. */ xorigin = 0; yorigin = 0; if (x < 0) { xorigin = -x; x = 0; } if (y < 0) { yorigin = -y; y = 0; } #ifdef TODO /* Correct cursor position in DoubleScan modes */ if (XF86SCRNINFO(pScr)->modes->Flags & V_DBLSCAN) y *= 2; #endif if (Is_ET6K) { outb(pTseng->IOAddress + 0x82, xorigin); outb(pTseng->IOAddress + 0x83, yorigin); outb(pTseng->IOAddress + 0x84, (x & 0xff)); /* X bits 7-0 */ outb(pTseng->IOAddress + 0x85, ((x >> 8) & 0x0f)); /* X bits 11-8 */ outb(pTseng->IOAddress + 0x86, (y & 0xff)); /* Y bits 7-0 */ outb(pTseng->IOAddress + 0x87, ((y >> 8) & 0x0f)); /* Y bits 11-8 */ } else {
static Bool xf86RandRSetConfig (ScreenPtr pScreen, Rotation rotation, int rate, RRScreenSizePtr pSize) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); DisplayModePtr mode; int px, py; Bool useVirtual = FALSE; Rotation oldRotation = randrp->rotation; miPointerPosition (&px, &py); for (mode = scrp->modes; ; mode = mode->next) { if (mode->HDisplay == pSize->width && mode->VDisplay == pSize->height && (rate == 0 || xf86RandRModeRefresh (mode) == rate)) break; if (mode->next == scrp->modes) { if (pSize->width == randrp->virtualX && pSize->height == randrp->virtualY) { mode = scrp->modes; useVirtual = TRUE; break; } return FALSE; } } if (randrp->rotation != rotation) { /* Have the driver do its thing. */ if (scrp->DriverFunc) { xorgRRRotation RRRotation; RRRotation.RRConfig.rotation = rotation; RRRotation.RRConfig.rate = rate; RRRotation.RRConfig.width = pSize->width; RRRotation.RRConfig.height = pSize->height; /* * Currently we need to rely on HW support for rotation. */ if (!(*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation)) return FALSE; } else return FALSE; randrp->rotation = rotation; } 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; } /* * Move the cursor back where it belongs; SwitchMode repositions it */ if (pScreen == miPointerCurrentScreen ()) { px = (px >= pScreen->width ? (pScreen->width - 1) : px); py = (py >= pScreen->height ? (pScreen->height - 1) : py); xf86SetViewport(pScreen, px, py); (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE); } return TRUE; }
void xf86LockZoom(ScreenPtr pScreen, Bool lock) { XF86SCRNINFO(pScreen)->zoomLocked = lock; }
static Bool xf86RandRSetConfig (ScreenPtr pScreen, Rotation rotation, int rate, RRScreenSizePtr pSize) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); DisplayModePtr mode; int pos[MAXDEVICES][2]; Bool useVirtual = FALSE; Rotation oldRotation = randrp->rotation; DeviceIntPtr dev; Bool view_adjusted = FALSE; for (dev = inputInfo.devices; dev; dev = dev->next) { if (!IsMaster(dev) && !IsFloating(dev)) continue; miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]); } for (mode = scrp->modes; ; mode = mode->next) { if (mode->HDisplay == pSize->width && mode->VDisplay == pSize->height && (rate == 0 || xf86RandRModeRefresh (mode) == rate)) break; if (mode->next == scrp->modes) { if (pSize->width == randrp->virtualX && pSize->height == randrp->virtualY) { mode = scrp->modes; useVirtual = TRUE; break; } return FALSE; } } if (randrp->rotation != rotation) { /* Have the driver do its thing. */ if (scrp->DriverFunc) { xorgRRRotation RRRotation; RRRotation.RRConfig.rotation = rotation; RRRotation.RRConfig.rate = rate; RRRotation.RRConfig.width = pSize->width; RRRotation.RRConfig.height = pSize->height; /* * Currently we need to rely on HW support for rotation. */ if (!(*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation)) return FALSE; } else return FALSE; randrp->rotation = rotation; } 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 = scrp->virtualX; RRRotation.RRConfig.height = scrp->virtualY; (*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation); } randrp->rotation = oldRotation; } return FALSE; } /* * Move the cursor back where it belongs; SwitchMode repositions it * FIXME: duplicated code, see modes/xf86RandR12.c */ for (dev = inputInfo.devices; dev; dev = dev->next) { if (!IsMaster(dev) && !IsFloating(dev)) continue; if (pScreen == miPointerGetScreen(dev)) { int px = pos[dev->id][0]; int py = pos[dev->id][1]; px = (px >= pScreen->width ? (pScreen->width - 1) : px); py = (py >= pScreen->height ? (pScreen->height - 1) : py); /* Setting the viewpoint makes only sense on one device */ if (!view_adjusted && IsMaster(dev)) { xf86SetViewport(pScreen, px, py); view_adjusted = TRUE; } (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE); } } return TRUE; }
static Bool xf86RandRSetMode (ScreenPtr pScreen, DisplayModePtr mode, Bool useVirtual, int mmWidth, int mmHeight) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); int oldWidth = pScreen->width; int oldHeight = pScreen->height; int oldmmWidth = pScreen->mmWidth; int oldmmHeight = pScreen->mmHeight; int oldVirtualX = scrp->virtualX; int oldVirtualY = scrp->virtualY; WindowPtr pRoot = pScreen->root; Bool ret = TRUE; if (pRoot && scrp->vtSema) (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE); if (useVirtual) { scrp->virtualX = randrp->virtualX; scrp->virtualY = randrp->virtualY; } else { scrp->virtualX = mode->HDisplay; scrp->virtualY = mode->VDisplay; } /* * The DIX forgets the physical dimensions we passed into RRRegisterSize, so * reconstruct them if possible. */ if(scrp->DriverFunc) { xorgRRModeMM RRModeMM; RRModeMM.mode = mode; RRModeMM.virtX = scrp->virtualX; RRModeMM.virtY = scrp->virtualY; RRModeMM.mmWidth = mmWidth; RRModeMM.mmHeight = mmHeight; (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM); mmWidth = RRModeMM.mmWidth; mmHeight = RRModeMM.mmHeight; } if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) { /* If the screen is rotated 90 or 270 degrees, swap the sizes. */ pScreen->width = scrp->virtualY; pScreen->height = scrp->virtualX; pScreen->mmWidth = mmHeight; pScreen->mmHeight = mmWidth; } else { pScreen->width = scrp->virtualX; pScreen->height = scrp->virtualY; pScreen->mmWidth = mmWidth; pScreen->mmHeight = mmHeight; } if (!xf86SwitchMode (pScreen, mode)) { pScreen->width = oldWidth; pScreen->height = oldHeight; pScreen->mmWidth = oldmmWidth; pScreen->mmHeight = oldmmHeight; scrp->virtualX = oldVirtualX; scrp->virtualY = oldVirtualY; ret = FALSE; } /* * Make sure the layout is correct */ xf86ReconfigureLayout(); /* * Make sure the whole screen is visible */ xf86SetViewport (pScreen, pScreen->width, pScreen->height); xf86SetViewport (pScreen, 0, 0); if (pRoot && scrp->vtSema) (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE); return ret; }
Bool xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode) { ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); ScreenPtr pCursorScreen; Bool Switched; int px, py, was_blocked; DeviceIntPtr dev, it; if (!pScr->vtSema || !mode || !pScr->SwitchMode) return FALSE; #ifdef XFreeXDGA if (DGAActive(pScr->scrnIndex)) return FALSE; #endif if (mode == pScr->currentMode) return TRUE; if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY) return FALSE; /* Let's take an educated guess for which pointer to take here. And about as educated as it gets is to take the first pointer we find. */ for (dev = inputInfo.devices; dev; dev = dev->next) { if (IsPointerDevice(dev) && dev->spriteInfo->spriteOwner) break; } pCursorScreen = miPointerGetScreen(dev); if (pScreen == pCursorScreen) miPointerGetPosition(dev, &px, &py); was_blocked = xf86BlockSIGIO(); Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0); if (Switched) { pScr->currentMode = mode; /* * Adjust frame for new display size. * Frame is centered around cursor position if cursor is on same screen. */ if (pScreen == pCursorScreen) pScr->frameX0 = px - (mode->HDisplay / 2) + 1; else pScr->frameX0 = (pScr->frameX0 + pScr->frameX1 + 1 - mode->HDisplay) / 2; if (pScr->frameX0 < 0) pScr->frameX0 = 0; pScr->frameX1 = pScr->frameX0 + mode->HDisplay - 1; if (pScr->frameX1 >= pScr->virtualX) { pScr->frameX0 = pScr->virtualX - mode->HDisplay; pScr->frameX1 = pScr->virtualX - 1; } if (pScreen == pCursorScreen) pScr->frameY0 = py - (mode->VDisplay / 2) + 1; else pScr->frameY0 = (pScr->frameY0 + pScr->frameY1 + 1 - mode->VDisplay) / 2; if (pScr->frameY0 < 0) pScr->frameY0 = 0; pScr->frameY1 = pScr->frameY0 + mode->VDisplay - 1; if (pScr->frameY1 >= pScr->virtualY) { pScr->frameY0 = pScr->virtualY - mode->VDisplay; pScr->frameY1 = pScr->virtualY - 1; } } xf86UnblockSIGIO(was_blocked); if (pScr->AdjustFrame) (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0); /* The original code centered the frame around the cursor if possible. * Since this is hard to achieve with multiple cursors, we do the following: * - center around the first pointer * - move all other pointers to the nearest edge on the screen (or leave * them unmodified if they are within the boundaries). */ if (pScreen == pCursorScreen) { xf86WarpCursor(dev, pScreen, px, py); } for (it = inputInfo.devices; it; it = it->next) { if (it == dev) continue; if (IsPointerDevice(it) && it->spriteInfo->spriteOwner) { pCursorScreen = miPointerGetScreen(it); if (pScreen == pCursorScreen) { miPointerGetPosition(it, &px, &py); if (px < pScr->frameX0) px = pScr->frameX0; else if (px > pScr->frameX1) px = pScr->frameX1; if(py < pScr->frameY0) py = pScr->frameY0; else if(py > pScr->frameY1) py = pScr->frameY1; xf86WarpCursor(it, pScreen, px, py); } } } return Switched; }
_X_EXPORT Bool xf86RandR12SetConfig (ScreenPtr pScreen, Rotation rotation, int rate, RRScreenSizePtr pSize) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); DisplayModePtr mode; int px, py; Bool useVirtual = FALSE; int maxX = 0, maxY = 0; Rotation oldRotation = randrp->rotation; randrp->rotation = rotation; if (randrp->virtualX == -1 || randrp->virtualY == -1) { randrp->virtualX = scrp->virtualX; randrp->virtualY = scrp->virtualY; } miPointerPosition (&px, &py); for (mode = scrp->modes; ; mode = mode->next) { if (randrp->maxX == 0 || randrp->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 || xf86RandR12ModeRefresh (mode) == rate)) break; if (mode->next == scrp->modes) { if (pSize->width == randrp->virtualX && pSize->height == randrp->virtualY) { mode = scrp->modes; useVirtual = TRUE; break; } if (randrp->maxX == 0 || randrp->maxY == 0) { randrp->maxX = maxX; randrp->maxY = maxY; } return FALSE; } } if (randrp->maxX == 0 || randrp->maxY == 0) { randrp->maxX = maxX; randrp->maxY = maxY; } if (!xf86RandR12SetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) { randrp->rotation = oldRotation; return FALSE; } /* * Move the cursor back where it belongs; SwitchMode repositions it */ if (pScreen == miPointerCurrentScreen ()) { px = (px >= pScreen->width ? (pScreen->width - 1) : px); py = (py >= pScreen->height ? (pScreen->height - 1) : py); xf86SetViewport(pScreen, px, py); (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE); } return TRUE; }
static Bool xf86RandR12SetMode (ScreenPtr pScreen, DisplayModePtr mode, Bool useVirtual, int mmWidth, int mmHeight) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); int oldWidth = pScreen->width; int oldHeight = pScreen->height; int oldmmWidth = pScreen->mmWidth; int oldmmHeight = pScreen->mmHeight; WindowPtr pRoot = WindowTable[pScreen->myNum]; DisplayModePtr currentMode = NULL; Bool ret = TRUE; PixmapPtr pspix = NULL; if (pRoot) (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE); if (useVirtual) { scrp->virtualX = randrp->virtualX; scrp->virtualY = randrp->virtualY; } else { scrp->virtualX = mode->HDisplay; scrp->virtualY = mode->VDisplay; } if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) { /* If the screen is rotated 90 or 270 degrees, swap the sizes. */ pScreen->width = scrp->virtualY; pScreen->height = scrp->virtualX; pScreen->mmWidth = mmHeight; pScreen->mmHeight = mmWidth; } else { pScreen->width = scrp->virtualX; pScreen->height = scrp->virtualY; pScreen->mmWidth = mmWidth; pScreen->mmHeight = mmHeight; } if (scrp->currentMode == mode) { /* Save current mode */ currentMode = scrp->currentMode; /* Reset, just so we ensure the drivers SwitchMode is called */ scrp->currentMode = NULL; } /* * We know that if the driver failed to SwitchMode to the rotated * version, then it should revert back to it's prior mode. */ if (!xf86SwitchMode (pScreen, mode)) { ret = FALSE; scrp->virtualX = pScreen->width = oldWidth; scrp->virtualY = pScreen->height = oldHeight; pScreen->mmWidth = oldmmWidth; pScreen->mmHeight = oldmmHeight; scrp->currentMode = currentMode; } /* * Get the new Screen pixmap ptr as SwitchMode might have called * ModifyPixmapHeader and xf86EnableDisableFBAccess will put it back... * Unfortunately. */ pspix = (*pScreen->GetScreenPixmap) (pScreen); if (pspix->devPrivate.ptr) scrp->pixmapPrivate = pspix->devPrivate; /* * Make sure the layout is correct */ xf86ReconfigureLayout(); /* * Make sure the whole screen is visible */ xf86SetViewport (pScreen, pScreen->width, pScreen->height); xf86SetViewport (pScreen, 0, 0); if (pRoot) (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE); return ret; }
static Bool xf86RandR12ScreenSetSize (ScreenPtr pScreen, CARD16 width, CARD16 height, CARD32 mmWidth, CARD32 mmHeight) { XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); WindowPtr pRoot = WindowTable[pScreen->myNum]; PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen); Bool ret = FALSE; int c; #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) if (xf86RandR12Key) { #endif if (randrp->virtualX == -1 || randrp->virtualY == -1) { randrp->virtualX = pScrn->virtualX; randrp->virtualY = pScrn->virtualY; } #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) } #endif if (pRoot && pScrn->vtSema) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE); /* Let the driver update virtualX and virtualY */ if (!(*config->funcs->resize)(pScrn, width, height)) goto finish; ret = TRUE; /* Update panning information */ for (c = 0; c < config->num_crtc; c++) { xf86CrtcPtr crtc = config->crtc[c]; if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1 || crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) { if (crtc->panningTotalArea.x2 > crtc->panningTrackingArea.x1) crtc->panningTotalArea.x2 += width - pScreen->width; if (crtc->panningTotalArea.y2 > crtc->panningTrackingArea.y1) crtc->panningTotalArea.y2 += height - pScreen->height; if (crtc->panningTrackingArea.x2 > crtc->panningTrackingArea.x1) crtc->panningTrackingArea.x2 += width - pScreen->width; if (crtc->panningTrackingArea.y2 > crtc->panningTrackingArea.y1) crtc->panningTrackingArea.y2 += height - pScreen->height; xf86RandR13VerifyPanningArea (crtc, width, height); xf86RandR13Pan (crtc, randrp->pointerX, randrp->pointerY); } } pScreen->width = pScrnPix->drawable.width = width; pScreen->height = pScrnPix->drawable.height = height; randrp->mmWidth = pScreen->mmWidth = mmWidth; randrp->mmHeight = pScreen->mmHeight = mmHeight; xf86SetViewport (pScreen, pScreen->width-1, pScreen->height-1); xf86SetViewport (pScreen, 0, 0); finish: if (pRoot && pScrn->vtSema) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE); #if RANDR_12_INTERFACE if (xf86RandR12Key && WindowTable[pScreen->myNum] && ret) RRScreenSizeNotify (pScreen); #endif return ret; }
static Bool xf86RandRSetMode (ScreenPtr pScreen, DisplayModePtr mode, Bool useVirtual, int mmWidth, int mmHeight) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); int oldWidth = pScreen->width; int oldHeight = pScreen->height; int oldmmWidth = pScreen->mmWidth; int oldmmHeight = pScreen->mmHeight; WindowPtr pRoot = WindowTable[pScreen->myNum]; if (pRoot) (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE); if (useVirtual) { scrp->virtualX = randrp->virtualX; scrp->virtualY = randrp->virtualY; } else { scrp->virtualX = mode->HDisplay; scrp->virtualY = mode->VDisplay; } if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) { /* If the screen is rotated 90 or 270 degrees, swap the sizes. */ pScreen->width = scrp->virtualY; pScreen->height = scrp->virtualX; pScreen->mmWidth = mmHeight; pScreen->mmHeight = mmWidth; } else { pScreen->width = scrp->virtualX; pScreen->height = scrp->virtualY; pScreen->mmWidth = mmWidth; pScreen->mmHeight = mmHeight; } if (!xf86SwitchMode (pScreen, mode)) { scrp->virtualX = pScreen->width = oldWidth; scrp->virtualY = pScreen->height = oldHeight; pScreen->mmWidth = oldmmWidth; pScreen->mmHeight = oldmmHeight; return FALSE; } /* * Make sure the layout is correct */ xf86ReconfigureLayout(); /* * Make sure the whole screen is visible */ xf86SetViewport (pScreen, pScreen->width, pScreen->height); xf86SetViewport (pScreen, 0, 0); if (pRoot) (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE); return TRUE; }