File: | Xext/panoramiXprocs.c |
Location: | line 1992, column 18 |
Description: | Call to 'malloc' has an allocation size of 0 bytes |
1 | /***************************************************************** | |||
2 | Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. | |||
3 | Permission is hereby granted, free of charge, to any person obtaining a copy | |||
4 | of this software and associated documentation files (the "Software"), to deal | |||
5 | in the Software without restriction, including without limitation the rights | |||
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
7 | copies of the Software. | |||
8 | ||||
9 | The above copyright notice and this permission notice shall be included in | |||
10 | all copies or substantial portions of the Software. | |||
11 | ||||
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |||
15 | DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, | |||
16 | BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, | |||
17 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR | |||
18 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
19 | ||||
20 | Except as contained in this notice, the name of Digital Equipment Corporation | |||
21 | shall not be used in advertising or otherwise to promote the sale, use or other | |||
22 | dealings in this Software without prior written authorization from Digital | |||
23 | Equipment Corporation. | |||
24 | ******************************************************************/ | |||
25 | ||||
26 | /* Massively rewritten by Mark Vojkovich <markv@valinux.com> */ | |||
27 | ||||
28 | #ifdef HAVE_DIX_CONFIG_H1 | |||
29 | #include <dix-config.h> | |||
30 | #endif | |||
31 | ||||
32 | #include <stdio.h> | |||
33 | #include <X11/X.h> | |||
34 | #include <X11/Xproto.h> | |||
35 | #include "windowstr.h" | |||
36 | #include "dixfontstr.h" | |||
37 | #include "gcstruct.h" | |||
38 | #include "colormapst.h" | |||
39 | #include "scrnintstr.h" | |||
40 | #include "opaque.h" | |||
41 | #include "inputstr.h" | |||
42 | #include "migc.h" | |||
43 | #include "misc.h" | |||
44 | #include "dixstruct.h" | |||
45 | #include "panoramiX.h" | |||
46 | #include "panoramiXsrv.h" | |||
47 | #include "resource.h" | |||
48 | #include "panoramiXh.h" | |||
49 | ||||
50 | #define XINERAMA_IMAGE_BUFSIZE(256*1024) (256*1024) | |||
51 | #define INPUTONLY_LEGAL_MASK((1L<<5) | (1L<<11) | (1L<<12) | (1L<< 9) | (1L<<14) ) (CWWinGravity(1L<<5) | CWEventMask(1L<<11) | \ | |||
52 | CWDontPropagate(1L<<12) | CWOverrideRedirect(1L<<9) | CWCursor(1L<<14) ) | |||
53 | ||||
54 | int | |||
55 | PanoramiXCreateWindow(ClientPtr client) | |||
56 | { | |||
57 | PanoramiXRes *parent, *newWin; | |||
58 | PanoramiXRes *backPix = NULL((void*)0); | |||
59 | PanoramiXRes *bordPix = NULL((void*)0); | |||
60 | PanoramiXRes *cmap = NULL((void*)0); | |||
61 | ||||
62 | REQUEST(xCreateWindowReq)xCreateWindowReq *stuff = (xCreateWindowReq *)client->requestBuffer; | |||
63 | int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; | |||
64 | int result, len, j; | |||
65 | int orig_x, orig_y; | |||
66 | XID orig_visual, tmp; | |||
67 | Bool parentIsRoot; | |||
68 | ||||
69 | REQUEST_AT_LEAST_SIZE(xCreateWindowReq)if ((sizeof(xCreateWindowReq) >> 2) > client->req_len ) return(16); | |||
70 | ||||
71 | len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq)); | |||
72 | if (Ones(stuff->mask) != len) | |||
73 | return BadLength16; | |||
74 | ||||
75 | result = dixLookupResourceByType((void **) &parent, stuff->parent, | |||
76 | XRT_WINDOW, client, DixWriteAccess(1<<1)); | |||
77 | if (result != Success0) | |||
78 | return result; | |||
79 | ||||
80 | if (stuff->class == CopyFromParent0L) | |||
81 | stuff->class = parent->u.win.class; | |||
82 | ||||
83 | if ((stuff->class == InputOnly2) && (stuff->mask & (~INPUTONLY_LEGAL_MASK((1L<<5) | (1L<<11) | (1L<<12) | (1L<< 9) | (1L<<14) )))) | |||
84 | return BadMatch8; | |||
85 | ||||
86 | if ((Mask) stuff->mask & CWBackPixmap(1L<<0)) { | |||
87 | pback_offset = Ones((Mask) stuff->mask & (CWBackPixmap(1L<<0) - 1)); | |||
88 | tmp = *((CARD32 *) &stuff[1] + pback_offset); | |||
89 | if ((tmp != None0L) && (tmp != ParentRelative1L)) { | |||
90 | result = dixLookupResourceByType((void **) &backPix, tmp, | |||
91 | XRT_PIXMAP, client, DixReadAccess(1<<0)); | |||
92 | if (result != Success0) | |||
93 | return result; | |||
94 | } | |||
95 | } | |||
96 | if ((Mask) stuff->mask & CWBorderPixmap(1L<<2)) { | |||
97 | pbord_offset = Ones((Mask) stuff->mask & (CWBorderPixmap(1L<<2) - 1)); | |||
98 | tmp = *((CARD32 *) &stuff[1] + pbord_offset); | |||
99 | if (tmp != CopyFromParent0L) { | |||
100 | result = dixLookupResourceByType((void **) &bordPix, tmp, | |||
101 | XRT_PIXMAP, client, DixReadAccess(1<<0)); | |||
102 | if (result != Success0) | |||
103 | return result; | |||
104 | } | |||
105 | } | |||
106 | if ((Mask) stuff->mask & CWColormap(1L<<13)) { | |||
107 | cmap_offset = Ones((Mask) stuff->mask & (CWColormap(1L<<13) - 1)); | |||
108 | tmp = *((CARD32 *) &stuff[1] + cmap_offset); | |||
109 | if ((tmp != CopyFromParent0L) && (tmp != None0L)) { | |||
110 | result = dixLookupResourceByType((void **) &cmap, tmp, | |||
111 | XRT_COLORMAP, client, | |||
112 | DixReadAccess(1<<0)); | |||
113 | if (result != Success0) | |||
114 | return result; | |||
115 | } | |||
116 | } | |||
117 | ||||
118 | if (!(newWin = malloc(sizeof(PanoramiXRes)))) | |||
119 | return BadAlloc11; | |||
120 | ||||
121 | newWin->type = XRT_WINDOW; | |||
122 | newWin->u.win.visibility = VisibilityNotViewable3; | |||
123 | newWin->u.win.class = stuff->class; | |||
124 | newWin->u.win.root = FALSE0; | |||
125 | panoramix_setup_ids(newWin, client, stuff->wid); | |||
126 | ||||
127 | if (stuff->class == InputOnly2) | |||
128 | stuff->visual = CopyFromParent0L; | |||
129 | orig_visual = stuff->visual; | |||
130 | orig_x = stuff->x; | |||
131 | orig_y = stuff->y; | |||
132 | parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) | |||
133 | || (stuff->parent == screenInfo.screens[0]->screensaver.wid); | |||
134 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
135 | stuff->wid = newWin->info[j].id; | |||
136 | stuff->parent = parent->info[j].id; | |||
137 | if (parentIsRoot) { | |||
138 | stuff->x = orig_x - screenInfo.screens[j]->x; | |||
139 | stuff->y = orig_y - screenInfo.screens[j]->y; | |||
140 | } | |||
141 | if (backPix) | |||
142 | *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; | |||
143 | if (bordPix) | |||
144 | *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; | |||
145 | if (cmap) | |||
146 | *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; | |||
147 | if (orig_visual != CopyFromParent0L) | |||
148 | stuff->visual = PanoramiXTranslateVisualID(j, orig_visual); | |||
149 | result = (*SavedProcVector[X_CreateWindow1]) (client); | |||
150 | if (result != Success0) | |||
151 | break; | |||
152 | } | |||
153 | ||||
154 | if (result == Success0) | |||
155 | AddResourceDarwin_X_AddResource(newWin->info[0].id, XRT_WINDOW, newWin); | |||
156 | else | |||
157 | free(newWin); | |||
158 | ||||
159 | return result; | |||
160 | } | |||
161 | ||||
162 | int | |||
163 | PanoramiXChangeWindowAttributes(ClientPtr client) | |||
164 | { | |||
165 | PanoramiXRes *win; | |||
166 | PanoramiXRes *backPix = NULL((void*)0); | |||
167 | PanoramiXRes *bordPix = NULL((void*)0); | |||
168 | PanoramiXRes *cmap = NULL((void*)0); | |||
169 | ||||
170 | REQUEST(xChangeWindowAttributesReq)xChangeWindowAttributesReq *stuff = (xChangeWindowAttributesReq *)client->requestBuffer; | |||
171 | int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; | |||
172 | int result, len, j; | |||
173 | XID tmp; | |||
174 | ||||
175 | REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq)if ((sizeof(xChangeWindowAttributesReq) >> 2) > client ->req_len ) return(16); | |||
176 | ||||
177 | len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq)); | |||
178 | if (Ones(stuff->valueMask) != len) | |||
179 | return BadLength16; | |||
180 | ||||
181 | result = dixLookupResourceByType((void **) &win, stuff->window, | |||
182 | XRT_WINDOW, client, DixWriteAccess(1<<1)); | |||
183 | if (result != Success0) | |||
184 | return result; | |||
185 | ||||
186 | if ((win->u.win.class == InputOnly2) && | |||
187 | (stuff->valueMask & (~INPUTONLY_LEGAL_MASK((1L<<5) | (1L<<11) | (1L<<12) | (1L<< 9) | (1L<<14) )))) | |||
188 | return BadMatch8; | |||
189 | ||||
190 | if ((Mask) stuff->valueMask & CWBackPixmap(1L<<0)) { | |||
191 | pback_offset = Ones((Mask) stuff->valueMask & (CWBackPixmap(1L<<0) - 1)); | |||
192 | tmp = *((CARD32 *) &stuff[1] + pback_offset); | |||
193 | if ((tmp != None0L) && (tmp != ParentRelative1L)) { | |||
194 | result = dixLookupResourceByType((void **) &backPix, tmp, | |||
195 | XRT_PIXMAP, client, DixReadAccess(1<<0)); | |||
196 | if (result != Success0) | |||
197 | return result; | |||
198 | } | |||
199 | } | |||
200 | if ((Mask) stuff->valueMask & CWBorderPixmap(1L<<2)) { | |||
201 | pbord_offset = Ones((Mask) stuff->valueMask & (CWBorderPixmap(1L<<2) - 1)); | |||
202 | tmp = *((CARD32 *) &stuff[1] + pbord_offset); | |||
203 | if (tmp != CopyFromParent0L) { | |||
204 | result = dixLookupResourceByType((void **) &bordPix, tmp, | |||
205 | XRT_PIXMAP, client, DixReadAccess(1<<0)); | |||
206 | if (result != Success0) | |||
207 | return result; | |||
208 | } | |||
209 | } | |||
210 | if ((Mask) stuff->valueMask & CWColormap(1L<<13)) { | |||
211 | cmap_offset = Ones((Mask) stuff->valueMask & (CWColormap(1L<<13) - 1)); | |||
212 | tmp = *((CARD32 *) &stuff[1] + cmap_offset); | |||
213 | if ((tmp != CopyFromParent0L) && (tmp != None0L)) { | |||
214 | result = dixLookupResourceByType((void **) &cmap, tmp, | |||
215 | XRT_COLORMAP, client, | |||
216 | DixReadAccess(1<<0)); | |||
217 | if (result != Success0) | |||
218 | return result; | |||
219 | } | |||
220 | } | |||
221 | ||||
222 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
223 | stuff->window = win->info[j].id; | |||
224 | if (backPix) | |||
225 | *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; | |||
226 | if (bordPix) | |||
227 | *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; | |||
228 | if (cmap) | |||
229 | *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; | |||
230 | result = (*SavedProcVector[X_ChangeWindowAttributes2]) (client); | |||
231 | } | |||
232 | ||||
233 | return result; | |||
234 | } | |||
235 | ||||
236 | int | |||
237 | PanoramiXDestroyWindow(ClientPtr client) | |||
238 | { | |||
239 | PanoramiXRes *win; | |||
240 | int result, j; | |||
241 | ||||
242 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
243 | ||||
244 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
245 | ||||
246 | result = dixLookupResourceByType((void **) &win, stuff->id, XRT_WINDOW, | |||
247 | client, DixDestroyAccess(1<<2)); | |||
248 | if (result != Success0) | |||
249 | return result; | |||
250 | ||||
251 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
252 | stuff->id = win->info[j].id; | |||
253 | result = (*SavedProcVector[X_DestroyWindow4]) (client); | |||
254 | if (result != Success0) | |||
255 | break; | |||
256 | } | |||
257 | ||||
258 | /* Since ProcDestroyWindow is using FreeResource, it will free | |||
259 | our resource for us on the last pass through the loop above */ | |||
260 | ||||
261 | return result; | |||
262 | } | |||
263 | ||||
264 | int | |||
265 | PanoramiXDestroySubwindows(ClientPtr client) | |||
266 | { | |||
267 | PanoramiXRes *win; | |||
268 | int result, j; | |||
269 | ||||
270 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
271 | ||||
272 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
273 | ||||
274 | result = dixLookupResourceByType((void **) &win, stuff->id, XRT_WINDOW, | |||
275 | client, DixDestroyAccess(1<<2)); | |||
276 | if (result != Success0) | |||
277 | return result; | |||
278 | ||||
279 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
280 | stuff->id = win->info[j].id; | |||
281 | result = (*SavedProcVector[X_DestroySubwindows5]) (client); | |||
282 | if (result != Success0) | |||
283 | break; | |||
284 | } | |||
285 | ||||
286 | /* DestroySubwindows is using FreeResource which will free | |||
287 | our resources for us on the last pass through the loop above */ | |||
288 | ||||
289 | return result; | |||
290 | } | |||
291 | ||||
292 | int | |||
293 | PanoramiXChangeSaveSet(ClientPtr client) | |||
294 | { | |||
295 | PanoramiXRes *win; | |||
296 | int result, j; | |||
297 | ||||
298 | REQUEST(xChangeSaveSetReq)xChangeSaveSetReq *stuff = (xChangeSaveSetReq *)client->requestBuffer; | |||
299 | ||||
300 | REQUEST_SIZE_MATCH(xChangeSaveSetReq)if ((sizeof(xChangeSaveSetReq) >> 2) != client->req_len ) return(16); | |||
301 | ||||
302 | result = dixLookupResourceByType((void **) &win, stuff->window, | |||
303 | XRT_WINDOW, client, DixReadAccess(1<<0)); | |||
304 | if (result != Success0) | |||
305 | return result; | |||
306 | ||||
307 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
308 | stuff->window = win->info[j].id; | |||
309 | result = (*SavedProcVector[X_ChangeSaveSet6]) (client); | |||
310 | if (result != Success0) | |||
311 | break; | |||
312 | } | |||
313 | ||||
314 | return result; | |||
315 | } | |||
316 | ||||
317 | int | |||
318 | PanoramiXReparentWindow(ClientPtr client) | |||
319 | { | |||
320 | PanoramiXRes *win, *parent; | |||
321 | int result, j; | |||
322 | int x, y; | |||
323 | Bool parentIsRoot; | |||
324 | ||||
325 | REQUEST(xReparentWindowReq)xReparentWindowReq *stuff = (xReparentWindowReq *)client-> requestBuffer; | |||
326 | ||||
327 | REQUEST_SIZE_MATCH(xReparentWindowReq)if ((sizeof(xReparentWindowReq) >> 2) != client->req_len ) return(16); | |||
328 | ||||
329 | result = dixLookupResourceByType((void **) &win, stuff->window, | |||
330 | XRT_WINDOW, client, DixWriteAccess(1<<1)); | |||
331 | if (result != Success0) | |||
332 | return result; | |||
333 | ||||
334 | result = dixLookupResourceByType((void **) &parent, stuff->parent, | |||
335 | XRT_WINDOW, client, DixWriteAccess(1<<1)); | |||
336 | if (result != Success0) | |||
337 | return result; | |||
338 | ||||
339 | x = stuff->x; | |||
340 | y = stuff->y; | |||
341 | parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) | |||
342 | || (stuff->parent == screenInfo.screens[0]->screensaver.wid); | |||
343 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
344 | stuff->window = win->info[j].id; | |||
345 | stuff->parent = parent->info[j].id; | |||
346 | if (parentIsRoot) { | |||
347 | stuff->x = x - screenInfo.screens[j]->x; | |||
348 | stuff->y = y - screenInfo.screens[j]->y; | |||
349 | } | |||
350 | result = (*SavedProcVector[X_ReparentWindow7]) (client); | |||
351 | if (result != Success0) | |||
352 | break; | |||
353 | } | |||
354 | ||||
355 | return result; | |||
356 | } | |||
357 | ||||
358 | int | |||
359 | PanoramiXMapWindow(ClientPtr client) | |||
360 | { | |||
361 | PanoramiXRes *win; | |||
362 | int result, j; | |||
363 | ||||
364 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
365 | ||||
366 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
367 | ||||
368 | result = dixLookupResourceByType((void **) &win, stuff->id, | |||
369 | XRT_WINDOW, client, DixReadAccess(1<<0)); | |||
370 | if (result != Success0) | |||
371 | return result; | |||
372 | ||||
373 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
374 | stuff->id = win->info[j].id; | |||
375 | result = (*SavedProcVector[X_MapWindow8]) (client); | |||
376 | if (result != Success0) | |||
377 | break; | |||
378 | } | |||
379 | ||||
380 | return result; | |||
381 | } | |||
382 | ||||
383 | int | |||
384 | PanoramiXMapSubwindows(ClientPtr client) | |||
385 | { | |||
386 | PanoramiXRes *win; | |||
387 | int result, j; | |||
388 | ||||
389 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
390 | ||||
391 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
392 | ||||
393 | result = dixLookupResourceByType((void **) &win, stuff->id, | |||
394 | XRT_WINDOW, client, DixReadAccess(1<<0)); | |||
395 | if (result != Success0) | |||
396 | return result; | |||
397 | ||||
398 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
399 | stuff->id = win->info[j].id; | |||
400 | result = (*SavedProcVector[X_MapSubwindows9]) (client); | |||
401 | if (result != Success0) | |||
402 | break; | |||
403 | } | |||
404 | ||||
405 | return result; | |||
406 | } | |||
407 | ||||
408 | int | |||
409 | PanoramiXUnmapWindow(ClientPtr client) | |||
410 | { | |||
411 | PanoramiXRes *win; | |||
412 | int result, j; | |||
413 | ||||
414 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
415 | ||||
416 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
417 | ||||
418 | result = dixLookupResourceByType((void **) &win, stuff->id, | |||
419 | XRT_WINDOW, client, DixReadAccess(1<<0)); | |||
420 | if (result != Success0) | |||
421 | return result; | |||
422 | ||||
423 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
424 | stuff->id = win->info[j].id; | |||
425 | result = (*SavedProcVector[X_UnmapWindow10]) (client); | |||
426 | if (result != Success0) | |||
427 | break; | |||
428 | } | |||
429 | ||||
430 | return result; | |||
431 | } | |||
432 | ||||
433 | int | |||
434 | PanoramiXUnmapSubwindows(ClientPtr client) | |||
435 | { | |||
436 | PanoramiXRes *win; | |||
437 | int result, j; | |||
438 | ||||
439 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
440 | ||||
441 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
442 | ||||
443 | result = dixLookupResourceByType((void **) &win, stuff->id, | |||
444 | XRT_WINDOW, client, DixReadAccess(1<<0)); | |||
445 | if (result != Success0) | |||
446 | return result; | |||
447 | ||||
448 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
449 | stuff->id = win->info[j].id; | |||
450 | result = (*SavedProcVector[X_UnmapSubwindows11]) (client); | |||
451 | if (result != Success0) | |||
452 | break; | |||
453 | } | |||
454 | ||||
455 | return result; | |||
456 | } | |||
457 | ||||
458 | int | |||
459 | PanoramiXConfigureWindow(ClientPtr client) | |||
460 | { | |||
461 | PanoramiXRes *win; | |||
462 | PanoramiXRes *sib = NULL((void*)0); | |||
463 | WindowPtr pWin; | |||
464 | int result, j, len, sib_offset = 0, x = 0, y = 0; | |||
465 | int x_offset = -1; | |||
466 | int y_offset = -1; | |||
467 | ||||
468 | REQUEST(xConfigureWindowReq)xConfigureWindowReq *stuff = (xConfigureWindowReq *)client-> requestBuffer; | |||
469 | ||||
470 | REQUEST_AT_LEAST_SIZE(xConfigureWindowReq)if ((sizeof(xConfigureWindowReq) >> 2) > client-> req_len ) return(16); | |||
471 | ||||
472 | len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq)); | |||
473 | if (Ones(stuff->mask) != len) | |||
474 | return BadLength16; | |||
475 | ||||
476 | /* because we need the parent */ | |||
477 | result = dixLookupResourceByType((void **) &pWin, stuff->window, | |||
478 | RT_WINDOW((RESTYPE)1|((RESTYPE)1<<30)), client, DixWriteAccess(1<<1)); | |||
479 | if (result != Success0) | |||
480 | return result; | |||
481 | ||||
482 | result = dixLookupResourceByType((void **) &win, stuff->window, | |||
483 | XRT_WINDOW, client, DixWriteAccess(1<<1)); | |||
484 | if (result != Success0) | |||
485 | return result; | |||
486 | ||||
487 | if ((Mask) stuff->mask & CWSibling(1<<5)) { | |||
488 | XID tmp; | |||
489 | ||||
490 | sib_offset = Ones((Mask) stuff->mask & (CWSibling(1<<5) - 1)); | |||
491 | if ((tmp = *((CARD32 *) &stuff[1] + sib_offset))) { | |||
492 | result = dixLookupResourceByType((void **) &sib, tmp, XRT_WINDOW, | |||
493 | client, DixReadAccess(1<<0)); | |||
494 | if (result != Success0) | |||
495 | return result; | |||
496 | } | |||
497 | } | |||
498 | ||||
499 | if (pWin->parent && ((pWin->parent == screenInfo.screens[0]->root) || | |||
500 | (pWin->parent->drawable.id == | |||
501 | screenInfo.screens[0]->screensaver.wid))) { | |||
502 | if ((Mask) stuff->mask & CWX(1<<0)) { | |||
503 | x_offset = 0; | |||
504 | x = *((CARD32 *) &stuff[1]); | |||
505 | } | |||
506 | if ((Mask) stuff->mask & CWY(1<<1)) { | |||
507 | y_offset = (x_offset == -1) ? 0 : 1; | |||
508 | y = *((CARD32 *) &stuff[1] + y_offset); | |||
509 | } | |||
510 | } | |||
511 | ||||
512 | /* have to go forward or you get expose events before | |||
513 | ConfigureNotify events */ | |||
514 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
515 | stuff->window = win->info[j].id; | |||
516 | if (sib) | |||
517 | *((CARD32 *) &stuff[1] + sib_offset) = sib->info[j].id; | |||
518 | if (x_offset >= 0) | |||
519 | *((CARD32 *) &stuff[1] + x_offset) = x - screenInfo.screens[j]->x; | |||
520 | if (y_offset >= 0) | |||
521 | *((CARD32 *) &stuff[1] + y_offset) = y - screenInfo.screens[j]->y; | |||
522 | result = (*SavedProcVector[X_ConfigureWindow12]) (client); | |||
523 | if (result != Success0) | |||
524 | break; | |||
525 | } | |||
526 | ||||
527 | return result; | |||
528 | } | |||
529 | ||||
530 | int | |||
531 | PanoramiXCirculateWindow(ClientPtr client) | |||
532 | { | |||
533 | PanoramiXRes *win; | |||
534 | int result, j; | |||
535 | ||||
536 | REQUEST(xCirculateWindowReq)xCirculateWindowReq *stuff = (xCirculateWindowReq *)client-> requestBuffer; | |||
537 | ||||
538 | REQUEST_SIZE_MATCH(xCirculateWindowReq)if ((sizeof(xCirculateWindowReq) >> 2) != client->req_len ) return(16); | |||
539 | ||||
540 | result = dixLookupResourceByType((void **) &win, stuff->window, | |||
541 | XRT_WINDOW, client, DixWriteAccess(1<<1)); | |||
542 | if (result != Success0) | |||
543 | return result; | |||
544 | ||||
545 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
546 | stuff->window = win->info[j].id; | |||
547 | result = (*SavedProcVector[X_CirculateWindow13]) (client); | |||
548 | if (result != Success0) | |||
549 | break; | |||
550 | } | |||
551 | ||||
552 | return result; | |||
553 | } | |||
554 | ||||
555 | int | |||
556 | PanoramiXGetGeometry(ClientPtr client) | |||
557 | { | |||
558 | xGetGeometryReply rep; | |||
559 | DrawablePtr pDraw; | |||
560 | int rc; | |||
561 | ||||
562 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
563 | ||||
564 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
565 | rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY(-1), DixGetAttrAccess(1<<4)); | |||
566 | if (rc != Success0) | |||
567 | return rc; | |||
568 | ||||
569 | rep = (xGetGeometryReply) { | |||
570 | .type = X_Reply1, | |||
571 | .sequenceNumber = client->sequence, | |||
572 | .length = 0, | |||
573 | .root = screenInfo.screens[0]->root->drawable.id, | |||
574 | .depth = pDraw->depth, | |||
575 | .width = pDraw->width, | |||
576 | .height = pDraw->height, | |||
577 | .x = 0, | |||
578 | .y = 0, | |||
579 | .borderWidth = 0 | |||
580 | }; | |||
581 | ||||
582 | if (stuff->id == rep.root) { | |||
583 | xWindowRoot *root = (xWindowRoot *) | |||
584 | (ConnectionInfo + connBlockScreenStart); | |||
585 | ||||
586 | rep.width = root->pixWidth; | |||
587 | rep.height = root->pixHeight; | |||
588 | } | |||
589 | else if (WindowDrawable(pDraw->type)((pDraw->type == 0) || (pDraw->type == 2))) { | |||
590 | WindowPtr pWin = (WindowPtr) pDraw; | |||
591 | ||||
592 | rep.x = pWin->origin.x - wBorderWidth(pWin)((int) (pWin)->borderWidth); | |||
593 | rep.y = pWin->origin.y - wBorderWidth(pWin)((int) (pWin)->borderWidth); | |||
594 | if ((pWin->parent == screenInfo.screens[0]->root) || | |||
595 | (pWin->parent->drawable.id == | |||
596 | screenInfo.screens[0]->screensaver.wid)) { | |||
597 | rep.x += screenInfo.screens[0]->x; | |||
598 | rep.y += screenInfo.screens[0]->y; | |||
599 | } | |||
600 | rep.borderWidth = pWin->borderWidth; | |||
601 | } | |||
602 | ||||
603 | WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep){ if ((client)->swapped) (*ReplySwapVector[((xReq *)(client )->requestBuffer)->reqType]) (client, (int)(sizeof(xGetGeometryReply )), &rep); else WriteToClient(client, (int)(sizeof(xGetGeometryReply )), (&rep)); }; | |||
604 | return Success0; | |||
605 | } | |||
606 | ||||
607 | int | |||
608 | PanoramiXTranslateCoords(ClientPtr client) | |||
609 | { | |||
610 | INT16 x, y; | |||
611 | ||||
612 | REQUEST(xTranslateCoordsReq)xTranslateCoordsReq *stuff = (xTranslateCoordsReq *)client-> requestBuffer; | |||
613 | int rc; | |||
614 | WindowPtr pWin, pDst; | |||
615 | xTranslateCoordsReply rep; | |||
616 | ||||
617 | REQUEST_SIZE_MATCH(xTranslateCoordsReq)if ((sizeof(xTranslateCoordsReq) >> 2) != client->req_len ) return(16); | |||
618 | rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess(1<<0)); | |||
619 | if (rc != Success0) | |||
620 | return rc; | |||
621 | rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess(1<<0)); | |||
622 | if (rc != Success0) | |||
623 | return rc; | |||
624 | rep = (xTranslateCoordsReply) { | |||
625 | .type = X_Reply1, | |||
626 | .sequenceNumber = client->sequence, | |||
627 | .length = 0, | |||
628 | .sameScreen = xTrue1, | |||
629 | .child = None0L | |||
630 | }; | |||
631 | ||||
632 | if ((pWin == screenInfo.screens[0]->root) || | |||
633 | (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid)) { | |||
634 | x = stuff->srcX - screenInfo.screens[0]->x; | |||
635 | y = stuff->srcY - screenInfo.screens[0]->y; | |||
636 | } | |||
637 | else { | |||
638 | x = pWin->drawable.x + stuff->srcX; | |||
639 | y = pWin->drawable.y + stuff->srcY; | |||
640 | } | |||
641 | pWin = pDst->firstChild; | |||
642 | while (pWin) { | |||
643 | BoxRec box; | |||
644 | ||||
645 | if ((pWin->mapped) && | |||
646 | (x >= pWin->drawable.x - wBorderWidth(pWin)((int) (pWin)->borderWidth)) && | |||
647 | (x < pWin->drawable.x + (int) pWin->drawable.width + | |||
648 | wBorderWidth(pWin)((int) (pWin)->borderWidth)) && | |||
649 | (y >= pWin->drawable.y - wBorderWidth(pWin)((int) (pWin)->borderWidth)) && | |||
650 | (y < pWin->drawable.y + (int) pWin->drawable.height + | |||
651 | wBorderWidth(pWin)((int) (pWin)->borderWidth)) | |||
652 | /* When a window is shaped, a further check | |||
653 | * is made to see if the point is inside | |||
654 | * borderSize | |||
655 | */ | |||
656 | && (!wBoundingShape(pWin)((pWin)->optional ? (pWin)->optional->boundingShape : ((void*)0)) || | |||
657 | RegionContainsPoint(wBoundingShape(pWin)((pWin)->optional ? (pWin)->optional->boundingShape : ((void*)0)), | |||
658 | x - pWin->drawable.x, | |||
659 | y - pWin->drawable.y, &box)) | |||
660 | ) { | |||
661 | rep.child = pWin->drawable.id; | |||
662 | pWin = (WindowPtr) NULL((void*)0); | |||
663 | } | |||
664 | else | |||
665 | pWin = pWin->nextSib; | |||
666 | } | |||
667 | rep.dstX = x - pDst->drawable.x; | |||
668 | rep.dstY = y - pDst->drawable.y; | |||
669 | if ((pDst == screenInfo.screens[0]->root) || | |||
670 | (pDst->drawable.id == screenInfo.screens[0]->screensaver.wid)) { | |||
671 | rep.dstX += screenInfo.screens[0]->x; | |||
672 | rep.dstY += screenInfo.screens[0]->y; | |||
673 | } | |||
674 | ||||
675 | WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep){ if ((client)->swapped) (*ReplySwapVector[((xReq *)(client )->requestBuffer)->reqType]) (client, (int)(sizeof(xTranslateCoordsReply )), &rep); else WriteToClient(client, (int)(sizeof(xTranslateCoordsReply )), (&rep)); }; | |||
676 | return Success0; | |||
677 | } | |||
678 | ||||
679 | int | |||
680 | PanoramiXCreatePixmap(ClientPtr client) | |||
681 | { | |||
682 | PanoramiXRes *refDraw, *newPix; | |||
683 | int result, j; | |||
684 | ||||
685 | REQUEST(xCreatePixmapReq)xCreatePixmapReq *stuff = (xCreatePixmapReq *)client->requestBuffer; | |||
686 | ||||
687 | REQUEST_SIZE_MATCH(xCreatePixmapReq)if ((sizeof(xCreatePixmapReq) >> 2) != client->req_len ) return(16); | |||
688 | client->errorValue = stuff->pid; | |||
689 | ||||
690 | result = dixLookupResourceByClass((void **) &refDraw, stuff->drawable, | |||
691 | XRC_DRAWABLE, client, DixReadAccess(1<<0)); | |||
692 | if (result != Success0) | |||
693 | return (result == BadValue2) ? BadDrawable9 : result; | |||
694 | ||||
695 | if (!(newPix = malloc(sizeof(PanoramiXRes)))) | |||
696 | return BadAlloc11; | |||
697 | ||||
698 | newPix->type = XRT_PIXMAP; | |||
699 | newPix->u.pix.shared = FALSE0; | |||
700 | panoramix_setup_ids(newPix, client, stuff->pid); | |||
701 | ||||
702 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
703 | stuff->pid = newPix->info[j].id; | |||
704 | stuff->drawable = refDraw->info[j].id; | |||
705 | result = (*SavedProcVector[X_CreatePixmap53]) (client); | |||
706 | if (result != Success0) | |||
707 | break; | |||
708 | } | |||
709 | ||||
710 | if (result == Success0) | |||
711 | AddResourceDarwin_X_AddResource(newPix->info[0].id, XRT_PIXMAP, newPix); | |||
712 | else | |||
713 | free(newPix); | |||
714 | ||||
715 | return result; | |||
716 | } | |||
717 | ||||
718 | int | |||
719 | PanoramiXFreePixmap(ClientPtr client) | |||
720 | { | |||
721 | PanoramiXRes *pix; | |||
722 | int result, j; | |||
723 | ||||
724 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
725 | ||||
726 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
727 | ||||
728 | client->errorValue = stuff->id; | |||
729 | ||||
730 | result = dixLookupResourceByType((void **) &pix, stuff->id, XRT_PIXMAP, | |||
731 | client, DixDestroyAccess(1<<2)); | |||
732 | if (result != Success0) | |||
733 | return result; | |||
734 | ||||
735 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
736 | stuff->id = pix->info[j].id; | |||
737 | result = (*SavedProcVector[X_FreePixmap54]) (client); | |||
738 | if (result != Success0) | |||
739 | break; | |||
740 | } | |||
741 | ||||
742 | /* Since ProcFreePixmap is using FreeResource, it will free | |||
743 | our resource for us on the last pass through the loop above */ | |||
744 | ||||
745 | return result; | |||
746 | } | |||
747 | ||||
748 | int | |||
749 | PanoramiXCreateGC(ClientPtr client) | |||
750 | { | |||
751 | PanoramiXRes *refDraw; | |||
752 | PanoramiXRes *newGC; | |||
753 | PanoramiXRes *stip = NULL((void*)0); | |||
754 | PanoramiXRes *tile = NULL((void*)0); | |||
755 | PanoramiXRes *clip = NULL((void*)0); | |||
756 | ||||
757 | REQUEST(xCreateGCReq)xCreateGCReq *stuff = (xCreateGCReq *)client->requestBuffer; | |||
758 | int tile_offset = 0, stip_offset = 0, clip_offset = 0; | |||
759 | int result, len, j; | |||
760 | XID tmp; | |||
761 | ||||
762 | REQUEST_AT_LEAST_SIZE(xCreateGCReq)if ((sizeof(xCreateGCReq) >> 2) > client->req_len ) return(16); | |||
763 | ||||
764 | client->errorValue = stuff->gc; | |||
765 | len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq)); | |||
766 | if (Ones(stuff->mask) != len) | |||
767 | return BadLength16; | |||
768 | ||||
769 | result = dixLookupResourceByClass((void **) &refDraw, stuff->drawable, | |||
770 | XRC_DRAWABLE, client, DixReadAccess(1<<0)); | |||
771 | if (result != Success0) | |||
772 | return (result == BadValue2) ? BadDrawable9 : result; | |||
773 | ||||
774 | if ((Mask) stuff->mask & GCTile(1L<<10)) { | |||
775 | tile_offset = Ones((Mask) stuff->mask & (GCTile(1L<<10) - 1)); | |||
776 | if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { | |||
777 | result = dixLookupResourceByType((void **) &tile, tmp, XRT_PIXMAP, | |||
778 | client, DixReadAccess(1<<0)); | |||
779 | if (result != Success0) | |||
780 | return result; | |||
781 | } | |||
782 | } | |||
783 | if ((Mask) stuff->mask & GCStipple(1L<<11)) { | |||
784 | stip_offset = Ones((Mask) stuff->mask & (GCStipple(1L<<11) - 1)); | |||
785 | if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { | |||
786 | result = dixLookupResourceByType((void **) &stip, tmp, XRT_PIXMAP, | |||
787 | client, DixReadAccess(1<<0)); | |||
788 | if (result != Success0) | |||
789 | return result; | |||
790 | } | |||
791 | } | |||
792 | if ((Mask) stuff->mask & GCClipMask(1L<<19)) { | |||
793 | clip_offset = Ones((Mask) stuff->mask & (GCClipMask(1L<<19) - 1)); | |||
794 | if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { | |||
795 | result = dixLookupResourceByType((void **) &clip, tmp, XRT_PIXMAP, | |||
796 | client, DixReadAccess(1<<0)); | |||
797 | if (result != Success0) | |||
798 | return result; | |||
799 | } | |||
800 | } | |||
801 | ||||
802 | if (!(newGC = malloc(sizeof(PanoramiXRes)))) | |||
803 | return BadAlloc11; | |||
804 | ||||
805 | newGC->type = XRT_GC; | |||
806 | panoramix_setup_ids(newGC, client, stuff->gc); | |||
807 | ||||
808 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
809 | stuff->gc = newGC->info[j].id; | |||
810 | stuff->drawable = refDraw->info[j].id; | |||
811 | if (tile) | |||
812 | *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; | |||
813 | if (stip) | |||
814 | *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; | |||
815 | if (clip) | |||
816 | *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; | |||
817 | result = (*SavedProcVector[X_CreateGC55]) (client); | |||
818 | if (result != Success0) | |||
819 | break; | |||
820 | } | |||
821 | ||||
822 | if (result == Success0) | |||
823 | AddResourceDarwin_X_AddResource(newGC->info[0].id, XRT_GC, newGC); | |||
824 | else | |||
825 | free(newGC); | |||
826 | ||||
827 | return result; | |||
828 | } | |||
829 | ||||
830 | int | |||
831 | PanoramiXChangeGC(ClientPtr client) | |||
832 | { | |||
833 | PanoramiXRes *gc; | |||
834 | PanoramiXRes *stip = NULL((void*)0); | |||
835 | PanoramiXRes *tile = NULL((void*)0); | |||
836 | PanoramiXRes *clip = NULL((void*)0); | |||
837 | ||||
838 | REQUEST(xChangeGCReq)xChangeGCReq *stuff = (xChangeGCReq *)client->requestBuffer; | |||
839 | int tile_offset = 0, stip_offset = 0, clip_offset = 0; | |||
840 | int result, len, j; | |||
841 | XID tmp; | |||
842 | ||||
843 | REQUEST_AT_LEAST_SIZE(xChangeGCReq)if ((sizeof(xChangeGCReq) >> 2) > client->req_len ) return(16); | |||
844 | ||||
845 | len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq)); | |||
846 | if (Ones(stuff->mask) != len) | |||
847 | return BadLength16; | |||
848 | ||||
849 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
850 | client, DixReadAccess(1<<0)); | |||
851 | if (result != Success0) | |||
852 | return result; | |||
853 | ||||
854 | if ((Mask) stuff->mask & GCTile(1L<<10)) { | |||
855 | tile_offset = Ones((Mask) stuff->mask & (GCTile(1L<<10) - 1)); | |||
856 | if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { | |||
857 | result = dixLookupResourceByType((void **) &tile, tmp, XRT_PIXMAP, | |||
858 | client, DixReadAccess(1<<0)); | |||
859 | if (result != Success0) | |||
860 | return result; | |||
861 | } | |||
862 | } | |||
863 | if ((Mask) stuff->mask & GCStipple(1L<<11)) { | |||
864 | stip_offset = Ones((Mask) stuff->mask & (GCStipple(1L<<11) - 1)); | |||
865 | if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { | |||
866 | result = dixLookupResourceByType((void **) &stip, tmp, XRT_PIXMAP, | |||
867 | client, DixReadAccess(1<<0)); | |||
868 | if (result != Success0) | |||
869 | return result; | |||
870 | } | |||
871 | } | |||
872 | if ((Mask) stuff->mask & GCClipMask(1L<<19)) { | |||
873 | clip_offset = Ones((Mask) stuff->mask & (GCClipMask(1L<<19) - 1)); | |||
874 | if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { | |||
875 | result = dixLookupResourceByType((void **) &clip, tmp, XRT_PIXMAP, | |||
876 | client, DixReadAccess(1<<0)); | |||
877 | if (result != Success0) | |||
878 | return result; | |||
879 | } | |||
880 | } | |||
881 | ||||
882 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
883 | stuff->gc = gc->info[j].id; | |||
884 | if (tile) | |||
885 | *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; | |||
886 | if (stip) | |||
887 | *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; | |||
888 | if (clip) | |||
889 | *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; | |||
890 | result = (*SavedProcVector[X_ChangeGC56]) (client); | |||
891 | if (result != Success0) | |||
892 | break; | |||
893 | } | |||
894 | ||||
895 | return result; | |||
896 | } | |||
897 | ||||
898 | int | |||
899 | PanoramiXCopyGC(ClientPtr client) | |||
900 | { | |||
901 | PanoramiXRes *srcGC, *dstGC; | |||
902 | int result, j; | |||
903 | ||||
904 | REQUEST(xCopyGCReq)xCopyGCReq *stuff = (xCopyGCReq *)client->requestBuffer; | |||
905 | ||||
906 | REQUEST_SIZE_MATCH(xCopyGCReq)if ((sizeof(xCopyGCReq) >> 2) != client->req_len) return (16); | |||
907 | ||||
908 | result = dixLookupResourceByType((void **) &srcGC, stuff->srcGC, XRT_GC, | |||
909 | client, DixReadAccess(1<<0)); | |||
910 | if (result != Success0) | |||
911 | return result; | |||
912 | ||||
913 | result = dixLookupResourceByType((void **) &dstGC, stuff->dstGC, XRT_GC, | |||
914 | client, DixWriteAccess(1<<1)); | |||
915 | if (result != Success0) | |||
916 | return result; | |||
917 | ||||
918 | FOR_NSCREENS(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
919 | stuff->srcGC = srcGC->info[j].id; | |||
920 | stuff->dstGC = dstGC->info[j].id; | |||
921 | result = (*SavedProcVector[X_CopyGC57]) (client); | |||
922 | if (result != Success0) | |||
923 | break; | |||
924 | } | |||
925 | ||||
926 | return result; | |||
927 | } | |||
928 | ||||
929 | int | |||
930 | PanoramiXSetDashes(ClientPtr client) | |||
931 | { | |||
932 | PanoramiXRes *gc; | |||
933 | int result, j; | |||
934 | ||||
935 | REQUEST(xSetDashesReq)xSetDashesReq *stuff = (xSetDashesReq *)client->requestBuffer; | |||
936 | ||||
937 | REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes)if (((sizeof(xSetDashesReq) >> 2) > client->req_len ) || (((stuff->nDashes) >> 2) >= client->req_len ) || ((((uint64_t) sizeof(xSetDashesReq) + (stuff->nDashes ) + 3) >> 2) != (uint64_t) client->req_len)) return( 16); | |||
938 | ||||
939 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
940 | client, DixWriteAccess(1<<1)); | |||
941 | if (result != Success0) | |||
942 | return result; | |||
943 | ||||
944 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
945 | stuff->gc = gc->info[j].id; | |||
946 | result = (*SavedProcVector[X_SetDashes58]) (client); | |||
947 | if (result != Success0) | |||
948 | break; | |||
949 | } | |||
950 | ||||
951 | return result; | |||
952 | } | |||
953 | ||||
954 | int | |||
955 | PanoramiXSetClipRectangles(ClientPtr client) | |||
956 | { | |||
957 | PanoramiXRes *gc; | |||
958 | int result, j; | |||
959 | ||||
960 | REQUEST(xSetClipRectanglesReq)xSetClipRectanglesReq *stuff = (xSetClipRectanglesReq *)client ->requestBuffer; | |||
961 | ||||
962 | REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq)if ((sizeof(xSetClipRectanglesReq) >> 2) > client-> req_len ) return(16); | |||
963 | ||||
964 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
965 | client, DixWriteAccess(1<<1)); | |||
966 | if (result != Success0) | |||
967 | return result; | |||
968 | ||||
969 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
970 | stuff->gc = gc->info[j].id; | |||
971 | result = (*SavedProcVector[X_SetClipRectangles59]) (client); | |||
972 | if (result != Success0) | |||
973 | break; | |||
974 | } | |||
975 | ||||
976 | return result; | |||
977 | } | |||
978 | ||||
979 | int | |||
980 | PanoramiXFreeGC(ClientPtr client) | |||
981 | { | |||
982 | PanoramiXRes *gc; | |||
983 | int result, j; | |||
984 | ||||
985 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
986 | ||||
987 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
988 | ||||
989 | result = dixLookupResourceByType((void **) &gc, stuff->id, XRT_GC, | |||
990 | client, DixDestroyAccess(1<<2)); | |||
991 | if (result != Success0) | |||
992 | return result; | |||
993 | ||||
994 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
995 | stuff->id = gc->info[j].id; | |||
996 | result = (*SavedProcVector[X_FreeGC60]) (client); | |||
997 | if (result != Success0) | |||
998 | break; | |||
999 | } | |||
1000 | ||||
1001 | /* Since ProcFreeGC is using FreeResource, it will free | |||
1002 | our resource for us on the last pass through the loop above */ | |||
1003 | ||||
1004 | return result; | |||
1005 | } | |||
1006 | ||||
1007 | int | |||
1008 | PanoramiXClearToBackground(ClientPtr client) | |||
1009 | { | |||
1010 | PanoramiXRes *win; | |||
1011 | int result, j, x, y; | |||
1012 | Bool isRoot; | |||
1013 | ||||
1014 | REQUEST(xClearAreaReq)xClearAreaReq *stuff = (xClearAreaReq *)client->requestBuffer; | |||
1015 | ||||
1016 | REQUEST_SIZE_MATCH(xClearAreaReq)if ((sizeof(xClearAreaReq) >> 2) != client->req_len) return(16); | |||
1017 | ||||
1018 | result = dixLookupResourceByType((void **) &win, stuff->window, | |||
1019 | XRT_WINDOW, client, DixWriteAccess(1<<1)); | |||
1020 | if (result != Success0) | |||
1021 | return result; | |||
1022 | ||||
1023 | x = stuff->x; | |||
1024 | y = stuff->y; | |||
1025 | isRoot = win->u.win.root; | |||
1026 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
1027 | stuff->window = win->info[j].id; | |||
1028 | if (isRoot) { | |||
1029 | stuff->x = x - screenInfo.screens[j]->x; | |||
1030 | stuff->y = y - screenInfo.screens[j]->y; | |||
1031 | } | |||
1032 | result = (*SavedProcVector[X_ClearArea61]) (client); | |||
1033 | if (result != Success0) | |||
1034 | break; | |||
1035 | } | |||
1036 | ||||
1037 | return result; | |||
1038 | } | |||
1039 | ||||
1040 | /* | |||
1041 | For Window to Pixmap copies you're screwed since each screen's | |||
1042 | pixmap will look like what it sees on its screen. Unless the | |||
1043 | screens overlap and the window lies on each, the two copies | |||
1044 | will be out of sync. To remedy this we do a GetImage and PutImage | |||
1045 | in place of the copy. Doing this as a single Image isn't quite | |||
1046 | correct since it will include the obscured areas but we will | |||
1047 | have to fix this later. (MArk). | |||
1048 | */ | |||
1049 | ||||
1050 | int | |||
1051 | PanoramiXCopyArea(ClientPtr client) | |||
1052 | { | |||
1053 | int j, result, srcx, srcy, dstx, dsty; | |||
1054 | PanoramiXRes *gc, *src, *dst; | |||
1055 | Bool srcIsRoot = FALSE0; | |||
1056 | Bool dstIsRoot = FALSE0; | |||
1057 | Bool srcShared, dstShared; | |||
1058 | ||||
1059 | REQUEST(xCopyAreaReq)xCopyAreaReq *stuff = (xCopyAreaReq *)client->requestBuffer; | |||
1060 | ||||
1061 | REQUEST_SIZE_MATCH(xCopyAreaReq)if ((sizeof(xCopyAreaReq) >> 2) != client->req_len) return (16); | |||
1062 | ||||
1063 | result = dixLookupResourceByClass((void **) &src, stuff->srcDrawable, | |||
1064 | XRC_DRAWABLE, client, DixReadAccess(1<<0)); | |||
1065 | if (result != Success0) | |||
1066 | return (result == BadValue2) ? BadDrawable9 : result; | |||
1067 | ||||
1068 | srcShared = IS_SHARED_PIXMAP(src)(((src)->type == XRT_PIXMAP) && (src)->u.pix.shared ); | |||
1069 | ||||
1070 | result = dixLookupResourceByClass((void **) &dst, stuff->dstDrawable, | |||
1071 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
1072 | if (result != Success0) | |||
1073 | return (result == BadValue2) ? BadDrawable9 : result; | |||
1074 | ||||
1075 | dstShared = IS_SHARED_PIXMAP(dst)(((dst)->type == XRT_PIXMAP) && (dst)->u.pix.shared ); | |||
1076 | ||||
1077 | if (dstShared && srcShared) | |||
1078 | return (*SavedProcVector[X_CopyArea62]) (client); | |||
1079 | ||||
1080 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
1081 | client, DixReadAccess(1<<0)); | |||
1082 | if (result != Success0) | |||
1083 | return result; | |||
1084 | ||||
1085 | if ((dst->type == XRT_WINDOW) && dst->u.win.root) | |||
1086 | dstIsRoot = TRUE1; | |||
1087 | if ((src->type == XRT_WINDOW) && src->u.win.root) | |||
1088 | srcIsRoot = TRUE1; | |||
1089 | ||||
1090 | srcx = stuff->srcX; | |||
1091 | srcy = stuff->srcY; | |||
1092 | dstx = stuff->dstX; | |||
1093 | dsty = stuff->dstY; | |||
1094 | if ((dst->type == XRT_PIXMAP) && (src->type == XRT_WINDOW)) { | |||
1095 | DrawablePtr drawables[MAXSCREENS16]; | |||
1096 | DrawablePtr pDst; | |||
1097 | GCPtr pGC; | |||
1098 | char *data; | |||
1099 | int pitch, rc; | |||
1100 | ||||
1101 | FOR_NSCREENS(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
1102 | rc = dixLookupDrawable(drawables + j, src->info[j].id, client, 0, | |||
1103 | DixGetAttrAccess(1<<4)); | |||
1104 | if (rc != Success0) | |||
1105 | return rc; | |||
1106 | } | |||
1107 | ||||
1108 | pitch = PixmapBytePad(stuff->width, drawables[0]->depth)((PixmapWidthPaddingInfo[drawables[0]->depth].notPower2 ? ( ((int)(stuff->width) * PixmapWidthPaddingInfo[drawables[0] ->depth].bytesPerPixel + PixmapWidthPaddingInfo[drawables[ 0]->depth].bytesPerPixel) >> PixmapWidthPaddingInfo[ drawables[0]->depth].padBytesLog2) : ((int)((stuff->width ) + PixmapWidthPaddingInfo[drawables[0]->depth].padRoundUp ) >> PixmapWidthPaddingInfo[drawables[0]->depth].padPixelsLog2 )) << PixmapWidthPaddingInfo[drawables[0]->depth].padBytesLog2 ); | |||
1109 | if (!(data = calloc(1, stuff->height * pitch))) | |||
1110 | return BadAlloc11; | |||
1111 | ||||
1112 | XineramaGetImageData(drawables, srcx, srcy, | |||
1113 | stuff->width, stuff->height, ZPixmap2, ~0, data, | |||
1114 | pitch, srcIsRoot); | |||
1115 | ||||
1116 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
1117 | stuff->gc = gc->info[j].id; | |||
1118 | VALIDATE_DRAWABLE_AND_GC(dst->info[j].id, pDst, DixWriteAccess){ int tmprc = dixLookupDrawable(&(pDst), dst->info[j]. id, client, (-1), (1<<1)); if (tmprc != 0) return tmprc ; tmprc = dixLookupGC(&(pGC), stuff->gc, client, (1<< 24)); if (tmprc != 0) return tmprc; if ((pGC->depth != pDst ->depth) || (pGC->pScreen != pDst->pScreen)) return 8 ; } if (pGC->serialNumber != pDst->serialNumber) ValidateGC (pDst, pGC);; | |||
1119 | if (drawables[0]->depth != pDst->depth) { | |||
1120 | client->errorValue = stuff->dstDrawable; | |||
1121 | free(data); | |||
1122 | return BadMatch8; | |||
1123 | } | |||
1124 | ||||
1125 | (*pGC->ops->PutImage) (pDst, pGC, pDst->depth, dstx, dsty, | |||
1126 | stuff->width, stuff->height, | |||
1127 | 0, ZPixmap2, data); | |||
1128 | ||||
1129 | if (dstShared) | |||
1130 | break; | |||
1131 | } | |||
1132 | ||||
1133 | free(data); | |||
1134 | } | |||
1135 | else { | |||
1136 | DrawablePtr pDst = NULL((void*)0), pSrc = NULL((void*)0); | |||
1137 | GCPtr pGC = NULL((void*)0); | |||
1138 | RegionRec totalReg; | |||
1139 | int rc; | |||
1140 | ||||
1141 | RegionNull(&totalReg); | |||
1142 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
1143 | RegionPtr pRgn; | |||
1144 | ||||
1145 | stuff->dstDrawable = dst->info[j].id; | |||
1146 | stuff->srcDrawable = src->info[j].id; | |||
1147 | stuff->gc = gc->info[j].id; | |||
1148 | if (srcIsRoot) { | |||
1149 | stuff->srcX = srcx - screenInfo.screens[j]->x; | |||
1150 | stuff->srcY = srcy - screenInfo.screens[j]->y; | |||
1151 | } | |||
1152 | if (dstIsRoot) { | |||
1153 | stuff->dstX = dstx - screenInfo.screens[j]->x; | |||
1154 | stuff->dstY = dsty - screenInfo.screens[j]->y; | |||
1155 | } | |||
1156 | ||||
1157 | VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess){ int tmprc = dixLookupDrawable(&(pDst), stuff->dstDrawable , client, (-1), (1<<1)); if (tmprc != 0) return tmprc; tmprc = dixLookupGC(&(pGC), stuff->gc, client, (1<<24 )); if (tmprc != 0) return tmprc; if ((pGC->depth != pDst-> depth) || (pGC->pScreen != pDst->pScreen)) return 8; } if (pGC->serialNumber != pDst->serialNumber) ValidateGC(pDst , pGC);; | |||
1158 | ||||
1159 | if (stuff->dstDrawable != stuff->srcDrawable) { | |||
1160 | rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0, | |||
1161 | DixReadAccess(1<<0)); | |||
1162 | if (rc != Success0) | |||
1163 | return rc; | |||
1164 | ||||
1165 | if ((pDst->pScreen != pSrc->pScreen) || | |||
1166 | (pDst->depth != pSrc->depth)) { | |||
1167 | client->errorValue = stuff->dstDrawable; | |||
1168 | return BadMatch8; | |||
1169 | } | |||
1170 | } | |||
1171 | else | |||
1172 | pSrc = pDst; | |||
1173 | ||||
1174 | pRgn = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, | |||
1175 | stuff->srcX, stuff->srcY, | |||
1176 | stuff->width, stuff->height, | |||
1177 | stuff->dstX, stuff->dstY); | |||
1178 | if (pGC->graphicsExposures && pRgn) { | |||
1179 | if (srcIsRoot) { | |||
1180 | RegionTranslate(pRgn, | |||
1181 | screenInfo.screens[j]->x, | |||
1182 | screenInfo.screens[j]->y); | |||
1183 | } | |||
1184 | RegionAppend(&totalReg, pRgn); | |||
1185 | RegionDestroy(pRgn); | |||
1186 | } | |||
1187 | ||||
1188 | if (dstShared) | |||
1189 | break; | |||
1190 | } | |||
1191 | ||||
1192 | if (pGC->graphicsExposures) { | |||
1193 | Bool overlap; | |||
1194 | ||||
1195 | RegionValidate(&totalReg, &overlap); | |||
1196 | SendGraphicsExpose(client, &totalReg, stuff->dstDrawable, | |||
1197 | X_CopyArea62, 0); | |||
1198 | RegionUninit(&totalReg); | |||
1199 | } | |||
1200 | } | |||
1201 | ||||
1202 | return Success0; | |||
1203 | } | |||
1204 | ||||
1205 | int | |||
1206 | PanoramiXCopyPlane(ClientPtr client) | |||
1207 | { | |||
1208 | int j, srcx, srcy, dstx, dsty, rc; | |||
1209 | PanoramiXRes *gc, *src, *dst; | |||
1210 | Bool srcIsRoot = FALSE0; | |||
1211 | Bool dstIsRoot = FALSE0; | |||
1212 | Bool srcShared, dstShared; | |||
1213 | DrawablePtr psrcDraw, pdstDraw = NULL((void*)0); | |||
1214 | GCPtr pGC = NULL((void*)0); | |||
1215 | RegionRec totalReg; | |||
1216 | ||||
1217 | REQUEST(xCopyPlaneReq)xCopyPlaneReq *stuff = (xCopyPlaneReq *)client->requestBuffer; | |||
1218 | ||||
1219 | REQUEST_SIZE_MATCH(xCopyPlaneReq)if ((sizeof(xCopyPlaneReq) >> 2) != client->req_len) return(16); | |||
1220 | ||||
1221 | rc = dixLookupResourceByClass((void **) &src, stuff->srcDrawable, | |||
1222 | XRC_DRAWABLE, client, DixReadAccess(1<<0)); | |||
1223 | if (rc != Success0) | |||
1224 | return (rc == BadValue2) ? BadDrawable9 : rc; | |||
1225 | ||||
1226 | srcShared = IS_SHARED_PIXMAP(src)(((src)->type == XRT_PIXMAP) && (src)->u.pix.shared ); | |||
1227 | ||||
1228 | rc = dixLookupResourceByClass((void **) &dst, stuff->dstDrawable, | |||
1229 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
1230 | if (rc != Success0) | |||
1231 | return (rc == BadValue2) ? BadDrawable9 : rc; | |||
1232 | ||||
1233 | dstShared = IS_SHARED_PIXMAP(dst)(((dst)->type == XRT_PIXMAP) && (dst)->u.pix.shared ); | |||
1234 | ||||
1235 | if (dstShared && srcShared) | |||
1236 | return (*SavedProcVector[X_CopyPlane63]) (client); | |||
1237 | ||||
1238 | rc = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
1239 | client, DixReadAccess(1<<0)); | |||
1240 | if (rc != Success0) | |||
1241 | return rc; | |||
1242 | ||||
1243 | if ((dst->type == XRT_WINDOW) && dst->u.win.root) | |||
1244 | dstIsRoot = TRUE1; | |||
1245 | if ((src->type == XRT_WINDOW) && src->u.win.root) | |||
1246 | srcIsRoot = TRUE1; | |||
1247 | ||||
1248 | srcx = stuff->srcX; | |||
1249 | srcy = stuff->srcY; | |||
1250 | dstx = stuff->dstX; | |||
1251 | dsty = stuff->dstY; | |||
1252 | ||||
1253 | RegionNull(&totalReg); | |||
1254 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
1255 | RegionPtr pRgn; | |||
1256 | ||||
1257 | stuff->dstDrawable = dst->info[j].id; | |||
1258 | stuff->srcDrawable = src->info[j].id; | |||
1259 | stuff->gc = gc->info[j].id; | |||
1260 | if (srcIsRoot) { | |||
1261 | stuff->srcX = srcx - screenInfo.screens[j]->x; | |||
1262 | stuff->srcY = srcy - screenInfo.screens[j]->y; | |||
1263 | } | |||
1264 | if (dstIsRoot) { | |||
1265 | stuff->dstX = dstx - screenInfo.screens[j]->x; | |||
1266 | stuff->dstY = dsty - screenInfo.screens[j]->y; | |||
1267 | } | |||
1268 | ||||
1269 | VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess){ int tmprc = dixLookupDrawable(&(pdstDraw), stuff->dstDrawable , client, (-1), (1<<1)); if (tmprc != 0) return tmprc; tmprc = dixLookupGC(&(pGC), stuff->gc, client, (1<<24 )); if (tmprc != 0) return tmprc; if ((pGC->depth != pdstDraw ->depth) || (pGC->pScreen != pdstDraw->pScreen)) return 8; } if (pGC->serialNumber != pdstDraw->serialNumber) ValidateGC (pdstDraw, pGC);; | |||
1270 | if (stuff->dstDrawable != stuff->srcDrawable) { | |||
1271 | rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0, | |||
1272 | DixReadAccess(1<<0)); | |||
1273 | if (rc != Success0) | |||
1274 | return rc; | |||
1275 | ||||
1276 | if (pdstDraw->pScreen != psrcDraw->pScreen) { | |||
1277 | client->errorValue = stuff->dstDrawable; | |||
1278 | return BadMatch8; | |||
1279 | } | |||
1280 | } | |||
1281 | else | |||
1282 | psrcDraw = pdstDraw; | |||
1283 | ||||
1284 | if (stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) || | |||
1285 | (stuff->bitPlane > (1L << (psrcDraw->depth - 1)))) { | |||
1286 | client->errorValue = stuff->bitPlane; | |||
1287 | return BadValue2; | |||
1288 | } | |||
1289 | ||||
1290 | pRgn = (*pGC->ops->CopyPlane) (psrcDraw, pdstDraw, pGC, | |||
1291 | stuff->srcX, stuff->srcY, | |||
1292 | stuff->width, stuff->height, | |||
1293 | stuff->dstX, stuff->dstY, | |||
1294 | stuff->bitPlane); | |||
1295 | if (pGC->graphicsExposures && pRgn) { | |||
1296 | RegionAppend(&totalReg, pRgn); | |||
1297 | RegionDestroy(pRgn); | |||
1298 | } | |||
1299 | ||||
1300 | if (dstShared) | |||
1301 | break; | |||
1302 | } | |||
1303 | ||||
1304 | if (pGC->graphicsExposures) { | |||
1305 | Bool overlap; | |||
1306 | ||||
1307 | RegionValidate(&totalReg, &overlap); | |||
1308 | SendGraphicsExpose(client, &totalReg, stuff->dstDrawable, | |||
1309 | X_CopyPlane63, 0); | |||
1310 | RegionUninit(&totalReg); | |||
1311 | } | |||
1312 | ||||
1313 | return Success0; | |||
1314 | } | |||
1315 | ||||
1316 | int | |||
1317 | PanoramiXPolyPoint(ClientPtr client) | |||
1318 | { | |||
1319 | PanoramiXRes *gc, *draw; | |||
1320 | int result, npoint, j; | |||
1321 | xPoint *origPts; | |||
1322 | Bool isRoot; | |||
1323 | ||||
1324 | REQUEST(xPolyPointReq)xPolyPointReq *stuff = (xPolyPointReq *)client->requestBuffer; | |||
1325 | ||||
1326 | REQUEST_AT_LEAST_SIZE(xPolyPointReq)if ((sizeof(xPolyPointReq) >> 2) > client->req_len ) return(16); | |||
1327 | ||||
1328 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
1329 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
1330 | if (result != Success0) | |||
1331 | return (result == BadValue2) ? BadDrawable9 : result; | |||
1332 | ||||
1333 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
1334 | return (*SavedProcVector[X_PolyPoint64]) (client); | |||
1335 | ||||
1336 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
1337 | client, DixReadAccess(1<<0)); | |||
1338 | if (result != Success0) | |||
1339 | return result; | |||
1340 | ||||
1341 | isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; | |||
1342 | npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq)); | |||
1343 | if (npoint > 0) { | |||
1344 | origPts = malloc(npoint * sizeof(xPoint)); | |||
1345 | memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint))__builtin___memcpy_chk ((char *) origPts, (char *) &stuff [1], npoint * sizeof(xPoint), __builtin_object_size ((char *) origPts, 0)); | |||
1346 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
1347 | ||||
1348 | if (j) | |||
1349 | memcpy(&stuff[1], origPts, npoint * sizeof(xPoint))__builtin___memcpy_chk (&stuff[1], origPts, npoint * sizeof (xPoint), __builtin_object_size (&stuff[1], 0)); | |||
1350 | ||||
1351 | if (isRoot) { | |||
1352 | int x_off = screenInfo.screens[j]->x; | |||
1353 | int y_off = screenInfo.screens[j]->y; | |||
1354 | ||||
1355 | if (x_off || y_off) { | |||
1356 | xPoint *pnts = (xPoint *) &stuff[1]; | |||
1357 | int i = | |||
1358 | (stuff->coordMode == CoordModePrevious1) ? 1 : npoint; | |||
1359 | ||||
1360 | while (i--) { | |||
1361 | pnts->x -= x_off; | |||
1362 | pnts->y -= y_off; | |||
1363 | pnts++; | |||
1364 | } | |||
1365 | } | |||
1366 | } | |||
1367 | ||||
1368 | stuff->drawable = draw->info[j].id; | |||
1369 | stuff->gc = gc->info[j].id; | |||
1370 | result = (*SavedProcVector[X_PolyPoint64]) (client); | |||
1371 | if (result != Success0) | |||
1372 | break; | |||
1373 | } | |||
1374 | free(origPts); | |||
1375 | return result; | |||
1376 | } | |||
1377 | else | |||
1378 | return Success0; | |||
1379 | } | |||
1380 | ||||
1381 | int | |||
1382 | PanoramiXPolyLine(ClientPtr client) | |||
1383 | { | |||
1384 | PanoramiXRes *gc, *draw; | |||
1385 | int result, npoint, j; | |||
1386 | xPoint *origPts; | |||
1387 | Bool isRoot; | |||
1388 | ||||
1389 | REQUEST(xPolyLineReq)xPolyLineReq *stuff = (xPolyLineReq *)client->requestBuffer; | |||
1390 | ||||
1391 | REQUEST_AT_LEAST_SIZE(xPolyLineReq)if ((sizeof(xPolyLineReq) >> 2) > client->req_len ) return(16); | |||
1392 | ||||
1393 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
1394 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
1395 | if (result != Success0) | |||
1396 | return (result == BadValue2) ? BadDrawable9 : result; | |||
1397 | ||||
1398 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
1399 | return (*SavedProcVector[X_PolyLine65]) (client); | |||
1400 | ||||
1401 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
1402 | client, DixReadAccess(1<<0)); | |||
1403 | if (result != Success0) | |||
1404 | return result; | |||
1405 | ||||
1406 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
1407 | npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq)); | |||
1408 | if (npoint > 0) { | |||
1409 | origPts = malloc(npoint * sizeof(xPoint)); | |||
1410 | memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint))__builtin___memcpy_chk ((char *) origPts, (char *) &stuff [1], npoint * sizeof(xPoint), __builtin_object_size ((char *) origPts, 0)); | |||
1411 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
1412 | ||||
1413 | if (j) | |||
1414 | memcpy(&stuff[1], origPts, npoint * sizeof(xPoint))__builtin___memcpy_chk (&stuff[1], origPts, npoint * sizeof (xPoint), __builtin_object_size (&stuff[1], 0)); | |||
1415 | ||||
1416 | if (isRoot) { | |||
1417 | int x_off = screenInfo.screens[j]->x; | |||
1418 | int y_off = screenInfo.screens[j]->y; | |||
1419 | ||||
1420 | if (x_off || y_off) { | |||
1421 | xPoint *pnts = (xPoint *) &stuff[1]; | |||
1422 | int i = | |||
1423 | (stuff->coordMode == CoordModePrevious1) ? 1 : npoint; | |||
1424 | ||||
1425 | while (i--) { | |||
1426 | pnts->x -= x_off; | |||
1427 | pnts->y -= y_off; | |||
1428 | pnts++; | |||
1429 | } | |||
1430 | } | |||
1431 | } | |||
1432 | ||||
1433 | stuff->drawable = draw->info[j].id; | |||
1434 | stuff->gc = gc->info[j].id; | |||
1435 | result = (*SavedProcVector[X_PolyLine65]) (client); | |||
1436 | if (result != Success0) | |||
1437 | break; | |||
1438 | } | |||
1439 | free(origPts); | |||
1440 | return result; | |||
1441 | } | |||
1442 | else | |||
1443 | return Success0; | |||
1444 | } | |||
1445 | ||||
1446 | int | |||
1447 | PanoramiXPolySegment(ClientPtr client) | |||
1448 | { | |||
1449 | int result, nsegs, i, j; | |||
1450 | PanoramiXRes *gc, *draw; | |||
1451 | xSegment *origSegs; | |||
1452 | Bool isRoot; | |||
1453 | ||||
1454 | REQUEST(xPolySegmentReq)xPolySegmentReq *stuff = (xPolySegmentReq *)client->requestBuffer; | |||
1455 | ||||
1456 | REQUEST_AT_LEAST_SIZE(xPolySegmentReq)if ((sizeof(xPolySegmentReq) >> 2) > client->req_len ) return(16); | |||
1457 | ||||
1458 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
1459 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
1460 | if (result != Success0) | |||
1461 | return (result == BadValue2) ? BadDrawable9 : result; | |||
1462 | ||||
1463 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
1464 | return (*SavedProcVector[X_PolySegment66]) (client); | |||
1465 | ||||
1466 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
1467 | client, DixReadAccess(1<<0)); | |||
1468 | if (result != Success0) | |||
1469 | return result; | |||
1470 | ||||
1471 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
1472 | ||||
1473 | nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq); | |||
1474 | if (nsegs & 4) | |||
1475 | return BadLength16; | |||
1476 | nsegs >>= 3; | |||
1477 | if (nsegs > 0) { | |||
1478 | origSegs = malloc(nsegs * sizeof(xSegment)); | |||
1479 | memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment))__builtin___memcpy_chk ((char *) origSegs, (char *) &stuff [1], nsegs * sizeof(xSegment), __builtin_object_size ((char * ) origSegs, 0)); | |||
1480 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
1481 | ||||
1482 | if (j) | |||
1483 | memcpy(&stuff[1], origSegs, nsegs * sizeof(xSegment))__builtin___memcpy_chk (&stuff[1], origSegs, nsegs * sizeof (xSegment), __builtin_object_size (&stuff[1], 0)); | |||
1484 | ||||
1485 | if (isRoot) { | |||
1486 | int x_off = screenInfo.screens[j]->x; | |||
1487 | int y_off = screenInfo.screens[j]->y; | |||
1488 | ||||
1489 | if (x_off || y_off) { | |||
1490 | xSegment *segs = (xSegment *) &stuff[1]; | |||
1491 | ||||
1492 | for (i = nsegs; i--; segs++) { | |||
1493 | segs->x1 -= x_off; | |||
1494 | segs->x2 -= x_off; | |||
1495 | segs->y1 -= y_off; | |||
1496 | segs->y2 -= y_off; | |||
1497 | } | |||
1498 | } | |||
1499 | } | |||
1500 | ||||
1501 | stuff->drawable = draw->info[j].id; | |||
1502 | stuff->gc = gc->info[j].id; | |||
1503 | result = (*SavedProcVector[X_PolySegment66]) (client); | |||
1504 | if (result != Success0) | |||
1505 | break; | |||
1506 | } | |||
1507 | free(origSegs); | |||
1508 | return result; | |||
1509 | } | |||
1510 | else | |||
1511 | return Success0; | |||
1512 | } | |||
1513 | ||||
1514 | int | |||
1515 | PanoramiXPolyRectangle(ClientPtr client) | |||
1516 | { | |||
1517 | int result, nrects, i, j; | |||
1518 | PanoramiXRes *gc, *draw; | |||
1519 | Bool isRoot; | |||
1520 | xRectangle *origRecs; | |||
1521 | ||||
1522 | REQUEST(xPolyRectangleReq)xPolyRectangleReq *stuff = (xPolyRectangleReq *)client->requestBuffer; | |||
1523 | ||||
1524 | REQUEST_AT_LEAST_SIZE(xPolyRectangleReq)if ((sizeof(xPolyRectangleReq) >> 2) > client->req_len ) return(16); | |||
1525 | ||||
1526 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
1527 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
1528 | if (result != Success0) | |||
1529 | return (result == BadValue2) ? BadDrawable9 : result; | |||
1530 | ||||
1531 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
1532 | return (*SavedProcVector[X_PolyRectangle67]) (client); | |||
1533 | ||||
1534 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
1535 | client, DixReadAccess(1<<0)); | |||
1536 | if (result != Success0) | |||
1537 | return result; | |||
1538 | ||||
1539 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
1540 | ||||
1541 | nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq); | |||
1542 | if (nrects & 4) | |||
1543 | return BadLength16; | |||
1544 | nrects >>= 3; | |||
1545 | if (nrects > 0) { | |||
1546 | origRecs = malloc(nrects * sizeof(xRectangle)); | |||
1547 | memcpy((char *) origRecs, (char *) &stuff[1],__builtin___memcpy_chk ((char *) origRecs, (char *) &stuff [1], nrects * sizeof(xRectangle), __builtin_object_size ((char *) origRecs, 0)) | |||
1548 | nrects * sizeof(xRectangle))__builtin___memcpy_chk ((char *) origRecs, (char *) &stuff [1], nrects * sizeof(xRectangle), __builtin_object_size ((char *) origRecs, 0)); | |||
1549 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
1550 | ||||
1551 | if (j) | |||
1552 | memcpy(&stuff[1], origRecs, nrects * sizeof(xRectangle))__builtin___memcpy_chk (&stuff[1], origRecs, nrects * sizeof (xRectangle), __builtin_object_size (&stuff[1], 0)); | |||
1553 | ||||
1554 | if (isRoot) { | |||
1555 | int x_off = screenInfo.screens[j]->x; | |||
1556 | int y_off = screenInfo.screens[j]->y; | |||
1557 | ||||
1558 | if (x_off || y_off) { | |||
1559 | xRectangle *rects = (xRectangle *) &stuff[1]; | |||
1560 | ||||
1561 | for (i = nrects; i--; rects++) { | |||
1562 | rects->x -= x_off; | |||
1563 | rects->y -= y_off; | |||
1564 | } | |||
1565 | } | |||
1566 | } | |||
1567 | ||||
1568 | stuff->drawable = draw->info[j].id; | |||
1569 | stuff->gc = gc->info[j].id; | |||
1570 | result = (*SavedProcVector[X_PolyRectangle67]) (client); | |||
1571 | if (result != Success0) | |||
1572 | break; | |||
1573 | } | |||
1574 | free(origRecs); | |||
1575 | return result; | |||
1576 | } | |||
1577 | else | |||
1578 | return Success0; | |||
1579 | } | |||
1580 | ||||
1581 | int | |||
1582 | PanoramiXPolyArc(ClientPtr client) | |||
1583 | { | |||
1584 | int result, narcs, i, j; | |||
1585 | PanoramiXRes *gc, *draw; | |||
1586 | Bool isRoot; | |||
1587 | xArc *origArcs; | |||
1588 | ||||
1589 | REQUEST(xPolyArcReq)xPolyArcReq *stuff = (xPolyArcReq *)client->requestBuffer; | |||
1590 | ||||
1591 | REQUEST_AT_LEAST_SIZE(xPolyArcReq)if ((sizeof(xPolyArcReq) >> 2) > client->req_len ) return(16); | |||
1592 | ||||
1593 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
1594 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
1595 | if (result != Success0) | |||
1596 | return (result == BadValue2) ? BadDrawable9 : result; | |||
1597 | ||||
1598 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
1599 | return (*SavedProcVector[X_PolyArc68]) (client); | |||
1600 | ||||
1601 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
1602 | client, DixReadAccess(1<<0)); | |||
1603 | if (result != Success0) | |||
1604 | return result; | |||
1605 | ||||
1606 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
1607 | ||||
1608 | narcs = (client->req_len << 2) - sizeof(xPolyArcReq); | |||
1609 | if (narcs % sizeof(xArc)) | |||
1610 | return BadLength16; | |||
1611 | narcs /= sizeof(xArc); | |||
1612 | if (narcs > 0) { | |||
1613 | origArcs = malloc(narcs * sizeof(xArc)); | |||
1614 | memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc))__builtin___memcpy_chk ((char *) origArcs, (char *) &stuff [1], narcs * sizeof(xArc), __builtin_object_size ((char *) origArcs , 0)); | |||
1615 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
1616 | ||||
1617 | if (j) | |||
1618 | memcpy(&stuff[1], origArcs, narcs * sizeof(xArc))__builtin___memcpy_chk (&stuff[1], origArcs, narcs * sizeof (xArc), __builtin_object_size (&stuff[1], 0)); | |||
1619 | ||||
1620 | if (isRoot) { | |||
1621 | int x_off = screenInfo.screens[j]->x; | |||
1622 | int y_off = screenInfo.screens[j]->y; | |||
1623 | ||||
1624 | if (x_off || y_off) { | |||
1625 | xArc *arcs = (xArc *) &stuff[1]; | |||
1626 | ||||
1627 | for (i = narcs; i--; arcs++) { | |||
1628 | arcs->x -= x_off; | |||
1629 | arcs->y -= y_off; | |||
1630 | } | |||
1631 | } | |||
1632 | } | |||
1633 | stuff->drawable = draw->info[j].id; | |||
1634 | stuff->gc = gc->info[j].id; | |||
1635 | result = (*SavedProcVector[X_PolyArc68]) (client); | |||
1636 | if (result != Success0) | |||
1637 | break; | |||
1638 | } | |||
1639 | free(origArcs); | |||
1640 | return result; | |||
1641 | } | |||
1642 | else | |||
1643 | return Success0; | |||
1644 | } | |||
1645 | ||||
1646 | int | |||
1647 | PanoramiXFillPoly(ClientPtr client) | |||
1648 | { | |||
1649 | int result, count, j; | |||
1650 | PanoramiXRes *gc, *draw; | |||
1651 | Bool isRoot; | |||
1652 | DDXPointPtr locPts; | |||
1653 | ||||
1654 | REQUEST(xFillPolyReq)xFillPolyReq *stuff = (xFillPolyReq *)client->requestBuffer; | |||
1655 | ||||
1656 | REQUEST_AT_LEAST_SIZE(xFillPolyReq)if ((sizeof(xFillPolyReq) >> 2) > client->req_len ) return(16); | |||
1657 | ||||
1658 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
1659 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
1660 | if (result != Success0) | |||
1661 | return (result == BadValue2) ? BadDrawable9 : result; | |||
1662 | ||||
1663 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
1664 | return (*SavedProcVector[X_FillPoly69]) (client); | |||
1665 | ||||
1666 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
1667 | client, DixReadAccess(1<<0)); | |||
1668 | if (result != Success0) | |||
1669 | return result; | |||
1670 | ||||
1671 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
1672 | ||||
1673 | count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq)); | |||
1674 | if (count > 0) { | |||
1675 | locPts = malloc(count * sizeof(DDXPointRec)); | |||
1676 | memcpy((char *) locPts, (char *) &stuff[1],__builtin___memcpy_chk ((char *) locPts, (char *) &stuff[ 1], count * sizeof(DDXPointRec), __builtin_object_size ((char *) locPts, 0)) | |||
1677 | count * sizeof(DDXPointRec))__builtin___memcpy_chk ((char *) locPts, (char *) &stuff[ 1], count * sizeof(DDXPointRec), __builtin_object_size ((char *) locPts, 0)); | |||
1678 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
1679 | ||||
1680 | if (j) | |||
1681 | memcpy(&stuff[1], locPts, count * sizeof(DDXPointRec))__builtin___memcpy_chk (&stuff[1], locPts, count * sizeof (DDXPointRec), __builtin_object_size (&stuff[1], 0)); | |||
1682 | ||||
1683 | if (isRoot) { | |||
1684 | int x_off = screenInfo.screens[j]->x; | |||
1685 | int y_off = screenInfo.screens[j]->y; | |||
1686 | ||||
1687 | if (x_off || y_off) { | |||
1688 | DDXPointPtr pnts = (DDXPointPtr) &stuff[1]; | |||
1689 | int i = (stuff->coordMode == CoordModePrevious1) ? 1 : count; | |||
1690 | ||||
1691 | while (i--) { | |||
1692 | pnts->x -= x_off; | |||
1693 | pnts->y -= y_off; | |||
1694 | pnts++; | |||
1695 | } | |||
1696 | } | |||
1697 | } | |||
1698 | ||||
1699 | stuff->drawable = draw->info[j].id; | |||
1700 | stuff->gc = gc->info[j].id; | |||
1701 | result = (*SavedProcVector[X_FillPoly69]) (client); | |||
1702 | if (result != Success0) | |||
1703 | break; | |||
1704 | } | |||
1705 | free(locPts); | |||
1706 | return result; | |||
1707 | } | |||
1708 | else | |||
1709 | return Success0; | |||
1710 | } | |||
1711 | ||||
1712 | int | |||
1713 | PanoramiXPolyFillRectangle(ClientPtr client) | |||
1714 | { | |||
1715 | int result, things, i, j; | |||
1716 | PanoramiXRes *gc, *draw; | |||
1717 | Bool isRoot; | |||
1718 | xRectangle *origRects; | |||
1719 | ||||
1720 | REQUEST(xPolyFillRectangleReq)xPolyFillRectangleReq *stuff = (xPolyFillRectangleReq *)client ->requestBuffer; | |||
1721 | ||||
1722 | REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq)if ((sizeof(xPolyFillRectangleReq) >> 2) > client-> req_len ) return(16); | |||
1723 | ||||
1724 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
1725 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
1726 | if (result != Success0) | |||
1727 | return (result == BadValue2) ? BadDrawable9 : result; | |||
1728 | ||||
1729 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
1730 | return (*SavedProcVector[X_PolyFillRectangle70]) (client); | |||
1731 | ||||
1732 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
1733 | client, DixReadAccess(1<<0)); | |||
1734 | if (result != Success0) | |||
1735 | return result; | |||
1736 | ||||
1737 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
1738 | ||||
1739 | things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq); | |||
1740 | if (things & 4) | |||
1741 | return BadLength16; | |||
1742 | things >>= 3; | |||
1743 | if (things > 0) { | |||
1744 | origRects = malloc(things * sizeof(xRectangle)); | |||
1745 | memcpy((char *) origRects, (char *) &stuff[1],__builtin___memcpy_chk ((char *) origRects, (char *) &stuff [1], things * sizeof(xRectangle), __builtin_object_size ((char *) origRects, 0)) | |||
1746 | things * sizeof(xRectangle))__builtin___memcpy_chk ((char *) origRects, (char *) &stuff [1], things * sizeof(xRectangle), __builtin_object_size ((char *) origRects, 0)); | |||
1747 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
1748 | ||||
1749 | if (j) | |||
1750 | memcpy(&stuff[1], origRects, things * sizeof(xRectangle))__builtin___memcpy_chk (&stuff[1], origRects, things * sizeof (xRectangle), __builtin_object_size (&stuff[1], 0)); | |||
1751 | ||||
1752 | if (isRoot) { | |||
1753 | int x_off = screenInfo.screens[j]->x; | |||
1754 | int y_off = screenInfo.screens[j]->y; | |||
1755 | ||||
1756 | if (x_off || y_off) { | |||
1757 | xRectangle *rects = (xRectangle *) &stuff[1]; | |||
1758 | ||||
1759 | for (i = things; i--; rects++) { | |||
1760 | rects->x -= x_off; | |||
1761 | rects->y -= y_off; | |||
1762 | } | |||
1763 | } | |||
1764 | } | |||
1765 | ||||
1766 | stuff->drawable = draw->info[j].id; | |||
1767 | stuff->gc = gc->info[j].id; | |||
1768 | result = (*SavedProcVector[X_PolyFillRectangle70]) (client); | |||
1769 | if (result != Success0) | |||
1770 | break; | |||
1771 | } | |||
1772 | free(origRects); | |||
1773 | return result; | |||
1774 | } | |||
1775 | else | |||
1776 | return Success0; | |||
1777 | } | |||
1778 | ||||
1779 | int | |||
1780 | PanoramiXPolyFillArc(ClientPtr client) | |||
1781 | { | |||
1782 | PanoramiXRes *gc, *draw; | |||
1783 | Bool isRoot; | |||
1784 | int result, narcs, i, j; | |||
1785 | xArc *origArcs; | |||
1786 | ||||
1787 | REQUEST(xPolyFillArcReq)xPolyFillArcReq *stuff = (xPolyFillArcReq *)client->requestBuffer; | |||
1788 | ||||
1789 | REQUEST_AT_LEAST_SIZE(xPolyFillArcReq)if ((sizeof(xPolyFillArcReq) >> 2) > client->req_len ) return(16); | |||
1790 | ||||
1791 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
1792 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
1793 | if (result != Success0) | |||
1794 | return (result == BadValue2) ? BadDrawable9 : result; | |||
1795 | ||||
1796 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
1797 | return (*SavedProcVector[X_PolyFillArc71]) (client); | |||
1798 | ||||
1799 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
1800 | client, DixReadAccess(1<<0)); | |||
1801 | if (result != Success0) | |||
1802 | return result; | |||
1803 | ||||
1804 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
1805 | ||||
1806 | narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq); | |||
1807 | if (narcs % sizeof(xArc)) | |||
1808 | return BadLength16; | |||
1809 | narcs /= sizeof(xArc); | |||
1810 | if (narcs > 0) { | |||
1811 | origArcs = malloc(narcs * sizeof(xArc)); | |||
1812 | memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc))__builtin___memcpy_chk ((char *) origArcs, (char *) &stuff [1], narcs * sizeof(xArc), __builtin_object_size ((char *) origArcs , 0)); | |||
1813 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
1814 | ||||
1815 | if (j) | |||
1816 | memcpy(&stuff[1], origArcs, narcs * sizeof(xArc))__builtin___memcpy_chk (&stuff[1], origArcs, narcs * sizeof (xArc), __builtin_object_size (&stuff[1], 0)); | |||
1817 | ||||
1818 | if (isRoot) { | |||
1819 | int x_off = screenInfo.screens[j]->x; | |||
1820 | int y_off = screenInfo.screens[j]->y; | |||
1821 | ||||
1822 | if (x_off || y_off) { | |||
1823 | xArc *arcs = (xArc *) &stuff[1]; | |||
1824 | ||||
1825 | for (i = narcs; i--; arcs++) { | |||
1826 | arcs->x -= x_off; | |||
1827 | arcs->y -= y_off; | |||
1828 | } | |||
1829 | } | |||
1830 | } | |||
1831 | ||||
1832 | stuff->drawable = draw->info[j].id; | |||
1833 | stuff->gc = gc->info[j].id; | |||
1834 | result = (*SavedProcVector[X_PolyFillArc71]) (client); | |||
1835 | if (result != Success0) | |||
1836 | break; | |||
1837 | } | |||
1838 | free(origArcs); | |||
1839 | return result; | |||
1840 | } | |||
1841 | else | |||
1842 | return Success0; | |||
1843 | } | |||
1844 | ||||
1845 | int | |||
1846 | PanoramiXPutImage(ClientPtr client) | |||
1847 | { | |||
1848 | PanoramiXRes *gc, *draw; | |||
1849 | Bool isRoot; | |||
1850 | int j, result, orig_x, orig_y; | |||
1851 | ||||
1852 | REQUEST(xPutImageReq)xPutImageReq *stuff = (xPutImageReq *)client->requestBuffer; | |||
1853 | ||||
1854 | REQUEST_AT_LEAST_SIZE(xPutImageReq)if ((sizeof(xPutImageReq) >> 2) > client->req_len ) return(16); | |||
1855 | ||||
1856 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
1857 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
1858 | if (result != Success0) | |||
1859 | return (result == BadValue2) ? BadDrawable9 : result; | |||
1860 | ||||
1861 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
1862 | return (*SavedProcVector[X_PutImage72]) (client); | |||
1863 | ||||
1864 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
1865 | client, DixReadAccess(1<<0)); | |||
1866 | if (result != Success0) | |||
1867 | return result; | |||
1868 | ||||
1869 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
1870 | ||||
1871 | orig_x = stuff->dstX; | |||
1872 | orig_y = stuff->dstY; | |||
1873 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
1874 | if (isRoot) { | |||
1875 | stuff->dstX = orig_x - screenInfo.screens[j]->x; | |||
1876 | stuff->dstY = orig_y - screenInfo.screens[j]->y; | |||
1877 | } | |||
1878 | stuff->drawable = draw->info[j].id; | |||
1879 | stuff->gc = gc->info[j].id; | |||
1880 | result = (*SavedProcVector[X_PutImage72]) (client); | |||
1881 | if (result != Success0) | |||
1882 | break; | |||
1883 | } | |||
1884 | return result; | |||
1885 | } | |||
1886 | ||||
1887 | int | |||
1888 | PanoramiXGetImage(ClientPtr client) | |||
1889 | { | |||
1890 | DrawablePtr drawables[MAXSCREENS16]; | |||
1891 | DrawablePtr pDraw; | |||
1892 | PanoramiXRes *draw; | |||
1893 | xGetImageReply xgi; | |||
1894 | Bool isRoot; | |||
1895 | char *pBuf; | |||
1896 | int i, x, y, w, h, format, rc; | |||
1897 | Mask plane = 0, planemask; | |||
1898 | int linesDone, nlines, linesPerBuf; | |||
1899 | long widthBytesLine, length; | |||
1900 | ||||
1901 | REQUEST(xGetImageReq)xGetImageReq *stuff = (xGetImageReq *)client->requestBuffer; | |||
1902 | ||||
1903 | REQUEST_SIZE_MATCH(xGetImageReq)if ((sizeof(xGetImageReq) >> 2) != client->req_len) return (16); | |||
1904 | ||||
1905 | if ((stuff->format != XYPixmap1) && (stuff->format != ZPixmap2)) { | |||
1906 | client->errorValue = stuff->format; | |||
1907 | return BadValue2; | |||
1908 | } | |||
1909 | ||||
1910 | rc = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
1911 | XRC_DRAWABLE, client, DixReadAccess(1<<0)); | |||
1912 | if (rc != Success0) | |||
| ||||
1913 | return (rc == BadValue2) ? BadDrawable9 : rc; | |||
1914 | ||||
1915 | if (draw->type == XRT_PIXMAP) | |||
1916 | return (*SavedProcVector[X_GetImage73]) (client); | |||
1917 | ||||
1918 | rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReadAccess(1<<0)); | |||
1919 | if (rc != Success0) | |||
1920 | return rc; | |||
1921 | ||||
1922 | if (!((WindowPtr) pDraw)->realized) | |||
1923 | return BadMatch8; | |||
1924 | ||||
1925 | x = stuff->x; | |||
1926 | y = stuff->y; | |||
1927 | w = stuff->width; | |||
1928 | h = stuff->height; | |||
1929 | format = stuff->format; | |||
1930 | planemask = stuff->planeMask; | |||
1931 | ||||
1932 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
1933 | ||||
1934 | if (isRoot) { | |||
1935 | /* check for being onscreen */ | |||
1936 | if (x < 0 || x + w > PanoramiXPixWidth || | |||
1937 | y < 0 || y + h > PanoramiXPixHeight) | |||
1938 | return BadMatch8; | |||
1939 | } | |||
1940 | else { | |||
1941 | /* check for being onscreen and inside of border */ | |||
1942 | if (screenInfo.screens[0]->x + pDraw->x + x < 0 || | |||
1943 | screenInfo.screens[0]->x + pDraw->x + x + w > PanoramiXPixWidth || | |||
1944 | screenInfo.screens[0]->y + pDraw->y + y < 0 || | |||
1945 | screenInfo.screens[0]->y + pDraw->y + y + h > PanoramiXPixHeight || | |||
1946 | x < -wBorderWidth((WindowPtr) pDraw)((int) ((WindowPtr) pDraw)->borderWidth) || | |||
1947 | x + w > wBorderWidth((WindowPtr) pDraw)((int) ((WindowPtr) pDraw)->borderWidth) + (int) pDraw->width || | |||
1948 | y < -wBorderWidth((WindowPtr) pDraw)((int) ((WindowPtr) pDraw)->borderWidth) || | |||
1949 | y + h > wBorderWidth((WindowPtr) pDraw)((int) ((WindowPtr) pDraw)->borderWidth) + (int) pDraw->height) | |||
1950 | return BadMatch8; | |||
1951 | } | |||
1952 | ||||
1953 | drawables[0] = pDraw; | |||
1954 | FOR_NSCREENS_FORWARD_SKIP(i)for(i = 1; i < PanoramiXNumScreens; i++) { | |||
1955 | rc = dixLookupDrawable(drawables + i, draw->info[i].id, client, 0, | |||
1956 | DixGetAttrAccess(1<<4)); | |||
1957 | if (rc != Success0) | |||
1958 | return rc; | |||
1959 | } | |||
1960 | ||||
1961 | xgi = (xGetImageReply) { | |||
1962 | .type = X_Reply1, | |||
1963 | .sequenceNumber = client->sequence, | |||
1964 | .visual = wVisual(((WindowPtr) pDraw))((((WindowPtr) pDraw))->optional ? (((WindowPtr) pDraw))-> optional->visual : FindWindowWithOptional(((WindowPtr) pDraw ))->optional->visual), | |||
1965 | .depth = pDraw->depth | |||
1966 | }; | |||
1967 | if (format == ZPixmap2) { | |||
1968 | widthBytesLine = PixmapBytePad(w, pDraw->depth)((PixmapWidthPaddingInfo[pDraw->depth].notPower2 ? (((int) (w) * PixmapWidthPaddingInfo[pDraw->depth].bytesPerPixel + PixmapWidthPaddingInfo[pDraw->depth].bytesPerPixel) >> PixmapWidthPaddingInfo[pDraw->depth].padBytesLog2) : ((int )((w) + PixmapWidthPaddingInfo[pDraw->depth].padRoundUp) >> PixmapWidthPaddingInfo[pDraw->depth].padPixelsLog2)) << PixmapWidthPaddingInfo[pDraw->depth].padBytesLog2); | |||
1969 | length = widthBytesLine * h; | |||
1970 | ||||
1971 | } | |||
1972 | else { | |||
1973 | widthBytesLine = BitmapBytePad(w)(((int)((w) + 32 - 1) >> 5) << 2); | |||
1974 | plane = ((Mask) 1) << (pDraw->depth - 1); | |||
1975 | /* only planes asked for */ | |||
1976 | length = widthBytesLine * h * Ones(planemask & (plane | (plane - 1))); | |||
1977 | ||||
1978 | } | |||
1979 | ||||
1980 | xgi.length = bytes_to_int32(length); | |||
1981 | ||||
1982 | if (widthBytesLine == 0 || h == 0) | |||
1983 | linesPerBuf = 0; | |||
1984 | else if (widthBytesLine >= XINERAMA_IMAGE_BUFSIZE(256*1024)) | |||
1985 | linesPerBuf = 1; | |||
1986 | else { | |||
1987 | linesPerBuf = XINERAMA_IMAGE_BUFSIZE(256*1024) / widthBytesLine; | |||
1988 | if (linesPerBuf > h) | |||
1989 | linesPerBuf = h; | |||
1990 | } | |||
1991 | length = linesPerBuf * widthBytesLine; | |||
1992 | if (!(pBuf = malloc(length))) | |||
| ||||
1993 | return BadAlloc11; | |||
1994 | ||||
1995 | WriteReplyToClient(client, sizeof(xGetImageReply), &xgi){ if ((client)->swapped) (*ReplySwapVector[((xReq *)(client )->requestBuffer)->reqType]) (client, (int)(sizeof(xGetImageReply )), &xgi); else WriteToClient(client, (int)(sizeof(xGetImageReply )), (&xgi)); }; | |||
1996 | ||||
1997 | if (linesPerBuf == 0) { | |||
1998 | /* nothing to do */ | |||
1999 | } | |||
2000 | else if (format == ZPixmap2) { | |||
2001 | linesDone = 0; | |||
2002 | while (h - linesDone > 0) { | |||
2003 | nlines = min(linesPerBuf, h - linesDone)(((linesPerBuf) < (h - linesDone)) ? (linesPerBuf) : (h - linesDone )); | |||
2004 | ||||
2005 | if (pDraw->depth == 1) | |||
2006 | memset(pBuf, 0, nlines * widthBytesLine)__builtin___memset_chk (pBuf, 0, nlines * widthBytesLine, __builtin_object_size (pBuf, 0)); | |||
2007 | ||||
2008 | XineramaGetImageData(drawables, x, y + linesDone, w, nlines, | |||
2009 | format, planemask, pBuf, widthBytesLine, | |||
2010 | isRoot); | |||
2011 | ||||
2012 | WriteToClient(client, (int) (nlines * widthBytesLine), pBuf); | |||
2013 | linesDone += nlines; | |||
2014 | } | |||
2015 | } | |||
2016 | else { /* XYPixmap */ | |||
2017 | for (; plane; plane >>= 1) { | |||
2018 | if (planemask & plane) { | |||
2019 | linesDone = 0; | |||
2020 | while (h - linesDone > 0) { | |||
2021 | nlines = min(linesPerBuf, h - linesDone)(((linesPerBuf) < (h - linesDone)) ? (linesPerBuf) : (h - linesDone )); | |||
2022 | ||||
2023 | memset(pBuf, 0, nlines * widthBytesLine)__builtin___memset_chk (pBuf, 0, nlines * widthBytesLine, __builtin_object_size (pBuf, 0)); | |||
2024 | ||||
2025 | XineramaGetImageData(drawables, x, y + linesDone, w, | |||
2026 | nlines, format, plane, pBuf, | |||
2027 | widthBytesLine, isRoot); | |||
2028 | ||||
2029 | WriteToClient(client, (int)(nlines * widthBytesLine), pBuf); | |||
2030 | ||||
2031 | linesDone += nlines; | |||
2032 | } | |||
2033 | } | |||
2034 | } | |||
2035 | } | |||
2036 | free(pBuf); | |||
2037 | return Success0; | |||
2038 | } | |||
2039 | ||||
2040 | /* The text stuff should be rewritten so that duplication happens | |||
2041 | at the GlyphBlt level. That is, loading the font and getting | |||
2042 | the glyphs should only happen once */ | |||
2043 | ||||
2044 | int | |||
2045 | PanoramiXPolyText8(ClientPtr client) | |||
2046 | { | |||
2047 | PanoramiXRes *gc, *draw; | |||
2048 | Bool isRoot; | |||
2049 | int result, j; | |||
2050 | int orig_x, orig_y; | |||
2051 | ||||
2052 | REQUEST(xPolyTextReq)xPolyTextReq *stuff = (xPolyTextReq *)client->requestBuffer; | |||
2053 | ||||
2054 | REQUEST_AT_LEAST_SIZE(xPolyTextReq)if ((sizeof(xPolyTextReq) >> 2) > client->req_len ) return(16); | |||
2055 | ||||
2056 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
2057 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
2058 | if (result != Success0) | |||
2059 | return (result == BadValue2) ? BadDrawable9 : result; | |||
2060 | ||||
2061 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
2062 | return (*SavedProcVector[X_PolyText874]) (client); | |||
2063 | ||||
2064 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
2065 | client, DixReadAccess(1<<0)); | |||
2066 | if (result != Success0) | |||
2067 | return result; | |||
2068 | ||||
2069 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
2070 | ||||
2071 | orig_x = stuff->x; | |||
2072 | orig_y = stuff->y; | |||
2073 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2074 | stuff->drawable = draw->info[j].id; | |||
2075 | stuff->gc = gc->info[j].id; | |||
2076 | if (isRoot) { | |||
2077 | stuff->x = orig_x - screenInfo.screens[j]->x; | |||
2078 | stuff->y = orig_y - screenInfo.screens[j]->y; | |||
2079 | } | |||
2080 | result = (*SavedProcVector[X_PolyText874]) (client); | |||
2081 | if (result != Success0) | |||
2082 | break; | |||
2083 | } | |||
2084 | return result; | |||
2085 | } | |||
2086 | ||||
2087 | int | |||
2088 | PanoramiXPolyText16(ClientPtr client) | |||
2089 | { | |||
2090 | PanoramiXRes *gc, *draw; | |||
2091 | Bool isRoot; | |||
2092 | int result, j; | |||
2093 | int orig_x, orig_y; | |||
2094 | ||||
2095 | REQUEST(xPolyTextReq)xPolyTextReq *stuff = (xPolyTextReq *)client->requestBuffer; | |||
2096 | ||||
2097 | REQUEST_AT_LEAST_SIZE(xPolyTextReq)if ((sizeof(xPolyTextReq) >> 2) > client->req_len ) return(16); | |||
2098 | ||||
2099 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
2100 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
2101 | if (result != Success0) | |||
2102 | return (result == BadValue2) ? BadDrawable9 : result; | |||
2103 | ||||
2104 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
2105 | return (*SavedProcVector[X_PolyText1675]) (client); | |||
2106 | ||||
2107 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
2108 | client, DixReadAccess(1<<0)); | |||
2109 | if (result != Success0) | |||
2110 | return result; | |||
2111 | ||||
2112 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
2113 | ||||
2114 | orig_x = stuff->x; | |||
2115 | orig_y = stuff->y; | |||
2116 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2117 | stuff->drawable = draw->info[j].id; | |||
2118 | stuff->gc = gc->info[j].id; | |||
2119 | if (isRoot) { | |||
2120 | stuff->x = orig_x - screenInfo.screens[j]->x; | |||
2121 | stuff->y = orig_y - screenInfo.screens[j]->y; | |||
2122 | } | |||
2123 | result = (*SavedProcVector[X_PolyText1675]) (client); | |||
2124 | if (result != Success0) | |||
2125 | break; | |||
2126 | } | |||
2127 | return result; | |||
2128 | } | |||
2129 | ||||
2130 | int | |||
2131 | PanoramiXImageText8(ClientPtr client) | |||
2132 | { | |||
2133 | int result, j; | |||
2134 | PanoramiXRes *gc, *draw; | |||
2135 | Bool isRoot; | |||
2136 | int orig_x, orig_y; | |||
2137 | ||||
2138 | REQUEST(xImageTextReq)xImageTextReq *stuff = (xImageTextReq *)client->requestBuffer; | |||
2139 | ||||
2140 | REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars)if (((sizeof(xImageTextReq) >> 2) > client->req_len ) || (((stuff->nChars) >> 2) >= client->req_len ) || ((((uint64_t) sizeof(xImageTextReq) + (stuff->nChars) + 3) >> 2) != (uint64_t) client->req_len)) return(16 ); | |||
2141 | ||||
2142 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
2143 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
2144 | if (result != Success0) | |||
2145 | return (result == BadValue2) ? BadDrawable9 : result; | |||
2146 | ||||
2147 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
2148 | return (*SavedProcVector[X_ImageText876]) (client); | |||
2149 | ||||
2150 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
2151 | client, DixReadAccess(1<<0)); | |||
2152 | if (result != Success0) | |||
2153 | return result; | |||
2154 | ||||
2155 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
2156 | ||||
2157 | orig_x = stuff->x; | |||
2158 | orig_y = stuff->y; | |||
2159 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2160 | stuff->drawable = draw->info[j].id; | |||
2161 | stuff->gc = gc->info[j].id; | |||
2162 | if (isRoot) { | |||
2163 | stuff->x = orig_x - screenInfo.screens[j]->x; | |||
2164 | stuff->y = orig_y - screenInfo.screens[j]->y; | |||
2165 | } | |||
2166 | result = (*SavedProcVector[X_ImageText876]) (client); | |||
2167 | if (result != Success0) | |||
2168 | break; | |||
2169 | } | |||
2170 | return result; | |||
2171 | } | |||
2172 | ||||
2173 | int | |||
2174 | PanoramiXImageText16(ClientPtr client) | |||
2175 | { | |||
2176 | int result, j; | |||
2177 | PanoramiXRes *gc, *draw; | |||
2178 | Bool isRoot; | |||
2179 | int orig_x, orig_y; | |||
2180 | ||||
2181 | REQUEST(xImageTextReq)xImageTextReq *stuff = (xImageTextReq *)client->requestBuffer; | |||
2182 | ||||
2183 | REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1)if (((sizeof(xImageTextReq) >> 2) > client->req_len ) || (((stuff->nChars << 1) >> 2) >= client ->req_len) || ((((uint64_t) sizeof(xImageTextReq) + (stuff ->nChars << 1) + 3) >> 2) != (uint64_t) client ->req_len)) return(16); | |||
2184 | ||||
2185 | result = dixLookupResourceByClass((void **) &draw, stuff->drawable, | |||
2186 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
2187 | if (result != Success0) | |||
2188 | return (result == BadValue2) ? BadDrawable9 : result; | |||
2189 | ||||
2190 | if (IS_SHARED_PIXMAP(draw)(((draw)->type == XRT_PIXMAP) && (draw)->u.pix. shared)) | |||
2191 | return (*SavedProcVector[X_ImageText1677]) (client); | |||
2192 | ||||
2193 | result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC, | |||
2194 | client, DixReadAccess(1<<0)); | |||
2195 | if (result != Success0) | |||
2196 | return result; | |||
2197 | ||||
2198 | isRoot = IS_ROOT_DRAWABLE(draw)(((draw)->type == XRT_WINDOW) && (draw)->u.win. root); | |||
2199 | ||||
2200 | orig_x = stuff->x; | |||
2201 | orig_y = stuff->y; | |||
2202 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2203 | stuff->drawable = draw->info[j].id; | |||
2204 | stuff->gc = gc->info[j].id; | |||
2205 | if (isRoot) { | |||
2206 | stuff->x = orig_x - screenInfo.screens[j]->x; | |||
2207 | stuff->y = orig_y - screenInfo.screens[j]->y; | |||
2208 | } | |||
2209 | result = (*SavedProcVector[X_ImageText1677]) (client); | |||
2210 | if (result != Success0) | |||
2211 | break; | |||
2212 | } | |||
2213 | return result; | |||
2214 | } | |||
2215 | ||||
2216 | int | |||
2217 | PanoramiXCreateColormap(ClientPtr client) | |||
2218 | { | |||
2219 | PanoramiXRes *win, *newCmap; | |||
2220 | int result, j, orig_visual; | |||
2221 | ||||
2222 | REQUEST(xCreateColormapReq)xCreateColormapReq *stuff = (xCreateColormapReq *)client-> requestBuffer; | |||
2223 | ||||
2224 | REQUEST_SIZE_MATCH(xCreateColormapReq)if ((sizeof(xCreateColormapReq) >> 2) != client->req_len ) return(16); | |||
2225 | ||||
2226 | result = dixLookupResourceByType((void **) &win, stuff->window, | |||
2227 | XRT_WINDOW, client, DixReadAccess(1<<0)); | |||
2228 | if (result != Success0) | |||
2229 | return result; | |||
2230 | ||||
2231 | if (!(newCmap = malloc(sizeof(PanoramiXRes)))) | |||
2232 | return BadAlloc11; | |||
2233 | ||||
2234 | newCmap->type = XRT_COLORMAP; | |||
2235 | panoramix_setup_ids(newCmap, client, stuff->mid); | |||
2236 | ||||
2237 | orig_visual = stuff->visual; | |||
2238 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2239 | stuff->mid = newCmap->info[j].id; | |||
2240 | stuff->window = win->info[j].id; | |||
2241 | stuff->visual = PanoramiXTranslateVisualID(j, orig_visual); | |||
2242 | result = (*SavedProcVector[X_CreateColormap78]) (client); | |||
2243 | if (result != Success0) | |||
2244 | break; | |||
2245 | } | |||
2246 | ||||
2247 | if (result == Success0) | |||
2248 | AddResourceDarwin_X_AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap); | |||
2249 | else | |||
2250 | free(newCmap); | |||
2251 | ||||
2252 | return result; | |||
2253 | } | |||
2254 | ||||
2255 | int | |||
2256 | PanoramiXFreeColormap(ClientPtr client) | |||
2257 | { | |||
2258 | PanoramiXRes *cmap; | |||
2259 | int result, j; | |||
2260 | ||||
2261 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
2262 | ||||
2263 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
2264 | ||||
2265 | client->errorValue = stuff->id; | |||
2266 | ||||
2267 | result = dixLookupResourceByType((void **) &cmap, stuff->id, XRT_COLORMAP, | |||
2268 | client, DixDestroyAccess(1<<2)); | |||
2269 | if (result != Success0) | |||
2270 | return result; | |||
2271 | ||||
2272 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2273 | stuff->id = cmap->info[j].id; | |||
2274 | result = (*SavedProcVector[X_FreeColormap79]) (client); | |||
2275 | if (result != Success0) | |||
2276 | break; | |||
2277 | } | |||
2278 | ||||
2279 | /* Since ProcFreeColormap is using FreeResource, it will free | |||
2280 | our resource for us on the last pass through the loop above */ | |||
2281 | ||||
2282 | return result; | |||
2283 | } | |||
2284 | ||||
2285 | int | |||
2286 | PanoramiXCopyColormapAndFree(ClientPtr client) | |||
2287 | { | |||
2288 | PanoramiXRes *cmap, *newCmap; | |||
2289 | int result, j; | |||
2290 | ||||
2291 | REQUEST(xCopyColormapAndFreeReq)xCopyColormapAndFreeReq *stuff = (xCopyColormapAndFreeReq *)client ->requestBuffer; | |||
2292 | ||||
2293 | REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq)if ((sizeof(xCopyColormapAndFreeReq) >> 2) != client-> req_len) return(16); | |||
2294 | ||||
2295 | client->errorValue = stuff->srcCmap; | |||
2296 | ||||
2297 | result = dixLookupResourceByType((void **) &cmap, stuff->srcCmap, | |||
2298 | XRT_COLORMAP, client, | |||
2299 | DixReadAccess(1<<0) | DixWriteAccess(1<<1)); | |||
2300 | if (result != Success0) | |||
2301 | return result; | |||
2302 | ||||
2303 | if (!(newCmap = malloc(sizeof(PanoramiXRes)))) | |||
2304 | return BadAlloc11; | |||
2305 | ||||
2306 | newCmap->type = XRT_COLORMAP; | |||
2307 | panoramix_setup_ids(newCmap, client, stuff->mid); | |||
2308 | ||||
2309 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2310 | stuff->srcCmap = cmap->info[j].id; | |||
2311 | stuff->mid = newCmap->info[j].id; | |||
2312 | result = (*SavedProcVector[X_CopyColormapAndFree80]) (client); | |||
2313 | if (result != Success0) | |||
2314 | break; | |||
2315 | } | |||
2316 | ||||
2317 | if (result == Success0) | |||
2318 | AddResourceDarwin_X_AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap); | |||
2319 | else | |||
2320 | free(newCmap); | |||
2321 | ||||
2322 | return result; | |||
2323 | } | |||
2324 | ||||
2325 | int | |||
2326 | PanoramiXInstallColormap(ClientPtr client) | |||
2327 | { | |||
2328 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
2329 | int result, j; | |||
2330 | PanoramiXRes *cmap; | |||
2331 | ||||
2332 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
2333 | ||||
2334 | client->errorValue = stuff->id; | |||
2335 | ||||
2336 | result = dixLookupResourceByType((void **) &cmap, stuff->id, XRT_COLORMAP, | |||
2337 | client, DixReadAccess(1<<0)); | |||
2338 | if (result != Success0) | |||
2339 | return result; | |||
2340 | ||||
2341 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2342 | stuff->id = cmap->info[j].id; | |||
2343 | result = (*SavedProcVector[X_InstallColormap81]) (client); | |||
2344 | if (result != Success0) | |||
2345 | break; | |||
2346 | } | |||
2347 | return result; | |||
2348 | } | |||
2349 | ||||
2350 | int | |||
2351 | PanoramiXUninstallColormap(ClientPtr client) | |||
2352 | { | |||
2353 | REQUEST(xResourceReq)xResourceReq *stuff = (xResourceReq *)client->requestBuffer; | |||
2354 | int result, j; | |||
2355 | PanoramiXRes *cmap; | |||
2356 | ||||
2357 | REQUEST_SIZE_MATCH(xResourceReq)if ((sizeof(xResourceReq) >> 2) != client->req_len) return (16); | |||
2358 | ||||
2359 | client->errorValue = stuff->id; | |||
2360 | ||||
2361 | result = dixLookupResourceByType((void **) &cmap, stuff->id, XRT_COLORMAP, | |||
2362 | client, DixReadAccess(1<<0)); | |||
2363 | if (result != Success0) | |||
2364 | return result; | |||
2365 | ||||
2366 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2367 | stuff->id = cmap->info[j].id; | |||
2368 | result = (*SavedProcVector[X_UninstallColormap82]) (client); | |||
2369 | if (result != Success0) | |||
2370 | break; | |||
2371 | } | |||
2372 | return result; | |||
2373 | } | |||
2374 | ||||
2375 | int | |||
2376 | PanoramiXAllocColor(ClientPtr client) | |||
2377 | { | |||
2378 | int result, j; | |||
2379 | PanoramiXRes *cmap; | |||
2380 | ||||
2381 | REQUEST(xAllocColorReq)xAllocColorReq *stuff = (xAllocColorReq *)client->requestBuffer; | |||
2382 | ||||
2383 | REQUEST_SIZE_MATCH(xAllocColorReq)if ((sizeof(xAllocColorReq) >> 2) != client->req_len ) return(16); | |||
2384 | ||||
2385 | client->errorValue = stuff->cmap; | |||
2386 | ||||
2387 | result = dixLookupResourceByType((void **) &cmap, stuff->cmap, | |||
2388 | XRT_COLORMAP, client, DixWriteAccess(1<<1)); | |||
2389 | if (result != Success0) | |||
2390 | return result; | |||
2391 | ||||
2392 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2393 | stuff->cmap = cmap->info[j].id; | |||
2394 | result = (*SavedProcVector[X_AllocColor84]) (client); | |||
2395 | if (result != Success0) | |||
2396 | break; | |||
2397 | } | |||
2398 | return result; | |||
2399 | } | |||
2400 | ||||
2401 | int | |||
2402 | PanoramiXAllocNamedColor(ClientPtr client) | |||
2403 | { | |||
2404 | int result, j; | |||
2405 | PanoramiXRes *cmap; | |||
2406 | ||||
2407 | REQUEST(xAllocNamedColorReq)xAllocNamedColorReq *stuff = (xAllocNamedColorReq *)client-> requestBuffer; | |||
2408 | ||||
2409 | REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes)if (((sizeof(xAllocNamedColorReq) >> 2) > client-> req_len) || (((stuff->nbytes) >> 2) >= client-> req_len) || ((((uint64_t) sizeof(xAllocNamedColorReq) + (stuff ->nbytes) + 3) >> 2) != (uint64_t) client->req_len )) return(16); | |||
2410 | ||||
2411 | client->errorValue = stuff->cmap; | |||
2412 | ||||
2413 | result = dixLookupResourceByType((void **) &cmap, stuff->cmap, | |||
2414 | XRT_COLORMAP, client, DixWriteAccess(1<<1)); | |||
2415 | if (result != Success0) | |||
2416 | return result; | |||
2417 | ||||
2418 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2419 | stuff->cmap = cmap->info[j].id; | |||
2420 | result = (*SavedProcVector[X_AllocNamedColor85]) (client); | |||
2421 | if (result != Success0) | |||
2422 | break; | |||
2423 | } | |||
2424 | return result; | |||
2425 | } | |||
2426 | ||||
2427 | int | |||
2428 | PanoramiXAllocColorCells(ClientPtr client) | |||
2429 | { | |||
2430 | int result, j; | |||
2431 | PanoramiXRes *cmap; | |||
2432 | ||||
2433 | REQUEST(xAllocColorCellsReq)xAllocColorCellsReq *stuff = (xAllocColorCellsReq *)client-> requestBuffer; | |||
2434 | ||||
2435 | REQUEST_SIZE_MATCH(xAllocColorCellsReq)if ((sizeof(xAllocColorCellsReq) >> 2) != client->req_len ) return(16); | |||
2436 | ||||
2437 | client->errorValue = stuff->cmap; | |||
2438 | ||||
2439 | result = dixLookupResourceByType((void **) &cmap, stuff->cmap, | |||
2440 | XRT_COLORMAP, client, DixWriteAccess(1<<1)); | |||
2441 | if (result != Success0) | |||
2442 | return result; | |||
2443 | ||||
2444 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2445 | stuff->cmap = cmap->info[j].id; | |||
2446 | result = (*SavedProcVector[X_AllocColorCells86]) (client); | |||
2447 | if (result != Success0) | |||
2448 | break; | |||
2449 | } | |||
2450 | return result; | |||
2451 | } | |||
2452 | ||||
2453 | int | |||
2454 | PanoramiXAllocColorPlanes(ClientPtr client) | |||
2455 | { | |||
2456 | int result, j; | |||
2457 | PanoramiXRes *cmap; | |||
2458 | ||||
2459 | REQUEST(xAllocColorPlanesReq)xAllocColorPlanesReq *stuff = (xAllocColorPlanesReq *)client-> requestBuffer; | |||
2460 | ||||
2461 | REQUEST_SIZE_MATCH(xAllocColorPlanesReq)if ((sizeof(xAllocColorPlanesReq) >> 2) != client->req_len ) return(16); | |||
2462 | ||||
2463 | client->errorValue = stuff->cmap; | |||
2464 | ||||
2465 | result = dixLookupResourceByType((void **) &cmap, stuff->cmap, | |||
2466 | XRT_COLORMAP, client, DixWriteAccess(1<<1)); | |||
2467 | if (result != Success0) | |||
2468 | return result; | |||
2469 | ||||
2470 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2471 | stuff->cmap = cmap->info[j].id; | |||
2472 | result = (*SavedProcVector[X_AllocColorPlanes87]) (client); | |||
2473 | if (result != Success0) | |||
2474 | break; | |||
2475 | } | |||
2476 | return result; | |||
2477 | } | |||
2478 | ||||
2479 | int | |||
2480 | PanoramiXFreeColors(ClientPtr client) | |||
2481 | { | |||
2482 | int result, j; | |||
2483 | PanoramiXRes *cmap; | |||
2484 | ||||
2485 | REQUEST(xFreeColorsReq)xFreeColorsReq *stuff = (xFreeColorsReq *)client->requestBuffer; | |||
2486 | ||||
2487 | REQUEST_AT_LEAST_SIZE(xFreeColorsReq)if ((sizeof(xFreeColorsReq) >> 2) > client->req_len ) return(16); | |||
2488 | ||||
2489 | client->errorValue = stuff->cmap; | |||
2490 | ||||
2491 | result = dixLookupResourceByType((void **) &cmap, stuff->cmap, | |||
2492 | XRT_COLORMAP, client, DixWriteAccess(1<<1)); | |||
2493 | if (result != Success0) | |||
2494 | return result; | |||
2495 | ||||
2496 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2497 | stuff->cmap = cmap->info[j].id; | |||
2498 | result = (*SavedProcVector[X_FreeColors88]) (client); | |||
2499 | } | |||
2500 | return result; | |||
2501 | } | |||
2502 | ||||
2503 | int | |||
2504 | PanoramiXStoreColors(ClientPtr client) | |||
2505 | { | |||
2506 | int result, j; | |||
2507 | PanoramiXRes *cmap; | |||
2508 | ||||
2509 | REQUEST(xStoreColorsReq)xStoreColorsReq *stuff = (xStoreColorsReq *)client->requestBuffer; | |||
2510 | ||||
2511 | REQUEST_AT_LEAST_SIZE(xStoreColorsReq)if ((sizeof(xStoreColorsReq) >> 2) > client->req_len ) return(16); | |||
2512 | ||||
2513 | client->errorValue = stuff->cmap; | |||
2514 | ||||
2515 | result = dixLookupResourceByType((void **) &cmap, stuff->cmap, | |||
2516 | XRT_COLORMAP, client, DixWriteAccess(1<<1)); | |||
2517 | if (result != Success0) | |||
2518 | return result; | |||
2519 | ||||
2520 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2521 | stuff->cmap = cmap->info[j].id; | |||
2522 | result = (*SavedProcVector[X_StoreColors89]) (client); | |||
2523 | if (result != Success0) | |||
2524 | break; | |||
2525 | } | |||
2526 | return result; | |||
2527 | } | |||
2528 | ||||
2529 | int | |||
2530 | PanoramiXStoreNamedColor(ClientPtr client) | |||
2531 | { | |||
2532 | int result, j; | |||
2533 | PanoramiXRes *cmap; | |||
2534 | ||||
2535 | REQUEST(xStoreNamedColorReq)xStoreNamedColorReq *stuff = (xStoreNamedColorReq *)client-> requestBuffer; | |||
2536 | ||||
2537 | REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes)if (((sizeof(xStoreNamedColorReq) >> 2) > client-> req_len) || (((stuff->nbytes) >> 2) >= client-> req_len) || ((((uint64_t) sizeof(xStoreNamedColorReq) + (stuff ->nbytes) + 3) >> 2) != (uint64_t) client->req_len )) return(16); | |||
2538 | ||||
2539 | client->errorValue = stuff->cmap; | |||
2540 | ||||
2541 | result = dixLookupResourceByType((void **) &cmap, stuff->cmap, | |||
2542 | XRT_COLORMAP, client, DixWriteAccess(1<<1)); | |||
2543 | if (result != Success0) | |||
2544 | return result; | |||
2545 | ||||
2546 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2547 | stuff->cmap = cmap->info[j].id; | |||
2548 | result = (*SavedProcVector[X_StoreNamedColor90]) (client); | |||
2549 | if (result != Success0) | |||
2550 | break; | |||
2551 | } | |||
2552 | return result; | |||
2553 | } |