File: | composite/compext.c |
Location: | line 320, column 49 |
Description: | Dereference of null pointer |
1 | /* | |||
2 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. | |||
3 | * | |||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | |||
5 | * copy of this software and associated documentation files (the "Software"), | |||
6 | * to deal in the Software without restriction, including without limitation | |||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
8 | * and/or sell copies of the Software, and to permit persons to whom the | |||
9 | * Software is furnished to do so, subject to the following conditions: | |||
10 | * | |||
11 | * The above copyright notice and this permission notice (including the next | |||
12 | * paragraph) shall be included in all copies or substantial portions of the | |||
13 | * Software. | |||
14 | * | |||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |||
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |||
21 | * DEALINGS IN THE SOFTWARE. | |||
22 | * | |||
23 | * Copyright © 2003 Keith Packard | |||
24 | * | |||
25 | * Permission to use, copy, modify, distribute, and sell this software and its | |||
26 | * documentation for any purpose is hereby granted without fee, provided that | |||
27 | * the above copyright notice appear in all copies and that both that | |||
28 | * copyright notice and this permission notice appear in supporting | |||
29 | * documentation, and that the name of Keith Packard not be used in | |||
30 | * advertising or publicity pertaining to distribution of the software without | |||
31 | * specific, written prior permission. Keith Packard makes no | |||
32 | * representations about the suitability of this software for any purpose. It | |||
33 | * is provided "as is" without express or implied warranty. | |||
34 | * | |||
35 | * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | |||
36 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | |||
37 | * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR | |||
38 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | |||
39 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | |||
40 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |||
41 | * PERFORMANCE OF THIS SOFTWARE. | |||
42 | */ | |||
43 | ||||
44 | #ifdef HAVE_DIX_CONFIG_H1 | |||
45 | #include <dix-config.h> | |||
46 | #endif | |||
47 | ||||
48 | #include "compint.h" | |||
49 | #include "xace.h" | |||
50 | #include "protocol-versions.h" | |||
51 | #include "extinit.h" | |||
52 | ||||
53 | static CARD8 CompositeReqCode; | |||
54 | static DevPrivateKeyRec CompositeClientPrivateKeyRec; | |||
55 | ||||
56 | #define CompositeClientPrivateKey(&CompositeClientPrivateKeyRec) (&CompositeClientPrivateKeyRec) | |||
57 | RESTYPE CompositeClientWindowType; | |||
58 | RESTYPE CompositeClientSubwindowsType; | |||
59 | RESTYPE CompositeClientOverlayType; | |||
60 | ||||
61 | typedef struct _CompositeClient { | |||
62 | int major_version; | |||
63 | int minor_version; | |||
64 | } CompositeClientRec, *CompositeClientPtr; | |||
65 | ||||
66 | #define GetCompositeClient(pClient)((CompositeClientPtr) dixLookupPrivate(&(pClient)->devPrivates , (&CompositeClientPrivateKeyRec))) ((CompositeClientPtr) \ | |||
67 | dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey(&CompositeClientPrivateKeyRec))) | |||
68 | ||||
69 | static void | |||
70 | CompositeClientCallback(CallbackListPtr *list, void *closure, void *data) | |||
71 | { | |||
72 | NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; | |||
73 | ClientPtr pClient = clientinfo->client; | |||
74 | CompositeClientPtr pCompositeClient = GetCompositeClient(pClient)((CompositeClientPtr) dixLookupPrivate(&(pClient)->devPrivates , (&CompositeClientPrivateKeyRec))); | |||
75 | ||||
76 | pCompositeClient->major_version = 0; | |||
77 | pCompositeClient->minor_version = 0; | |||
78 | } | |||
79 | ||||
80 | static int | |||
81 | FreeCompositeClientWindow(void *value, XID ccwid) | |||
82 | { | |||
83 | WindowPtr pWin = value; | |||
84 | ||||
85 | compFreeClientWindow(pWin, ccwid); | |||
86 | return Success0; | |||
87 | } | |||
88 | ||||
89 | static int | |||
90 | FreeCompositeClientSubwindows(void *value, XID ccwid) | |||
91 | { | |||
92 | WindowPtr pWin = value; | |||
93 | ||||
94 | compFreeClientSubwindows(pWin, ccwid); | |||
95 | return Success0; | |||
96 | } | |||
97 | ||||
98 | static int | |||
99 | FreeCompositeClientOverlay(void *value, XID ccwid) | |||
100 | { | |||
101 | CompOverlayClientPtr pOc = (CompOverlayClientPtr) value; | |||
102 | ||||
103 | compFreeOverlayClient(pOc); | |||
104 | return Success0; | |||
105 | } | |||
106 | ||||
107 | static int | |||
108 | ProcCompositeQueryVersion(ClientPtr client) | |||
109 | { | |||
110 | CompositeClientPtr pCompositeClient = GetCompositeClient(client)((CompositeClientPtr) dixLookupPrivate(&(client)->devPrivates , (&CompositeClientPrivateKeyRec))); | |||
111 | xCompositeQueryVersionReply rep = { | |||
112 | .type = X_Reply1, | |||
113 | .sequenceNumber = client->sequence, | |||
114 | .length = 0 | |||
115 | }; | |||
116 | ||||
117 | REQUEST(xCompositeQueryVersionReq)xCompositeQueryVersionReq *stuff = (xCompositeQueryVersionReq *)client->requestBuffer; | |||
118 | ||||
119 | REQUEST_SIZE_MATCH(xCompositeQueryVersionReq)if ((sizeof(xCompositeQueryVersionReq) >> 2) != client-> req_len) return(16); | |||
120 | if (stuff->majorVersion < SERVER_COMPOSITE_MAJOR_VERSION0) { | |||
121 | rep.majorVersion = stuff->majorVersion; | |||
122 | rep.minorVersion = stuff->minorVersion; | |||
123 | } | |||
124 | else { | |||
125 | rep.majorVersion = SERVER_COMPOSITE_MAJOR_VERSION0; | |||
126 | rep.minorVersion = SERVER_COMPOSITE_MINOR_VERSION4; | |||
127 | } | |||
128 | pCompositeClient->major_version = rep.majorVersion; | |||
129 | pCompositeClient->minor_version = rep.minorVersion; | |||
130 | if (client->swapped) { | |||
131 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
132 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
133 | swapl(&rep.majorVersion)do { if (sizeof(*(&rep.majorVersion)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.majorVersion) & 3) && ((uintptr_t)(&rep.majorVersion) & 3) == 0) *(&rep.majorVersion) = lswapl(*(&rep.majorVersion )); else swap_uint32((uint32_t *)(&rep.majorVersion)); } while (0); | |||
134 | swapl(&rep.minorVersion)do { if (sizeof(*(&rep.minorVersion)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.minorVersion) & 3) && ((uintptr_t)(&rep.minorVersion) & 3) == 0) *(&rep.minorVersion) = lswapl(*(&rep.minorVersion )); else swap_uint32((uint32_t *)(&rep.minorVersion)); } while (0); | |||
135 | } | |||
136 | WriteToClient(client, sizeof(xCompositeQueryVersionReply), &rep); | |||
137 | return Success0; | |||
138 | } | |||
139 | ||||
140 | #define VERIFY_WINDOW(pWindow, wid, client, mode)do { int err; err = dixLookupResourceByType((void **) &pWindow , wid, ((RESTYPE)1|((RESTYPE)1<<30)), client, mode); if (err != 0) { client->errorValue = wid; return err; } } while (0) \ | |||
141 | do { \ | |||
142 | int err; \ | |||
143 | err = dixLookupResourceByType((void **) &pWindow, wid, \ | |||
144 | RT_WINDOW((RESTYPE)1|((RESTYPE)1<<30)), client, mode); \ | |||
145 | if (err != Success0) { \ | |||
146 | client->errorValue = wid; \ | |||
147 | return err; \ | |||
148 | } \ | |||
149 | } while (0) | |||
150 | ||||
151 | static int | |||
152 | ProcCompositeRedirectWindow(ClientPtr client) | |||
153 | { | |||
154 | WindowPtr pWin; | |||
155 | ||||
156 | REQUEST(xCompositeRedirectWindowReq)xCompositeRedirectWindowReq *stuff = (xCompositeRedirectWindowReq *)client->requestBuffer; | |||
157 | ||||
158 | REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq)if ((sizeof(xCompositeRedirectWindowReq) >> 2) != client ->req_len) return(16); | |||
159 | VERIFY_WINDOW(pWin, stuff->window, client,do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<5) | (1<<25) | (1<<16)); if (err != 0 ) { client->errorValue = stuff->window; return err; } } while (0) | |||
160 | DixSetAttrAccess | DixManageAccess | DixBlendAccess)do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<5) | (1<<25) | (1<<16)); if (err != 0 ) { client->errorValue = stuff->window; return err; } } while (0); | |||
161 | ||||
162 | return compRedirectWindow(client, pWin, stuff->update); | |||
163 | } | |||
164 | ||||
165 | static int | |||
166 | ProcCompositeRedirectSubwindows(ClientPtr client) | |||
167 | { | |||
168 | WindowPtr pWin; | |||
169 | ||||
170 | REQUEST(xCompositeRedirectSubwindowsReq)xCompositeRedirectSubwindowsReq *stuff = (xCompositeRedirectSubwindowsReq *)client->requestBuffer; | |||
171 | ||||
172 | REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq)if ((sizeof(xCompositeRedirectSubwindowsReq) >> 2) != client ->req_len) return(16); | |||
173 | VERIFY_WINDOW(pWin, stuff->window, client,do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<5) | (1<<25) | (1<<16)); if (err != 0 ) { client->errorValue = stuff->window; return err; } } while (0) | |||
174 | DixSetAttrAccess | DixManageAccess | DixBlendAccess)do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<5) | (1<<25) | (1<<16)); if (err != 0 ) { client->errorValue = stuff->window; return err; } } while (0); | |||
175 | ||||
176 | return compRedirectSubwindows(client, pWin, stuff->update); | |||
177 | } | |||
178 | ||||
179 | static int | |||
180 | ProcCompositeUnredirectWindow(ClientPtr client) | |||
181 | { | |||
182 | WindowPtr pWin; | |||
183 | ||||
184 | REQUEST(xCompositeUnredirectWindowReq)xCompositeUnredirectWindowReq *stuff = (xCompositeUnredirectWindowReq *)client->requestBuffer; | |||
185 | ||||
186 | REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq)if ((sizeof(xCompositeUnredirectWindowReq) >> 2) != client ->req_len) return(16); | |||
187 | VERIFY_WINDOW(pWin, stuff->window, client,do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<5) | (1<<25) | (1<<16)); if (err != 0 ) { client->errorValue = stuff->window; return err; } } while (0) | |||
188 | DixSetAttrAccess | DixManageAccess | DixBlendAccess)do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<5) | (1<<25) | (1<<16)); if (err != 0 ) { client->errorValue = stuff->window; return err; } } while (0); | |||
189 | ||||
190 | return compUnredirectWindow(client, pWin, stuff->update); | |||
191 | } | |||
192 | ||||
193 | static int | |||
194 | ProcCompositeUnredirectSubwindows(ClientPtr client) | |||
195 | { | |||
196 | WindowPtr pWin; | |||
197 | ||||
198 | REQUEST(xCompositeUnredirectSubwindowsReq)xCompositeUnredirectSubwindowsReq *stuff = (xCompositeUnredirectSubwindowsReq *)client->requestBuffer; | |||
199 | ||||
200 | REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq)if ((sizeof(xCompositeUnredirectSubwindowsReq) >> 2) != client->req_len) return(16); | |||
201 | VERIFY_WINDOW(pWin, stuff->window, client,do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<5) | (1<<25) | (1<<16)); if (err != 0 ) { client->errorValue = stuff->window; return err; } } while (0) | |||
202 | DixSetAttrAccess | DixManageAccess | DixBlendAccess)do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<5) | (1<<25) | (1<<16)); if (err != 0 ) { client->errorValue = stuff->window; return err; } } while (0); | |||
203 | ||||
204 | return compUnredirectSubwindows(client, pWin, stuff->update); | |||
205 | } | |||
206 | ||||
207 | static int | |||
208 | ProcCompositeCreateRegionFromBorderClip(ClientPtr client) | |||
209 | { | |||
210 | WindowPtr pWin; | |||
211 | CompWindowPtr cw; | |||
212 | RegionPtr pBorderClip, pRegion; | |||
213 | ||||
214 | REQUEST(xCompositeCreateRegionFromBorderClipReq)xCompositeCreateRegionFromBorderClipReq *stuff = (xCompositeCreateRegionFromBorderClipReq *)client->requestBuffer; | |||
215 | ||||
216 | REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq)if ((sizeof(xCompositeCreateRegionFromBorderClipReq) >> 2) != client->req_len) return(16); | |||
217 | VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess)do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<4)); if (err != 0) { client->errorValue = stuff ->window; return err; } } while (0); | |||
218 | LEGAL_NEW_RESOURCE(stuff->region, client)if (!LegalNewID(stuff->region,client)) { client->errorValue = stuff->region; return 14; }; | |||
219 | ||||
220 | cw = GetCompWindow(pWin)((CompWindowPtr) dixLookupPrivate(&(pWin)->devPrivates , (&CompWindowPrivateKeyRec))); | |||
221 | if (cw) | |||
222 | pBorderClip = &cw->borderClip; | |||
223 | else | |||
224 | pBorderClip = &pWin->borderClip; | |||
225 | pRegion = XFixesRegionCopy(pBorderClip); | |||
226 | if (!pRegion) | |||
227 | return BadAlloc11; | |||
228 | RegionTranslate(pRegion, -pWin->drawable.x, -pWin->drawable.y); | |||
229 | ||||
230 | if (!AddResourceDarwin_X_AddResource(stuff->region, RegionResType, (void *) pRegion)) | |||
231 | return BadAlloc11; | |||
232 | ||||
233 | return Success0; | |||
234 | } | |||
235 | ||||
236 | static int | |||
237 | ProcCompositeNameWindowPixmap(ClientPtr client) | |||
238 | { | |||
239 | WindowPtr pWin; | |||
240 | CompWindowPtr cw; | |||
241 | PixmapPtr pPixmap; | |||
242 | ScreenPtr pScreen; | |||
243 | int rc; | |||
244 | ||||
245 | REQUEST(xCompositeNameWindowPixmapReq)xCompositeNameWindowPixmapReq *stuff = (xCompositeNameWindowPixmapReq *)client->requestBuffer; | |||
246 | ||||
247 | REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq)if ((sizeof(xCompositeNameWindowPixmapReq) >> 2) != client ->req_len) return(16); | |||
248 | VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess)do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<4)); if (err != 0) { client->errorValue = stuff ->window; return err; } } while (0); | |||
249 | ||||
250 | pScreen = pWin->drawable.pScreen; | |||
251 | ||||
252 | if (!pWin->viewable) | |||
253 | return BadMatch8; | |||
254 | ||||
255 | LEGAL_NEW_RESOURCE(stuff->pixmap, client)if (!LegalNewID(stuff->pixmap,client)) { client->errorValue = stuff->pixmap; return 14; }; | |||
256 | ||||
257 | cw = GetCompWindow(pWin)((CompWindowPtr) dixLookupPrivate(&(pWin)->devPrivates , (&CompWindowPrivateKeyRec))); | |||
258 | if (!cw) | |||
259 | return BadMatch8; | |||
260 | ||||
261 | pPixmap = (*pScreen->GetWindowPixmap) (pWin); | |||
262 | if (!pPixmap) | |||
263 | return BadMatch8; | |||
264 | ||||
265 | /* security creation/labeling check */ | |||
266 | rc = XaceHook(XACE_RESOURCE_ACCESS2, client, stuff->pixmap, RT_PIXMAP((RESTYPE)2|((RESTYPE)1<<30)), | |||
267 | pPixmap, RT_WINDOW((RESTYPE)1|((RESTYPE)1<<30)), pWin, DixCreateAccess(1<<3)); | |||
268 | if (rc != Success0) | |||
269 | return rc; | |||
270 | ||||
271 | ++pPixmap->refcnt; | |||
272 | ||||
273 | if (!AddResourceDarwin_X_AddResource(stuff->pixmap, RT_PIXMAP((RESTYPE)2|((RESTYPE)1<<30)), (void *) pPixmap)) | |||
274 | return BadAlloc11; | |||
275 | ||||
276 | if (pScreen->NameWindowPixmap) { | |||
277 | rc = pScreen->NameWindowPixmap(pWin, pPixmap, stuff->pixmap); | |||
278 | if (rc != Success0) { | |||
279 | FreeResource(stuff->pixmap, RT_NONE((RESTYPE)0)); | |||
280 | return rc; | |||
281 | } | |||
282 | } | |||
283 | ||||
284 | return Success0; | |||
285 | } | |||
286 | ||||
287 | static int | |||
288 | ProcCompositeGetOverlayWindow(ClientPtr client) | |||
289 | { | |||
290 | REQUEST(xCompositeGetOverlayWindowReq)xCompositeGetOverlayWindowReq *stuff = (xCompositeGetOverlayWindowReq *)client->requestBuffer; | |||
291 | xCompositeGetOverlayWindowReply rep; | |||
292 | WindowPtr pWin; | |||
293 | ScreenPtr pScreen; | |||
294 | CompScreenPtr cs; | |||
295 | CompOverlayClientPtr pOc; | |||
296 | int rc; | |||
297 | ||||
298 | REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq)if ((sizeof(xCompositeGetOverlayWindowReq) >> 2) != client ->req_len) return(16); | |||
299 | VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess)do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<4)); if (err != 0) { client->errorValue = stuff ->window; return err; } } while (0); | |||
300 | pScreen = pWin->drawable.pScreen; | |||
301 | ||||
302 | /* | |||
303 | * Create an OverlayClient structure to mark this client's | |||
304 | * interest in the overlay window | |||
305 | */ | |||
306 | pOc = compCreateOverlayClient(pScreen, client); | |||
307 | if (pOc == NULL((void*)0)) | |||
| ||||
308 | return BadAlloc11; | |||
309 | ||||
310 | /* | |||
311 | * Make sure the overlay window exists | |||
312 | */ | |||
313 | cs = GetCompScreen(pScreen)((CompScreenPtr) dixLookupPrivate(&(pScreen)->devPrivates , (&CompScreenPrivateKeyRec))); | |||
314 | if (cs->pOverlayWin == NULL((void*)0)) | |||
315 | if (!compCreateOverlayWindow(pScreen)) { | |||
316 | FreeResource(pOc->resource, RT_NONE((RESTYPE)0)); | |||
317 | return BadAlloc11; | |||
318 | } | |||
319 | ||||
320 | rc = XaceHook(XACE_RESOURCE_ACCESS2, client, cs->pOverlayWin->drawable.id, | |||
| ||||
321 | RT_WINDOW((RESTYPE)1|((RESTYPE)1<<30)), cs->pOverlayWin, RT_NONE((RESTYPE)0), NULL((void*)0), DixGetAttrAccess(1<<4)); | |||
322 | if (rc != Success0) { | |||
323 | FreeResource(pOc->resource, RT_NONE((RESTYPE)0)); | |||
324 | return rc; | |||
325 | } | |||
326 | ||||
327 | rep = (xCompositeGetOverlayWindowReply) { | |||
328 | .type = X_Reply1, | |||
329 | .sequenceNumber = client->sequence, | |||
330 | .length = 0, | |||
331 | .overlayWin = cs->pOverlayWin->drawable.id | |||
332 | }; | |||
333 | ||||
334 | if (client->swapped) { | |||
335 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
336 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
337 | swapl(&rep.overlayWin)do { if (sizeof(*(&rep.overlayWin)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.overlayWin) & 3) && ((uintptr_t)(&rep.overlayWin) & 3) == 0 ) *(&rep.overlayWin) = lswapl(*(&rep.overlayWin)); else swap_uint32((uint32_t *)(&rep.overlayWin)); } while (0); | |||
338 | } | |||
339 | WriteToClient(client, sz_xCompositeGetOverlayWindowReplysizeof(xCompositeGetOverlayWindowReply), &rep); | |||
340 | ||||
341 | return Success0; | |||
342 | } | |||
343 | ||||
344 | static int | |||
345 | ProcCompositeReleaseOverlayWindow(ClientPtr client) | |||
346 | { | |||
347 | REQUEST(xCompositeReleaseOverlayWindowReq)xCompositeReleaseOverlayWindowReq *stuff = (xCompositeReleaseOverlayWindowReq *)client->requestBuffer; | |||
348 | WindowPtr pWin; | |||
349 | CompOverlayClientPtr pOc; | |||
350 | ||||
351 | REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq)if ((sizeof(xCompositeReleaseOverlayWindowReq) >> 2) != client->req_len) return(16); | |||
352 | VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess)do { int err; err = dixLookupResourceByType((void **) &pWin , stuff->window, ((RESTYPE)1|((RESTYPE)1<<30)), client , (1<<4)); if (err != 0) { client->errorValue = stuff ->window; return err; } } while (0); | |||
353 | ||||
354 | /* | |||
355 | * Has client queried a reference to the overlay window | |||
356 | * on this screen? If not, generate an error. | |||
357 | */ | |||
358 | pOc = compFindOverlayClient(pWin->drawable.pScreen, client); | |||
359 | if (pOc == NULL((void*)0)) | |||
360 | return BadMatch8; | |||
361 | ||||
362 | /* The delete function will free the client structure */ | |||
363 | FreeResource(pOc->resource, RT_NONE((RESTYPE)0)); | |||
364 | ||||
365 | return Success0; | |||
366 | } | |||
367 | ||||
368 | static int (*ProcCompositeVector[CompositeNumberRequests(8 + 1)]) (ClientPtr) = { | |||
369 | ProcCompositeQueryVersion, | |||
370 | ProcCompositeRedirectWindow, | |||
371 | ProcCompositeRedirectSubwindows, | |||
372 | ProcCompositeUnredirectWindow, | |||
373 | ProcCompositeUnredirectSubwindows, | |||
374 | ProcCompositeCreateRegionFromBorderClip, | |||
375 | ProcCompositeNameWindowPixmap, | |||
376 | ProcCompositeGetOverlayWindow, ProcCompositeReleaseOverlayWindow,}; | |||
377 | ||||
378 | static int | |||
379 | ProcCompositeDispatch(ClientPtr client) | |||
380 | { | |||
381 | REQUEST(xReq)xReq *stuff = (xReq *)client->requestBuffer; | |||
382 | ||||
383 | if (stuff->data < CompositeNumberRequests(8 + 1)) | |||
384 | return (*ProcCompositeVector[stuff->data]) (client); | |||
385 | else | |||
386 | return BadRequest1; | |||
387 | } | |||
388 | ||||
389 | static int | |||
390 | SProcCompositeQueryVersion(ClientPtr client) | |||
391 | { | |||
392 | REQUEST(xCompositeQueryVersionReq)xCompositeQueryVersionReq *stuff = (xCompositeQueryVersionReq *)client->requestBuffer; | |||
393 | ||||
394 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
395 | REQUEST_SIZE_MATCH(xCompositeQueryVersionReq)if ((sizeof(xCompositeQueryVersionReq) >> 2) != client-> req_len) return(16); | |||
396 | swapl(&stuff->majorVersion)do { if (sizeof(*(&stuff->majorVersion)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->majorVersion ) & 3) && ((uintptr_t)(&stuff->majorVersion ) & 3) == 0) *(&stuff->majorVersion) = lswapl(*(& stuff->majorVersion)); else swap_uint32((uint32_t *)(& stuff->majorVersion)); } while (0); | |||
397 | swapl(&stuff->minorVersion)do { if (sizeof(*(&stuff->minorVersion)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->minorVersion ) & 3) && ((uintptr_t)(&stuff->minorVersion ) & 3) == 0) *(&stuff->minorVersion) = lswapl(*(& stuff->minorVersion)); else swap_uint32((uint32_t *)(& stuff->minorVersion)); } while (0); | |||
398 | return (*ProcCompositeVector[stuff->compositeReqType]) (client); | |||
399 | } | |||
400 | ||||
401 | static int | |||
402 | SProcCompositeRedirectWindow(ClientPtr client) | |||
403 | { | |||
404 | REQUEST(xCompositeRedirectWindowReq)xCompositeRedirectWindowReq *stuff = (xCompositeRedirectWindowReq *)client->requestBuffer; | |||
405 | ||||
406 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
407 | REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq)if ((sizeof(xCompositeRedirectWindowReq) >> 2) != client ->req_len) return(16); | |||
408 | swapl(&stuff->window)do { if (sizeof(*(&stuff->window)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->window) & 3) && ((uintptr_t)(&stuff->window) & 3) == 0) *(&stuff->window) = lswapl(*(&stuff->window )); else swap_uint32((uint32_t *)(&stuff->window)); } while (0); | |||
409 | return (*ProcCompositeVector[stuff->compositeReqType]) (client); | |||
410 | } | |||
411 | ||||
412 | static int | |||
413 | SProcCompositeRedirectSubwindows(ClientPtr client) | |||
414 | { | |||
415 | REQUEST(xCompositeRedirectSubwindowsReq)xCompositeRedirectSubwindowsReq *stuff = (xCompositeRedirectSubwindowsReq *)client->requestBuffer; | |||
416 | ||||
417 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
418 | REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq)if ((sizeof(xCompositeRedirectSubwindowsReq) >> 2) != client ->req_len) return(16); | |||
419 | swapl(&stuff->window)do { if (sizeof(*(&stuff->window)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->window) & 3) && ((uintptr_t)(&stuff->window) & 3) == 0) *(&stuff->window) = lswapl(*(&stuff->window )); else swap_uint32((uint32_t *)(&stuff->window)); } while (0); | |||
420 | return (*ProcCompositeVector[stuff->compositeReqType]) (client); | |||
421 | } | |||
422 | ||||
423 | static int | |||
424 | SProcCompositeUnredirectWindow(ClientPtr client) | |||
425 | { | |||
426 | REQUEST(xCompositeUnredirectWindowReq)xCompositeUnredirectWindowReq *stuff = (xCompositeUnredirectWindowReq *)client->requestBuffer; | |||
427 | ||||
428 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
429 | REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq)if ((sizeof(xCompositeUnredirectWindowReq) >> 2) != client ->req_len) return(16); | |||
430 | swapl(&stuff->window)do { if (sizeof(*(&stuff->window)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->window) & 3) && ((uintptr_t)(&stuff->window) & 3) == 0) *(&stuff->window) = lswapl(*(&stuff->window )); else swap_uint32((uint32_t *)(&stuff->window)); } while (0); | |||
431 | return (*ProcCompositeVector[stuff->compositeReqType]) (client); | |||
432 | } | |||
433 | ||||
434 | static int | |||
435 | SProcCompositeUnredirectSubwindows(ClientPtr client) | |||
436 | { | |||
437 | REQUEST(xCompositeUnredirectSubwindowsReq)xCompositeUnredirectSubwindowsReq *stuff = (xCompositeUnredirectSubwindowsReq *)client->requestBuffer; | |||
438 | ||||
439 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
440 | REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq)if ((sizeof(xCompositeUnredirectSubwindowsReq) >> 2) != client->req_len) return(16); | |||
441 | swapl(&stuff->window)do { if (sizeof(*(&stuff->window)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->window) & 3) && ((uintptr_t)(&stuff->window) & 3) == 0) *(&stuff->window) = lswapl(*(&stuff->window )); else swap_uint32((uint32_t *)(&stuff->window)); } while (0); | |||
442 | return (*ProcCompositeVector[stuff->compositeReqType]) (client); | |||
443 | } | |||
444 | ||||
445 | static int | |||
446 | SProcCompositeCreateRegionFromBorderClip(ClientPtr client) | |||
447 | { | |||
448 | REQUEST(xCompositeCreateRegionFromBorderClipReq)xCompositeCreateRegionFromBorderClipReq *stuff = (xCompositeCreateRegionFromBorderClipReq *)client->requestBuffer; | |||
449 | ||||
450 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
451 | REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq)if ((sizeof(xCompositeCreateRegionFromBorderClipReq) >> 2) != client->req_len) return(16); | |||
452 | swapl(&stuff->region)do { if (sizeof(*(&stuff->region)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->region) & 3) && ((uintptr_t)(&stuff->region) & 3) == 0) *(&stuff->region) = lswapl(*(&stuff->region )); else swap_uint32((uint32_t *)(&stuff->region)); } while (0); | |||
453 | swapl(&stuff->window)do { if (sizeof(*(&stuff->window)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->window) & 3) && ((uintptr_t)(&stuff->window) & 3) == 0) *(&stuff->window) = lswapl(*(&stuff->window )); else swap_uint32((uint32_t *)(&stuff->window)); } while (0); | |||
454 | return (*ProcCompositeVector[stuff->compositeReqType]) (client); | |||
455 | } | |||
456 | ||||
457 | static int | |||
458 | SProcCompositeNameWindowPixmap(ClientPtr client) | |||
459 | { | |||
460 | REQUEST(xCompositeNameWindowPixmapReq)xCompositeNameWindowPixmapReq *stuff = (xCompositeNameWindowPixmapReq *)client->requestBuffer; | |||
461 | ||||
462 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
463 | REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq)if ((sizeof(xCompositeNameWindowPixmapReq) >> 2) != client ->req_len) return(16); | |||
464 | swapl(&stuff->window)do { if (sizeof(*(&stuff->window)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->window) & 3) && ((uintptr_t)(&stuff->window) & 3) == 0) *(&stuff->window) = lswapl(*(&stuff->window )); else swap_uint32((uint32_t *)(&stuff->window)); } while (0); | |||
465 | swapl(&stuff->pixmap)do { if (sizeof(*(&stuff->pixmap)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->pixmap) & 3) && ((uintptr_t)(&stuff->pixmap) & 3) == 0) *(&stuff->pixmap) = lswapl(*(&stuff->pixmap )); else swap_uint32((uint32_t *)(&stuff->pixmap)); } while (0); | |||
466 | return (*ProcCompositeVector[stuff->compositeReqType]) (client); | |||
467 | } | |||
468 | ||||
469 | static int | |||
470 | SProcCompositeGetOverlayWindow(ClientPtr client) | |||
471 | { | |||
472 | REQUEST(xCompositeGetOverlayWindowReq)xCompositeGetOverlayWindowReq *stuff = (xCompositeGetOverlayWindowReq *)client->requestBuffer; | |||
473 | ||||
474 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
475 | REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq)if ((sizeof(xCompositeGetOverlayWindowReq) >> 2) != client ->req_len) return(16); | |||
476 | swapl(&stuff->window)do { if (sizeof(*(&stuff->window)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->window) & 3) && ((uintptr_t)(&stuff->window) & 3) == 0) *(&stuff->window) = lswapl(*(&stuff->window )); else swap_uint32((uint32_t *)(&stuff->window)); } while (0); | |||
477 | return (*ProcCompositeVector[stuff->compositeReqType]) (client); | |||
478 | } | |||
479 | ||||
480 | static int | |||
481 | SProcCompositeReleaseOverlayWindow(ClientPtr client) | |||
482 | { | |||
483 | REQUEST(xCompositeReleaseOverlayWindowReq)xCompositeReleaseOverlayWindowReq *stuff = (xCompositeReleaseOverlayWindowReq *)client->requestBuffer; | |||
484 | ||||
485 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
486 | REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq)if ((sizeof(xCompositeReleaseOverlayWindowReq) >> 2) != client->req_len) return(16); | |||
487 | swapl(&stuff->window)do { if (sizeof(*(&stuff->window)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->window) & 3) && ((uintptr_t)(&stuff->window) & 3) == 0) *(&stuff->window) = lswapl(*(&stuff->window )); else swap_uint32((uint32_t *)(&stuff->window)); } while (0); | |||
488 | return (*ProcCompositeVector[stuff->compositeReqType]) (client); | |||
489 | } | |||
490 | ||||
491 | static int (*SProcCompositeVector[CompositeNumberRequests(8 + 1)]) (ClientPtr) = { | |||
492 | SProcCompositeQueryVersion, | |||
493 | SProcCompositeRedirectWindow, | |||
494 | SProcCompositeRedirectSubwindows, | |||
495 | SProcCompositeUnredirectWindow, | |||
496 | SProcCompositeUnredirectSubwindows, | |||
497 | SProcCompositeCreateRegionFromBorderClip, | |||
498 | SProcCompositeNameWindowPixmap, | |||
499 | SProcCompositeGetOverlayWindow, SProcCompositeReleaseOverlayWindow,}; | |||
500 | ||||
501 | static int | |||
502 | SProcCompositeDispatch(ClientPtr client) | |||
503 | { | |||
504 | REQUEST(xReq)xReq *stuff = (xReq *)client->requestBuffer; | |||
505 | ||||
506 | if (stuff->data < CompositeNumberRequests(8 + 1)) | |||
507 | return (*SProcCompositeVector[stuff->data]) (client); | |||
508 | else | |||
509 | return BadRequest1; | |||
510 | } | |||
511 | ||||
512 | /** @see GetDefaultBytes */ | |||
513 | static void | |||
514 | GetCompositeClientWindowBytes(void *value, XID id, ResourceSizePtr size) | |||
515 | { | |||
516 | WindowPtr window = value; | |||
517 | ||||
518 | /* Currently only pixmap bytes are reported to clients. */ | |||
519 | size->resourceSize = 0; | |||
520 | ||||
521 | /* Calculate pixmap reference sizes. */ | |||
522 | size->pixmapRefSize = 0; | |||
523 | if (window->redirectDraw != RedirectDrawNone0) | |||
524 | { | |||
525 | SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP((RESTYPE)2|((RESTYPE)1<<30))); | |||
526 | ResourceSizeRec pixmapSize = { 0, 0 }; | |||
527 | ScreenPtr screen = window->drawable.pScreen; | |||
528 | PixmapPtr pixmap = screen->GetWindowPixmap(window); | |||
529 | pixmapSizeFunc(pixmap, pixmap->drawable.id, &pixmapSize); | |||
530 | size->pixmapRefSize += pixmapSize.pixmapRefSize; | |||
531 | } | |||
532 | } | |||
533 | ||||
534 | void | |||
535 | CompositeExtensionInit(void) | |||
536 | { | |||
537 | ExtensionEntry *extEntry; | |||
538 | int s; | |||
539 | ||||
540 | /* Assume initialization is going to fail */ | |||
541 | noCompositeExtension = TRUE1; | |||
542 | ||||
543 | for (s = 0; s < screenInfo.numScreens; s++) { | |||
544 | ScreenPtr pScreen = screenInfo.screens[s]; | |||
545 | VisualPtr vis; | |||
546 | ||||
547 | /* Composite on 8bpp pseudocolor root windows appears to fail, so | |||
548 | * just disable it on anything pseudocolor for safety. | |||
549 | */ | |||
550 | for (vis = pScreen->visuals; vis->vid != pScreen->rootVisual; vis++); | |||
551 | if ((vis->class | DynamicClass1) == PseudoColor3) | |||
552 | return; | |||
553 | ||||
554 | /* Ensure that Render is initialized, which is required for automatic | |||
555 | * compositing. | |||
556 | */ | |||
557 | if (GetPictureScreenIfSet(pScreen)(dixPrivateKeyRegistered((&PictureScreenPrivateKeyRec)) ? ((PictureScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates , (&PictureScreenPrivateKeyRec))) : ((void*)0)) == NULL((void*)0)) | |||
558 | return; | |||
559 | } | |||
560 | ||||
561 | CompositeClientWindowType = CreateNewResourceType | |||
562 | (FreeCompositeClientWindow, "CompositeClientWindow"); | |||
563 | if (!CompositeClientWindowType) | |||
564 | return; | |||
565 | ||||
566 | SetResourceTypeSizeFunc(CompositeClientWindowType, | |||
567 | GetCompositeClientWindowBytes); | |||
568 | ||||
569 | CompositeClientSubwindowsType = CreateNewResourceType | |||
570 | (FreeCompositeClientSubwindows, "CompositeClientSubwindows"); | |||
571 | if (!CompositeClientSubwindowsType) | |||
572 | return; | |||
573 | ||||
574 | CompositeClientOverlayType = CreateNewResourceType | |||
575 | (FreeCompositeClientOverlay, "CompositeClientOverlay"); | |||
576 | if (!CompositeClientOverlayType) | |||
577 | return; | |||
578 | ||||
579 | if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec, PRIVATE_CLIENT, | |||
580 | sizeof(CompositeClientRec))) | |||
581 | return; | |||
582 | ||||
583 | if (!AddCallback(&ClientStateCallback, CompositeClientCallback, 0)) | |||
584 | return; | |||
585 | ||||
586 | for (s = 0; s < screenInfo.numScreens; s++) | |||
587 | if (!compScreenInit(screenInfo.screens[s])) | |||
588 | return; | |||
589 | ||||
590 | extEntry = AddExtension(COMPOSITE_NAME"Composite", 0, 0, | |||
591 | ProcCompositeDispatch, SProcCompositeDispatch, | |||
592 | NULL((void*)0), StandardMinorOpcode); | |||
593 | if (!extEntry) | |||
594 | return; | |||
595 | CompositeReqCode = (CARD8) extEntry->base; | |||
596 | ||||
597 | /* Initialization succeeded */ | |||
598 | noCompositeExtension = FALSE0; | |||
599 | } | |||
600 | ||||
601 | #ifdef PANORAMIX1 | |||
602 | #include "panoramiXsrv.h" | |||
603 | ||||
604 | int (*PanoramiXSaveCompositeVector[CompositeNumberRequests(8 + 1)]) (ClientPtr); | |||
605 | ||||
606 | static int | |||
607 | PanoramiXCompositeRedirectWindow(ClientPtr client) | |||
608 | { | |||
609 | PanoramiXRes *win; | |||
610 | int rc = 0, j; | |||
611 | ||||
612 | REQUEST(xCompositeRedirectWindowReq)xCompositeRedirectWindowReq *stuff = (xCompositeRedirectWindowReq *)client->requestBuffer; | |||
613 | ||||
614 | REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq)if ((sizeof(xCompositeRedirectWindowReq) >> 2) != client ->req_len) return(16); | |||
615 | ||||
616 | if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW, | |||
617 | client, DixUnknownAccess0))) { | |||
618 | client->errorValue = stuff->window; | |||
619 | return rc; | |||
620 | } | |||
621 | ||||
622 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
623 | stuff->window = win->info[j].id; | |||
624 | rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); | |||
625 | if (rc != Success0) | |||
626 | break; | |||
627 | } | |||
628 | ||||
629 | return rc; | |||
630 | } | |||
631 | ||||
632 | static int | |||
633 | PanoramiXCompositeRedirectSubwindows(ClientPtr client) | |||
634 | { | |||
635 | PanoramiXRes *win; | |||
636 | int rc = 0, j; | |||
637 | ||||
638 | REQUEST(xCompositeRedirectSubwindowsReq)xCompositeRedirectSubwindowsReq *stuff = (xCompositeRedirectSubwindowsReq *)client->requestBuffer; | |||
639 | ||||
640 | REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq)if ((sizeof(xCompositeRedirectSubwindowsReq) >> 2) != client ->req_len) return(16); | |||
641 | ||||
642 | if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW, | |||
643 | client, DixUnknownAccess0))) { | |||
644 | client->errorValue = stuff->window; | |||
645 | return rc; | |||
646 | } | |||
647 | ||||
648 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
649 | stuff->window = win->info[j].id; | |||
650 | rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); | |||
651 | if (rc != Success0) | |||
652 | break; | |||
653 | } | |||
654 | ||||
655 | return rc; | |||
656 | } | |||
657 | ||||
658 | static int | |||
659 | PanoramiXCompositeUnredirectWindow(ClientPtr client) | |||
660 | { | |||
661 | PanoramiXRes *win; | |||
662 | int rc = 0, j; | |||
663 | ||||
664 | REQUEST(xCompositeUnredirectWindowReq)xCompositeUnredirectWindowReq *stuff = (xCompositeUnredirectWindowReq *)client->requestBuffer; | |||
665 | ||||
666 | REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq)if ((sizeof(xCompositeUnredirectWindowReq) >> 2) != client ->req_len) return(16); | |||
667 | ||||
668 | if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW, | |||
669 | client, DixUnknownAccess0))) { | |||
670 | client->errorValue = stuff->window; | |||
671 | return rc; | |||
672 | } | |||
673 | ||||
674 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
675 | stuff->window = win->info[j].id; | |||
676 | rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); | |||
677 | if (rc != Success0) | |||
678 | break; | |||
679 | } | |||
680 | ||||
681 | return rc; | |||
682 | } | |||
683 | ||||
684 | static int | |||
685 | PanoramiXCompositeUnredirectSubwindows(ClientPtr client) | |||
686 | { | |||
687 | PanoramiXRes *win; | |||
688 | int rc = 0, j; | |||
689 | ||||
690 | REQUEST(xCompositeUnredirectSubwindowsReq)xCompositeUnredirectSubwindowsReq *stuff = (xCompositeUnredirectSubwindowsReq *)client->requestBuffer; | |||
691 | ||||
692 | REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq)if ((sizeof(xCompositeUnredirectSubwindowsReq) >> 2) != client->req_len) return(16); | |||
693 | ||||
694 | if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW, | |||
695 | client, DixUnknownAccess0))) { | |||
696 | client->errorValue = stuff->window; | |||
697 | return rc; | |||
698 | } | |||
699 | ||||
700 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
701 | stuff->window = win->info[j].id; | |||
702 | rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); | |||
703 | if (rc != Success0) | |||
704 | break; | |||
705 | } | |||
706 | ||||
707 | return rc; | |||
708 | } | |||
709 | ||||
710 | static int | |||
711 | PanoramiXCompositeNameWindowPixmap(ClientPtr client) | |||
712 | { | |||
713 | WindowPtr pWin; | |||
714 | CompWindowPtr cw; | |||
715 | PixmapPtr pPixmap; | |||
716 | int rc; | |||
717 | PanoramiXRes *win, *newPix; | |||
718 | int i; | |||
719 | ||||
720 | REQUEST(xCompositeNameWindowPixmapReq)xCompositeNameWindowPixmapReq *stuff = (xCompositeNameWindowPixmapReq *)client->requestBuffer; | |||
721 | ||||
722 | REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq)if ((sizeof(xCompositeNameWindowPixmapReq) >> 2) != client ->req_len) return(16); | |||
723 | ||||
724 | if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW, | |||
725 | client, DixUnknownAccess0))) { | |||
726 | client->errorValue = stuff->window; | |||
727 | return rc; | |||
728 | } | |||
729 | ||||
730 | LEGAL_NEW_RESOURCE(stuff->pixmap, client)if (!LegalNewID(stuff->pixmap,client)) { client->errorValue = stuff->pixmap; return 14; }; | |||
731 | ||||
732 | if (!(newPix = malloc(sizeof(PanoramiXRes)))) | |||
733 | return BadAlloc11; | |||
734 | ||||
735 | newPix->type = XRT_PIXMAP; | |||
736 | newPix->u.pix.shared = FALSE0; | |||
737 | panoramix_setup_ids(newPix, client, stuff->pixmap); | |||
738 | ||||
739 | FOR_NSCREENS(i)for(i = 0; i < PanoramiXNumScreens; i++) { | |||
740 | rc = dixLookupResourceByType((void **) &pWin, win->info[i].id, | |||
741 | RT_WINDOW((RESTYPE)1|((RESTYPE)1<<30)), client, DixGetAttrAccess(1<<4)); | |||
742 | if (rc != Success0) { | |||
743 | client->errorValue = stuff->window; | |||
744 | free(newPix); | |||
745 | return rc; | |||
746 | } | |||
747 | ||||
748 | if (!pWin->viewable) { | |||
749 | free(newPix); | |||
750 | return BadMatch8; | |||
751 | } | |||
752 | ||||
753 | cw = GetCompWindow(pWin)((CompWindowPtr) dixLookupPrivate(&(pWin)->devPrivates , (&CompWindowPrivateKeyRec))); | |||
754 | if (!cw) { | |||
755 | free(newPix); | |||
756 | return BadMatch8; | |||
757 | } | |||
758 | ||||
759 | pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin); | |||
760 | if (!pPixmap) { | |||
761 | free(newPix); | |||
762 | return BadMatch8; | |||
763 | } | |||
764 | ||||
765 | if (!AddResourceDarwin_X_AddResource(newPix->info[i].id, RT_PIXMAP((RESTYPE)2|((RESTYPE)1<<30)), (void *) pPixmap)) | |||
766 | return BadAlloc11; | |||
767 | ||||
768 | ++pPixmap->refcnt; | |||
769 | } | |||
770 | ||||
771 | if (!AddResourceDarwin_X_AddResource(stuff->pixmap, XRT_PIXMAP, (void *) newPix)) | |||
772 | return BadAlloc11; | |||
773 | ||||
774 | return Success0; | |||
775 | } | |||
776 | ||||
777 | static int | |||
778 | PanoramiXCompositeGetOverlayWindow(ClientPtr client) | |||
779 | { | |||
780 | REQUEST(xCompositeGetOverlayWindowReq)xCompositeGetOverlayWindowReq *stuff = (xCompositeGetOverlayWindowReq *)client->requestBuffer; | |||
781 | xCompositeGetOverlayWindowReply rep; | |||
782 | WindowPtr pWin; | |||
783 | ScreenPtr pScreen; | |||
784 | CompScreenPtr cs; | |||
785 | CompOverlayClientPtr pOc; | |||
786 | int rc; | |||
787 | PanoramiXRes *win, *overlayWin = NULL((void*)0); | |||
788 | int i; | |||
789 | ||||
790 | REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq)if ((sizeof(xCompositeGetOverlayWindowReq) >> 2) != client ->req_len) return(16); | |||
791 | ||||
792 | if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW, | |||
793 | client, DixUnknownAccess0))) { | |||
794 | client->errorValue = stuff->window; | |||
795 | return rc; | |||
796 | } | |||
797 | ||||
798 | cs = GetCompScreen(screenInfo.screens[0])((CompScreenPtr) dixLookupPrivate(&(screenInfo.screens[0] )->devPrivates, (&CompScreenPrivateKeyRec))); | |||
799 | if (!cs->pOverlayWin) { | |||
800 | if (!(overlayWin = malloc(sizeof(PanoramiXRes)))) | |||
801 | return BadAlloc11; | |||
802 | ||||
803 | overlayWin->type = XRT_WINDOW; | |||
804 | overlayWin->u.win.root = FALSE0; | |||
805 | } | |||
806 | ||||
807 | FOR_NSCREENS_BACKWARD(i)for(i = PanoramiXNumScreens - 1; i >= 0; i--) { | |||
808 | rc = dixLookupResourceByType((void **) &pWin, win->info[i].id, | |||
809 | RT_WINDOW((RESTYPE)1|((RESTYPE)1<<30)), client, DixGetAttrAccess(1<<4)); | |||
810 | if (rc != Success0) { | |||
811 | client->errorValue = stuff->window; | |||
812 | free(overlayWin); | |||
813 | return rc; | |||
814 | } | |||
815 | pScreen = pWin->drawable.pScreen; | |||
816 | ||||
817 | /* | |||
818 | * Create an OverlayClient structure to mark this client's | |||
819 | * interest in the overlay window | |||
820 | */ | |||
821 | pOc = compCreateOverlayClient(pScreen, client); | |||
822 | if (pOc == NULL((void*)0)) { | |||
823 | free(overlayWin); | |||
824 | return BadAlloc11; | |||
825 | } | |||
826 | ||||
827 | /* | |||
828 | * Make sure the overlay window exists | |||
829 | */ | |||
830 | cs = GetCompScreen(pScreen)((CompScreenPtr) dixLookupPrivate(&(pScreen)->devPrivates , (&CompScreenPrivateKeyRec))); | |||
831 | if (cs->pOverlayWin == NULL((void*)0)) | |||
832 | if (!compCreateOverlayWindow(pScreen)) { | |||
833 | FreeResource(pOc->resource, RT_NONE((RESTYPE)0)); | |||
834 | free(overlayWin); | |||
835 | return BadAlloc11; | |||
836 | } | |||
837 | ||||
838 | rc = XaceHook(XACE_RESOURCE_ACCESS2, client, | |||
839 | cs->pOverlayWin->drawable.id, | |||
840 | RT_WINDOW((RESTYPE)1|((RESTYPE)1<<30)), cs->pOverlayWin, RT_NONE((RESTYPE)0), NULL((void*)0), | |||
841 | DixGetAttrAccess(1<<4)); | |||
842 | if (rc != Success0) { | |||
843 | FreeResource(pOc->resource, RT_NONE((RESTYPE)0)); | |||
844 | free(overlayWin); | |||
845 | return rc; | |||
846 | } | |||
847 | } | |||
848 | ||||
849 | if (overlayWin) { | |||
850 | FOR_NSCREENS(i)for(i = 0; i < PanoramiXNumScreens; i++) { | |||
851 | cs = GetCompScreen(screenInfo.screens[i])((CompScreenPtr) dixLookupPrivate(&(screenInfo.screens[i] )->devPrivates, (&CompScreenPrivateKeyRec))); | |||
852 | overlayWin->info[i].id = cs->pOverlayWin->drawable.id; | |||
853 | } | |||
854 | ||||
855 | AddResourceDarwin_X_AddResource(overlayWin->info[0].id, XRT_WINDOW, overlayWin); | |||
856 | } | |||
857 | ||||
858 | cs = GetCompScreen(screenInfo.screens[0])((CompScreenPtr) dixLookupPrivate(&(screenInfo.screens[0] )->devPrivates, (&CompScreenPrivateKeyRec))); | |||
859 | ||||
860 | rep = (xCompositeGetOverlayWindowReply) { | |||
861 | .type = X_Reply1, | |||
862 | .sequenceNumber = client->sequence, | |||
863 | .length = 0, | |||
864 | .overlayWin = cs->pOverlayWin->drawable.id | |||
865 | }; | |||
866 | ||||
867 | if (client->swapped) { | |||
868 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
869 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
870 | swapl(&rep.overlayWin)do { if (sizeof(*(&rep.overlayWin)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.overlayWin) & 3) && ((uintptr_t)(&rep.overlayWin) & 3) == 0 ) *(&rep.overlayWin) = lswapl(*(&rep.overlayWin)); else swap_uint32((uint32_t *)(&rep.overlayWin)); } while (0); | |||
871 | } | |||
872 | WriteToClient(client, sz_xCompositeGetOverlayWindowReplysizeof(xCompositeGetOverlayWindowReply), &rep); | |||
873 | ||||
874 | return Success0; | |||
875 | } | |||
876 | ||||
877 | static int | |||
878 | PanoramiXCompositeReleaseOverlayWindow(ClientPtr client) | |||
879 | { | |||
880 | REQUEST(xCompositeReleaseOverlayWindowReq)xCompositeReleaseOverlayWindowReq *stuff = (xCompositeReleaseOverlayWindowReq *)client->requestBuffer; | |||
881 | WindowPtr pWin; | |||
882 | CompOverlayClientPtr pOc; | |||
883 | PanoramiXRes *win; | |||
884 | int i, rc; | |||
885 | ||||
886 | REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq)if ((sizeof(xCompositeReleaseOverlayWindowReq) >> 2) != client->req_len) return(16); | |||
887 | ||||
888 | if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW, | |||
889 | client, DixUnknownAccess0))) { | |||
890 | client->errorValue = stuff->window; | |||
891 | return rc; | |||
892 | } | |||
893 | ||||
894 | FOR_NSCREENS_BACKWARD(i)for(i = PanoramiXNumScreens - 1; i >= 0; i--) { | |||
895 | if ((rc = dixLookupResourceByType((void **) &pWin, win->info[i].id, | |||
896 | XRT_WINDOW, client, | |||
897 | DixUnknownAccess0))) { | |||
898 | client->errorValue = stuff->window; | |||
899 | return rc; | |||
900 | } | |||
901 | ||||
902 | /* | |||
903 | * Has client queried a reference to the overlay window | |||
904 | * on this screen? If not, generate an error. | |||
905 | */ | |||
906 | pOc = compFindOverlayClient(pWin->drawable.pScreen, client); | |||
907 | if (pOc == NULL((void*)0)) | |||
908 | return BadMatch8; | |||
909 | ||||
910 | /* The delete function will free the client structure */ | |||
911 | FreeResource(pOc->resource, RT_NONE((RESTYPE)0)); | |||
912 | } | |||
913 | ||||
914 | return Success0; | |||
915 | } | |||
916 | ||||
917 | void | |||
918 | PanoramiXCompositeInit(void) | |||
919 | { | |||
920 | int i; | |||
921 | ||||
922 | for (i = 0; i < CompositeNumberRequests(8 + 1); i++) | |||
923 | PanoramiXSaveCompositeVector[i] = ProcCompositeVector[i]; | |||
924 | /* | |||
925 | * Stuff in Xinerama aware request processing hooks | |||
926 | */ | |||
927 | ProcCompositeVector[X_CompositeRedirectWindow1] = | |||
928 | PanoramiXCompositeRedirectWindow; | |||
929 | ProcCompositeVector[X_CompositeRedirectSubwindows2] = | |||
930 | PanoramiXCompositeRedirectSubwindows; | |||
931 | ProcCompositeVector[X_CompositeUnredirectWindow3] = | |||
932 | PanoramiXCompositeUnredirectWindow; | |||
933 | ProcCompositeVector[X_CompositeUnredirectSubwindows4] = | |||
934 | PanoramiXCompositeUnredirectSubwindows; | |||
935 | ProcCompositeVector[X_CompositeNameWindowPixmap6] = | |||
936 | PanoramiXCompositeNameWindowPixmap; | |||
937 | ProcCompositeVector[X_CompositeGetOverlayWindow7] = | |||
938 | PanoramiXCompositeGetOverlayWindow; | |||
939 | ProcCompositeVector[X_CompositeReleaseOverlayWindow8] = | |||
940 | PanoramiXCompositeReleaseOverlayWindow; | |||
941 | } | |||
942 | ||||
943 | void | |||
944 | PanoramiXCompositeReset(void) | |||
945 | { | |||
946 | int i; | |||
947 | ||||
948 | for (i = 0; i < CompositeNumberRequests(8 + 1); i++) | |||
949 | ProcCompositeVector[i] = PanoramiXSaveCompositeVector[i]; | |||
950 | } | |||
951 | ||||
952 | #endif |