2006-11-26 11:13:41 -07:00
|
|
|
/*
|
2007-11-24 10:55:21 -07:00
|
|
|
* Copyright © 2000 Compaq Computer Corporation
|
|
|
|
* Copyright © 2002 Hewlett-Packard Company
|
|
|
|
* Copyright © 2006 Intel Corporation
|
2019-07-27 01:57:06 -06:00
|
|
|
* Copyright © 2017 Keith Packard
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
2007-11-24 10:55:21 -07:00
|
|
|
* 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.
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
2007-11-24 10:55:21 -07:00
|
|
|
* 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.
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
2007-11-24 10:55:21 -07:00
|
|
|
* Author: Jim Gettys, Hewlett-Packard Company, Inc.
|
|
|
|
* Keith Packard, Intel Corporation
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "randrstr.h"
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "extinit.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* From render.h */
|
|
|
|
#ifndef SubPixelUnknown
|
|
|
|
#define SubPixelUnknown 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define RR_VALIDATE
|
2012-06-10 07:21:05 -06:00
|
|
|
static int RRNScreens;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#define wrap(priv,real,mem,func) {\
|
|
|
|
priv->mem = real->mem; \
|
|
|
|
real->mem = func; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define unwrap(priv,real,mem) {\
|
|
|
|
real->mem = priv->mem; \
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int ProcRRDispatch(ClientPtr pClient);
|
|
|
|
static int SProcRRDispatch(ClientPtr pClient);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
int RREventBase;
|
|
|
|
int RRErrorBase;
|
|
|
|
RESTYPE RRClientType, RREventType; /* resource types for event masks */
|
2010-12-05 08:36:02 -07:00
|
|
|
DevPrivateKeyRec RRClientPrivateKeyRec;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
DevPrivateKeyRec rrPrivKeyRec;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
2014-09-27 11:52:59 -06:00
|
|
|
RRClientCallback(CallbackListPtr *list, void *closure, void *data)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
|
|
|
|
ClientPtr pClient = clientinfo->client;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
rrClientPriv(pClient);
|
2012-06-10 07:21:05 -06:00
|
|
|
RRTimesPtr pTimes = (RRTimesPtr) (pRRClient + 1);
|
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pRRClient->major_version = 0;
|
|
|
|
pRRClient->minor_version = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[i];
|
|
|
|
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
|
|
|
|
if (pScrPriv) {
|
|
|
|
pTimes[i].setTime = pScrPriv->lastSetTime;
|
|
|
|
pTimes[i].configTime = pScrPriv->lastConfigTime;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2013-06-07 11:28:45 -06:00
|
|
|
RRCloseScreen(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
rrScrPriv(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
int j;
|
2019-07-27 01:57:06 -06:00
|
|
|
RRLeasePtr lease, next;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
unwrap(pScrPriv, pScreen, CloseScreen);
|
2019-07-27 01:57:06 -06:00
|
|
|
|
|
|
|
xorg_list_for_each_entry_safe(lease, next, &pScrPriv->leases, list)
|
|
|
|
RRTerminateLease(lease);
|
2007-11-24 10:55:21 -07:00
|
|
|
for (j = pScrPriv->numCrtcs - 1; j >= 0; j--)
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcDestroy(pScrPriv->crtcs[j]);
|
2007-11-24 10:55:21 -07:00
|
|
|
for (j = pScrPriv->numOutputs - 1; j >= 0; j--)
|
2012-06-10 07:21:05 -06:00
|
|
|
RROutputDestroy(pScrPriv->outputs[j]);
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
if (pScrPriv->provider)
|
|
|
|
RRProviderDestroy(pScrPriv->provider);
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
RRMonitorClose(pScreen);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pScrPriv->crtcs);
|
|
|
|
free(pScrPriv->outputs);
|
|
|
|
free(pScrPriv);
|
2012-06-10 07:21:05 -06:00
|
|
|
RRNScreens -= 1; /* ok, one fewer screen with RandR running */
|
2013-06-07 11:28:45 -06:00
|
|
|
return (*pScreen->CloseScreen) (pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SRRScreenChangeNotifyEvent(xRRScreenChangeNotifyEvent * from,
|
|
|
|
xRRScreenChangeNotifyEvent * to)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
to->type = from->type;
|
|
|
|
to->rotation = from->rotation;
|
|
|
|
cpswaps(from->sequenceNumber, to->sequenceNumber);
|
|
|
|
cpswapl(from->timestamp, to->timestamp);
|
|
|
|
cpswapl(from->configTimestamp, to->configTimestamp);
|
|
|
|
cpswapl(from->root, to->root);
|
|
|
|
cpswapl(from->window, to->window);
|
|
|
|
cpswaps(from->sizeID, to->sizeID);
|
2009-09-06 13:44:18 -06:00
|
|
|
cpswaps(from->subpixelOrder, to->subpixelOrder);
|
2006-11-26 11:13:41 -07:00
|
|
|
cpswaps(from->widthInPixels, to->widthInPixels);
|
|
|
|
cpswaps(from->heightInPixels, to->heightInPixels);
|
|
|
|
cpswaps(from->widthInMillimeters, to->widthInMillimeters);
|
|
|
|
cpswaps(from->heightInMillimeters, to->heightInMillimeters);
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SRRCrtcChangeNotifyEvent(xRRCrtcChangeNotifyEvent * from,
|
|
|
|
xRRCrtcChangeNotifyEvent * to)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
to->type = from->type;
|
|
|
|
to->subCode = from->subCode;
|
|
|
|
cpswaps(from->sequenceNumber, to->sequenceNumber);
|
|
|
|
cpswapl(from->timestamp, to->timestamp);
|
|
|
|
cpswapl(from->window, to->window);
|
|
|
|
cpswapl(from->crtc, to->crtc);
|
|
|
|
cpswapl(from->mode, to->mode);
|
|
|
|
cpswaps(from->rotation, to->rotation);
|
2009-09-06 13:44:18 -06:00
|
|
|
/* pad1 */
|
2007-11-24 10:55:21 -07:00
|
|
|
cpswaps(from->x, to->x);
|
|
|
|
cpswaps(from->y, to->y);
|
|
|
|
cpswaps(from->width, to->width);
|
|
|
|
cpswaps(from->height, to->height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SRROutputChangeNotifyEvent(xRROutputChangeNotifyEvent * from,
|
|
|
|
xRROutputChangeNotifyEvent * to)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
to->type = from->type;
|
|
|
|
to->subCode = from->subCode;
|
|
|
|
cpswaps(from->sequenceNumber, to->sequenceNumber);
|
|
|
|
cpswapl(from->timestamp, to->timestamp);
|
|
|
|
cpswapl(from->configTimestamp, to->configTimestamp);
|
|
|
|
cpswapl(from->window, to->window);
|
|
|
|
cpswapl(from->output, to->output);
|
|
|
|
cpswapl(from->crtc, to->crtc);
|
|
|
|
cpswapl(from->mode, to->mode);
|
|
|
|
cpswaps(from->rotation, to->rotation);
|
2009-09-06 13:44:18 -06:00
|
|
|
to->connection = from->connection;
|
|
|
|
to->subpixelOrder = from->subpixelOrder;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SRROutputPropertyNotifyEvent(xRROutputPropertyNotifyEvent * from,
|
|
|
|
xRROutputPropertyNotifyEvent * to)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
to->type = from->type;
|
|
|
|
to->subCode = from->subCode;
|
|
|
|
cpswaps(from->sequenceNumber, to->sequenceNumber);
|
|
|
|
cpswapl(from->window, to->window);
|
|
|
|
cpswapl(from->output, to->output);
|
|
|
|
cpswapl(from->atom, to->atom);
|
|
|
|
cpswapl(from->timestamp, to->timestamp);
|
2009-09-06 13:44:18 -06:00
|
|
|
to->state = from->state;
|
|
|
|
/* pad1 */
|
|
|
|
/* pad2 */
|
|
|
|
/* pad3 */
|
|
|
|
/* pad4 */
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
static void
|
|
|
|
SRRProviderChangeNotifyEvent(xRRProviderChangeNotifyEvent * from,
|
|
|
|
xRRProviderChangeNotifyEvent * to)
|
|
|
|
{
|
|
|
|
to->type = from->type;
|
|
|
|
to->subCode = from->subCode;
|
|
|
|
cpswaps(from->sequenceNumber, to->sequenceNumber);
|
|
|
|
cpswapl(from->timestamp, to->timestamp);
|
|
|
|
cpswapl(from->window, to->window);
|
|
|
|
cpswapl(from->provider, to->provider);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
SRRProviderPropertyNotifyEvent(xRRProviderPropertyNotifyEvent * from,
|
|
|
|
xRRProviderPropertyNotifyEvent * to)
|
|
|
|
{
|
|
|
|
to->type = from->type;
|
|
|
|
to->subCode = from->subCode;
|
|
|
|
cpswaps(from->sequenceNumber, to->sequenceNumber);
|
|
|
|
cpswapl(from->window, to->window);
|
|
|
|
cpswapl(from->provider, to->provider);
|
|
|
|
cpswapl(from->atom, to->atom);
|
|
|
|
cpswapl(from->timestamp, to->timestamp);
|
|
|
|
to->state = from->state;
|
|
|
|
/* pad1 */
|
|
|
|
/* pad2 */
|
|
|
|
/* pad3 */
|
|
|
|
/* pad4 */
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static void _X_COLD
|
2013-06-07 11:28:45 -06:00
|
|
|
SRRResourceChangeNotifyEvent(xRRResourceChangeNotifyEvent * from,
|
|
|
|
xRRResourceChangeNotifyEvent * to)
|
|
|
|
{
|
|
|
|
to->type = from->type;
|
|
|
|
to->subCode = from->subCode;
|
|
|
|
cpswaps(from->sequenceNumber, to->sequenceNumber);
|
|
|
|
cpswapl(from->timestamp, to->timestamp);
|
|
|
|
cpswapl(from->window, to->window);
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static void _X_COLD
|
|
|
|
SRRLeaseNotifyEvent(xRRLeaseNotifyEvent * from,
|
|
|
|
xRRLeaseNotifyEvent * to)
|
|
|
|
{
|
|
|
|
to->type = from->type;
|
|
|
|
to->subCode = from->subCode;
|
|
|
|
cpswaps(from->sequenceNumber, to->sequenceNumber);
|
|
|
|
cpswapl(from->timestamp, to->timestamp);
|
|
|
|
cpswapl(from->window, to->window);
|
|
|
|
cpswapl(from->lease, to->lease);
|
|
|
|
to->created = from->created;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _X_COLD
|
2012-06-10 07:21:05 -06:00
|
|
|
SRRNotifyEvent(xEvent *from, xEvent *to)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
switch (from->u.u.detail) {
|
|
|
|
case RRNotify_CrtcChange:
|
2012-06-10 07:21:05 -06:00
|
|
|
SRRCrtcChangeNotifyEvent((xRRCrtcChangeNotifyEvent *) from,
|
|
|
|
(xRRCrtcChangeNotifyEvent *) to);
|
|
|
|
break;
|
2007-11-24 10:55:21 -07:00
|
|
|
case RRNotify_OutputChange:
|
2012-06-10 07:21:05 -06:00
|
|
|
SRROutputChangeNotifyEvent((xRROutputChangeNotifyEvent *) from,
|
|
|
|
(xRROutputChangeNotifyEvent *) to);
|
|
|
|
break;
|
2007-11-24 10:55:21 -07:00
|
|
|
case RRNotify_OutputProperty:
|
2012-06-10 07:21:05 -06:00
|
|
|
SRROutputPropertyNotifyEvent((xRROutputPropertyNotifyEvent *) from,
|
|
|
|
(xRROutputPropertyNotifyEvent *) to);
|
|
|
|
break;
|
2013-06-07 11:28:45 -06:00
|
|
|
case RRNotify_ProviderChange:
|
|
|
|
SRRProviderChangeNotifyEvent((xRRProviderChangeNotifyEvent *) from,
|
|
|
|
(xRRProviderChangeNotifyEvent *) to);
|
|
|
|
break;
|
|
|
|
case RRNotify_ProviderProperty:
|
|
|
|
SRRProviderPropertyNotifyEvent((xRRProviderPropertyNotifyEvent *) from,
|
|
|
|
(xRRProviderPropertyNotifyEvent *) to);
|
|
|
|
break;
|
|
|
|
case RRNotify_ResourceChange:
|
|
|
|
SRRResourceChangeNotifyEvent((xRRResourceChangeNotifyEvent *) from,
|
|
|
|
(xRRResourceChangeNotifyEvent *) to);
|
2019-07-27 01:57:06 -06:00
|
|
|
break;
|
|
|
|
case RRNotify_Lease:
|
|
|
|
SRRLeaseNotifyEvent((xRRLeaseNotifyEvent *) from,
|
|
|
|
(xRRLeaseNotifyEvent *) to);
|
|
|
|
break;
|
2007-11-24 10:55:21 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
break;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int RRGeneration;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool
|
|
|
|
RRInit(void)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (RRGeneration != serverGeneration) {
|
|
|
|
if (!RRModeInit())
|
|
|
|
return FALSE;
|
|
|
|
if (!RRCrtcInit())
|
|
|
|
return FALSE;
|
|
|
|
if (!RROutputInit())
|
|
|
|
return FALSE;
|
2013-06-07 11:28:45 -06:00
|
|
|
if (!RRProviderInit())
|
|
|
|
return FALSE;
|
2019-07-27 01:57:06 -06:00
|
|
|
if (!RRLeaseInit())
|
|
|
|
return FALSE;
|
2012-06-10 07:21:05 -06:00
|
|
|
RRGeneration = serverGeneration;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!dixRegisterPrivateKey(&rrPrivKeyRec, PRIVATE_SCREEN, 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool
|
|
|
|
RRScreenInit(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
rrScrPrivPtr pScrPriv;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!RRInit())
|
|
|
|
return FALSE;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pScrPriv = (rrScrPrivPtr) calloc(1, sizeof(rrScrPrivRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pScrPriv)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
SetRRScreen(pScreen, pScrPriv);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calling function best set these function vectors
|
|
|
|
*/
|
|
|
|
pScrPriv->rrGetInfo = 0;
|
2007-11-24 10:55:21 -07:00
|
|
|
pScrPriv->maxWidth = pScrPriv->minWidth = pScreen->width;
|
|
|
|
pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
pScrPriv->width = pScreen->width;
|
|
|
|
pScrPriv->height = pScreen->height;
|
|
|
|
pScrPriv->mmWidth = pScreen->mmWidth;
|
|
|
|
pScrPriv->mmHeight = pScreen->mmHeight;
|
|
|
|
#if RANDR_12_INTERFACE
|
|
|
|
pScrPriv->rrScreenSetSize = NULL;
|
|
|
|
pScrPriv->rrCrtcSet = NULL;
|
|
|
|
pScrPriv->rrCrtcSetGamma = NULL;
|
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
#if RANDR_10_INTERFACE
|
2007-11-24 10:55:21 -07:00
|
|
|
pScrPriv->rrSetConfig = 0;
|
|
|
|
pScrPriv->rotations = RR_Rotate_0;
|
|
|
|
pScrPriv->reqWidth = pScreen->width;
|
|
|
|
pScrPriv->reqHeight = pScreen->height;
|
|
|
|
pScrPriv->nSizes = 0;
|
|
|
|
pScrPriv->pSizes = NULL;
|
|
|
|
pScrPriv->rotation = RR_Rotate_0;
|
|
|
|
pScrPriv->rate = 0;
|
|
|
|
pScrPriv->size = 0;
|
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* This value doesn't really matter -- any client must call
|
|
|
|
* GetScreenInfo before reading it which will automatically update
|
|
|
|
* the time
|
|
|
|
*/
|
|
|
|
pScrPriv->lastSetTime = currentTime;
|
|
|
|
pScrPriv->lastConfigTime = currentTime;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
wrap(pScrPriv, pScreen, CloseScreen, RRCloseScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
pScreen->ConstrainCursorHarder = RRConstrainCursorHarder;
|
2013-06-07 11:28:45 -06:00
|
|
|
pScreen->ReplaceScanoutPixmap = RRReplaceScanoutPixmap;
|
2007-11-24 10:55:21 -07:00
|
|
|
pScrPriv->numOutputs = 0;
|
|
|
|
pScrPriv->outputs = NULL;
|
|
|
|
pScrPriv->numCrtcs = 0;
|
|
|
|
pScrPriv->crtcs = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
xorg_list_init(&pScrPriv->leases);
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
RRMonitorInit(pScreen);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
RRNScreens += 1; /* keep count of screens that implement randr */
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/*ARGSUSED*/ static int
|
2014-09-27 11:52:59 -06:00
|
|
|
RRFreeClient(void *data, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RREventPtr pRREvent;
|
|
|
|
WindowPtr pWin;
|
|
|
|
RREventPtr *pHead, pCur, pPrev;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pRREvent = (RREventPtr) data;
|
|
|
|
pWin = pRREvent->window;
|
2014-09-27 11:52:59 -06:00
|
|
|
dixLookupResourceByType((void **) &pHead, pWin->drawable.id,
|
2012-06-10 07:21:05 -06:00
|
|
|
RREventType, serverClient, DixDestroyAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pHead) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pPrev = 0;
|
|
|
|
for (pCur = *pHead; pCur && pCur != pRREvent; pCur = pCur->next)
|
|
|
|
pPrev = pCur;
|
|
|
|
if (pCur) {
|
|
|
|
if (pPrev)
|
|
|
|
pPrev->next = pRREvent->next;
|
|
|
|
else
|
|
|
|
*pHead = pRREvent->next;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2014-09-27 11:52:59 -06:00
|
|
|
free((void *) pRREvent);
|
2006-11-26 11:13:41 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/*ARGSUSED*/ static int
|
2014-09-27 11:52:59 -06:00
|
|
|
RRFreeEvents(void *data, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RREventPtr *pHead, pCur, pNext;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pHead = (RREventPtr *) data;
|
|
|
|
for (pCur = *pHead; pCur; pCur = pNext) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pNext = pCur->next;
|
|
|
|
FreeResource(pCur->clientResource, RRClientType);
|
2014-09-27 11:52:59 -06:00
|
|
|
free((void *) pCur);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2014-09-27 11:52:59 -06:00
|
|
|
free((void *) pHead);
|
2006-11-26 11:13:41 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
RRExtensionInit(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ExtensionEntry *extEntry;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (RRNScreens == 0)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!dixRegisterPrivateKey(&RRClientPrivateKeyRec, PRIVATE_CLIENT,
|
2012-06-10 07:21:05 -06:00
|
|
|
sizeof(RRClientRec) +
|
|
|
|
screenInfo.numScreens * sizeof(RRTimesRec)))
|
|
|
|
return;
|
|
|
|
if (!AddCallback(&ClientStateCallback, RRClientCallback, 0))
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
RRClientType = CreateNewResourceType(RRFreeClient, "RandRClient");
|
2007-11-24 10:55:21 -07:00
|
|
|
if (!RRClientType)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2010-07-27 13:02:24 -06:00
|
|
|
RREventType = CreateNewResourceType(RRFreeEvents, "RandREvent");
|
2007-11-24 10:55:21 -07:00
|
|
|
if (!RREventType)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
extEntry = AddExtension(RANDR_NAME, RRNumberEvents, RRNumberErrors,
|
|
|
|
ProcRRDispatch, SProcRRDispatch,
|
|
|
|
NULL, StandardMinorOpcode);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!extEntry)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2007-11-24 10:55:21 -07:00
|
|
|
RRErrorBase = extEntry->errorBase;
|
2006-11-26 11:13:41 -07:00
|
|
|
RREventBase = extEntry->eventBase;
|
2012-06-10 07:21:05 -06:00
|
|
|
EventSwapVector[RREventBase + RRScreenChangeNotify] = (EventSwapPtr)
|
|
|
|
SRRScreenChangeNotifyEvent;
|
2007-11-24 10:55:21 -07:00
|
|
|
EventSwapVector[RREventBase + RRNotify] = (EventSwapPtr)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRRNotifyEvent;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
|
|
|
RRModeInitErrorValue();
|
|
|
|
RRCrtcInitErrorValue();
|
|
|
|
RROutputInitErrorValue();
|
2013-06-07 11:28:45 -06:00
|
|
|
RRProviderInitErrorValue();
|
2007-11-24 10:55:21 -07:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
RRXineramaExtensionInit();
|
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2013-12-28 07:40:01 -07:00
|
|
|
void
|
|
|
|
RRResourcesChanged(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
pScrPriv->resourcesChanged = TRUE;
|
|
|
|
|
|
|
|
RRSetChanged(pScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
RRDeliverResourceEvent(ClientPtr client, WindowPtr pWin)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
|
|
|
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
|
|
|
|
xRRResourceChangeNotifyEvent re = {
|
|
|
|
.type = RRNotify + RREventBase,
|
|
|
|
.subCode = RRNotify_ResourceChange,
|
|
|
|
.timestamp = pScrPriv->lastSetTime.milliseconds,
|
|
|
|
.window = pWin->drawable.id
|
|
|
|
};
|
|
|
|
|
|
|
|
WriteEventsToClient(client, 1, (xEvent *) &re);
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
TellChanged(WindowPtr pWin, void *value)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RREventPtr *pHead, pRREvent;
|
|
|
|
ClientPtr client;
|
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
2013-12-28 07:40:01 -07:00
|
|
|
ScreenPtr iter;
|
|
|
|
rrScrPrivPtr pSlaveScrPriv;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
rrScrPriv(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
dixLookupResourceByType((void **) &pHead, pWin->drawable.id,
|
2012-06-10 07:21:05 -06:00
|
|
|
RREventType, serverClient, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pHead)
|
2012-06-10 07:21:05 -06:00
|
|
|
return WT_WALKCHILDREN;
|
|
|
|
|
|
|
|
for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) {
|
|
|
|
client = pRREvent->client;
|
|
|
|
if (client == serverClient || client->clientGone)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (pRREvent->mask & RRScreenChangeNotifyMask)
|
|
|
|
RRDeliverScreenEvent(client, pWin, pScreen);
|
|
|
|
|
|
|
|
if (pRREvent->mask & RRCrtcChangeNotifyMask) {
|
|
|
|
for (i = 0; i < pScrPriv->numCrtcs; i++) {
|
|
|
|
RRCrtcPtr crtc = pScrPriv->crtcs[i];
|
|
|
|
|
|
|
|
if (crtc->changed)
|
|
|
|
RRDeliverCrtcEvent(client, pWin, crtc);
|
|
|
|
}
|
2013-12-28 07:40:01 -07:00
|
|
|
|
2017-12-08 08:01:59 -07:00
|
|
|
xorg_list_for_each_entry(iter, &pScreen->slave_list, slave_head) {
|
|
|
|
if (!iter->is_output_slave)
|
|
|
|
continue;
|
|
|
|
|
2013-12-28 07:40:01 -07:00
|
|
|
pSlaveScrPriv = rrGetScrPriv(iter);
|
|
|
|
for (i = 0; i < pSlaveScrPriv->numCrtcs; i++) {
|
|
|
|
RRCrtcPtr crtc = pSlaveScrPriv->crtcs[i];
|
|
|
|
|
|
|
|
if (crtc->changed)
|
|
|
|
RRDeliverCrtcEvent(client, pWin, crtc);
|
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pRREvent->mask & RROutputChangeNotifyMask) {
|
|
|
|
for (i = 0; i < pScrPriv->numOutputs; i++) {
|
|
|
|
RROutputPtr output = pScrPriv->outputs[i];
|
|
|
|
|
|
|
|
if (output->changed)
|
|
|
|
RRDeliverOutputEvent(client, pWin, output);
|
|
|
|
}
|
2013-12-28 07:40:01 -07:00
|
|
|
|
2017-12-08 08:01:59 -07:00
|
|
|
xorg_list_for_each_entry(iter, &pScreen->slave_list, slave_head) {
|
|
|
|
if (!iter->is_output_slave)
|
|
|
|
continue;
|
|
|
|
|
2013-12-28 07:40:01 -07:00
|
|
|
pSlaveScrPriv = rrGetScrPriv(iter);
|
|
|
|
for (i = 0; i < pSlaveScrPriv->numOutputs; i++) {
|
|
|
|
RROutputPtr output = pSlaveScrPriv->outputs[i];
|
|
|
|
|
|
|
|
if (output->changed)
|
|
|
|
RRDeliverOutputEvent(client, pWin, output);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pRREvent->mask & RRProviderChangeNotifyMask) {
|
2017-12-08 08:01:59 -07:00
|
|
|
xorg_list_for_each_entry(iter, &pScreen->slave_list, slave_head) {
|
2013-12-28 07:40:01 -07:00
|
|
|
pSlaveScrPriv = rrGetScrPriv(iter);
|
|
|
|
if (pSlaveScrPriv->provider->changed)
|
|
|
|
RRDeliverProviderEvent(client, pWin, pSlaveScrPriv->provider);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pRREvent->mask & RRResourceChangeNotifyMask) {
|
|
|
|
if (pScrPriv->resourcesChanged) {
|
|
|
|
RRDeliverResourceEvent(client, pWin);
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2019-07-27 01:57:06 -06:00
|
|
|
|
|
|
|
if (pRREvent->mask & RRLeaseNotifyMask) {
|
|
|
|
if (pScrPriv->leasesChanged) {
|
|
|
|
RRDeliverLeaseEvent(client, pWin);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
return WT_WALKCHILDREN;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2013-12-28 07:40:01 -07:00
|
|
|
void
|
|
|
|
RRSetChanged(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
/* set changed bits on the master screen only */
|
|
|
|
ScreenPtr master;
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
rrScrPrivPtr mastersp;
|
|
|
|
|
|
|
|
if (pScreen->isGPU) {
|
|
|
|
master = pScreen->current_master;
|
|
|
|
if (!master)
|
|
|
|
return;
|
|
|
|
mastersp = rrGetScrPriv(master);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
master = pScreen;
|
|
|
|
mastersp = pScrPriv;
|
|
|
|
}
|
|
|
|
|
|
|
|
mastersp->changed = TRUE;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* Something changed; send events and adjust pointer position
|
|
|
|
*/
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
RRTellChanged(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
ScreenPtr master;
|
2012-06-10 07:21:05 -06:00
|
|
|
rrScrPriv(pScreen);
|
2013-06-07 11:28:45 -06:00
|
|
|
rrScrPrivPtr mastersp;
|
2007-11-24 10:55:21 -07:00
|
|
|
int i;
|
2013-12-28 07:40:01 -07:00
|
|
|
ScreenPtr iter;
|
|
|
|
rrScrPrivPtr pSlaveScrPriv;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
if (pScreen->isGPU) {
|
|
|
|
master = pScreen->current_master;
|
2019-07-27 01:57:06 -06:00
|
|
|
if (!master)
|
|
|
|
return;
|
2013-06-07 11:28:45 -06:00
|
|
|
mastersp = rrGetScrPriv(master);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
master = pScreen;
|
|
|
|
mastersp = pScrPriv;
|
|
|
|
}
|
|
|
|
|
2017-12-08 08:01:59 -07:00
|
|
|
xorg_list_for_each_entry(iter, &master->slave_list, slave_head) {
|
|
|
|
pSlaveScrPriv = rrGetScrPriv(iter);
|
|
|
|
|
|
|
|
if (!iter->is_output_slave)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (CompareTimeStamps(mastersp->lastSetTime,
|
|
|
|
pSlaveScrPriv->lastSetTime) == EARLIER) {
|
|
|
|
mastersp->lastSetTime = pSlaveScrPriv->lastSetTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-28 07:40:01 -07:00
|
|
|
if (mastersp->changed) {
|
2012-08-05 12:11:37 -06:00
|
|
|
UpdateCurrentTimeIf();
|
2013-06-07 11:28:45 -06:00
|
|
|
if (mastersp->configChanged) {
|
|
|
|
mastersp->lastConfigTime = currentTime;
|
|
|
|
mastersp->configChanged = FALSE;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
pScrPriv->changed = FALSE;
|
2013-06-07 11:28:45 -06:00
|
|
|
mastersp->changed = FALSE;
|
2013-12-28 07:40:01 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
WalkTree(master, TellChanged, (void *) master);
|
2013-12-28 07:40:01 -07:00
|
|
|
|
|
|
|
mastersp->resourcesChanged = FALSE;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < pScrPriv->numOutputs; i++)
|
|
|
|
pScrPriv->outputs[i]->changed = FALSE;
|
|
|
|
for (i = 0; i < pScrPriv->numCrtcs; i++)
|
|
|
|
pScrPriv->crtcs[i]->changed = FALSE;
|
2013-12-28 07:40:01 -07:00
|
|
|
|
2017-12-08 08:01:59 -07:00
|
|
|
xorg_list_for_each_entry(iter, &master->slave_list, slave_head) {
|
2013-12-28 07:40:01 -07:00
|
|
|
pSlaveScrPriv = rrGetScrPriv(iter);
|
|
|
|
pSlaveScrPriv->provider->changed = FALSE;
|
2017-12-08 08:01:59 -07:00
|
|
|
if (iter->is_output_slave) {
|
|
|
|
for (i = 0; i < pSlaveScrPriv->numOutputs; i++)
|
|
|
|
pSlaveScrPriv->outputs[i]->changed = FALSE;
|
|
|
|
for (i = 0; i < pSlaveScrPriv->numCrtcs; i++)
|
|
|
|
pSlaveScrPriv->crtcs[i]->changed = FALSE;
|
|
|
|
}
|
2013-12-28 07:40:01 -07:00
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
if (mastersp->layoutChanged) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pScrPriv->layoutChanged = FALSE;
|
2013-06-07 11:28:45 -06:00
|
|
|
RRPointerScreenConfigured(master);
|
|
|
|
RRSendConfigNotify(master);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* Return the first output which is connected to an active CRTC
|
|
|
|
* Used in emulating 1.0 behaviour
|
|
|
|
*/
|
|
|
|
RROutputPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
RRFirstOutput(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
rrScrPriv(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
RROutputPtr output;
|
|
|
|
int i, j;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
if (!pScrPriv)
|
|
|
|
return NULL;
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc)
|
2012-06-10 07:21:05 -06:00
|
|
|
return pScrPriv->primaryOutput;
|
|
|
|
|
|
|
|
for (i = 0; i < pScrPriv->numCrtcs; i++) {
|
|
|
|
RRCrtcPtr crtc = pScrPriv->crtcs[i];
|
|
|
|
|
|
|
|
for (j = 0; j < pScrPriv->numOutputs; j++) {
|
|
|
|
output = pScrPriv->outputs[j];
|
|
|
|
if (output->crtc == crtc)
|
|
|
|
return output;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
CARD16
|
2012-06-10 07:21:05 -06:00
|
|
|
RRVerticalRefresh(xRRModeInfo * mode)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
CARD32 refresh;
|
|
|
|
CARD32 dots = mode->hTotal * mode->vTotal;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
if (!dots)
|
2012-06-10 07:21:05 -06:00
|
|
|
return 0;
|
|
|
|
refresh = (mode->dotClock + dots / 2) / dots;
|
2007-11-24 10:55:21 -07:00
|
|
|
if (refresh > 0xffff)
|
2012-06-10 07:21:05 -06:00
|
|
|
refresh = 0xffff;
|
2007-11-24 10:55:21 -07:00
|
|
|
return (CARD16) refresh;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcRRDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data])
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2017-12-08 08:01:59 -07:00
|
|
|
UpdateCurrentTimeIf();
|
2007-11-24 10:55:21 -07:00
|
|
|
return (*ProcRandrVector[stuff->data]) (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int _X_COLD
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcRRDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2014-09-27 11:52:59 -06:00
|
|
|
if (stuff->data >= RRNumberRequests || !SProcRandrVector[stuff->data])
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2017-12-08 08:01:59 -07:00
|
|
|
UpdateCurrentTimeIf();
|
2007-11-24 10:55:21 -07:00
|
|
|
return (*SProcRandrVector[stuff->data]) (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|