2 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
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:
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
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.
23 * Copyright © 2003 Keith Packard
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.
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.
44 #ifdef HAVE_DIX_CONFIG_H
45 #include <dix-config.h>
50 #include "protocol-versions.h"
52 static CARD8 CompositeReqCode
;
53 static DevPrivateKeyRec CompositeClientPrivateKeyRec
;
55 #define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec)
56 RESTYPE CompositeClientWindowType
;
57 RESTYPE CompositeClientSubwindowsType
;
58 RESTYPE CompositeClientOverlayType
;
60 typedef struct _CompositeClient
{
63 } CompositeClientRec
, *CompositeClientPtr
;
65 #define GetCompositeClient(pClient) ((CompositeClientPtr) \
66 dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey))
69 CompositeClientCallback(CallbackListPtr
*list
, pointer closure
, pointer data
)
71 NewClientInfoRec
*clientinfo
= (NewClientInfoRec
*) data
;
72 ClientPtr pClient
= clientinfo
->client
;
73 CompositeClientPtr pCompositeClient
= GetCompositeClient(pClient
);
75 pCompositeClient
->major_version
= 0;
76 pCompositeClient
->minor_version
= 0;
80 FreeCompositeClientWindow(pointer value
, XID ccwid
)
82 WindowPtr pWin
= value
;
84 compFreeClientWindow(pWin
, ccwid
);
89 FreeCompositeClientSubwindows(pointer value
, XID ccwid
)
91 WindowPtr pWin
= value
;
93 compFreeClientSubwindows(pWin
, ccwid
);
98 FreeCompositeClientOverlay(pointer value
, XID ccwid
)
100 CompOverlayClientPtr pOc
= (CompOverlayClientPtr
) value
;
102 compFreeOverlayClient(pOc
);
107 ProcCompositeQueryVersion(ClientPtr client
)
109 CompositeClientPtr pCompositeClient
= GetCompositeClient(client
);
110 xCompositeQueryVersionReply rep
;
112 REQUEST(xCompositeQueryVersionReq
);
114 REQUEST_SIZE_MATCH(xCompositeQueryVersionReq
);
117 rep
.sequenceNumber
= client
->sequence
;
118 if (stuff
->majorVersion
< SERVER_COMPOSITE_MAJOR_VERSION
) {
119 rep
.majorVersion
= stuff
->majorVersion
;
120 rep
.minorVersion
= stuff
->minorVersion
;
123 rep
.majorVersion
= SERVER_COMPOSITE_MAJOR_VERSION
;
124 rep
.minorVersion
= SERVER_COMPOSITE_MINOR_VERSION
;
126 pCompositeClient
->major_version
= rep
.majorVersion
;
127 pCompositeClient
->minor_version
= rep
.minorVersion
;
128 if (client
->swapped
) {
129 swaps(&rep
.sequenceNumber
);
131 swapl(&rep
.majorVersion
);
132 swapl(&rep
.minorVersion
);
134 WriteToClient(client
, sizeof(xCompositeQueryVersionReply
), (char *) &rep
);
138 #define VERIFY_WINDOW(pWindow, wid, client, mode) \
141 err = dixLookupResourceByType((pointer *) &pWindow, wid, \
142 RT_WINDOW, client, mode); \
143 if (err != Success) { \
144 client->errorValue = wid; \
150 ProcCompositeRedirectWindow(ClientPtr client
)
154 REQUEST(xCompositeRedirectWindowReq
);
156 REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq
);
157 VERIFY_WINDOW(pWin
, stuff
->window
, client
,
158 DixSetAttrAccess
| DixManageAccess
| DixBlendAccess
);
160 return compRedirectWindow(client
, pWin
, stuff
->update
);
164 ProcCompositeRedirectSubwindows(ClientPtr client
)
168 REQUEST(xCompositeRedirectSubwindowsReq
);
170 REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq
);
171 VERIFY_WINDOW(pWin
, stuff
->window
, client
,
172 DixSetAttrAccess
| DixManageAccess
| DixBlendAccess
);
174 return compRedirectSubwindows(client
, pWin
, stuff
->update
);
178 ProcCompositeUnredirectWindow(ClientPtr client
)
182 REQUEST(xCompositeUnredirectWindowReq
);
184 REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq
);
185 VERIFY_WINDOW(pWin
, stuff
->window
, client
,
186 DixSetAttrAccess
| DixManageAccess
| DixBlendAccess
);
188 return compUnredirectWindow(client
, pWin
, stuff
->update
);
192 ProcCompositeUnredirectSubwindows(ClientPtr client
)
196 REQUEST(xCompositeUnredirectSubwindowsReq
);
198 REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq
);
199 VERIFY_WINDOW(pWin
, stuff
->window
, client
,
200 DixSetAttrAccess
| DixManageAccess
| DixBlendAccess
);
202 return compUnredirectSubwindows(client
, pWin
, stuff
->update
);
206 ProcCompositeCreateRegionFromBorderClip(ClientPtr client
)
210 RegionPtr pBorderClip
, pRegion
;
212 REQUEST(xCompositeCreateRegionFromBorderClipReq
);
214 REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq
);
215 VERIFY_WINDOW(pWin
, stuff
->window
, client
, DixGetAttrAccess
);
216 LEGAL_NEW_RESOURCE(stuff
->region
, client
);
218 cw
= GetCompWindow(pWin
);
220 pBorderClip
= &cw
->borderClip
;
222 pBorderClip
= &pWin
->borderClip
;
223 pRegion
= XFixesRegionCopy(pBorderClip
);
226 RegionTranslate(pRegion
, -pWin
->drawable
.x
, -pWin
->drawable
.y
);
228 if (!AddResource(stuff
->region
, RegionResType
, (pointer
) pRegion
))
235 ProcCompositeNameWindowPixmap(ClientPtr client
)
242 REQUEST(xCompositeNameWindowPixmapReq
);
244 REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq
);
245 VERIFY_WINDOW(pWin
, stuff
->window
, client
, DixGetAttrAccess
);
250 LEGAL_NEW_RESOURCE(stuff
->pixmap
, client
);
252 cw
= GetCompWindow(pWin
);
256 pPixmap
= (*pWin
->drawable
.pScreen
->GetWindowPixmap
) (pWin
);
260 /* security creation/labeling check */
261 rc
= XaceHook(XACE_RESOURCE_ACCESS
, client
, stuff
->pixmap
, RT_PIXMAP
,
262 pPixmap
, RT_WINDOW
, pWin
, DixCreateAccess
);
268 if (!AddResource(stuff
->pixmap
, RT_PIXMAP
, (pointer
) pPixmap
))
275 ProcCompositeGetOverlayWindow(ClientPtr client
)
277 REQUEST(xCompositeGetOverlayWindowReq
);
278 xCompositeGetOverlayWindowReply rep
;
282 CompOverlayClientPtr pOc
;
285 REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq
);
286 VERIFY_WINDOW(pWin
, stuff
->window
, client
, DixGetAttrAccess
);
287 pScreen
= pWin
->drawable
.pScreen
;
290 * Create an OverlayClient structure to mark this client's
291 * interest in the overlay window
293 pOc
= compCreateOverlayClient(pScreen
, client
);
298 * Make sure the overlay window exists
300 cs
= GetCompScreen(pScreen
);
301 if (cs
->pOverlayWin
== NULL
)
302 if (!compCreateOverlayWindow(pScreen
)) {
303 FreeResource(pOc
->resource
, RT_NONE
);
307 rc
= XaceHook(XACE_RESOURCE_ACCESS
, client
, cs
->pOverlayWin
->drawable
.id
,
308 RT_WINDOW
, cs
->pOverlayWin
, RT_NONE
, NULL
, DixGetAttrAccess
);
310 FreeResource(pOc
->resource
, RT_NONE
);
315 rep
.sequenceNumber
= client
->sequence
;
317 rep
.overlayWin
= cs
->pOverlayWin
->drawable
.id
;
319 if (client
->swapped
) {
320 swaps(&rep
.sequenceNumber
);
322 swapl(&rep
.overlayWin
);
324 (void) WriteToClient(client
, sz_xCompositeGetOverlayWindowReply
,
331 ProcCompositeReleaseOverlayWindow(ClientPtr client
)
333 REQUEST(xCompositeReleaseOverlayWindowReq
);
336 CompOverlayClientPtr pOc
;
338 REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq
);
339 VERIFY_WINDOW(pWin
, stuff
->window
, client
, DixGetAttrAccess
);
340 pScreen
= pWin
->drawable
.pScreen
;
343 * Has client queried a reference to the overlay window
344 * on this screen? If not, generate an error.
346 pOc
= compFindOverlayClient(pWin
->drawable
.pScreen
, client
);
350 /* The delete function will free the client structure */
351 FreeResource(pOc
->resource
, RT_NONE
);
356 static int (*ProcCompositeVector
[CompositeNumberRequests
]) (ClientPtr
) = {
357 ProcCompositeQueryVersion
,
358 ProcCompositeRedirectWindow
,
359 ProcCompositeRedirectSubwindows
,
360 ProcCompositeUnredirectWindow
,
361 ProcCompositeUnredirectSubwindows
,
362 ProcCompositeCreateRegionFromBorderClip
,
363 ProcCompositeNameWindowPixmap
,
364 ProcCompositeGetOverlayWindow
, ProcCompositeReleaseOverlayWindow
,};
367 ProcCompositeDispatch(ClientPtr client
)
371 if (stuff
->data
< CompositeNumberRequests
)
372 return (*ProcCompositeVector
[stuff
->data
]) (client
);
378 SProcCompositeQueryVersion(ClientPtr client
)
380 REQUEST(xCompositeQueryVersionReq
);
382 swaps(&stuff
->length
);
383 REQUEST_SIZE_MATCH(xCompositeQueryVersionReq
);
384 swapl(&stuff
->majorVersion
);
385 swapl(&stuff
->minorVersion
);
386 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
390 SProcCompositeRedirectWindow(ClientPtr client
)
392 REQUEST(xCompositeRedirectWindowReq
);
394 swaps(&stuff
->length
);
395 REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq
);
396 swapl(&stuff
->window
);
397 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
401 SProcCompositeRedirectSubwindows(ClientPtr client
)
403 REQUEST(xCompositeRedirectSubwindowsReq
);
405 swaps(&stuff
->length
);
406 REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq
);
407 swapl(&stuff
->window
);
408 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
412 SProcCompositeUnredirectWindow(ClientPtr client
)
414 REQUEST(xCompositeUnredirectWindowReq
);
416 swaps(&stuff
->length
);
417 REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq
);
418 swapl(&stuff
->window
);
419 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
423 SProcCompositeUnredirectSubwindows(ClientPtr client
)
425 REQUEST(xCompositeUnredirectSubwindowsReq
);
427 swaps(&stuff
->length
);
428 REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq
);
429 swapl(&stuff
->window
);
430 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
434 SProcCompositeCreateRegionFromBorderClip(ClientPtr client
)
436 REQUEST(xCompositeCreateRegionFromBorderClipReq
);
438 swaps(&stuff
->length
);
439 REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq
);
440 swapl(&stuff
->region
);
441 swapl(&stuff
->window
);
442 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
446 SProcCompositeNameWindowPixmap(ClientPtr client
)
448 REQUEST(xCompositeNameWindowPixmapReq
);
450 swaps(&stuff
->length
);
451 REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq
);
452 swapl(&stuff
->window
);
453 swapl(&stuff
->pixmap
);
454 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
458 SProcCompositeGetOverlayWindow(ClientPtr client
)
460 REQUEST(xCompositeGetOverlayWindowReq
);
462 swaps(&stuff
->length
);
463 REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq
);
464 swapl(&stuff
->window
);
465 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
469 SProcCompositeReleaseOverlayWindow(ClientPtr client
)
471 REQUEST(xCompositeReleaseOverlayWindowReq
);
473 swaps(&stuff
->length
);
474 REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq
);
475 swapl(&stuff
->window
);
476 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
479 static int (*SProcCompositeVector
[CompositeNumberRequests
]) (ClientPtr
) = {
480 SProcCompositeQueryVersion
,
481 SProcCompositeRedirectWindow
,
482 SProcCompositeRedirectSubwindows
,
483 SProcCompositeUnredirectWindow
,
484 SProcCompositeUnredirectSubwindows
,
485 SProcCompositeCreateRegionFromBorderClip
,
486 SProcCompositeNameWindowPixmap
,
487 SProcCompositeGetOverlayWindow
, SProcCompositeReleaseOverlayWindow
,};
490 SProcCompositeDispatch(ClientPtr client
)
494 if (stuff
->data
< CompositeNumberRequests
)
495 return (*SProcCompositeVector
[stuff
->data
]) (client
);
500 /** @see GetDefaultBytes */
502 GetCompositeClientWindowBytes(pointer value
, XID id
, ResourceSizePtr size
)
504 WindowPtr window
= value
;
506 /* Currently only pixmap bytes are reported to clients. */
507 size
->resourceSize
= 0;
509 /* Calculate pixmap reference sizes. */
510 size
->pixmapRefSize
= 0;
511 if (window
->redirectDraw
!= RedirectDrawNone
)
513 SizeType pixmapSizeFunc
= GetResourceTypeSizeFunc(RT_PIXMAP
);
514 ResourceSizeRec pixmapSize
= { 0, 0 };
515 ScreenPtr screen
= window
->drawable
.pScreen
;
516 PixmapPtr pixmap
= screen
->GetWindowPixmap(window
);
517 pixmapSizeFunc(pixmap
, pixmap
->drawable
.id
, &pixmapSize
);
518 size
->pixmapRefSize
+= pixmapSize
.pixmapRefSize
;
523 CompositeExtensionInit(void)
525 ExtensionEntry
*extEntry
;
528 /* Assume initialization is going to fail */
529 noCompositeExtension
= TRUE
;
531 for (s
= 0; s
< screenInfo
.numScreens
; s
++) {
532 ScreenPtr pScreen
= screenInfo
.screens
[s
];
535 /* Composite on 8bpp pseudocolor root windows appears to fail, so
536 * just disable it on anything pseudocolor for safety.
538 for (vis
= pScreen
->visuals
; vis
->vid
!= pScreen
->rootVisual
; vis
++);
539 if ((vis
->class | DynamicClass
) == PseudoColor
)
542 /* Ensure that Render is initialized, which is required for automatic
545 if (GetPictureScreenIfSet(pScreen
) == NULL
)
549 CompositeClientWindowType
= CreateNewResourceType
550 (FreeCompositeClientWindow
, "CompositeClientWindow");
551 if (!CompositeClientWindowType
)
554 SetResourceTypeSizeFunc(CompositeClientWindowType
,
555 GetCompositeClientWindowBytes
);
557 CompositeClientSubwindowsType
= CreateNewResourceType
558 (FreeCompositeClientSubwindows
, "CompositeClientSubwindows");
559 if (!CompositeClientSubwindowsType
)
562 CompositeClientOverlayType
= CreateNewResourceType
563 (FreeCompositeClientOverlay
, "CompositeClientOverlay");
564 if (!CompositeClientOverlayType
)
567 if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec
, PRIVATE_CLIENT
,
568 sizeof(CompositeClientRec
)))
571 if (!AddCallback(&ClientStateCallback
, CompositeClientCallback
, 0))
574 for (s
= 0; s
< screenInfo
.numScreens
; s
++)
575 if (!compScreenInit(screenInfo
.screens
[s
]))
578 extEntry
= AddExtension(COMPOSITE_NAME
, 0, 0,
579 ProcCompositeDispatch
, SProcCompositeDispatch
,
580 NULL
, StandardMinorOpcode
);
583 CompositeReqCode
= (CARD8
) extEntry
->base
;
585 miRegisterRedirectBorderClipProc(compSetRedirectBorderClip
,
586 compGetRedirectBorderClip
);
588 /* Initialization succeeded */
589 noCompositeExtension
= FALSE
;
593 #include "panoramiXsrv.h"
595 int (*PanoramiXSaveCompositeVector
[CompositeNumberRequests
]) (ClientPtr
);
598 PanoramiXCompositeRedirectWindow(ClientPtr client
)
603 REQUEST(xCompositeRedirectWindowReq
);
605 REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq
);
607 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
608 client
, DixUnknownAccess
))) {
609 client
->errorValue
= stuff
->window
;
613 FOR_NSCREENS_FORWARD(j
) {
614 stuff
->window
= win
->info
[j
].id
;
615 rc
= (*PanoramiXSaveCompositeVector
[stuff
->compositeReqType
]) (client
);
624 PanoramiXCompositeRedirectSubwindows(ClientPtr client
)
629 REQUEST(xCompositeRedirectSubwindowsReq
);
631 REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq
);
633 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
634 client
, DixUnknownAccess
))) {
635 client
->errorValue
= stuff
->window
;
639 FOR_NSCREENS_FORWARD(j
) {
640 stuff
->window
= win
->info
[j
].id
;
641 rc
= (*PanoramiXSaveCompositeVector
[stuff
->compositeReqType
]) (client
);
650 PanoramiXCompositeUnredirectWindow(ClientPtr client
)
655 REQUEST(xCompositeUnredirectWindowReq
);
657 REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq
);
659 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
660 client
, DixUnknownAccess
))) {
661 client
->errorValue
= stuff
->window
;
665 FOR_NSCREENS_FORWARD(j
) {
666 stuff
->window
= win
->info
[j
].id
;
667 rc
= (*PanoramiXSaveCompositeVector
[stuff
->compositeReqType
]) (client
);
676 PanoramiXCompositeUnredirectSubwindows(ClientPtr client
)
681 REQUEST(xCompositeUnredirectSubwindowsReq
);
683 REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq
);
685 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
686 client
, DixUnknownAccess
))) {
687 client
->errorValue
= stuff
->window
;
691 FOR_NSCREENS_FORWARD(j
) {
692 stuff
->window
= win
->info
[j
].id
;
693 rc
= (*PanoramiXSaveCompositeVector
[stuff
->compositeReqType
]) (client
);
702 PanoramiXCompositeNameWindowPixmap(ClientPtr client
)
708 PanoramiXRes
*win
, *newPix
;
711 REQUEST(xCompositeNameWindowPixmapReq
);
713 REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq
);
715 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
716 client
, DixUnknownAccess
))) {
717 client
->errorValue
= stuff
->window
;
721 LEGAL_NEW_RESOURCE(stuff
->pixmap
, client
);
723 if (!(newPix
= malloc(sizeof(PanoramiXRes
))))
726 newPix
->type
= XRT_PIXMAP
;
727 newPix
->u
.pix
.shared
= FALSE
;
728 panoramix_setup_ids(newPix
, client
, stuff
->pixmap
);
731 rc
= dixLookupResourceByType((void **) &pWin
, win
->info
[i
].id
,
732 RT_WINDOW
, client
, DixGetAttrAccess
);
734 client
->errorValue
= stuff
->window
;
739 if (!pWin
->viewable
) {
744 cw
= GetCompWindow(pWin
);
750 pPixmap
= (*pWin
->drawable
.pScreen
->GetWindowPixmap
) (pWin
);
756 if (!AddResource(newPix
->info
[i
].id
, RT_PIXMAP
, (pointer
) pPixmap
))
762 if (!AddResource(stuff
->pixmap
, XRT_PIXMAP
, (pointer
) newPix
))
769 PanoramiXCompositeGetOverlayWindow(ClientPtr client
)
771 REQUEST(xCompositeGetOverlayWindowReq
);
772 xCompositeGetOverlayWindowReply rep
;
776 CompOverlayClientPtr pOc
;
778 PanoramiXRes
*win
, *overlayWin
= NULL
;
781 REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq
);
783 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
784 client
, DixUnknownAccess
))) {
785 client
->errorValue
= stuff
->window
;
789 cs
= GetCompScreen(screenInfo
.screens
[0]);
790 if (!cs
->pOverlayWin
) {
791 if (!(overlayWin
= malloc(sizeof(PanoramiXRes
))))
794 overlayWin
->type
= XRT_WINDOW
;
795 overlayWin
->u
.win
.root
= FALSE
;
798 FOR_NSCREENS_BACKWARD(i
) {
799 rc
= dixLookupResourceByType((pointer
*) &pWin
, win
->info
[i
].id
,
800 RT_WINDOW
, client
, DixGetAttrAccess
);
802 client
->errorValue
= stuff
->window
;
805 pScreen
= pWin
->drawable
.pScreen
;
808 * Create an OverlayClient structure to mark this client's
809 * interest in the overlay window
811 pOc
= compCreateOverlayClient(pScreen
, client
);
816 * Make sure the overlay window exists
818 cs
= GetCompScreen(pScreen
);
819 if (cs
->pOverlayWin
== NULL
)
820 if (!compCreateOverlayWindow(pScreen
)) {
821 FreeResource(pOc
->resource
, RT_NONE
);
825 rc
= XaceHook(XACE_RESOURCE_ACCESS
, client
,
826 cs
->pOverlayWin
->drawable
.id
,
827 RT_WINDOW
, cs
->pOverlayWin
, RT_NONE
, NULL
,
830 FreeResource(pOc
->resource
, RT_NONE
);
837 cs
= GetCompScreen(screenInfo
.screens
[i
]);
838 overlayWin
->info
[i
].id
= cs
->pOverlayWin
->drawable
.id
;
841 AddResource(overlayWin
->info
[0].id
, XRT_WINDOW
, overlayWin
);
844 cs
= GetCompScreen(screenInfo
.screens
[0]);
847 rep
.sequenceNumber
= client
->sequence
;
849 rep
.overlayWin
= cs
->pOverlayWin
->drawable
.id
;
851 if (client
->swapped
) {
852 swaps(&rep
.sequenceNumber
);
854 swapl(&rep
.overlayWin
);
856 (void) WriteToClient(client
, sz_xCompositeGetOverlayWindowReply
,
863 PanoramiXCompositeReleaseOverlayWindow(ClientPtr client
)
865 REQUEST(xCompositeReleaseOverlayWindowReq
);
868 CompOverlayClientPtr pOc
;
872 REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq
);
874 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
875 client
, DixUnknownAccess
))) {
876 client
->errorValue
= stuff
->window
;
880 FOR_NSCREENS_BACKWARD(i
) {
881 if ((rc
= dixLookupResourceByType((void **) &pWin
, win
->info
[i
].id
,
883 DixUnknownAccess
))) {
884 client
->errorValue
= stuff
->window
;
887 pScreen
= pWin
->drawable
.pScreen
;
890 * Has client queried a reference to the overlay window
891 * on this screen? If not, generate an error.
893 pOc
= compFindOverlayClient(pWin
->drawable
.pScreen
, client
);
897 /* The delete function will free the client structure */
898 FreeResource(pOc
->resource
, RT_NONE
);
905 PanoramiXCompositeInit(void)
909 for (i
= 0; i
< CompositeNumberRequests
; i
++)
910 PanoramiXSaveCompositeVector
[i
] = ProcCompositeVector
[i
];
912 * Stuff in Xinerama aware request processing hooks
914 ProcCompositeVector
[X_CompositeRedirectWindow
] =
915 PanoramiXCompositeRedirectWindow
;
916 ProcCompositeVector
[X_CompositeRedirectSubwindows
] =
917 PanoramiXCompositeRedirectSubwindows
;
918 ProcCompositeVector
[X_CompositeUnredirectWindow
] =
919 PanoramiXCompositeUnredirectWindow
;
920 ProcCompositeVector
[X_CompositeUnredirectSubwindows
] =
921 PanoramiXCompositeUnredirectSubwindows
;
922 ProcCompositeVector
[X_CompositeNameWindowPixmap
] =
923 PanoramiXCompositeNameWindowPixmap
;
924 ProcCompositeVector
[X_CompositeGetOverlayWindow
] =
925 PanoramiXCompositeGetOverlayWindow
;
926 ProcCompositeVector
[X_CompositeReleaseOverlayWindow
] =
927 PanoramiXCompositeReleaseOverlayWindow
;
931 PanoramiXCompositeReset(void)
935 for (i
= 0; i
< CompositeNumberRequests
; i
++)
936 ProcCompositeVector
[i
] = PanoramiXSaveCompositeVector
[i
];