File: | Xrandr.c |
Location: | line 329, column 18 |
Description: | The left operand of '!=' is a garbage value |
1 | /* | |||
2 | * Copyright © 2000 Compaq Computer Corporation, Inc. | |||
3 | * Copyright © 2002 Hewlett Packard Company, Inc. | |||
4 | * | |||
5 | * Permission to use, copy, modify, distribute, and sell this software and its | |||
6 | * documentation for any purpose is hereby granted without fee, provided that | |||
7 | * the above copyright notice appear in all copies and that both that | |||
8 | * copyright notice and this permission notice appear in supporting | |||
9 | * documentation, and that the name of Compaq or HP not be used in advertising | |||
10 | * or publicity pertaining to distribution of the software without specific, | |||
11 | * written prior permission. HP makes no representations about the | |||
12 | * suitability of this software for any purpose. It is provided "as is" | |||
13 | * without express or implied warranty. | |||
14 | * | |||
15 | * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL | |||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL COMPAQ | |||
17 | * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |||
18 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | |||
19 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
21 | * | |||
22 | * Author: Jim Gettys, HP Labs, HP. | |||
23 | */ | |||
24 | ||||
25 | #ifdef HAVE_CONFIG_H1 | |||
26 | #include <config.h> | |||
27 | #endif | |||
28 | ||||
29 | #include <stdio.h> | |||
30 | #include <X11/Xlib.h> | |||
31 | /* we need to be able to manipulate the Display structure on events */ | |||
32 | #include <X11/Xlibint.h> | |||
33 | #include <X11/extensions/render.h> | |||
34 | #include <X11/extensions/Xrender.h> | |||
35 | #include "Xrandrint.h" | |||
36 | ||||
37 | static XExtensionInfo XRRExtensionInfo; | |||
38 | _X_HIDDEN__attribute__((visibility("hidden"))) char XRRExtensionName[] = RANDR_NAME"RANDR"; | |||
39 | ||||
40 | static Boolint XRRWireToEvent(Display *dpy, XEvent *event, xEvent *wire); | |||
41 | static Statusint XRREventToWire(Display *dpy, XEvent *event, xEvent *wire); | |||
42 | ||||
43 | static int | |||
44 | XRRCloseDisplay (Display *dpy, XExtCodes *codes); | |||
45 | ||||
46 | static /* const */ XExtensionHooks rr_extension_hooks = { | |||
47 | NULL((void*)0), /* create_gc */ | |||
48 | NULL((void*)0), /* copy_gc */ | |||
49 | NULL((void*)0), /* flush_gc */ | |||
50 | NULL((void*)0), /* free_gc */ | |||
51 | NULL((void*)0), /* create_font */ | |||
52 | NULL((void*)0), /* free_font */ | |||
53 | XRRCloseDisplay, /* close_display */ | |||
54 | XRRWireToEvent, /* wire_to_event */ | |||
55 | XRREventToWire, /* event_to_wire */ | |||
56 | NULL((void*)0), /* error */ | |||
57 | NULL((void*)0), /* error_string */ | |||
58 | }; | |||
59 | ||||
60 | static Boolint XRRWireToEvent(Display *dpy, XEvent *event, xEvent *wire) | |||
61 | { | |||
62 | XExtDisplayInfo *info = XRRFindDisplay(dpy); | |||
63 | ||||
64 | RRCheckExtension(dpy, info, False)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, XRRExtensionName); return 0; }; | |||
65 | ||||
66 | switch ((wire->u.u.type & 0x7F) - info->codes->first_event) | |||
67 | { | |||
68 | case RRScreenChangeNotify0: { | |||
69 | XRRScreenChangeNotifyEvent *aevent= (XRRScreenChangeNotifyEvent *) event; | |||
70 | xRRScreenChangeNotifyEvent *awire = (xRRScreenChangeNotifyEvent *) wire; | |||
71 | aevent->type = awire->type & 0x7F; | |||
72 | aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); | |||
73 | aevent->send_event = (awire->type & 0x80) != 0; | |||
74 | aevent->display = dpy; | |||
75 | aevent->window = awire->window; | |||
76 | aevent->root = awire->root; | |||
77 | aevent->timestamp = awire->timestamp; | |||
78 | aevent->config_timestamp = awire->configTimestamp; | |||
79 | aevent->size_index = awire->sizeID; | |||
80 | aevent->subpixel_order = awire->subpixelOrder; | |||
81 | aevent->rotation = awire->rotation; | |||
82 | aevent->width = awire->widthInPixels; | |||
83 | aevent->height = awire->heightInPixels; | |||
84 | aevent->mwidth = awire->widthInMillimeters; | |||
85 | aevent->mheight = awire->heightInMillimeters; | |||
86 | return True1; | |||
87 | } | |||
88 | case RRNotify1: { | |||
89 | switch (wire->u.u.detail) { | |||
90 | case RRNotify_OutputChange1: { | |||
91 | XRROutputChangeNotifyEvent *aevent = (XRROutputChangeNotifyEvent *) event; | |||
92 | xRROutputChangeNotifyEvent *awire = (xRROutputChangeNotifyEvent *) wire; | |||
93 | aevent->type = awire->type & 0x7F; | |||
94 | aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); | |||
95 | aevent->send_event = (awire->type & 0x80) != 0; | |||
96 | aevent->display = dpy; | |||
97 | aevent->window = awire->window; | |||
98 | aevent->subtype = awire->subCode; | |||
99 | aevent->output = awire->output; | |||
100 | aevent->crtc = awire->crtc; | |||
101 | aevent->mode = awire->mode; | |||
102 | aevent->rotation = awire->rotation; | |||
103 | aevent->connection = awire->connection; | |||
104 | aevent->subpixel_order = awire->subpixelOrder; | |||
105 | return True1; | |||
106 | } | |||
107 | case RRNotify_CrtcChange0: { | |||
108 | XRRCrtcChangeNotifyEvent *aevent = (XRRCrtcChangeNotifyEvent *) event; | |||
109 | xRRCrtcChangeNotifyEvent *awire = (xRRCrtcChangeNotifyEvent *) wire; | |||
110 | aevent->type = awire->type & 0x7F; | |||
111 | aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); | |||
112 | aevent->send_event = (awire->type & 0x80) != 0; | |||
113 | aevent->display = dpy; | |||
114 | aevent->window = awire->window; | |||
115 | aevent->subtype = awire->subCode; | |||
116 | aevent->crtc = awire->crtc; | |||
117 | aevent->mode = awire->mode; | |||
118 | aevent->rotation = awire->rotation; | |||
119 | aevent->x = awire->x; | |||
120 | aevent->y = awire->y; | |||
121 | aevent->width = awire->width; | |||
122 | aevent->height = awire->height; | |||
123 | return True1; | |||
124 | } | |||
125 | case RRNotify_OutputProperty2: { | |||
126 | XRROutputPropertyNotifyEvent *aevent = (XRROutputPropertyNotifyEvent *) event; | |||
127 | xRROutputPropertyNotifyEvent *awire = (xRROutputPropertyNotifyEvent *) wire; | |||
128 | aevent->type = awire->type & 0x7F; | |||
129 | aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); | |||
130 | aevent->send_event = (awire->type & 0x80) != 0; | |||
131 | aevent->display = dpy; | |||
132 | aevent->window = awire->window; | |||
133 | aevent->subtype = awire->subCode; | |||
134 | aevent->output = awire->output; | |||
135 | aevent->property = awire->atom; | |||
136 | aevent->timestamp = awire->timestamp; | |||
137 | aevent->state = awire->state; | |||
138 | return True1; | |||
139 | } | |||
140 | case RRNotify_ProviderChange3: { | |||
141 | XRRProviderChangeNotifyEvent *aevent = (XRRProviderChangeNotifyEvent *) event; | |||
142 | xRRProviderChangeNotifyEvent *awire = (xRRProviderChangeNotifyEvent *) wire; | |||
143 | aevent->type = awire->type & 0x7F; | |||
144 | aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); | |||
145 | aevent->send_event = (awire->type & 0x80) != 0; | |||
146 | aevent->display = dpy; | |||
147 | aevent->window = awire->window; | |||
148 | aevent->subtype = awire->subCode; | |||
149 | aevent->provider = awire->provider; | |||
150 | aevent->timestamp = awire->timestamp; | |||
151 | return True1; | |||
152 | } | |||
153 | case RRNotify_ProviderProperty4: { | |||
154 | XRRProviderPropertyNotifyEvent *aevent = (XRRProviderPropertyNotifyEvent *) event; | |||
155 | xRRProviderPropertyNotifyEvent *awire = (xRRProviderPropertyNotifyEvent *) wire; | |||
156 | aevent->type = awire->type & 0x7F; | |||
157 | aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); | |||
158 | aevent->send_event = (awire->type & 0x80) != 0; | |||
159 | aevent->display = dpy; | |||
160 | aevent->window = awire->window; | |||
161 | aevent->subtype = awire->subCode; | |||
162 | aevent->provider = awire->provider; | |||
163 | aevent->property = awire->atom; | |||
164 | aevent->timestamp = awire->timestamp; | |||
165 | aevent->state = awire->state; | |||
166 | return True1; | |||
167 | } | |||
168 | case RRNotify_ResourceChange5: { | |||
169 | XRRResourceChangeNotifyEvent *aevent = (XRRResourceChangeNotifyEvent *) event; | |||
170 | xRRResourceChangeNotifyEvent *awire = (xRRResourceChangeNotifyEvent *) wire; | |||
171 | aevent->type = awire->type & 0x7F; | |||
172 | aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); | |||
173 | aevent->send_event = (awire->type & 0x80) != 0; | |||
174 | aevent->display = dpy; | |||
175 | aevent->window = awire->window; | |||
176 | aevent->subtype = awire->subCode; | |||
177 | aevent->timestamp = awire->timestamp; | |||
178 | return True1; | |||
179 | } | |||
180 | break; | |||
181 | } | |||
182 | } | |||
183 | } | |||
184 | ||||
185 | return False0; | |||
186 | } | |||
187 | ||||
188 | static Statusint XRREventToWire(Display *dpy, XEvent *event, xEvent *wire) | |||
189 | { | |||
190 | XExtDisplayInfo *info = XRRFindDisplay(dpy); | |||
191 | ||||
192 | RRCheckExtension(dpy, info, False)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, XRRExtensionName); return 0; }; | |||
193 | ||||
194 | switch ((event->type & 0x7F) - info->codes->first_event) | |||
195 | { | |||
196 | case RRScreenChangeNotify0: { | |||
197 | xRRScreenChangeNotifyEvent *awire = (xRRScreenChangeNotifyEvent *) wire; | |||
198 | XRRScreenChangeNotifyEvent *aevent = (XRRScreenChangeNotifyEvent *) event; | |||
199 | awire->type = aevent->type | (aevent->send_event ? 0x80 : 0); | |||
200 | awire->rotation = (CARD8) aevent->rotation; | |||
201 | awire->sequenceNumber = aevent->serial & 0xFFFF; | |||
202 | awire->timestamp = aevent->timestamp; | |||
203 | awire->configTimestamp = aevent->config_timestamp; | |||
204 | awire->root = aevent->root; | |||
205 | awire->window = aevent->window; | |||
206 | awire->sizeID = aevent->size_index; | |||
207 | awire->subpixelOrder = aevent->subpixel_order; | |||
208 | awire->widthInPixels = aevent->width; | |||
209 | awire->heightInPixels = aevent->height; | |||
210 | awire->widthInMillimeters = aevent->mwidth; | |||
211 | awire->heightInMillimeters = aevent->mheight; | |||
212 | return True1; | |||
213 | } | |||
214 | case RRNotify1: { | |||
215 | xRRCrtcChangeNotifyEvent *awire = (xRRCrtcChangeNotifyEvent *) wire; | |||
216 | XRRNotifyEvent *aevent = (XRRNotifyEvent *) event; | |||
217 | awire->type = aevent->type | (aevent->send_event ? 0x80 : 0); | |||
218 | awire->sequenceNumber = aevent->serial & 0xFFFF; | |||
219 | awire->subCode = aevent->subtype; | |||
220 | switch (aevent->subtype) { | |||
221 | case RRNotify_OutputChange1: { | |||
222 | xRROutputChangeNotifyEvent *sawire = (xRROutputChangeNotifyEvent *) wire; | |||
223 | XRROutputChangeNotifyEvent *saevent = (XRROutputChangeNotifyEvent *) event; | |||
224 | sawire->window = saevent->window; | |||
225 | sawire->output = saevent->output; | |||
226 | sawire->crtc = saevent->crtc; | |||
227 | sawire->mode = saevent->mode; | |||
228 | sawire->rotation = saevent->rotation; | |||
229 | sawire->connection = saevent->connection; | |||
230 | sawire->subpixelOrder = saevent->subpixel_order; | |||
231 | return True1; | |||
232 | } | |||
233 | case RRNotify_CrtcChange0: { | |||
234 | xRRCrtcChangeNotifyEvent *sawire = (xRRCrtcChangeNotifyEvent *) wire; | |||
235 | XRRCrtcChangeNotifyEvent *saevent = (XRRCrtcChangeNotifyEvent *) event; | |||
236 | sawire->window = saevent->window; | |||
237 | sawire->crtc = saevent->crtc; | |||
238 | sawire->mode = saevent->mode; | |||
239 | sawire->rotation = saevent->rotation; | |||
240 | sawire->x = saevent->x; | |||
241 | sawire->y = saevent->y; | |||
242 | sawire->width = saevent->width; | |||
243 | sawire->height = saevent->height; | |||
244 | return True1; | |||
245 | } | |||
246 | case RRNotify_OutputProperty2: { | |||
247 | xRROutputPropertyNotifyEvent *sawire = (xRROutputPropertyNotifyEvent *) wire; | |||
248 | XRROutputPropertyNotifyEvent *saevent = (XRROutputPropertyNotifyEvent *) event; | |||
249 | sawire->window = saevent->window; | |||
250 | sawire->output = saevent->output; | |||
251 | sawire->atom = saevent->property; | |||
252 | sawire->timestamp = saevent->timestamp; | |||
253 | sawire->state = saevent->state; | |||
254 | return True1; | |||
255 | } | |||
256 | case RRNotify_ProviderChange3: { | |||
257 | xRRProviderChangeNotifyEvent *sawire = (xRRProviderChangeNotifyEvent *) wire; | |||
258 | XRRProviderChangeNotifyEvent *saevent = (XRRProviderChangeNotifyEvent *) event; | |||
259 | sawire->window = saevent->window; | |||
260 | sawire->provider = saevent->provider; | |||
261 | return True1; | |||
262 | } | |||
263 | case RRNotify_ProviderProperty4: { | |||
264 | xRRProviderPropertyNotifyEvent *sawire = (xRRProviderPropertyNotifyEvent *) wire; | |||
265 | XRRProviderPropertyNotifyEvent *saevent = (XRRProviderPropertyNotifyEvent *) event; | |||
266 | sawire->window = saevent->window; | |||
267 | sawire->provider = saevent->provider; | |||
268 | sawire->atom = saevent->property; | |||
269 | sawire->timestamp = saevent->timestamp; | |||
270 | sawire->state = saevent->state; | |||
271 | return True1; | |||
272 | } | |||
273 | case RRNotify_ResourceChange5: { | |||
274 | xRRResourceChangeNotifyEvent *sawire = (xRRResourceChangeNotifyEvent *) wire; | |||
275 | XRRResourceChangeNotifyEvent *saevent = (XRRResourceChangeNotifyEvent *) event; | |||
276 | sawire->window = saevent->window; | |||
277 | sawire->timestamp = saevent->timestamp; | |||
278 | return True1; | |||
279 | } | |||
280 | } | |||
281 | } | |||
282 | } | |||
283 | return False0; | |||
284 | } | |||
285 | ||||
286 | _X_HIDDEN__attribute__((visibility("hidden"))) XExtDisplayInfo * | |||
287 | XRRFindDisplay (Display *dpy) | |||
288 | { | |||
289 | XExtDisplayInfo *dpyinfo; | |||
290 | XRandRInfo *xrri; | |||
291 | int i, numscreens; | |||
292 | ||||
293 | dpyinfo = XextFindDisplay (&XRRExtensionInfo, dpy); | |||
294 | if (!dpyinfo) { | |||
295 | dpyinfo = XextAddDisplay (&XRRExtensionInfo, dpy, | |||
296 | XRRExtensionName, | |||
297 | &rr_extension_hooks, | |||
298 | RRNumberEvents2, NULL((void*)0)); | |||
299 | numscreens = ScreenCount(dpy)(((_XPrivDisplay)(dpy))->nscreens); | |||
300 | xrri = Xmalloc (sizeof(XRandRInfo) +malloc(((sizeof(XRandRInfo) + sizeof(char *) * numscreens) == 0 ? 1 : (sizeof(XRandRInfo) + sizeof(char *) * numscreens))) | |||
301 | sizeof(char *) * numscreens)malloc(((sizeof(XRandRInfo) + sizeof(char *) * numscreens) == 0 ? 1 : (sizeof(XRandRInfo) + sizeof(char *) * numscreens))); | |||
302 | xrri->config = (XRRScreenConfiguration **)(xrri + 1); | |||
303 | for(i = 0; i < numscreens; i++) | |||
304 | xrri->config[i] = NULL((void*)0); | |||
305 | xrri->major_version = -1; | |||
306 | dpyinfo->data = (char *) xrri; | |||
307 | } | |||
308 | return dpyinfo; | |||
309 | } | |||
310 | ||||
311 | static int | |||
312 | XRRCloseDisplay (Display *dpy, XExtCodes *codes) | |||
313 | { | |||
314 | int i; | |||
315 | XRRScreenConfiguration **configs; | |||
316 | XExtDisplayInfo *info = XRRFindDisplay (dpy); | |||
317 | XRandRInfo *xrri; | |||
318 | ||||
319 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); | |||
320 | /* | |||
321 | * free cached data | |||
322 | */ | |||
323 | if (XextHasExtension(info)((info) && ((info)->codes))) { | |||
| ||||
324 | xrri = (XRandRInfo *) info->data; | |||
325 | if (xrri) { | |||
326 | configs = xrri->config; | |||
327 | ||||
328 | for (i = 0; i < ScreenCount(dpy)(((_XPrivDisplay)(dpy))->nscreens); i++) { | |||
329 | if (configs[i] != NULL((void*)0)) XFree (configs[i]); | |||
| ||||
330 | } | |||
331 | XFree (xrri); | |||
332 | } | |||
333 | } | |||
334 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); | |||
335 | return XextRemoveDisplay (&XRRExtensionInfo, dpy); | |||
336 | } | |||
337 | ||||
338 | int XRRRootToScreen(Display *dpy, Window root) | |||
339 | { | |||
340 | int snum; | |||
341 | for (snum = 0; snum < ScreenCount(dpy)(((_XPrivDisplay)(dpy))->nscreens); snum++) { | |||
342 | if (RootWindow(dpy, snum)((&((_XPrivDisplay)(dpy))->screens[snum])->root) == root) return snum; | |||
343 | } | |||
344 | return -1; | |||
345 | } | |||
346 | ||||
347 | ||||
348 | Boolint XRRQueryExtension (Display *dpy, | |||
349 | int *event_base_return, | |||
350 | int *error_base_return) | |||
351 | { | |||
352 | XExtDisplayInfo *info = XRRFindDisplay (dpy); | |||
353 | ||||
354 | if (XextHasExtension(info)((info) && ((info)->codes))) { | |||
355 | *event_base_return = info->codes->first_event; | |||
356 | *error_base_return = info->codes->first_error; | |||
357 | return True1; | |||
358 | } else { | |||
359 | return False0; | |||
360 | } | |||
361 | } | |||
362 | ||||
363 | _X_HIDDEN__attribute__((visibility("hidden"))) Boolint | |||
364 | _XRRHasRates (int major, int minor) | |||
365 | { | |||
366 | return major > 1 || (major == 1 && minor >= 1); | |||
367 | } | |||
368 | ||||
369 | Statusint XRRQueryVersion (Display *dpy, | |||
370 | int *major_versionp, | |||
371 | int *minor_versionp) | |||
372 | { | |||
373 | XExtDisplayInfo *info = XRRFindDisplay (dpy); | |||
374 | xRRQueryVersionReply rep; | |||
375 | xRRQueryVersionReq *req; | |||
376 | XRandRInfo *xrri; | |||
377 | ||||
378 | RRCheckExtension (dpy, info, 0)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, XRRExtensionName); return 0; }; | |||
379 | ||||
380 | xrri = (XRandRInfo *) info->data; | |||
381 | ||||
382 | /* | |||
383 | * only get the version information from the server if we don't have it already | |||
384 | */ | |||
385 | if (xrri->major_version == -1) { | |||
386 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); | |||
387 | GetReq (RRQueryVersion, req)req = (xRRQueryVersionReq *) _XGetRequest(dpy, 0, 12); | |||
388 | req->reqType = info->codes->major_opcode; | |||
389 | req->randrReqType = X_RRQueryVersion0; | |||
390 | req->majorVersion = RANDR_MAJOR1; | |||
391 | req->minorVersion = RANDR_MINOR5; | |||
392 | if (!_XReply (dpy, (xReply *) &rep, 0, xTrue1)) { | |||
393 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); | |||
394 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); | |||
395 | return 0; | |||
396 | } | |||
397 | xrri->major_version = rep.majorVersion; | |||
398 | xrri->minor_version = rep.minorVersion; | |||
399 | xrri->has_rates = _XRRHasRates (xrri->major_version, xrri->minor_version); | |||
400 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); | |||
401 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); | |||
402 | } | |||
403 | *major_versionp = xrri->major_version; | |||
404 | *minor_versionp = xrri->minor_version; | |||
405 | return 1; | |||
406 | } | |||
407 | ||||
408 | _X_HIDDEN__attribute__((visibility("hidden"))) Boolint | |||
409 | _XRRVersionHandler (Display *dpy, | |||
410 | xReply *rep, | |||
411 | char *buf, | |||
412 | int len, | |||
413 | XPointer data) | |||
414 | { | |||
415 | xRRQueryVersionReply replbuf; | |||
416 | xRRQueryVersionReply *repl; | |||
417 | _XRRVersionState *state = (_XRRVersionState *) data; | |||
418 | ||||
419 | if (dpy->last_request_read != state->version_seq) | |||
420 | return False0; | |||
421 | if (rep->generic.type == X_Error0) | |||
422 | { | |||
423 | state->error = True1; | |||
424 | return False0; | |||
425 | } | |||
426 | repl = (xRRQueryVersionReply *) | |||
427 | _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len, | |||
428 | (SIZEOF(xRRQueryVersionReply)32 - SIZEOF(xReply)32) >> 2, | |||
429 | True1); | |||
430 | state->major_version = repl->majorVersion; | |||
431 | state->minor_version = repl->minorVersion; | |||
432 | return True1; | |||
433 | } | |||
434 | ||||
435 | /* | |||
436 | * in protocol version 0.1, routine added to allow selecting for new events. | |||
437 | */ | |||
438 | ||||
439 | void XRRSelectInput (Display *dpy, Window window, int mask) | |||
440 | { | |||
441 | XExtDisplayInfo *info = XRRFindDisplay (dpy); | |||
442 | xRRSelectInputReq *req; | |||
443 | ||||
444 | RRSimpleCheckExtension (dpy, info)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, XRRExtensionName); return; }; | |||
445 | ||||
446 | LockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); | |||
447 | GetReq (RRSelectInput, req)req = (xRRSelectInputReq *) _XGetRequest(dpy, 4, 12); | |||
448 | req->reqType = info->codes->major_opcode; | |||
449 | req->randrReqType = X_RRSelectInput4; | |||
450 | req->window = window; | |||
451 | req->enable = 0; | |||
452 | if (mask) req->enable = mask; | |||
453 | UnlockDisplay (dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); | |||
454 | SyncHandle ()if (dpy->synchandler) (*dpy->synchandler)(dpy); | |||
455 | return; | |||
456 | } | |||
457 | ||||
458 | int XRRUpdateConfiguration(XEvent *event) | |||
459 | { | |||
460 | XRRScreenChangeNotifyEvent *scevent; | |||
461 | XConfigureEvent *rcevent; | |||
462 | Display *dpy = event->xany.display; | |||
463 | XExtDisplayInfo *info; | |||
464 | XRandRInfo *xrri; | |||
465 | int snum; | |||
466 | ||||
467 | /* first, see if it is a vanilla configure notify event */ | |||
468 | if (event->type == ConfigureNotify22) { | |||
469 | rcevent = (XConfigureEvent *) event; | |||
470 | snum = XRRRootToScreen(dpy, rcevent->window); | |||
471 | if (snum != -1) { | |||
472 | dpy->screens[snum].width = rcevent->width; | |||
473 | dpy->screens[snum].height = rcevent->height; | |||
474 | return 1; | |||
475 | } | |||
476 | } | |||
477 | ||||
478 | info = XRRFindDisplay(dpy); | |||
479 | RRCheckExtension (dpy, info, 0)if (!((info) && ((info)->codes))) { XMissingExtension (dpy, XRRExtensionName); return 0; }; | |||
480 | ||||
481 | switch (event->type - info->codes->first_event) { | |||
482 | case RRScreenChangeNotify0: | |||
483 | scevent = (XRRScreenChangeNotifyEvent *) event; | |||
484 | snum = XRRRootToScreen(dpy, | |||
485 | ((XRRScreenChangeNotifyEvent *) event)->root); | |||
486 | if (snum < 0) | |||
487 | return 0; | |||
488 | ||||
489 | if (scevent->rotation & (RR_Rotate_902 | RR_Rotate_2708)) { | |||
490 | dpy->screens[snum].width = scevent->height; | |||
491 | dpy->screens[snum].height = scevent->width; | |||
492 | dpy->screens[snum].mwidth = scevent->mheight; | |||
493 | dpy->screens[snum].mheight = scevent->mwidth; | |||
494 | } else { | |||
495 | dpy->screens[snum].width = scevent->width; | |||
496 | dpy->screens[snum].height = scevent->height; | |||
497 | dpy->screens[snum].mwidth = scevent->mwidth; | |||
498 | dpy->screens[snum].mheight = scevent->mheight; | |||
499 | } | |||
500 | XRenderSetSubpixelOrder (dpy, snum, scevent->subpixel_order); | |||
501 | break; | |||
502 | default: | |||
503 | return 0; | |||
504 | } | |||
505 | xrri = (XRandRInfo *) info->data; | |||
506 | /* | |||
507 | * so the next time someone wants some data, it will be fetched; | |||
508 | * it might be better to force the round trip immediately, but | |||
509 | * I dislike pounding the server simultaneously when not necessary | |||
510 | */ | |||
511 | if (xrri->config[snum] != NULL((void*)0)) { | |||
512 | XFree (xrri->config[snum]); | |||
513 | xrri->config[snum] = NULL((void*)0); | |||
514 | } | |||
515 | return 1; | |||
516 | } |