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
= {
40 .sequenceNumber
= client
->sequence
,
43 REQUEST(xRRQueryVersionReq
);
46 REQUEST_SIZE_MATCH(xRRQueryVersionReq
);
47 pRRClient
->major_version
= stuff
->majorVersion
;
48 pRRClient
->minor_version
= stuff
->minorVersion
;
50 if (version_compare(stuff
->majorVersion
, stuff
->minorVersion
,
51 SERVER_RANDR_MAJOR_VERSION
,
52 SERVER_RANDR_MINOR_VERSION
) < 0) {
53 rep
.majorVersion
= stuff
->majorVersion
;
54 rep
.minorVersion
= stuff
->minorVersion
;
57 rep
.majorVersion
= SERVER_RANDR_MAJOR_VERSION
;
58 rep
.minorVersion
= SERVER_RANDR_MINOR_VERSION
;
61 if (client
->swapped
) {
62 swaps(&rep
.sequenceNumber
);
64 swapl(&rep
.majorVersion
);
65 swapl(&rep
.minorVersion
);
67 WriteToClient(client
, sizeof(xRRQueryVersionReply
), &rep
);
72 ProcRRSelectInput(ClientPtr client
)
74 REQUEST(xRRSelectInputReq
);
78 RREventPtr pRREvent
, *pHead
;
82 REQUEST_SIZE_MATCH(xRRSelectInputReq
);
83 rc
= dixLookupWindow(&pWin
, stuff
->window
, client
, DixReceiveAccess
);
86 rc
= dixLookupResourceByType((pointer
*) &pHead
, pWin
->drawable
.id
,
87 RREventType
, client
, DixWriteAccess
);
88 if (rc
!= Success
&& rc
!= BadValue
)
91 if (stuff
->enable
& (RRScreenChangeNotifyMask
|
92 RRCrtcChangeNotifyMask
|
93 RROutputChangeNotifyMask
|
94 RROutputPropertyNotifyMask
|
95 RRProviderPropertyNotifyMask
)) {
96 ScreenPtr pScreen
= pWin
->drawable
.pScreen
;
102 /* check for existing entry. */
103 for (pRREvent
= *pHead
; pRREvent
; pRREvent
= pRREvent
->next
)
104 if (pRREvent
->client
== client
)
109 /* build the entry */
110 pRREvent
= (RREventPtr
) malloc(sizeof(RREventRec
));
114 pRREvent
->client
= client
;
115 pRREvent
->window
= pWin
;
116 pRREvent
->mask
= stuff
->enable
;
118 * add a resource that will be deleted when
119 * the client goes away
121 clientResource
= FakeClientID(client
->index
);
122 pRREvent
->clientResource
= clientResource
;
123 if (!AddResource(clientResource
, RRClientType
, (pointer
) pRREvent
))
126 * create a resource to contain a pointer to the list
127 * of clients selecting input. This must be indirect as
128 * the list may be arbitrarily rearranged which cannot be
129 * done through the resource database.
132 pHead
= (RREventPtr
*) malloc(sizeof(RREventPtr
));
134 !AddResource(pWin
->drawable
.id
, RREventType
,
136 FreeResource(clientResource
, RT_NONE
);
141 pRREvent
->next
= *pHead
;
145 * Now see if the client needs an event
148 pTimes
= &((RRTimesPtr
) (pRRClient
+ 1))[pScreen
->myNum
];
149 if (CompareTimeStamps(pTimes
->setTime
,
150 pScrPriv
->lastSetTime
) != 0 ||
151 CompareTimeStamps(pTimes
->configTime
,
152 pScrPriv
->lastConfigTime
) != 0) {
153 if (pRREvent
->mask
& RRScreenChangeNotifyMask
) {
154 RRDeliverScreenEvent(client
, pWin
, pScreen
);
157 if (pRREvent
->mask
& RRCrtcChangeNotifyMask
) {
160 for (i
= 0; i
< pScrPriv
->numCrtcs
; i
++) {
161 RRDeliverCrtcEvent(client
, pWin
, pScrPriv
->crtcs
[i
]);
165 if (pRREvent
->mask
& RROutputChangeNotifyMask
) {
168 for (i
= 0; i
< pScrPriv
->numOutputs
; i
++) {
169 RRDeliverOutputEvent(client
, pWin
,
170 pScrPriv
->outputs
[i
]);
174 /* We don't check for RROutputPropertyNotifyMask, as randrproto.txt doesn't
175 * say if there ought to be notifications of changes to output properties
176 * if those changes occurred before the time RRSelectInput is called.
181 else if (stuff
->enable
== 0) {
182 /* delete the interest */
184 RREventPtr pNewRREvent
= 0;
186 for (pRREvent
= *pHead
; pRREvent
; pRREvent
= pRREvent
->next
) {
187 if (pRREvent
->client
== client
)
189 pNewRREvent
= pRREvent
;
192 FreeResource(pRREvent
->clientResource
, RRClientType
);
194 pNewRREvent
->next
= pRREvent
->next
;
196 *pHead
= pRREvent
->next
;
202 client
->errorValue
= stuff
->enable
;
208 int (*ProcRandrVector
[RRNumberRequests
]) (ClientPtr
) = {
209 ProcRRQueryVersion
, /* 0 */
210 /* we skip 1 to make old clients fail pretty immediately */
211 NULL
, /* 1 ProcRandrOldGetScreenInfo */
212 /* V1.0 apps share the same set screen config request id */
213 ProcRRSetScreenConfig
, /* 2 */
214 NULL
, /* 3 ProcRandrOldScreenChangeSelectInput */
215 /* 3 used to be ScreenChangeSelectInput; deprecated */
216 ProcRRSelectInput
, /* 4 */
217 ProcRRGetScreenInfo
, /* 5 */
219 ProcRRGetScreenSizeRange
, /* 6 */
220 ProcRRSetScreenSize
, /* 7 */
221 ProcRRGetScreenResources
, /* 8 */
222 ProcRRGetOutputInfo
, /* 9 */
223 ProcRRListOutputProperties
, /* 10 */
224 ProcRRQueryOutputProperty
, /* 11 */
225 ProcRRConfigureOutputProperty
, /* 12 */
226 ProcRRChangeOutputProperty
, /* 13 */
227 ProcRRDeleteOutputProperty
, /* 14 */
228 ProcRRGetOutputProperty
, /* 15 */
229 ProcRRCreateMode
, /* 16 */
230 ProcRRDestroyMode
, /* 17 */
231 ProcRRAddOutputMode
, /* 18 */
232 ProcRRDeleteOutputMode
, /* 19 */
233 ProcRRGetCrtcInfo
, /* 20 */
234 ProcRRSetCrtcConfig
, /* 21 */
235 ProcRRGetCrtcGammaSize
, /* 22 */
236 ProcRRGetCrtcGamma
, /* 23 */
237 ProcRRSetCrtcGamma
, /* 24 */
239 ProcRRGetScreenResourcesCurrent
, /* 25 */
240 ProcRRSetCrtcTransform
, /* 26 */
241 ProcRRGetCrtcTransform
, /* 27 */
242 ProcRRGetPanning
, /* 28 */
243 ProcRRSetPanning
, /* 29 */
244 ProcRRSetOutputPrimary
, /* 30 */
245 ProcRRGetOutputPrimary
, /* 31 */
247 ProcRRGetProviders
, /* 32 */
248 ProcRRGetProviderInfo
, /* 33 */
249 ProcRRSetProviderOffloadSink
, /* 34 */
250 ProcRRSetProviderOutputSource
, /* 35 */
251 ProcRRListProviderProperties
, /* 36 */
252 ProcRRQueryProviderProperty
, /* 37 */
253 ProcRRConfigureProviderProperty
, /* 38 */
254 ProcRRChangeProviderProperty
, /* 39 */
255 ProcRRDeleteProviderProperty
, /* 40 */
256 ProcRRGetProviderProperty
, /* 41 */