Split RandR implementation into separate files.
RandR is getting too big to live in one file; split into one file per object type (crtc, mode, screen), leaving the rest of the code in randr.c. Code is slowly approaching the point where it will drop-in as a replacement for the old 1.0 implementation.
This commit is contained in:
parent
d7f1f286b7
commit
cbb587582e
|
@ -9,4 +9,8 @@ endif
|
||||||
librandr_la_SOURCES = \
|
librandr_la_SOURCES = \
|
||||||
mirandr.c \
|
mirandr.c \
|
||||||
randr.c \
|
randr.c \
|
||||||
randrstr.h
|
randrstr.h \
|
||||||
|
rrcrtc.c \
|
||||||
|
rrmode.c \
|
||||||
|
rroutput.c \
|
||||||
|
rrscreen.c
|
||||||
|
|
|
@ -70,16 +70,19 @@ Bool
|
||||||
miRandRInit (ScreenPtr pScreen)
|
miRandRInit (ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
rrScrPrivPtr pScrPriv;
|
rrScrPrivPtr pScrPriv;
|
||||||
|
#if RANDR_12_INTERFACE
|
||||||
RRModePtr mode;
|
RRModePtr mode;
|
||||||
RRCrtcPtr crtc;
|
RRCrtcPtr crtc;
|
||||||
RROutputPtr output;
|
RROutputPtr output;
|
||||||
xRRModeInfo modeInfo;
|
xRRModeInfo modeInfo;
|
||||||
char name[64];
|
char name[64];
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!RRScreenInit (pScreen))
|
if (!RRScreenInit (pScreen))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
pScrPriv = rrGetScrPriv(pScreen);
|
pScrPriv = rrGetScrPriv(pScreen);
|
||||||
pScrPriv->rrGetInfo = miRRGetInfo;
|
pScrPriv->rrGetInfo = miRRGetInfo;
|
||||||
|
#if RANDR_12_INTERFACE
|
||||||
pScrPriv->rrCrtcSet = miRRCrtcSet;
|
pScrPriv->rrCrtcSet = miRRCrtcSet;
|
||||||
|
|
||||||
RRScreenSetSizeRange (pScreen,
|
RRScreenSetSizeRange (pScreen,
|
||||||
|
@ -111,7 +114,7 @@ miRandRInit (ScreenPtr pScreen)
|
||||||
&crtc, 1, /* crtcs */
|
&crtc, 1, /* crtcs */
|
||||||
RR_Connected))
|
RR_Connected))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!RRCrtcSet (crtc, mode, 0, 0, RR_Rotate_0, 1, &output))
|
RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, 1, &output);
|
||||||
return FALSE;
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
419
randr/randr.c
419
randr/randr.c
|
@ -31,25 +31,7 @@
|
||||||
#include <dix-config.h>
|
#include <dix-config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <X11/X.h>
|
|
||||||
#include <X11/Xproto.h>
|
|
||||||
#include "misc.h"
|
|
||||||
#include "os.h"
|
|
||||||
#include "dixstruct.h"
|
|
||||||
#include "resource.h"
|
|
||||||
#include "scrnintstr.h"
|
|
||||||
#include "windowstr.h"
|
|
||||||
#include "pixmapstr.h"
|
|
||||||
#include "extnsionst.h"
|
|
||||||
#include "servermd.h"
|
|
||||||
#include <X11/extensions/randr.h>
|
|
||||||
#include <X11/extensions/randrproto.h>
|
|
||||||
#include "randrstr.h"
|
#include "randrstr.h"
|
||||||
#ifdef RENDER
|
|
||||||
#include <X11/extensions/render.h> /* we share subpixel order information */
|
|
||||||
#include "picturestr.h"
|
|
||||||
#endif
|
|
||||||
#include <X11/Xfuncproto.h>
|
|
||||||
|
|
||||||
/* From render.h */
|
/* From render.h */
|
||||||
#ifndef SubPixelUnknown
|
#ifndef SubPixelUnknown
|
||||||
|
@ -60,8 +42,6 @@
|
||||||
int RRGeneration;
|
int RRGeneration;
|
||||||
int RRNScreens;
|
int RRNScreens;
|
||||||
|
|
||||||
static RESTYPE ModeType, CrtcType, OutputType;
|
|
||||||
|
|
||||||
static int ProcRRQueryVersion (ClientPtr pClient);
|
static int ProcRRQueryVersion (ClientPtr pClient);
|
||||||
static int ProcRRDispatch (ClientPtr pClient);
|
static int ProcRRDispatch (ClientPtr pClient);
|
||||||
static int SProcRRDispatch (ClientPtr pClient);
|
static int SProcRRDispatch (ClientPtr pClient);
|
||||||
|
@ -80,7 +60,7 @@ static int SProcRRQueryVersion (ClientPtr pClient);
|
||||||
static CARD8 RRReqCode;
|
static CARD8 RRReqCode;
|
||||||
static int RRErrBase;
|
static int RRErrBase;
|
||||||
#endif
|
#endif
|
||||||
static int RREventBase;
|
int RREventBase;
|
||||||
static RESTYPE ClientType, EventType; /* resource types for event masks */
|
static RESTYPE ClientType, EventType; /* resource types for event masks */
|
||||||
static int RRClientPrivateIndex;
|
static int RRClientPrivateIndex;
|
||||||
|
|
||||||
|
@ -233,50 +213,21 @@ SRRNotifyEvent (xEvent *from,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
RRModeDestroyResource (pointer value, XID pid)
|
|
||||||
{
|
|
||||||
RRModeDestroy ((RRModePtr) value);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
RRCrtcDestroyResource (pointer value, XID pid)
|
|
||||||
{
|
|
||||||
RRCrtcDestroy ((RRCrtcPtr) value);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
RROutputDestroyResource (pointer value, XID pid)
|
|
||||||
{
|
|
||||||
RROutputDestroy ((RROutputPtr) value);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bool RRScreenInit(ScreenPtr pScreen)
|
Bool RRScreenInit(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
rrScrPrivPtr pScrPriv;
|
rrScrPrivPtr pScrPriv;
|
||||||
|
|
||||||
if (RRGeneration != serverGeneration)
|
if (RRGeneration != serverGeneration)
|
||||||
{
|
{
|
||||||
ModeType = CreateNewResourceType (RRModeDestroyResource);
|
if (!RRModeInit ())
|
||||||
if (!ModeType)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
CrtcType = CreateNewResourceType (RRCrtcDestroyResource);
|
if (!RRCrtcInit ())
|
||||||
if (!ModeType)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
OutputType = CreateNewResourceType (RROutputDestroyResource);
|
if (!RROutputInit ())
|
||||||
if (!ModeType)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if ((rrPrivIndex = AllocateScreenPrivateIndex()) < 0)
|
if ((rrPrivIndex = AllocateScreenPrivateIndex()) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
RRGeneration = serverGeneration;
|
RRGeneration = serverGeneration;
|
||||||
#ifdef XResExtension
|
|
||||||
RegisterResourceName (ModeType, "MODE");
|
|
||||||
RegisterResourceName (CrtcType, "CRTC");
|
|
||||||
RegisterResourceName (OutputType, "OUTPUT");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pScrPriv = (rrScrPrivPtr) xalloc (sizeof (rrScrPrivRec));
|
pScrPriv = (rrScrPrivPtr) xalloc (sizeof (rrScrPrivRec));
|
||||||
|
@ -288,14 +239,23 @@ Bool RRScreenInit(ScreenPtr pScreen)
|
||||||
/*
|
/*
|
||||||
* Calling function best set these function vectors
|
* Calling function best set these function vectors
|
||||||
*/
|
*/
|
||||||
pScrPriv->rrCrtcSet = 0;
|
|
||||||
pScrPriv->rrGetInfo = 0;
|
pScrPriv->rrGetInfo = 0;
|
||||||
pScrPriv->maxWidth = pScrPriv->minWidth = pScreen->width;
|
pScrPriv->maxWidth = pScrPriv->minWidth = pScreen->width;
|
||||||
pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height;
|
pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height;
|
||||||
#ifdef RANDR_SCREEN_INTERFACE
|
|
||||||
|
#if RANDR_12_INTERFACE
|
||||||
|
pScrPriv->rrCrtcSet = 0;
|
||||||
|
#endif
|
||||||
|
#if RANDR_10_INTERFACE
|
||||||
pScrPriv->rrSetConfig = 0;
|
pScrPriv->rrSetConfig = 0;
|
||||||
|
pScrPriv->rotations = RR_Rotate_0;
|
||||||
pScrPriv->reqWidth = pScreen->width;
|
pScrPriv->reqWidth = pScreen->width;
|
||||||
pScrPriv->reqHeight = pScreen->height;
|
pScrPriv->reqHeight = pScreen->height;
|
||||||
|
pScrPriv->nSizes = 0;
|
||||||
|
pScrPriv->pSizes = NULL;
|
||||||
|
pScrPriv->rotation = RR_Rotate_0;
|
||||||
|
pScrPriv->rate = 0;
|
||||||
|
pScrPriv->size = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -400,61 +360,6 @@ RRExtensionInit (void)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
DeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
|
|
||||||
{
|
|
||||||
rrScrPriv (pScreen);
|
|
||||||
xRRScreenChangeNotifyEvent se;
|
|
||||||
RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
|
|
||||||
RROutputPtr output = pScrPriv->numOutputs ? pScrPriv->outputs[0] : NULL;
|
|
||||||
RRModePtr mode = crtc ? crtc->mode : NULL;
|
|
||||||
WindowPtr pRoot = WindowTable[pScreen->myNum];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
se.type = RRScreenChangeNotify + RREventBase;
|
|
||||||
se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0);
|
|
||||||
se.timestamp = pScrPriv->lastSetTime.milliseconds;
|
|
||||||
se.sequenceNumber = client->sequence;
|
|
||||||
se.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
|
|
||||||
se.root = pRoot->drawable.id;
|
|
||||||
se.window = pWin->drawable.id;
|
|
||||||
#ifdef RENDER
|
|
||||||
se.subpixelOrder = PictureGetSubpixelOrder (pScreen);
|
|
||||||
#else
|
|
||||||
se.subpixelOrder = SubPixelUnknown;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
se.sequenceNumber = client->sequence;
|
|
||||||
if (mode)
|
|
||||||
{
|
|
||||||
se.sizeID = -1;
|
|
||||||
for (i = 0; i < output->numModes; i++)
|
|
||||||
if (mode == output->modes[i])
|
|
||||||
{
|
|
||||||
se.sizeID = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
se.widthInPixels = mode->mode.width;
|
|
||||||
se.heightInPixels = mode->mode.height;
|
|
||||||
se.widthInMillimeters = mode->mode.mmWidth;
|
|
||||||
se.heightInMillimeters = mode->mode.mmHeight;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* This "shouldn't happen", but a broken DDX can
|
|
||||||
* forget to set the current configuration on GetInfo
|
|
||||||
*/
|
|
||||||
se.sizeID = 0xffff;
|
|
||||||
se.widthInPixels = 0;
|
|
||||||
se.heightInPixels = 0;
|
|
||||||
se.widthInMillimeters = 0;
|
|
||||||
se.heightInMillimeters = 0;
|
|
||||||
}
|
|
||||||
WriteEventsToClient (client, 1, (xEvent *) &se);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
DeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc)
|
DeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc)
|
||||||
{
|
{
|
||||||
|
@ -485,7 +390,7 @@ TellChanged (WindowPtr pWin, pointer value)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (pRREvent->mask & RRScreenChangeNotifyMask)
|
if (pRREvent->mask & RRScreenChangeNotifyMask)
|
||||||
DeliverScreenEvent (client, pWin, pScreen);
|
RRDeliverScreenEvent (client, pWin, pScreen);
|
||||||
|
|
||||||
if (pRREvent->mask & RRCrtcChangeNotifyMask)
|
if (pRREvent->mask & RRCrtcChangeNotifyMask)
|
||||||
{
|
{
|
||||||
|
@ -529,47 +434,6 @@ RRTellChanged (ScreenPtr pScreen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RRModePtr
|
|
||||||
RRModeGet (ScreenPtr pScreen,
|
|
||||||
xRRModeInfo *modeInfo,
|
|
||||||
char *name)
|
|
||||||
{
|
|
||||||
rrScrPriv (pScreen);
|
|
||||||
int i;
|
|
||||||
RRModePtr mode;
|
|
||||||
|
|
||||||
for (i = 0; i < pScrPriv->numModes; i++)
|
|
||||||
{
|
|
||||||
mode = pScrPriv->modes[i];
|
|
||||||
if (!memcmp (modeInfo, &mode->mode, sizeof (xRRModeInfo)) &&
|
|
||||||
!memcmp (name, mode->name, modeInfo->nameLength))
|
|
||||||
{
|
|
||||||
++mode->refcnt;
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1);
|
|
||||||
mode->refcnt = 1;
|
|
||||||
mode->mode = *modeInfo;
|
|
||||||
mode->name = (char *) (mode + 1);
|
|
||||||
memcpy (mode->name, name, modeInfo->nameLength);
|
|
||||||
mode->name[modeInfo->nameLength] = '\0';
|
|
||||||
mode->id = FakeClientID(0);
|
|
||||||
if (!AddResource (mode->id, ModeType, (pointer) mode))
|
|
||||||
return NULL;
|
|
||||||
++mode->refcnt;
|
|
||||||
pScrPriv->changed = TRUE;
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
RRModeDestroy (RRModePtr mode)
|
|
||||||
{
|
|
||||||
if (--mode->refcnt > 0)
|
|
||||||
return;
|
|
||||||
xfree (mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the first output which is connected to an active CRTC
|
* Return the first output which is connected to an active CRTC
|
||||||
* Used in emulating 1.0 behaviour
|
* Used in emulating 1.0 behaviour
|
||||||
|
@ -594,11 +458,13 @@ RRFirstOutput (ScreenPtr pScreen)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RANDR_SCREEN_INTERFACE
|
#ifdef RANDR_10_INTERFACE
|
||||||
|
|
||||||
static Bool
|
static RRModePtr
|
||||||
RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh)
|
RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh)
|
||||||
{
|
{
|
||||||
|
ScreenPtr pScreen = output->pScreen;
|
||||||
|
rrScrPriv(pScreen);
|
||||||
xRRModeInfo modeInfo;
|
xRRModeInfo modeInfo;
|
||||||
char name[100];
|
char name[100];
|
||||||
RRModePtr mode;
|
RRModePtr mode;
|
||||||
|
@ -617,12 +483,15 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh)
|
||||||
modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->width *
|
modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->width *
|
||||||
(CARD32) refresh);
|
(CARD32) refresh);
|
||||||
modeInfo.nameLength = strlen (name);
|
modeInfo.nameLength = strlen (name);
|
||||||
mode = RRModeGet (output->pScreen, &modeInfo, name);
|
mode = RRModeGet (pScreen, &modeInfo, name);
|
||||||
if (!mode)
|
if (!mode)
|
||||||
return FALSE;
|
return NULL;
|
||||||
for (i = 0; i < output->numModes; i++)
|
for (i = 0; i < output->numModes; i++)
|
||||||
if (output->modes[i] == mode)
|
if (output->modes[i] == mode)
|
||||||
return TRUE;
|
{
|
||||||
|
RRModeDestroy (mode);
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
if (output->numModes)
|
if (output->numModes)
|
||||||
modes = xrealloc (output->modes,
|
modes = xrealloc (output->modes,
|
||||||
|
@ -630,11 +499,16 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh)
|
||||||
else
|
else
|
||||||
modes = xalloc (sizeof (RRModePtr));
|
modes = xalloc (sizeof (RRModePtr));
|
||||||
if (!modes)
|
if (!modes)
|
||||||
return FALSE;
|
{
|
||||||
|
RRModeDestroy (mode);
|
||||||
|
FreeResource (mode->id, 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
modes[output->numModes++] = mode;
|
modes[output->numModes++] = mode;
|
||||||
output->modes = modes;
|
output->modes = modes;
|
||||||
output->changed = TRUE;
|
output->changed = TRUE;
|
||||||
return TRUE;
|
pScrPriv->changed = TRUE;
|
||||||
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -643,6 +517,7 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
|
||||||
rrScrPriv(pScreen);
|
rrScrPriv(pScreen);
|
||||||
RROutputPtr output = RRFirstOutput (pScreen);
|
RROutputPtr output = RRFirstOutput (pScreen);
|
||||||
RRCrtcPtr crtc;
|
RRCrtcPtr crtc;
|
||||||
|
RRModePtr mode, newMode = NULL;
|
||||||
int i;
|
int i;
|
||||||
CARD16 minWidth = MAXSHORT, minHeight = MAXSHORT;
|
CARD16 minWidth = MAXSHORT, minHeight = MAXSHORT;
|
||||||
CARD16 maxWidth = 0, maxHeight = 0;
|
CARD16 maxWidth = 0, maxHeight = 0;
|
||||||
|
@ -666,11 +541,29 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (size->nRates)
|
if (size->nRates)
|
||||||
|
{
|
||||||
for (r = 0; r < size->nRates; r++)
|
for (r = 0; r < size->nRates; r++)
|
||||||
RROldModeAdd (output, size, size->pRates[r].rate);
|
{
|
||||||
|
mode = RROldModeAdd (output, size, size->pRates[r].rate);
|
||||||
|
if (i == pScrPriv->size &&
|
||||||
|
size->pRates[r].rate == pScrPriv->rate)
|
||||||
|
{
|
||||||
|
newMode = mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xfree (size->pRates);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
RROldModeAdd (output, size, 0);
|
{
|
||||||
|
mode = RROldModeAdd (output, size, 0);
|
||||||
|
if (i == pScrPriv->size)
|
||||||
|
newMode = mode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (pScrPriv->nSizes)
|
||||||
|
xfree (pScrPriv->pSizes);
|
||||||
|
pScrPriv->pSizes = NULL;
|
||||||
|
pScrPriv->nSizes = 0;
|
||||||
|
|
||||||
/* find size bounds */
|
/* find size bounds */
|
||||||
for (i = 0; i < output->numModes; i++)
|
for (i = 0; i < output->numModes; i++)
|
||||||
|
@ -697,9 +590,17 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
|
||||||
if (maxHeight != pScrPriv->maxHeight) {
|
if (maxHeight != pScrPriv->maxHeight) {
|
||||||
pScrPriv->maxHeight = maxHeight; pScrPriv->changed = TRUE;
|
pScrPriv->maxHeight = maxHeight; pScrPriv->changed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* notice current mode */
|
||||||
|
if (newMode)
|
||||||
|
RRCrtcSet (output->crtc, newMode, 0, 0, pScrPriv->rotation,
|
||||||
|
1, &output);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Poll the driver for changed information
|
||||||
|
*/
|
||||||
static Bool
|
static Bool
|
||||||
RRGetInfo (ScreenPtr pScreen)
|
RRGetInfo (ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
|
@ -718,7 +619,7 @@ RRGetInfo (ScreenPtr pScreen)
|
||||||
if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations))
|
if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#if RANDR_SCREEN_INTERFACE
|
#if RANDR_10_INTERFACE
|
||||||
if (pScrPriv->nSizes)
|
if (pScrPriv->nSizes)
|
||||||
RRScanOldConfig (pScreen, rotations);
|
RRScanOldConfig (pScreen, rotations);
|
||||||
#endif
|
#endif
|
||||||
|
@ -726,27 +627,6 @@ RRGetInfo (ScreenPtr pScreen)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
RRSendConfigNotify (ScreenPtr pScreen)
|
|
||||||
{
|
|
||||||
WindowPtr pWin = WindowTable[pScreen->myNum];
|
|
||||||
xEvent event;
|
|
||||||
|
|
||||||
event.u.u.type = ConfigureNotify;
|
|
||||||
event.u.configureNotify.window = pWin->drawable.id;
|
|
||||||
event.u.configureNotify.aboveSibling = None;
|
|
||||||
event.u.configureNotify.x = 0;
|
|
||||||
event.u.configureNotify.y = 0;
|
|
||||||
|
|
||||||
/* XXX xinerama stuff ? */
|
|
||||||
|
|
||||||
event.u.configureNotify.width = pWin->drawable.width;
|
|
||||||
event.u.configureNotify.height = pWin->drawable.height;
|
|
||||||
event.u.configureNotify.borderWidth = wBorderWidth (pWin);
|
|
||||||
event.u.configureNotify.override = pWin->overrideRedirect;
|
|
||||||
DeliverEvents(pWin, &event, 1, NullWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ProcRRQueryVersion (ClientPtr client)
|
ProcRRQueryVersion (ClientPtr client)
|
||||||
{
|
{
|
||||||
|
@ -777,50 +657,6 @@ ProcRRQueryVersion (ClientPtr client)
|
||||||
return (client->noClientException);
|
return (client->noClientException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern char *ConnectionInfo;
|
|
||||||
|
|
||||||
static int padlength[4] = {0, 3, 2, 1};
|
|
||||||
|
|
||||||
static void
|
|
||||||
RREditConnectionInfo (ScreenPtr pScreen)
|
|
||||||
{
|
|
||||||
xConnSetup *connSetup;
|
|
||||||
char *vendor;
|
|
||||||
xPixmapFormat *formats;
|
|
||||||
xWindowRoot *root;
|
|
||||||
xDepth *depth;
|
|
||||||
xVisualType *visual;
|
|
||||||
int screen = 0;
|
|
||||||
int d;
|
|
||||||
|
|
||||||
connSetup = (xConnSetup *) ConnectionInfo;
|
|
||||||
vendor = (char *) connSetup + sizeof (xConnSetup);
|
|
||||||
formats = (xPixmapFormat *) ((char *) vendor +
|
|
||||||
connSetup->nbytesVendor +
|
|
||||||
padlength[connSetup->nbytesVendor & 3]);
|
|
||||||
root = (xWindowRoot *) ((char *) formats +
|
|
||||||
sizeof (xPixmapFormat) * screenInfo.numPixmapFormats);
|
|
||||||
while (screen != pScreen->myNum)
|
|
||||||
{
|
|
||||||
depth = (xDepth *) ((char *) root +
|
|
||||||
sizeof (xWindowRoot));
|
|
||||||
for (d = 0; d < root->nDepths; d++)
|
|
||||||
{
|
|
||||||
visual = (xVisualType *) ((char *) depth +
|
|
||||||
sizeof (xDepth));
|
|
||||||
depth = (xDepth *) ((char *) visual +
|
|
||||||
depth->nVisuals * sizeof (xVisualType));
|
|
||||||
}
|
|
||||||
root = (xWindowRoot *) ((char *) depth);
|
|
||||||
screen++;
|
|
||||||
}
|
|
||||||
root->pixWidth = pScreen->width;
|
|
||||||
root->pixHeight = pScreen->height;
|
|
||||||
root->mmWidth = pScreen->mmWidth;
|
|
||||||
root->mmHeight = pScreen->mmHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct _RR10Data {
|
typedef struct _RR10Data {
|
||||||
RRScreenSizePtr sizes;
|
RRScreenSizePtr sizes;
|
||||||
int nsize;
|
int nsize;
|
||||||
|
@ -829,7 +665,7 @@ typedef struct _RR10Data {
|
||||||
CARD16 refresh;
|
CARD16 refresh;
|
||||||
} RR10DataRec, *RR10DataPtr;
|
} RR10DataRec, *RR10DataPtr;
|
||||||
|
|
||||||
static CARD16
|
CARD16
|
||||||
RRVerticalRefresh (xRRModeInfo *mode)
|
RRVerticalRefresh (xRRModeInfo *mode)
|
||||||
{
|
{
|
||||||
CARD32 refresh;
|
CARD32 refresh;
|
||||||
|
@ -1056,94 +892,6 @@ ProcRRGetScreenInfo (ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int
|
|
||||||
RRMonitorSetMode (ScreenPtr pScreen, RRMonitorPtr pMonitor,
|
|
||||||
RRModePtr pMode, int x, int y, Rotation rotation,
|
|
||||||
TimeStamp time)
|
|
||||||
{
|
|
||||||
rrScrPriv(pScreen);
|
|
||||||
short oldWidth, oldHeight;
|
|
||||||
|
|
||||||
oldWidth = pScreen->width;
|
|
||||||
oldHeight = pScreen->height;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* call out to ddx routine to effect the change
|
|
||||||
*/
|
|
||||||
if (pScrPriv->rrSetScreenSize && pScrPriv->rrSetMode)
|
|
||||||
{
|
|
||||||
xScreenSizes oldSize;
|
|
||||||
if (!(*pScrPriv->rrSetMode) (pScreen, 0, NULL, 0, 0, RR_Rotate_0))
|
|
||||||
return RRSetConfigFailed;
|
|
||||||
oldSize.widthInPixels = pScreen->width;
|
|
||||||
oldSize.heightInPixels = pScreen->width;
|
|
||||||
oldSize.widthInMillimeters = pScreen->mmWidth;
|
|
||||||
oldSize.heightInMillimeters = pScreen->mmHeight;
|
|
||||||
if (!(*pScrPriv->rrSetScreenSize) (pScreen,
|
|
||||||
pMode->mode.width,
|
|
||||||
pMode->mode.height,
|
|
||||||
pMode->mode.widthInMillimeters,
|
|
||||||
pMode->mode.heightInMillimeters))
|
|
||||||
{
|
|
||||||
(void) (*pScrPriv->rrSetMode) (pScreen, 0, pMonitor->pMode,
|
|
||||||
pMonitor->x, pMonitor->y,
|
|
||||||
pMonitor->rotation);
|
|
||||||
return RRSetConfigFailed;
|
|
||||||
}
|
|
||||||
if (!(*pScrPriv->rrSetMode) (pScreen, 0, pMode, 0, 0, rotation))
|
|
||||||
{
|
|
||||||
(void) (*pScrPriv->rrSetScreenSize) (pScreen,
|
|
||||||
oldSize.widthInPixels,
|
|
||||||
oldSize.heightInPixels,
|
|
||||||
oldSize.widthInMillimeters,
|
|
||||||
oldSize.heightInMillimeters);
|
|
||||||
(void) (*pScrPriv->rrSetMode) (pScreen, 0, pMonitor->pMode,
|
|
||||||
pMonitor->x, pMonitor->y,
|
|
||||||
pMonitor->rotation);
|
|
||||||
return RRSetConfigFailed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef RANDR_SCREEN_INTERFACE
|
|
||||||
else if (pScrPriv->rrSetConfig)
|
|
||||||
{
|
|
||||||
int rate = RRVerticalRefresh (&pMode->mode);
|
|
||||||
RRScreenSizeRec size;
|
|
||||||
|
|
||||||
size.width = pMode->mode.width;
|
|
||||||
size.height = pMode->mode.height;
|
|
||||||
size.mmWidth = pMode->mode.widthInMillimeters;
|
|
||||||
size.mmHeight = pMode->mode.heightInMillimeters;
|
|
||||||
if (!(*pScrPriv->rrSetConfig) (pScreen, rotation, rate, &size))
|
|
||||||
return RRSetConfigFailed;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
return RRSetConfigFailed;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* set current extension configuration pointers
|
|
||||||
*/
|
|
||||||
RRSetCurrentMode (pMonitor, pMode, 0, 0, rotation);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deliver ScreenChangeNotify events whenever
|
|
||||||
* the configuration is updated
|
|
||||||
*/
|
|
||||||
WalkTree (pScreen, TellChanged, (pointer) pScreen);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deliver ConfigureNotify events when root changes
|
|
||||||
* pixel size
|
|
||||||
*/
|
|
||||||
if (oldWidth != pScreen->width || oldHeight != pScreen->height)
|
|
||||||
RRSendConfigNotify (pScreen);
|
|
||||||
RREditConnectionInfo (pScreen);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fix pointer bounds and location
|
|
||||||
*/
|
|
||||||
ScreenRestructured (pScreen);
|
|
||||||
pScrPriv->lastSetTime = time;
|
|
||||||
return RRSetConfigSuccess;
|
return RRSetConfigSuccess;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1411,36 +1159,6 @@ RRSetScreenConfig (ScreenPtr pScreen,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Bool
|
|
||||||
RRSetScreenSize (ScreenPtr pScreen,
|
|
||||||
CARD16 width, CARD16 height,
|
|
||||||
CARD16 widthInMillimeters, CARD16 heightInMillimeters)
|
|
||||||
{
|
|
||||||
rrScrPriv(pScreen);
|
|
||||||
|
|
||||||
if (pScrPriv->rrScreenSetSize)
|
|
||||||
{
|
|
||||||
return (*pScrPriv->rrScreenSetSize) (pScreen, width, height,
|
|
||||||
widthInMillimeters,
|
|
||||||
heightInMillimeters);
|
|
||||||
}
|
|
||||||
#ifdef RANDR_SCREEN_INTERFACE
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Pend the size change until we get the set mode request.
|
|
||||||
* Yes, this is 'illegal', but the best we can do until
|
|
||||||
* drivers are updated
|
|
||||||
*/
|
|
||||||
pScrPriv->reqWidth = width;
|
|
||||||
pScrPriv->reqHeight = height;
|
|
||||||
pScreen->mmWidth = widthInMillimeters;
|
|
||||||
pScreen->mmHeight = heightInMillimeters;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ProcRRSelectInput (ClientPtr client)
|
ProcRRSelectInput (ClientPtr client)
|
||||||
{
|
{
|
||||||
|
@ -1524,7 +1242,7 @@ ProcRRSelectInput (ClientPtr client)
|
||||||
CompareTimeStamps (pTimes->configTime,
|
CompareTimeStamps (pTimes->configTime,
|
||||||
pScrPriv->lastConfigTime) != 0)
|
pScrPriv->lastConfigTime) != 0)
|
||||||
{
|
{
|
||||||
DeliverScreenEvent (client, pWin, pScreen);
|
RRDeliverScreenEvent (client, pWin, pScreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1651,7 +1369,7 @@ static int ProcRRSetScreenSize (ClientPtr client)
|
||||||
client->errorValue = 0;
|
client->errorValue = 0;
|
||||||
return BadValue;
|
return BadValue;
|
||||||
}
|
}
|
||||||
if (!RRSetScreenSize (pScreen,
|
if (!RRScreenSizeSet (pScreen,
|
||||||
stuff->width, stuff->height,
|
stuff->width, stuff->height,
|
||||||
stuff->widthInMillimeters,
|
stuff->widthInMillimeters,
|
||||||
stuff->heightInMillimeters))
|
stuff->heightInMillimeters))
|
||||||
|
@ -2000,6 +1718,7 @@ SProcRRDispatch (ClientPtr client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if RANDR_12_INTERFACE
|
||||||
/*
|
/*
|
||||||
* Register the range of sizes for the screen
|
* Register the range of sizes for the screen
|
||||||
*/
|
*/
|
||||||
|
@ -2019,8 +1738,9 @@ RRScreenSetSizeRange (ScreenPtr pScreen,
|
||||||
pScrPriv->maxWidth = maxWidth;
|
pScrPriv->maxWidth = maxWidth;
|
||||||
pScrPriv->maxHeight = maxHeight;
|
pScrPriv->maxHeight = maxHeight;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef RANDR_SCREEN_INTERFACE
|
#ifdef RANDR_10_INTERFACE
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
RRScreenSizeMatches (RRScreenSizePtr a,
|
RRScreenSizeMatches (RRScreenSizePtr a,
|
||||||
|
@ -2052,6 +1772,7 @@ RRRegisterSize (ScreenPtr pScreen,
|
||||||
if (!pScrPriv)
|
if (!pScrPriv)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
tmp.id = 0;
|
||||||
tmp.width = width;
|
tmp.width = width;
|
||||||
tmp.height= height;
|
tmp.height= height;
|
||||||
tmp.mmWidth = mmWidth;
|
tmp.mmWidth = mmWidth;
|
||||||
|
|
273
randr/randrstr.h
273
randr/randrstr.h
|
@ -32,15 +32,35 @@
|
||||||
#ifndef _RANDRSTR_H_
|
#ifndef _RANDRSTR_H_
|
||||||
#define _RANDRSTR_H_
|
#define _RANDRSTR_H_
|
||||||
|
|
||||||
|
#include <X11/X.h>
|
||||||
|
#include <X11/Xproto.h>
|
||||||
|
#include "misc.h"
|
||||||
|
#include "os.h"
|
||||||
|
#include "dixstruct.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#include "scrnintstr.h"
|
||||||
|
#include "windowstr.h"
|
||||||
|
#include "pixmapstr.h"
|
||||||
|
#include "extnsionst.h"
|
||||||
|
#include "servermd.h"
|
||||||
|
#include <X11/extensions/randr.h>
|
||||||
#include <X11/extensions/randrproto.h>
|
#include <X11/extensions/randrproto.h>
|
||||||
|
#ifdef RENDER
|
||||||
|
#include <X11/extensions/render.h> /* we share subpixel order information */
|
||||||
|
#include "picturestr.h"
|
||||||
|
#endif
|
||||||
|
#include <X11/Xfuncproto.h>
|
||||||
|
|
||||||
/* required for ABI compatibility for now */
|
/* required for ABI compatibility for now */
|
||||||
#define RANDR_SCREEN_INTERFACE 1
|
#define RANDR_10_INTERFACE 1
|
||||||
|
/* #define RANDR_12_INTERFACE 1 */
|
||||||
|
|
||||||
typedef XID RRMode;
|
typedef XID RRMode;
|
||||||
typedef XID RROutput;
|
typedef XID RROutput;
|
||||||
typedef XID RRCrtc;
|
typedef XID RRCrtc;
|
||||||
|
|
||||||
|
extern int RREventBase;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modeline for a monitor. Name follows directly after this struct
|
* Modeline for a monitor. Name follows directly after this struct
|
||||||
*/
|
*/
|
||||||
|
@ -64,9 +84,9 @@ struct _rrCrtc {
|
||||||
int x, y;
|
int x, y;
|
||||||
Rotation rotation;
|
Rotation rotation;
|
||||||
Rotation rotations;
|
Rotation rotations;
|
||||||
int numPossibleOutputs;
|
|
||||||
RROutputPtr *possibleOutputs;
|
|
||||||
Bool changed;
|
Bool changed;
|
||||||
|
int numOutputs;
|
||||||
|
RROutputPtr *outputs;
|
||||||
void *devPrivate;
|
void *devPrivate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,11 +108,12 @@ struct _rrOutput {
|
||||||
void *devPrivate;
|
void *devPrivate;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen,
|
#if RANDR_12_INTERFACE
|
||||||
|
typedef Bool (*RRScreentSizeSetProcPtr) (ScreenPtr pScreen,
|
||||||
CARD16 width,
|
CARD16 width,
|
||||||
CARD16 height,
|
CARD16 height,
|
||||||
CARD32 widthInMM,
|
CARD32 mmWidth,
|
||||||
CARD32 heightInMM);
|
CARD32 mmHeight);
|
||||||
|
|
||||||
typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen,
|
typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen,
|
||||||
RRCrtcPtr crtc,
|
RRCrtcPtr crtc,
|
||||||
|
@ -100,8 +121,9 @@ typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
Rotation rotation,
|
Rotation rotation,
|
||||||
int numOutput,
|
int numOutputs,
|
||||||
RROutputPtr *outputs);
|
RROutputPtr *outputs);
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations);
|
typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations);
|
||||||
typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen);
|
typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen);
|
||||||
|
@ -121,7 +143,7 @@ typedef struct _rrScreenSize {
|
||||||
RRScreenRatePtr pRates;
|
RRScreenRatePtr pRates;
|
||||||
} RRScreenSize, *RRScreenSizePtr;
|
} RRScreenSize, *RRScreenSizePtr;
|
||||||
|
|
||||||
#ifdef RANDR_SCREEN_INTERFACE
|
#ifdef RANDR_10_INTERFACE
|
||||||
|
|
||||||
typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen,
|
typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen,
|
||||||
Rotation rotation,
|
Rotation rotation,
|
||||||
|
@ -136,12 +158,14 @@ typedef struct _rrScrPriv {
|
||||||
* 'public' part of the structure; DDXen fill this in
|
* 'public' part of the structure; DDXen fill this in
|
||||||
* as they initialize
|
* as they initialize
|
||||||
*/
|
*/
|
||||||
#ifdef RANDR_SCREEN_INTERFACE
|
#if RANDR_10_INTERFACE
|
||||||
RRSetConfigProcPtr rrSetConfig;
|
RRSetConfigProcPtr rrSetConfig;
|
||||||
#endif
|
#endif
|
||||||
RRGetInfoProcPtr rrGetInfo;
|
RRGetInfoProcPtr rrGetInfo;
|
||||||
RRScreenSetSizeProcPtr rrScreenSetSize;
|
#if RANDR_12_INTERFACE
|
||||||
|
RRScreenSetSizeProcPtr rrScreenSizeSet;
|
||||||
RRCrtcSetProcPtr rrCrtcSet;
|
RRCrtcSetProcPtr rrCrtcSet;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private part of the structure; not considered part of the ABI
|
* Private part of the structure; not considered part of the ABI
|
||||||
|
@ -152,6 +176,7 @@ typedef struct _rrScrPriv {
|
||||||
Bool changed;
|
Bool changed;
|
||||||
CARD16 minWidth, minHeight;
|
CARD16 minWidth, minHeight;
|
||||||
CARD16 maxWidth, maxHeight;
|
CARD16 maxWidth, maxHeight;
|
||||||
|
CARD16 width, height; /* last known screen size */
|
||||||
|
|
||||||
/* modes, outputs and crtcs */
|
/* modes, outputs and crtcs */
|
||||||
int numModes;
|
int numModes;
|
||||||
|
@ -163,7 +188,7 @@ typedef struct _rrScrPriv {
|
||||||
int numCrtcs;
|
int numCrtcs;
|
||||||
RRCrtcPtr *crtcs;
|
RRCrtcPtr *crtcs;
|
||||||
|
|
||||||
#ifdef RANDR_SCREEN_INTERFACE
|
#ifdef RANDR_10_INTERFACE
|
||||||
/*
|
/*
|
||||||
* Configuration information
|
* Configuration information
|
||||||
*/
|
*/
|
||||||
|
@ -173,7 +198,6 @@ typedef struct _rrScrPriv {
|
||||||
int nSizes;
|
int nSizes;
|
||||||
RRScreenSizePtr pSizes;
|
RRScreenSizePtr pSizes;
|
||||||
|
|
||||||
RRScreenSizePtr pSize;
|
|
||||||
Rotation rotation;
|
Rotation rotation;
|
||||||
int rate;
|
int rate;
|
||||||
int size;
|
int size;
|
||||||
|
@ -190,6 +214,7 @@ extern int rrPrivIndex;
|
||||||
void
|
void
|
||||||
RRExtensionInit (void);
|
RRExtensionInit (void);
|
||||||
|
|
||||||
|
#ifdef RANDR_12_INTERFACE
|
||||||
/*
|
/*
|
||||||
* Set the range of sizes for the screen
|
* Set the range of sizes for the screen
|
||||||
*/
|
*/
|
||||||
|
@ -199,89 +224,34 @@ RRScreenSetSizeRange (ScreenPtr pScreen,
|
||||||
CARD16 minHeight,
|
CARD16 minHeight,
|
||||||
CARD16 maxWidth,
|
CARD16 maxWidth,
|
||||||
CARD16 maxHeight);
|
CARD16 maxHeight);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* rrscreen.c */
|
||||||
/*
|
/*
|
||||||
* Create a CRTC
|
* Notify the extension that the screen size has been changed.
|
||||||
|
* The driver is responsible for calling this whenever it has changed
|
||||||
|
* the size of the screen
|
||||||
*/
|
*/
|
||||||
RRCrtcPtr
|
void
|
||||||
RRCrtcCreate (ScreenPtr pScreen,
|
RRScreenSizeNotify (ScreenPtr pScreen);
|
||||||
void *devPrivate);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use this value for any num parameter to indicate that
|
* Request that the screen be resized
|
||||||
* the related data are unchanged
|
|
||||||
*/
|
|
||||||
#define RR_NUM_UNCHANGED -1
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Notify the extension that the Crtc has been reconfigured
|
|
||||||
*/
|
*/
|
||||||
Bool
|
Bool
|
||||||
RRCrtcSet (RRCrtcPtr crtc,
|
RRScreenSizeSet (ScreenPtr pScreen,
|
||||||
RRModePtr mode,
|
CARD16 width,
|
||||||
int x,
|
CARD16 height,
|
||||||
int y,
|
CARD32 mmWidth,
|
||||||
Rotation rotation,
|
CARD32 mmHeight);
|
||||||
int numOutput,
|
|
||||||
RROutputPtr *outputs);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Destroy a Crtc at shutdown
|
* Deliver a ScreenNotify event
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
RRCrtcDestroy (RRCrtcPtr crtc);
|
RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen);
|
||||||
|
|
||||||
/*
|
/* mirandr.c */
|
||||||
* Find, and if necessary, create a mode
|
|
||||||
*/
|
|
||||||
|
|
||||||
RRModePtr
|
|
||||||
RRModeGet (ScreenPtr pScreen,
|
|
||||||
xRRModeInfo *modeInfo,
|
|
||||||
char *name);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Destroy a mode.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
|
||||||
RRModeDestroy (RRModePtr mode);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create an output
|
|
||||||
*/
|
|
||||||
|
|
||||||
RROutputPtr
|
|
||||||
RROutputCreate (ScreenPtr pScreen,
|
|
||||||
char *name,
|
|
||||||
int nameLength,
|
|
||||||
void *devPrivate);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Notify extension that output parameters have been changed
|
|
||||||
*/
|
|
||||||
Bool
|
|
||||||
RROutputSet (RROutputPtr output,
|
|
||||||
RROutputPtr *clones,
|
|
||||||
int numClones,
|
|
||||||
RRModePtr *modes,
|
|
||||||
int numModes,
|
|
||||||
RRCrtcPtr *crtcs,
|
|
||||||
int numCrtcs,
|
|
||||||
CARD8 connection);
|
|
||||||
|
|
||||||
void
|
|
||||||
RROutputDestroy (RROutputPtr output);
|
|
||||||
|
|
||||||
void
|
|
||||||
RRTellChanged (ScreenPtr pScreen);
|
|
||||||
|
|
||||||
Bool RRScreenInit(ScreenPtr pScreen);
|
|
||||||
|
|
||||||
Rotation
|
|
||||||
RRGetRotation (ScreenPtr pScreen);
|
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
miRandRInit (ScreenPtr pScreen);
|
miRandRInit (ScreenPtr pScreen);
|
||||||
|
|
||||||
|
@ -301,7 +271,22 @@ miRRCrtcSet (ScreenPtr pScreen,
|
||||||
int numOutput,
|
int numOutput,
|
||||||
RROutputPtr *outputs);
|
RROutputPtr *outputs);
|
||||||
|
|
||||||
#ifdef RANDR_SCREEN_INTERFACE
|
/* randr.c */
|
||||||
|
/*
|
||||||
|
* Send all pending events
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
RRTellChanged (ScreenPtr pScreen);
|
||||||
|
|
||||||
|
Bool RRScreenInit(ScreenPtr pScreen);
|
||||||
|
|
||||||
|
Rotation
|
||||||
|
RRGetRotation (ScreenPtr pScreen);
|
||||||
|
|
||||||
|
CARD16
|
||||||
|
RRVerticalRefresh (xRRModeInfo *mode);
|
||||||
|
|
||||||
|
#ifdef RANDR_10_INTERFACE
|
||||||
/*
|
/*
|
||||||
* This is the old interface, deprecated but left
|
* This is the old interface, deprecated but left
|
||||||
* around for compatibility
|
* around for compatibility
|
||||||
|
@ -344,4 +329,122 @@ RRSetScreenConfig (ScreenPtr pScreen,
|
||||||
RRScreenSizePtr pSize);
|
RRScreenSizePtr pSize);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* rrcrtc.c */
|
||||||
|
/*
|
||||||
|
* Create a CRTC
|
||||||
|
*/
|
||||||
|
RRCrtcPtr
|
||||||
|
RRCrtcCreate (ScreenPtr pScreen,
|
||||||
|
void *devPrivate);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use this value for any num parameter to indicate that
|
||||||
|
* the related data are unchanged
|
||||||
|
*/
|
||||||
|
#define RR_NUM_UNCHANGED -1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Notify the extension that the Crtc has been reconfigured,
|
||||||
|
* the driver calls this whenever it has updated the mode
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
RRCrtcNotify (RRCrtcPtr crtc,
|
||||||
|
RRModePtr mode,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
Rotation rotation,
|
||||||
|
int numOutput,
|
||||||
|
RROutputPtr *outputs);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Request that the Crtc be reconfigured
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
RRCrtcSet (RRCrtcPtr crtc,
|
||||||
|
RRModePtr mode,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
Rotation rotation,
|
||||||
|
int numOutput,
|
||||||
|
RROutputPtr *outputs);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroy a Crtc at shutdown
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
RRCrtcDestroy (RRCrtcPtr crtc);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize crtc type
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
RRCrtcInit (void);
|
||||||
|
|
||||||
|
/* rrmode.c */
|
||||||
|
/*
|
||||||
|
* Find, and if necessary, create a mode
|
||||||
|
*/
|
||||||
|
|
||||||
|
RRModePtr
|
||||||
|
RRModeGet (ScreenPtr pScreen,
|
||||||
|
xRRModeInfo *modeInfo,
|
||||||
|
char *name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroy a mode.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
RRModeDestroy (RRModePtr mode);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize mode type
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
RRModeInit (void);
|
||||||
|
|
||||||
|
/* rroutput.c */
|
||||||
|
/*
|
||||||
|
* Create an output
|
||||||
|
*/
|
||||||
|
|
||||||
|
RROutputPtr
|
||||||
|
RROutputCreate (ScreenPtr pScreen,
|
||||||
|
char *name,
|
||||||
|
int nameLength,
|
||||||
|
void *devPrivate);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Notify extension that output parameters have been changed
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
RROutputSetClones (RROutputPtr output,
|
||||||
|
RROutputPtr *clones,
|
||||||
|
int numClones);
|
||||||
|
|
||||||
|
Bool
|
||||||
|
RROutputSetModes (RROutputPtr output,
|
||||||
|
RRModePtr *modes,
|
||||||
|
int numModes);
|
||||||
|
|
||||||
|
Bool
|
||||||
|
RROutputSetCrtcs (RROutputPtr output,
|
||||||
|
RRCrtcPtr *crtcs,
|
||||||
|
int numCrtcs);
|
||||||
|
|
||||||
|
Bool
|
||||||
|
RROutputSetConnection (RROutputPtr output,
|
||||||
|
CARD8 connection);
|
||||||
|
|
||||||
|
void
|
||||||
|
RROutputDestroy (RROutputPtr output);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize output type
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
RROutputInit (void);
|
||||||
|
|
||||||
#endif /* _RANDRSTR_H_ */
|
#endif /* _RANDRSTR_H_ */
|
||||||
|
|
238
randr/rrcrtc.c
Normal file
238
randr/rrcrtc.c
Normal file
|
@ -0,0 +1,238 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2006 Keith Packard
|
||||||
|
*
|
||||||
|
* 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 the copyright holders not be used in advertising or
|
||||||
|
* publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission. The copyright holders make no representations
|
||||||
|
* about the suitability of this software for any purpose. It is provided "as
|
||||||
|
* is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* EVENT SHALL THE COPYRIGHT HOLDERS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "randrstr.h"
|
||||||
|
|
||||||
|
static RESTYPE CrtcType;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a CRTC
|
||||||
|
*/
|
||||||
|
RRCrtcPtr
|
||||||
|
RRCrtcCreate (ScreenPtr pScreen,
|
||||||
|
void *devPrivate)
|
||||||
|
{
|
||||||
|
rrScrPriv (pScreen);
|
||||||
|
RRCrtcPtr crtc;
|
||||||
|
RRCrtcPtr *crtcs;
|
||||||
|
|
||||||
|
crtc = xalloc (sizeof (RRCrtcRec));
|
||||||
|
if (!crtc)
|
||||||
|
return NULL;
|
||||||
|
if (pScrPriv->numCrtcs)
|
||||||
|
crtcs = xrealloc (pScrPriv->crtcs,
|
||||||
|
(pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr));
|
||||||
|
else
|
||||||
|
crtcs = xalloc (sizeof (RRCrtcPtr));
|
||||||
|
if (!crtcs)
|
||||||
|
{
|
||||||
|
xfree (crtc);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
crtc->id = FakeClientID (0);
|
||||||
|
crtc->pScreen = pScreen;
|
||||||
|
crtc->mode = NULL;
|
||||||
|
crtc->x = 0;
|
||||||
|
crtc->y = 0;
|
||||||
|
crtc->rotation = RR_Rotate_0;
|
||||||
|
crtc->rotations = RR_Rotate_0;
|
||||||
|
crtc->outputs = NULL;
|
||||||
|
crtc->numOutputs = 0;
|
||||||
|
crtc->changed = TRUE;
|
||||||
|
crtc->devPrivate = devPrivate;
|
||||||
|
pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc;
|
||||||
|
return crtc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Notify the extension that the Crtc has been reconfigured,
|
||||||
|
* the driver calls this whenever it has updated the mode
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
RRCrtcNotify (RRCrtcPtr crtc,
|
||||||
|
RRModePtr mode,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
Rotation rotation,
|
||||||
|
int numOutputs,
|
||||||
|
RROutputPtr *outputs)
|
||||||
|
{
|
||||||
|
ScreenPtr pScreen = crtc->pScreen;
|
||||||
|
rrScrPriv(pScreen);
|
||||||
|
int i, j;
|
||||||
|
int prevNumOutputs = crtc->numOutputs;
|
||||||
|
|
||||||
|
if (numOutputs != prevNumOutputs)
|
||||||
|
{
|
||||||
|
RROutputPtr *outputs;
|
||||||
|
|
||||||
|
if (crtc->numOutputs)
|
||||||
|
outputs = xrealloc (crtc->outputs,
|
||||||
|
numOutputs * sizeof (RROutputPtr));
|
||||||
|
else
|
||||||
|
outputs = xalloc (numOutputs * sizeof (RROutputPtr));
|
||||||
|
if (!outputs)
|
||||||
|
return FALSE;
|
||||||
|
crtc->outputs = outputs;
|
||||||
|
}
|
||||||
|
for (i = 0; i < numOutputs; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j < crtc->numOutputs; j++)
|
||||||
|
if (outputs[i] == crtc->outputs[j])
|
||||||
|
break;
|
||||||
|
if (j != crtc->numOutputs)
|
||||||
|
{
|
||||||
|
outputs[i]->changed = TRUE;
|
||||||
|
crtc->changed = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (j = 0; j < crtc->numOutputs; j++)
|
||||||
|
{
|
||||||
|
for (i = 0; i < numOutputs; i++)
|
||||||
|
if (outputs[i] == crtc->outputs[j])
|
||||||
|
break;
|
||||||
|
if (i != numOutputs)
|
||||||
|
{
|
||||||
|
crtc->outputs[j]->changed = TRUE;
|
||||||
|
crtc->changed = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mode != crtc->mode)
|
||||||
|
{
|
||||||
|
if (crtc->mode)
|
||||||
|
RRModeDestroy (crtc->mode);
|
||||||
|
crtc->mode = mode;
|
||||||
|
mode->refcnt++;
|
||||||
|
crtc->changed = TRUE;
|
||||||
|
}
|
||||||
|
if (x != crtc->x)
|
||||||
|
{
|
||||||
|
crtc->x = x;
|
||||||
|
crtc->changed = TRUE;
|
||||||
|
}
|
||||||
|
if (y != crtc->y)
|
||||||
|
{
|
||||||
|
crtc->y = y;
|
||||||
|
crtc->changed = TRUE;
|
||||||
|
}
|
||||||
|
if (rotation != crtc->rotation)
|
||||||
|
{
|
||||||
|
crtc->rotation = rotation;
|
||||||
|
crtc->changed = TRUE;
|
||||||
|
}
|
||||||
|
if (crtc->changed)
|
||||||
|
pScrPriv->changed = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Request that the Crtc be reconfigured
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
RRCrtcSet (RRCrtcPtr crtc,
|
||||||
|
RRModePtr mode,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
Rotation rotation,
|
||||||
|
int numOutputs,
|
||||||
|
RROutputPtr *outputs)
|
||||||
|
{
|
||||||
|
ScreenPtr pScreen = crtc->pScreen;
|
||||||
|
rrScrPriv(pScreen);
|
||||||
|
|
||||||
|
#if RANDR_12_INTERFACE
|
||||||
|
if (pScrPriv->rrCrtcSet)
|
||||||
|
{
|
||||||
|
return (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y,
|
||||||
|
rotation, numOutputs, outputs);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if RANDR_10_INTERFACE
|
||||||
|
if (pScrPriv->rrSetConfig)
|
||||||
|
{
|
||||||
|
RRScreenSize size;
|
||||||
|
RRScreenRate rate;
|
||||||
|
Bool ret;
|
||||||
|
|
||||||
|
size.width = mode->mode.width;
|
||||||
|
size.height = mode->mode.height;
|
||||||
|
size.mmWidth = mode->mode.mmWidth;
|
||||||
|
size.mmHeight = mode->mode.mmHeight;
|
||||||
|
size.nRates = 1;
|
||||||
|
rate.rate = RRVerticalRefresh (&mode->mode);
|
||||||
|
size.pRates = &rate;
|
||||||
|
ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size);
|
||||||
|
/*
|
||||||
|
* Old 1.0 interface tied screen size to mode size
|
||||||
|
*/
|
||||||
|
if (ret)
|
||||||
|
RRScreenSizeNotify (pScreen);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroy a Crtc at shutdown
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
RRCrtcDestroy (RRCrtcPtr crtc)
|
||||||
|
{
|
||||||
|
FreeResource (crtc->id, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
RRCrtcDestroyResource (pointer value, XID pid)
|
||||||
|
{
|
||||||
|
RRCrtcPtr crtc = (RRCrtcPtr) value;
|
||||||
|
ScreenPtr pScreen = crtc->pScreen;
|
||||||
|
rrScrPriv(pScreen);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < pScrPriv->numCrtcs; i++)
|
||||||
|
{
|
||||||
|
if (pScrPriv->crtcs[i] == crtc)
|
||||||
|
{
|
||||||
|
memmove (pScrPriv->crtcs, pScrPriv->crtcs + 1,
|
||||||
|
(pScrPriv->numCrtcs - (i - 1)) * sizeof (RRCrtcPtr));
|
||||||
|
--pScrPriv->numCrtcs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (value);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize crtc type
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
RRCrtcInit (void)
|
||||||
|
{
|
||||||
|
CrtcType = CreateNewResourceType (RRCrtcDestroyResource);
|
||||||
|
if (!CrtcType)
|
||||||
|
return FALSE;
|
||||||
|
#ifdef XResExtension
|
||||||
|
RegisterResourceName (CrtcType, "CRTC");
|
||||||
|
#endif
|
||||||
|
return TRUE;
|
||||||
|
}
|
85
randr/rrmode.c
Normal file
85
randr/rrmode.c
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2006 Keith Packard
|
||||||
|
*
|
||||||
|
* 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 the copyright holders not be used in advertising or
|
||||||
|
* publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission. The copyright holders make no representations
|
||||||
|
* about the suitability of this software for any purpose. It is provided "as
|
||||||
|
* is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* EVENT SHALL THE COPYRIGHT HOLDERS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "randrstr.h"
|
||||||
|
|
||||||
|
static RESTYPE ModeType;
|
||||||
|
|
||||||
|
RRModePtr
|
||||||
|
RRModeGet (ScreenPtr pScreen,
|
||||||
|
xRRModeInfo *modeInfo,
|
||||||
|
char *name)
|
||||||
|
{
|
||||||
|
rrScrPriv (pScreen);
|
||||||
|
int i;
|
||||||
|
RRModePtr mode;
|
||||||
|
|
||||||
|
for (i = 0; i < pScrPriv->numModes; i++)
|
||||||
|
{
|
||||||
|
mode = pScrPriv->modes[i];
|
||||||
|
if (!memcmp (modeInfo, &mode->mode, sizeof (xRRModeInfo)) &&
|
||||||
|
!memcmp (name, mode->name, modeInfo->nameLength))
|
||||||
|
{
|
||||||
|
++mode->refcnt;
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1);
|
||||||
|
mode->refcnt = 1;
|
||||||
|
mode->mode = *modeInfo;
|
||||||
|
mode->name = (char *) (mode + 1);
|
||||||
|
memcpy (mode->name, name, modeInfo->nameLength);
|
||||||
|
mode->name[modeInfo->nameLength] = '\0';
|
||||||
|
mode->id = FakeClientID(0);
|
||||||
|
if (!AddResource (mode->id, ModeType, (pointer) mode))
|
||||||
|
return NULL;
|
||||||
|
++mode->refcnt;
|
||||||
|
pScrPriv->changed = TRUE;
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
RRModeDestroy (RRModePtr mode)
|
||||||
|
{
|
||||||
|
if (--mode->refcnt > 0)
|
||||||
|
return;
|
||||||
|
xfree (mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
RRModeDestroyResource (pointer value, XID pid)
|
||||||
|
{
|
||||||
|
RRModeDestroy ((RRModePtr) value);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bool
|
||||||
|
RRModeInit (void)
|
||||||
|
{
|
||||||
|
ModeType = CreateNewResourceType (RRModeDestroyResource);
|
||||||
|
if (!ModeType)
|
||||||
|
return FALSE;
|
||||||
|
#ifdef XResExtension
|
||||||
|
RegisterResourceName (ModeType, "MODE");
|
||||||
|
#endif
|
||||||
|
return TRUE;
|
||||||
|
}
|
56
randr/rroutput.c
Normal file
56
randr/rroutput.c
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2006 Keith Packard
|
||||||
|
*
|
||||||
|
* 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 the copyright holders not be used in advertising or
|
||||||
|
* publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission. The copyright holders make no representations
|
||||||
|
* about the suitability of this software for any purpose. It is provided "as
|
||||||
|
* is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* EVENT SHALL THE COPYRIGHT HOLDERS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "randrstr.h"
|
||||||
|
|
||||||
|
static RESTYPE OutputType;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroy a Output at shutdown
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
RROutputDestroy (RROutputPtr crtc)
|
||||||
|
{
|
||||||
|
FreeResource (crtc->id, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
RROutputDestroyResource (pointer value, XID pid)
|
||||||
|
{
|
||||||
|
free (value);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize crtc type
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
RROutputInit (void)
|
||||||
|
{
|
||||||
|
OutputType = CreateNewResourceType (RROutputDestroyResource);
|
||||||
|
if (!OutputType)
|
||||||
|
return FALSE;
|
||||||
|
#ifdef XResExtension
|
||||||
|
RegisterResourceName (OutputType, "OUTPUT");
|
||||||
|
#endif
|
||||||
|
return TRUE;
|
||||||
|
}
|
205
randr/rrscreen.c
Normal file
205
randr/rrscreen.c
Normal file
|
@ -0,0 +1,205 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2006 Keith Packard
|
||||||
|
*
|
||||||
|
* 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 the copyright holders not be used in advertising or
|
||||||
|
* publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission. The copyright holders make no representations
|
||||||
|
* about the suitability of this software for any purpose. It is provided "as
|
||||||
|
* is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* EVENT SHALL THE COPYRIGHT HOLDERS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "randrstr.h"
|
||||||
|
|
||||||
|
extern char *ConnectionInfo;
|
||||||
|
|
||||||
|
static int padlength[4] = {0, 3, 2, 1};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Edit connection information block so that new clients
|
||||||
|
* see the current screen size on connect
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
RREditConnectionInfo (ScreenPtr pScreen)
|
||||||
|
{
|
||||||
|
xConnSetup *connSetup;
|
||||||
|
char *vendor;
|
||||||
|
xPixmapFormat *formats;
|
||||||
|
xWindowRoot *root;
|
||||||
|
xDepth *depth;
|
||||||
|
xVisualType *visual;
|
||||||
|
int screen = 0;
|
||||||
|
int d;
|
||||||
|
|
||||||
|
connSetup = (xConnSetup *) ConnectionInfo;
|
||||||
|
vendor = (char *) connSetup + sizeof (xConnSetup);
|
||||||
|
formats = (xPixmapFormat *) ((char *) vendor +
|
||||||
|
connSetup->nbytesVendor +
|
||||||
|
padlength[connSetup->nbytesVendor & 3]);
|
||||||
|
root = (xWindowRoot *) ((char *) formats +
|
||||||
|
sizeof (xPixmapFormat) * screenInfo.numPixmapFormats);
|
||||||
|
while (screen != pScreen->myNum)
|
||||||
|
{
|
||||||
|
depth = (xDepth *) ((char *) root +
|
||||||
|
sizeof (xWindowRoot));
|
||||||
|
for (d = 0; d < root->nDepths; d++)
|
||||||
|
{
|
||||||
|
visual = (xVisualType *) ((char *) depth +
|
||||||
|
sizeof (xDepth));
|
||||||
|
depth = (xDepth *) ((char *) visual +
|
||||||
|
depth->nVisuals * sizeof (xVisualType));
|
||||||
|
}
|
||||||
|
root = (xWindowRoot *) ((char *) depth);
|
||||||
|
screen++;
|
||||||
|
}
|
||||||
|
root->pixWidth = pScreen->width;
|
||||||
|
root->pixHeight = pScreen->height;
|
||||||
|
root->mmWidth = pScreen->mmWidth;
|
||||||
|
root->mmHeight = pScreen->mmHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
RRSendConfigNotify (ScreenPtr pScreen)
|
||||||
|
{
|
||||||
|
WindowPtr pWin = WindowTable[pScreen->myNum];
|
||||||
|
xEvent event;
|
||||||
|
|
||||||
|
event.u.u.type = ConfigureNotify;
|
||||||
|
event.u.configureNotify.window = pWin->drawable.id;
|
||||||
|
event.u.configureNotify.aboveSibling = None;
|
||||||
|
event.u.configureNotify.x = 0;
|
||||||
|
event.u.configureNotify.y = 0;
|
||||||
|
|
||||||
|
/* XXX xinerama stuff ? */
|
||||||
|
|
||||||
|
event.u.configureNotify.width = pWin->drawable.width;
|
||||||
|
event.u.configureNotify.height = pWin->drawable.height;
|
||||||
|
event.u.configureNotify.borderWidth = wBorderWidth (pWin);
|
||||||
|
event.u.configureNotify.override = pWin->overrideRedirect;
|
||||||
|
DeliverEvents(pWin, &event, 1, NullWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
|
||||||
|
{
|
||||||
|
rrScrPriv (pScreen);
|
||||||
|
xRRScreenChangeNotifyEvent se;
|
||||||
|
RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
|
||||||
|
RROutputPtr output = pScrPriv->numOutputs ? pScrPriv->outputs[0] : NULL;
|
||||||
|
RRModePtr mode = crtc ? crtc->mode : NULL;
|
||||||
|
WindowPtr pRoot = WindowTable[pScreen->myNum];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
se.type = RRScreenChangeNotify + RREventBase;
|
||||||
|
se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0);
|
||||||
|
se.timestamp = pScrPriv->lastSetTime.milliseconds;
|
||||||
|
se.sequenceNumber = client->sequence;
|
||||||
|
se.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
|
||||||
|
se.root = pRoot->drawable.id;
|
||||||
|
se.window = pWin->drawable.id;
|
||||||
|
#ifdef RENDER
|
||||||
|
se.subpixelOrder = PictureGetSubpixelOrder (pScreen);
|
||||||
|
#else
|
||||||
|
se.subpixelOrder = SubPixelUnknown;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
se.sequenceNumber = client->sequence;
|
||||||
|
if (mode)
|
||||||
|
{
|
||||||
|
se.sizeID = -1;
|
||||||
|
for (i = 0; i < output->numModes; i++)
|
||||||
|
if (mode == output->modes[i])
|
||||||
|
{
|
||||||
|
se.sizeID = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
se.widthInPixels = mode->mode.width;
|
||||||
|
se.heightInPixels = mode->mode.height;
|
||||||
|
se.widthInMillimeters = mode->mode.mmWidth;
|
||||||
|
se.heightInMillimeters = mode->mode.mmHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* This "shouldn't happen", but a broken DDX can
|
||||||
|
* forget to set the current configuration on GetInfo
|
||||||
|
*/
|
||||||
|
se.sizeID = 0xffff;
|
||||||
|
se.widthInPixels = 0;
|
||||||
|
se.heightInPixels = 0;
|
||||||
|
se.widthInMillimeters = 0;
|
||||||
|
se.heightInMillimeters = 0;
|
||||||
|
}
|
||||||
|
WriteEventsToClient (client, 1, (xEvent *) &se);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Notify the extension that the screen size has been changed.
|
||||||
|
* The driver is responsible for calling this whenever it has changed
|
||||||
|
* the size of the screen
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
RRScreenSizeNotify (ScreenPtr pScreen)
|
||||||
|
{
|
||||||
|
rrScrPriv(pScreen);
|
||||||
|
/*
|
||||||
|
* Deliver ConfigureNotify events when root changes
|
||||||
|
* pixel size
|
||||||
|
*/
|
||||||
|
if (pScrPriv->width == pScreen->width &&
|
||||||
|
pScrPriv->height == pScreen->height)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pScrPriv->width = pScreen->width;
|
||||||
|
pScrPriv->height = pScreen->height;
|
||||||
|
pScrPriv->changed = TRUE;
|
||||||
|
|
||||||
|
RRSendConfigNotify (pScreen);
|
||||||
|
RREditConnectionInfo (pScreen);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fix pointer bounds and location
|
||||||
|
*/
|
||||||
|
ScreenRestructured (pScreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Request that the screen be resized
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
RRScreenSizeSet (ScreenPtr pScreen,
|
||||||
|
CARD16 width,
|
||||||
|
CARD16 height,
|
||||||
|
CARD32 mmWidth,
|
||||||
|
CARD32 mmHeight)
|
||||||
|
{
|
||||||
|
rrScrPriv(pScreen);
|
||||||
|
|
||||||
|
#if RANDR_12_INTERFACE
|
||||||
|
if (pScrPriv->rrScreenSizeSet)
|
||||||
|
{
|
||||||
|
return (*pScrPriv->rrScreenSizeSet) (pScreen,
|
||||||
|
width, height,
|
||||||
|
mmWidth, mmHeight);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if RANDR_10_INTERFACE
|
||||||
|
if (pScrPriv->rrSetConfig)
|
||||||
|
{
|
||||||
|
return TRUE; /* can't set size separately */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user