2 * Copyright © 2006 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 #include "protocol-versions.h"
27 RRClientKnowsRates(ClientPtr pClient
)
29 rrClientPriv(pClient
);
31 return version_compare(pRRClient
->major_version
, pRRClient
->minor_version
,
36 ProcRRQueryVersion(ClientPtr client
)
38 xRRQueryVersionReply rep
= { 0 };
39 REQUEST(xRRQueryVersionReq
);
42 REQUEST_SIZE_MATCH(xRRQueryVersionReq
);
43 pRRClient
->major_version
= stuff
->majorVersion
;
44 pRRClient
->minor_version
= stuff
->minorVersion
;
47 rep
.sequenceNumber
= client
->sequence
;
49 if (version_compare(stuff
->majorVersion
, stuff
->minorVersion
,
50 SERVER_RANDR_MAJOR_VERSION
,
51 SERVER_RANDR_MINOR_VERSION
) < 0) {
52 rep
.majorVersion
= stuff
->majorVersion
;
53 rep
.minorVersion
= stuff
->minorVersion
;
56 rep
.majorVersion
= SERVER_RANDR_MAJOR_VERSION
;
57 rep
.minorVersion
= SERVER_RANDR_MINOR_VERSION
;
60 if (client
->swapped
) {
61 swaps(&rep
.sequenceNumber
);
63 swapl(&rep
.majorVersion
);
64 swapl(&rep
.minorVersion
);
66 WriteToClient(client
, sizeof(xRRQueryVersionReply
), (char *) &rep
);
71 ProcRRSelectInput(ClientPtr client
)
73 REQUEST(xRRSelectInputReq
);
77 RREventPtr pRREvent
, *pHead
;
81 REQUEST_SIZE_MATCH(xRRSelectInputReq
);
82 rc
= dixLookupWindow(&pWin
, stuff
->window
, client
, DixReceiveAccess
);
85 rc
= dixLookupResourceByType((pointer
*) &pHead
, pWin
->drawable
.id
,
86 RREventType
, client
, DixWriteAccess
);
87 if (rc
!= Success
&& rc
!= BadValue
)
90 if (stuff
->enable
& (RRScreenChangeNotifyMask
|
91 RRCrtcChangeNotifyMask
|
92 RROutputChangeNotifyMask
|
93 RROutputPropertyNotifyMask
)) {
94 ScreenPtr pScreen
= pWin
->drawable
.pScreen
;
100 /* check for existing entry. */
101 for (pRREvent
= *pHead
; pRREvent
; pRREvent
= pRREvent
->next
)
102 if (pRREvent
->client
== client
)
107 /* build the entry */
108 pRREvent
= (RREventPtr
) malloc(sizeof(RREventRec
));
112 pRREvent
->client
= client
;
113 pRREvent
->window
= pWin
;
114 pRREvent
->mask
= stuff
->enable
;
116 * add a resource that will be deleted when
117 * the client goes away
119 clientResource
= FakeClientID(client
->index
);
120 pRREvent
->clientResource
= clientResource
;
121 if (!AddResource(clientResource
, RRClientType
, (pointer
) pRREvent
))
124 * create a resource to contain a pointer to the list
125 * of clients selecting input. This must be indirect as
126 * the list may be arbitrarily rearranged which cannot be
127 * done through the resource database.
130 pHead
= (RREventPtr
*) malloc(sizeof(RREventPtr
));
132 !AddResource(pWin
->drawable
.id
, RREventType
,
134 FreeResource(clientResource
, RT_NONE
);
139 pRREvent
->next
= *pHead
;
143 * Now see if the client needs an event
146 pTimes
= &((RRTimesPtr
) (pRRClient
+ 1))[pScreen
->myNum
];
147 if (CompareTimeStamps(pTimes
->setTime
,
148 pScrPriv
->lastSetTime
) != 0 ||
149 CompareTimeStamps(pTimes
->configTime
,
150 pScrPriv
->lastConfigTime
) != 0) {
151 if (pRREvent
->mask
& RRScreenChangeNotifyMask
) {
152 RRDeliverScreenEvent(client
, pWin
, pScreen
);
155 if (pRREvent
->mask
& RRCrtcChangeNotifyMask
) {
158 for (i
= 0; i
< pScrPriv
->numCrtcs
; i
++) {
159 RRDeliverCrtcEvent(client
, pWin
, pScrPriv
->crtcs
[i
]);
163 if (pRREvent
->mask
& RROutputChangeNotifyMask
) {
166 for (i
= 0; i
< pScrPriv
->numOutputs
; i
++) {
167 RRDeliverOutputEvent(client
, pWin
,
168 pScrPriv
->outputs
[i
]);
172 /* We don't check for RROutputPropertyNotifyMask, as randrproto.txt doesn't
173 * say if there ought to be notifications of changes to output properties
174 * if those changes occurred before the time RRSelectInput is called.
179 else if (stuff
->enable
== 0) {
180 /* delete the interest */
182 RREventPtr pNewRREvent
= 0;
184 for (pRREvent
= *pHead
; pRREvent
; pRREvent
= pRREvent
->next
) {
185 if (pRREvent
->client
== client
)
187 pNewRREvent
= pRREvent
;
190 FreeResource(pRREvent
->clientResource
, RRClientType
);
192 pNewRREvent
->next
= pRREvent
->next
;
194 *pHead
= pRREvent
->next
;
200 client
->errorValue
= stuff
->enable
;
206 int (*ProcRandrVector
[RRNumberRequests
]) (ClientPtr
) = {
207 ProcRRQueryVersion
, /* 0 */
208 /* we skip 1 to make old clients fail pretty immediately */
209 NULL
, /* 1 ProcRandrOldGetScreenInfo */
210 /* V1.0 apps share the same set screen config request id */
211 ProcRRSetScreenConfig
, /* 2 */
212 NULL
, /* 3 ProcRandrOldScreenChangeSelectInput */
213 /* 3 used to be ScreenChangeSelectInput; deprecated */
214 ProcRRSelectInput
, /* 4 */
215 ProcRRGetScreenInfo
, /* 5 */
217 ProcRRGetScreenSizeRange
, /* 6 */
218 ProcRRSetScreenSize
, /* 7 */
219 ProcRRGetScreenResources
, /* 8 */
220 ProcRRGetOutputInfo
, /* 9 */
221 ProcRRListOutputProperties
, /* 10 */
222 ProcRRQueryOutputProperty
, /* 11 */
223 ProcRRConfigureOutputProperty
, /* 12 */
224 ProcRRChangeOutputProperty
, /* 13 */
225 ProcRRDeleteOutputProperty
, /* 14 */
226 ProcRRGetOutputProperty
, /* 15 */
227 ProcRRCreateMode
, /* 16 */
228 ProcRRDestroyMode
, /* 17 */
229 ProcRRAddOutputMode
, /* 18 */
230 ProcRRDeleteOutputMode
, /* 19 */
231 ProcRRGetCrtcInfo
, /* 20 */
232 ProcRRSetCrtcConfig
, /* 21 */
233 ProcRRGetCrtcGammaSize
, /* 22 */
234 ProcRRGetCrtcGamma
, /* 23 */
235 ProcRRSetCrtcGamma
, /* 24 */
237 ProcRRGetScreenResourcesCurrent
, /* 25 */
238 ProcRRSetCrtcTransform
, /* 26 */
239 ProcRRGetCrtcTransform
, /* 27 */
240 ProcRRGetPanning
, /* 28 */
241 ProcRRSetPanning
, /* 29 */
242 ProcRRSetOutputPrimary
, /* 30 */
243 ProcRRGetOutputPrimary
, /* 31 */