2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
* documentation, and that the name of Keith Packard not be used in
|
|
|
|
* advertising or publicity pertaining to distribution of the software without
|
|
|
|
* specific, written prior permission. Keith Packard makes no
|
|
|
|
* representations about the suitability of this software for any purpose. It
|
|
|
|
* is provided "as is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include "os.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "xf86.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "xf86str.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "xf86Priv.h"
|
|
|
|
#include "xf86DDC.h"
|
|
|
|
#include "mipointer.h"
|
|
|
|
#include <randrstr.h>
|
2009-09-06 13:44:18 -06:00
|
|
|
#include "inputstr.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
typedef struct _xf86RandRInfo {
|
2012-06-10 07:21:05 -06:00
|
|
|
CreateScreenResourcesProcPtr CreateScreenResources;
|
|
|
|
CloseScreenProcPtr CloseScreen;
|
|
|
|
int virtualX;
|
|
|
|
int virtualY;
|
|
|
|
int mmWidth;
|
|
|
|
int mmHeight;
|
|
|
|
Rotation rotation;
|
2006-11-26 11:13:41 -07:00
|
|
|
} XF86RandRInfoRec, *XF86RandRInfoPtr;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
static DevPrivateKeyRec xf86RandRKeyRec;
|
2009-09-06 13:44:18 -06:00
|
|
|
static DevPrivateKey xf86RandRKey;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey))
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86RandRModeRefresh(DisplayModePtr mode)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (mode->VRefresh)
|
2012-06-10 07:21:05 -06:00
|
|
|
return (int) (mode->VRefresh + 0.5);
|
2008-11-02 08:26:08 -07:00
|
|
|
else if (mode->Clock == 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
return 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86RandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RRScreenSizePtr pSize;
|
2013-06-07 11:28:45 -06:00
|
|
|
ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
|
|
|
|
DisplayModePtr mode;
|
|
|
|
int refresh0 = 60;
|
|
|
|
xorgRRModeMM RRModeMM;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
*rotations = RR_Rotate_0;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (mode = scrp->modes; mode != NULL; mode = mode->next) {
|
|
|
|
int refresh = xf86RandRModeRefresh(mode);
|
|
|
|
|
|
|
|
if (mode == scrp->modes)
|
|
|
|
refresh0 = refresh;
|
|
|
|
|
|
|
|
RRModeMM.mode = mode;
|
|
|
|
RRModeMM.virtX = randrp->virtualX;
|
|
|
|
RRModeMM.virtY = randrp->virtualY;
|
|
|
|
RRModeMM.mmWidth = randrp->mmWidth;
|
|
|
|
RRModeMM.mmHeight = randrp->mmHeight;
|
|
|
|
|
|
|
|
if (scrp->DriverFunc) {
|
|
|
|
(*scrp->DriverFunc) (scrp, RR_GET_MODE_MM, &RRModeMM);
|
|
|
|
}
|
|
|
|
|
|
|
|
pSize = RRRegisterSize(pScreen,
|
|
|
|
mode->HDisplay, mode->VDisplay,
|
|
|
|
RRModeMM.mmWidth, RRModeMM.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;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (scrp->currentMode->HDisplay != randrp->virtualX ||
|
2012-06-10 07:21:05 -06:00
|
|
|
scrp->currentMode->VDisplay != randrp->virtualY) {
|
|
|
|
mode = scrp->modes;
|
|
|
|
|
|
|
|
RRModeMM.mode = NULL;
|
|
|
|
RRModeMM.virtX = randrp->virtualX;
|
|
|
|
RRModeMM.virtY = randrp->virtualY;
|
|
|
|
RRModeMM.mmWidth = randrp->mmWidth;
|
|
|
|
RRModeMM.mmHeight = randrp->mmHeight;
|
|
|
|
|
|
|
|
if (scrp->DriverFunc) {
|
|
|
|
(*scrp->DriverFunc) (scrp, RR_GET_MODE_MM, &RRModeMM);
|
|
|
|
}
|
|
|
|
|
|
|
|
pSize = RRRegisterSize(pScreen,
|
|
|
|
randrp->virtualX, randrp->virtualY,
|
|
|
|
RRModeMM.mmWidth, RRModeMM.mmHeight);
|
|
|
|
if (!pSize)
|
|
|
|
return FALSE;
|
|
|
|
RRRegisterRate(pScreen, pSize, refresh0);
|
|
|
|
if (scrp->virtualX == randrp->virtualX &&
|
|
|
|
scrp->virtualY == randrp->virtualY) {
|
|
|
|
RRSetCurrentConfig(pScreen, randrp->rotation, refresh0, pSize);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If there is driver support for randr, let it set our supported rotations */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (scrp->DriverFunc) {
|
|
|
|
xorgRRRotation RRRotation;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
RRRotation.RRRotations = *rotations;
|
|
|
|
if (!(*scrp->DriverFunc) (scrp, RR_GET_INFO, &RRRotation))
|
|
|
|
return TRUE;
|
|
|
|
*rotations = RRRotation.RRRotations;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86RandRSetMode(ScreenPtr pScreen,
|
|
|
|
DisplayModePtr mode,
|
|
|
|
Bool useVirtual, int mmWidth, int mmHeight)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (pRoot && scrp->vtSema)
|
2013-06-07 11:28:45 -06:00
|
|
|
(*scrp->EnableDisableFBAccess) (scrp, FALSE);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (useVirtual) {
|
|
|
|
scrp->virtualX = randrp->virtualX;
|
|
|
|
scrp->virtualY = randrp->virtualY;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
scrp->virtualX = mode->HDisplay;
|
|
|
|
scrp->virtualY = mode->VDisplay;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The DIX forgets the physical dimensions we passed into RRRegisterSize, so
|
|
|
|
* reconstruct them if possible.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
if (scrp->DriverFunc) {
|
|
|
|
xorgRRModeMM RRModeMM;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
RRModeMM.mode = mode;
|
|
|
|
RRModeMM.virtX = scrp->virtualX;
|
|
|
|
RRModeMM.virtY = scrp->virtualY;
|
|
|
|
RRModeMM.mmWidth = mmWidth;
|
|
|
|
RRModeMM.mmHeight = mmHeight;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*scrp->DriverFunc) (scrp, RR_GET_MODE_MM, &RRModeMM);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
mmWidth = RRModeMM.mmWidth;
|
|
|
|
mmHeight = RRModeMM.mmHeight;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
pScreen->width = scrp->virtualX;
|
|
|
|
pScreen->height = scrp->virtualY;
|
|
|
|
pScreen->mmWidth = mmWidth;
|
|
|
|
pScreen->mmHeight = mmHeight;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!xf86SwitchMode(pScreen, mode)) {
|
|
|
|
pScreen->width = oldWidth;
|
|
|
|
pScreen->height = oldHeight;
|
|
|
|
pScreen->mmWidth = oldmmWidth;
|
|
|
|
pScreen->mmHeight = oldmmHeight;
|
|
|
|
scrp->virtualX = oldVirtualX;
|
|
|
|
scrp->virtualY = oldVirtualY;
|
|
|
|
ret = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Make sure the layout is correct
|
|
|
|
*/
|
|
|
|
xf86ReconfigureLayout();
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
if (scrp->vtSema) {
|
|
|
|
/*
|
|
|
|
* Make sure the whole screen is visible
|
|
|
|
*/
|
|
|
|
xf86SetViewport (pScreen, pScreen->width, pScreen->height);
|
|
|
|
xf86SetViewport (pScreen, 0, 0);
|
|
|
|
if (pRoot)
|
|
|
|
(*scrp->EnableDisableFBAccess) (scrp, TRUE);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86RandRSetConfig(ScreenPtr pScreen,
|
|
|
|
Rotation rotation, int rate, RRScreenSizePtr pSize)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
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]);
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (randrp->rotation != rotation) {
|
|
|
|
|
|
|
|
/* Have the driver do its thing. */
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
update_desktop_dimensions();
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* Move the cursor back where it belongs; SwitchMode repositions it
|
2011-11-05 07:32:40 -06:00
|
|
|
* FIXME: duplicated code, see modes/xf86RandR12.c
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
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);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86RandRCreateScreenResources(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#if 0
|
2013-06-07 11:28:45 -06:00
|
|
|
ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
DisplayModePtr mode;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
pScreen->CreateScreenResources = randrp->CreateScreenResources;
|
|
|
|
if (!(*pScreen->CreateScreenResources) (pScreen))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
mode = scrp->currentMode;
|
|
|
|
if (mode)
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86RandRSetMode(pScreen, mode, TRUE);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset size back to original
|
|
|
|
*/
|
|
|
|
static Bool
|
2013-06-07 11:28:45 -06:00
|
|
|
xf86RandRCloseScreen(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
scrp->virtualX = pScreen->width = randrp->virtualX;
|
|
|
|
scrp->virtualY = pScreen->height = randrp->virtualY;
|
|
|
|
scrp->currentMode = scrp->modes;
|
|
|
|
pScreen->CloseScreen = randrp->CloseScreen;
|
2010-12-05 08:36:02 -07:00
|
|
|
free(randrp);
|
2008-11-02 08:26:08 -07:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, NULL);
|
2013-06-07 11:28:45 -06:00
|
|
|
return (*pScreen->CloseScreen) (pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Rotation
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86GetRotation(ScreenPtr pScreen)
|
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
if (xf86RandRKey == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return RR_Rotate_0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return XF86RANDRINFO(pScreen)->rotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Function to change RandR's idea of the virtual screen size */
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
|
2012-06-10 07:21:05 -06:00
|
|
|
int newvirtX, int newvirtY, int newmmWidth,
|
|
|
|
int newmmHeight, Bool resetMode)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XF86RandRInfoPtr randrp;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (xf86RandRKey == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
randrp = XF86RANDRINFO(pScreen);
|
|
|
|
if (randrp == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (newvirtX > 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
randrp->virtualX = newvirtX;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (newvirtY > 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
randrp->virtualY = newvirtY;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (newmmWidth > 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
randrp->mmWidth = newmmWidth;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (newmmHeight > 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
randrp->mmHeight = newmmHeight;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* This is only for during server start */
|
|
|
|
if (resetMode) {
|
2013-06-07 11:28:45 -06:00
|
|
|
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
return (xf86RandRSetMode(pScreen,
|
2013-06-07 11:28:45 -06:00
|
|
|
pScrn->currentMode,
|
2012-06-10 07:21:05 -06:00
|
|
|
TRUE, pScreen->mmWidth, pScreen->mmHeight));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86RandRInit(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
rrScrPrivPtr rp;
|
|
|
|
XF86RandRInfoPtr randrp;
|
2013-06-07 11:28:45 -06:00
|
|
|
ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
/* XXX disable RandR when using Xinerama */
|
|
|
|
if (!noPanoramiXExtension)
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
xf86RandRKey = &xf86RandRKeyRec;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!dixRegisterPrivateKey(&xf86RandRKeyRec, PRIVATE_SCREEN, 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
randrp = malloc(sizeof(XF86RandRInfoRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!randrp)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!RRScreenInit(pScreen)) {
|
|
|
|
free(randrp);
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, randrp);
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|