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"
53 static CARD8 CompositeReqCode
;
54 static DevPrivateKeyRec CompositeClientPrivateKeyRec
;
56 #define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec)
57 RESTYPE CompositeClientWindowType
;
58 RESTYPE CompositeClientSubwindowsType
;
59 RESTYPE CompositeClientOverlayType
;
61 typedef struct _CompositeClient
{
64 } CompositeClientRec
, *CompositeClientPtr
;
66 #define GetCompositeClient(pClient) ((CompositeClientPtr) \
67 dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey))
70 CompositeClientCallback(CallbackListPtr
*list
, pointer closure
, pointer data
)
72 NewClientInfoRec
*clientinfo
= (NewClientInfoRec
*) data
;
73 ClientPtr pClient
= clientinfo
->client
;
74 CompositeClientPtr pCompositeClient
= GetCompositeClient(pClient
);
76 pCompositeClient
->major_version
= 0;
77 pCompositeClient
->minor_version
= 0;
81 FreeCompositeClientWindow(pointer value
, XID ccwid
)
83 WindowPtr pWin
= value
;
85 compFreeClientWindow(pWin
, ccwid
);
90 FreeCompositeClientSubwindows(pointer value
, XID ccwid
)
92 WindowPtr pWin
= value
;
94 compFreeClientSubwindows(pWin
, ccwid
);
99 FreeCompositeClientOverlay(pointer value
, XID ccwid
)
101 CompOverlayClientPtr pOc
= (CompOverlayClientPtr
) value
;
103 compFreeOverlayClient(pOc
);
108 ProcCompositeQueryVersion(ClientPtr client
)
110 CompositeClientPtr pCompositeClient
= GetCompositeClient(client
);
111 xCompositeQueryVersionReply rep
= {
113 .sequenceNumber
= client
->sequence
,
117 REQUEST(xCompositeQueryVersionReq
);
119 REQUEST_SIZE_MATCH(xCompositeQueryVersionReq
);
120 if (stuff
->majorVersion
< SERVER_COMPOSITE_MAJOR_VERSION
) {
121 rep
.majorVersion
= stuff
->majorVersion
;
122 rep
.minorVersion
= stuff
->minorVersion
;
125 rep
.majorVersion
= SERVER_COMPOSITE_MAJOR_VERSION
;
126 rep
.minorVersion
= SERVER_COMPOSITE_MINOR_VERSION
;
128 pCompositeClient
->major_version
= rep
.majorVersion
;
129 pCompositeClient
->minor_version
= rep
.minorVersion
;
130 if (client
->swapped
) {
131 swaps(&rep
.sequenceNumber
);
133 swapl(&rep
.majorVersion
);
134 swapl(&rep
.minorVersion
);
136 WriteToClient(client
, sizeof(xCompositeQueryVersionReply
), &rep
);
140 #define VERIFY_WINDOW(pWindow, wid, client, mode) \
143 err = dixLookupResourceByType((pointer *) &pWindow, wid, \
144 RT_WINDOW, client, mode); \
145 if (err != Success) { \
146 client->errorValue = wid; \
152 ProcCompositeRedirectWindow(ClientPtr client
)
156 REQUEST(xCompositeRedirectWindowReq
);
158 REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq
);
159 VERIFY_WINDOW(pWin
, stuff
->window
, client
,
160 DixSetAttrAccess
| DixManageAccess
| DixBlendAccess
);
162 return compRedirectWindow(client
, pWin
, stuff
->update
);
166 ProcCompositeRedirectSubwindows(ClientPtr client
)
170 REQUEST(xCompositeRedirectSubwindowsReq
);
172 REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq
);
173 VERIFY_WINDOW(pWin
, stuff
->window
, client
,
174 DixSetAttrAccess
| DixManageAccess
| DixBlendAccess
);
176 return compRedirectSubwindows(client
, pWin
, stuff
->update
);
180 ProcCompositeUnredirectWindow(ClientPtr client
)
184 REQUEST(xCompositeUnredirectWindowReq
);
186 REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq
);
187 VERIFY_WINDOW(pWin
, stuff
->window
, client
,
188 DixSetAttrAccess
| DixManageAccess
| DixBlendAccess
);
190 return compUnredirectWindow(client
, pWin
, stuff
->update
);
194 ProcCompositeUnredirectSubwindows(ClientPtr client
)
198 REQUEST(xCompositeUnredirectSubwindowsReq
);
200 REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq
);
201 VERIFY_WINDOW(pWin
, stuff
->window
, client
,
202 DixSetAttrAccess
| DixManageAccess
| DixBlendAccess
);
204 return compUnredirectSubwindows(client
, pWin
, stuff
->update
);
208 ProcCompositeCreateRegionFromBorderClip(ClientPtr client
)
212 RegionPtr pBorderClip
, pRegion
;
214 REQUEST(xCompositeCreateRegionFromBorderClipReq
);
216 REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq
);
217 VERIFY_WINDOW(pWin
, stuff
->window
, client
, DixGetAttrAccess
);
218 LEGAL_NEW_RESOURCE(stuff
->region
, client
);
220 cw
= GetCompWindow(pWin
);
222 pBorderClip
= &cw
->borderClip
;
224 pBorderClip
= &pWin
->borderClip
;
225 pRegion
= XFixesRegionCopy(pBorderClip
);
228 RegionTranslate(pRegion
, -pWin
->drawable
.x
, -pWin
->drawable
.y
);
230 if (!AddResource(stuff
->region
, RegionResType
, (pointer
) pRegion
))
237 ProcCompositeNameWindowPixmap(ClientPtr client
)
244 REQUEST(xCompositeNameWindowPixmapReq
);
246 REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq
);
247 VERIFY_WINDOW(pWin
, stuff
->window
, client
, DixGetAttrAccess
);
252 LEGAL_NEW_RESOURCE(stuff
->pixmap
, client
);
254 cw
= GetCompWindow(pWin
);
258 pPixmap
= (*pWin
->drawable
.pScreen
->GetWindowPixmap
) (pWin
);
262 /* security creation/labeling check */
263 rc
= XaceHook(XACE_RESOURCE_ACCESS
, client
, stuff
->pixmap
, RT_PIXMAP
,
264 pPixmap
, RT_WINDOW
, pWin
, DixCreateAccess
);
270 if (!AddResource(stuff
->pixmap
, RT_PIXMAP
, (pointer
) pPixmap
))
277 ProcCompositeGetOverlayWindow(ClientPtr client
)
279 REQUEST(xCompositeGetOverlayWindowReq
);
280 xCompositeGetOverlayWindowReply rep
;
284 CompOverlayClientPtr pOc
;
287 REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq
);
288 VERIFY_WINDOW(pWin
, stuff
->window
, client
, DixGetAttrAccess
);
289 pScreen
= pWin
->drawable
.pScreen
;
292 * Create an OverlayClient structure to mark this client's
293 * interest in the overlay window
295 pOc
= compCreateOverlayClient(pScreen
, client
);
300 * Make sure the overlay window exists
302 cs
= GetCompScreen(pScreen
);
303 if (cs
->pOverlayWin
== NULL
)
304 if (!compCreateOverlayWindow(pScreen
)) {
305 FreeResource(pOc
->resource
, RT_NONE
);
309 rc
= XaceHook(XACE_RESOURCE_ACCESS
, client
, cs
->pOverlayWin
->drawable
.id
,
310 RT_WINDOW
, cs
->pOverlayWin
, RT_NONE
, NULL
, DixGetAttrAccess
);
312 FreeResource(pOc
->resource
, RT_NONE
);
316 rep
= (xCompositeGetOverlayWindowReply
) {
318 .sequenceNumber
= client
->sequence
,
320 .overlayWin
= cs
->pOverlayWin
->drawable
.id
323 if (client
->swapped
) {
324 swaps(&rep
.sequenceNumber
);
326 swapl(&rep
.overlayWin
);
328 WriteToClient(client
, sz_xCompositeGetOverlayWindowReply
, &rep
);
334 ProcCompositeReleaseOverlayWindow(ClientPtr client
)
336 REQUEST(xCompositeReleaseOverlayWindowReq
);
339 CompOverlayClientPtr pOc
;
341 REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq
);
342 VERIFY_WINDOW(pWin
, stuff
->window
, client
, DixGetAttrAccess
);
343 pScreen
= pWin
->drawable
.pScreen
;
346 * Has client queried a reference to the overlay window
347 * on this screen? If not, generate an error.
349 pOc
= compFindOverlayClient(pWin
->drawable
.pScreen
, client
);
353 /* The delete function will free the client structure */
354 FreeResource(pOc
->resource
, RT_NONE
);
359 static int (*ProcCompositeVector
[CompositeNumberRequests
]) (ClientPtr
) = {
360 ProcCompositeQueryVersion
,
361 ProcCompositeRedirectWindow
,
362 ProcCompositeRedirectSubwindows
,
363 ProcCompositeUnredirectWindow
,
364 ProcCompositeUnredirectSubwindows
,
365 ProcCompositeCreateRegionFromBorderClip
,
366 ProcCompositeNameWindowPixmap
,
367 ProcCompositeGetOverlayWindow
, ProcCompositeReleaseOverlayWindow
,};
370 ProcCompositeDispatch(ClientPtr client
)
374 if (stuff
->data
< CompositeNumberRequests
)
375 return (*ProcCompositeVector
[stuff
->data
]) (client
);
381 SProcCompositeQueryVersion(ClientPtr client
)
383 REQUEST(xCompositeQueryVersionReq
);
385 swaps(&stuff
->length
);
386 REQUEST_SIZE_MATCH(xCompositeQueryVersionReq
);
387 swapl(&stuff
->majorVersion
);
388 swapl(&stuff
->minorVersion
);
389 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
393 SProcCompositeRedirectWindow(ClientPtr client
)
395 REQUEST(xCompositeRedirectWindowReq
);
397 swaps(&stuff
->length
);
398 REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq
);
399 swapl(&stuff
->window
);
400 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
404 SProcCompositeRedirectSubwindows(ClientPtr client
)
406 REQUEST(xCompositeRedirectSubwindowsReq
);
408 swaps(&stuff
->length
);
409 REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq
);
410 swapl(&stuff
->window
);
411 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
415 SProcCompositeUnredirectWindow(ClientPtr client
)
417 REQUEST(xCompositeUnredirectWindowReq
);
419 swaps(&stuff
->length
);
420 REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq
);
421 swapl(&stuff
->window
);
422 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
426 SProcCompositeUnredirectSubwindows(ClientPtr client
)
428 REQUEST(xCompositeUnredirectSubwindowsReq
);
430 swaps(&stuff
->length
);
431 REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq
);
432 swapl(&stuff
->window
);
433 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
437 SProcCompositeCreateRegionFromBorderClip(ClientPtr client
)
439 REQUEST(xCompositeCreateRegionFromBorderClipReq
);
441 swaps(&stuff
->length
);
442 REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq
);
443 swapl(&stuff
->region
);
444 swapl(&stuff
->window
);
445 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
449 SProcCompositeNameWindowPixmap(ClientPtr client
)
451 REQUEST(xCompositeNameWindowPixmapReq
);
453 swaps(&stuff
->length
);
454 REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq
);
455 swapl(&stuff
->window
);
456 swapl(&stuff
->pixmap
);
457 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
461 SProcCompositeGetOverlayWindow(ClientPtr client
)
463 REQUEST(xCompositeGetOverlayWindowReq
);
465 swaps(&stuff
->length
);
466 REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq
);
467 swapl(&stuff
->window
);
468 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
472 SProcCompositeReleaseOverlayWindow(ClientPtr client
)
474 REQUEST(xCompositeReleaseOverlayWindowReq
);
476 swaps(&stuff
->length
);
477 REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq
);
478 swapl(&stuff
->window
);
479 return (*ProcCompositeVector
[stuff
->compositeReqType
]) (client
);
482 static int (*SProcCompositeVector
[CompositeNumberRequests
]) (ClientPtr
) = {
483 SProcCompositeQueryVersion
,
484 SProcCompositeRedirectWindow
,
485 SProcCompositeRedirectSubwindows
,
486 SProcCompositeUnredirectWindow
,
487 SProcCompositeUnredirectSubwindows
,
488 SProcCompositeCreateRegionFromBorderClip
,
489 SProcCompositeNameWindowPixmap
,
490 SProcCompositeGetOverlayWindow
, SProcCompositeReleaseOverlayWindow
,};
493 SProcCompositeDispatch(ClientPtr client
)
497 if (stuff
->data
< CompositeNumberRequests
)
498 return (*SProcCompositeVector
[stuff
->data
]) (client
);
503 /** @see GetDefaultBytes */
505 GetCompositeClientWindowBytes(pointer value
, XID id
, ResourceSizePtr size
)
507 WindowPtr window
= value
;
509 /* Currently only pixmap bytes are reported to clients. */
510 size
->resourceSize
= 0;
512 /* Calculate pixmap reference sizes. */
513 size
->pixmapRefSize
= 0;
514 if (window
->redirectDraw
!= RedirectDrawNone
)
516 SizeType pixmapSizeFunc
= GetResourceTypeSizeFunc(RT_PIXMAP
);
517 ResourceSizeRec pixmapSize
= { 0, 0 };
518 ScreenPtr screen
= window
->drawable
.pScreen
;
519 PixmapPtr pixmap
= screen
->GetWindowPixmap(window
);
520 pixmapSizeFunc(pixmap
, pixmap
->drawable
.id
, &pixmapSize
);
521 size
->pixmapRefSize
+= pixmapSize
.pixmapRefSize
;
526 CompositeExtensionInit(void)
528 ExtensionEntry
*extEntry
;
531 /* Assume initialization is going to fail */
532 noCompositeExtension
= TRUE
;
534 for (s
= 0; s
< screenInfo
.numScreens
; s
++) {
535 ScreenPtr pScreen
= screenInfo
.screens
[s
];
538 /* Composite on 8bpp pseudocolor root windows appears to fail, so
539 * just disable it on anything pseudocolor for safety.
541 for (vis
= pScreen
->visuals
; vis
->vid
!= pScreen
->rootVisual
; vis
++);
542 if ((vis
->class | DynamicClass
) == PseudoColor
)
545 /* Ensure that Render is initialized, which is required for automatic
548 if (GetPictureScreenIfSet(pScreen
) == NULL
)
552 CompositeClientWindowType
= CreateNewResourceType
553 (FreeCompositeClientWindow
, "CompositeClientWindow");
554 if (!CompositeClientWindowType
)
557 SetResourceTypeSizeFunc(CompositeClientWindowType
,
558 GetCompositeClientWindowBytes
);
560 CompositeClientSubwindowsType
= CreateNewResourceType
561 (FreeCompositeClientSubwindows
, "CompositeClientSubwindows");
562 if (!CompositeClientSubwindowsType
)
565 CompositeClientOverlayType
= CreateNewResourceType
566 (FreeCompositeClientOverlay
, "CompositeClientOverlay");
567 if (!CompositeClientOverlayType
)
570 if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec
, PRIVATE_CLIENT
,
571 sizeof(CompositeClientRec
)))
574 if (!AddCallback(&ClientStateCallback
, CompositeClientCallback
, 0))
577 for (s
= 0; s
< screenInfo
.numScreens
; s
++)
578 if (!compScreenInit(screenInfo
.screens
[s
]))
581 extEntry
= AddExtension(COMPOSITE_NAME
, 0, 0,
582 ProcCompositeDispatch
, SProcCompositeDispatch
,
583 NULL
, StandardMinorOpcode
);
586 CompositeReqCode
= (CARD8
) extEntry
->base
;
588 miRegisterRedirectBorderClipProc(compSetRedirectBorderClip
,
589 compGetRedirectBorderClip
);
591 /* Initialization succeeded */
592 noCompositeExtension
= FALSE
;
596 #include "panoramiXsrv.h"
598 int (*PanoramiXSaveCompositeVector
[CompositeNumberRequests
]) (ClientPtr
);
601 PanoramiXCompositeRedirectWindow(ClientPtr client
)
606 REQUEST(xCompositeRedirectWindowReq
);
608 REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq
);
610 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
611 client
, DixUnknownAccess
))) {
612 client
->errorValue
= stuff
->window
;
616 FOR_NSCREENS_FORWARD(j
) {
617 stuff
->window
= win
->info
[j
].id
;
618 rc
= (*PanoramiXSaveCompositeVector
[stuff
->compositeReqType
]) (client
);
627 PanoramiXCompositeRedirectSubwindows(ClientPtr client
)
632 REQUEST(xCompositeRedirectSubwindowsReq
);
634 REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq
);
636 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
637 client
, DixUnknownAccess
))) {
638 client
->errorValue
= stuff
->window
;
642 FOR_NSCREENS_FORWARD(j
) {
643 stuff
->window
= win
->info
[j
].id
;
644 rc
= (*PanoramiXSaveCompositeVector
[stuff
->compositeReqType
]) (client
);
653 PanoramiXCompositeUnredirectWindow(ClientPtr client
)
658 REQUEST(xCompositeUnredirectWindowReq
);
660 REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq
);
662 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
663 client
, DixUnknownAccess
))) {
664 client
->errorValue
= stuff
->window
;
668 FOR_NSCREENS_FORWARD(j
) {
669 stuff
->window
= win
->info
[j
].id
;
670 rc
= (*PanoramiXSaveCompositeVector
[stuff
->compositeReqType
]) (client
);
679 PanoramiXCompositeUnredirectSubwindows(ClientPtr client
)
684 REQUEST(xCompositeUnredirectSubwindowsReq
);
686 REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq
);
688 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
689 client
, DixUnknownAccess
))) {
690 client
->errorValue
= stuff
->window
;
694 FOR_NSCREENS_FORWARD(j
) {
695 stuff
->window
= win
->info
[j
].id
;
696 rc
= (*PanoramiXSaveCompositeVector
[stuff
->compositeReqType
]) (client
);
705 PanoramiXCompositeNameWindowPixmap(ClientPtr client
)
711 PanoramiXRes
*win
, *newPix
;
714 REQUEST(xCompositeNameWindowPixmapReq
);
716 REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq
);
718 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
719 client
, DixUnknownAccess
))) {
720 client
->errorValue
= stuff
->window
;
724 LEGAL_NEW_RESOURCE(stuff
->pixmap
, client
);
726 if (!(newPix
= malloc(sizeof(PanoramiXRes
))))
729 newPix
->type
= XRT_PIXMAP
;
730 newPix
->u
.pix
.shared
= FALSE
;
731 panoramix_setup_ids(newPix
, client
, stuff
->pixmap
);
734 rc
= dixLookupResourceByType((void **) &pWin
, win
->info
[i
].id
,
735 RT_WINDOW
, client
, DixGetAttrAccess
);
737 client
->errorValue
= stuff
->window
;
742 if (!pWin
->viewable
) {
747 cw
= GetCompWindow(pWin
);
753 pPixmap
= (*pWin
->drawable
.pScreen
->GetWindowPixmap
) (pWin
);
759 if (!AddResource(newPix
->info
[i
].id
, RT_PIXMAP
, (pointer
) pPixmap
))
765 if (!AddResource(stuff
->pixmap
, XRT_PIXMAP
, (pointer
) newPix
))
772 PanoramiXCompositeGetOverlayWindow(ClientPtr client
)
774 REQUEST(xCompositeGetOverlayWindowReq
);
775 xCompositeGetOverlayWindowReply rep
;
779 CompOverlayClientPtr pOc
;
781 PanoramiXRes
*win
, *overlayWin
= NULL
;
784 REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq
);
786 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
787 client
, DixUnknownAccess
))) {
788 client
->errorValue
= stuff
->window
;
792 cs
= GetCompScreen(screenInfo
.screens
[0]);
793 if (!cs
->pOverlayWin
) {
794 if (!(overlayWin
= malloc(sizeof(PanoramiXRes
))))
797 overlayWin
->type
= XRT_WINDOW
;
798 overlayWin
->u
.win
.root
= FALSE
;
801 FOR_NSCREENS_BACKWARD(i
) {
802 rc
= dixLookupResourceByType((pointer
*) &pWin
, win
->info
[i
].id
,
803 RT_WINDOW
, client
, DixGetAttrAccess
);
805 client
->errorValue
= stuff
->window
;
809 pScreen
= pWin
->drawable
.pScreen
;
812 * Create an OverlayClient structure to mark this client's
813 * interest in the overlay window
815 pOc
= compCreateOverlayClient(pScreen
, client
);
822 * Make sure the overlay window exists
824 cs
= GetCompScreen(pScreen
);
825 if (cs
->pOverlayWin
== NULL
)
826 if (!compCreateOverlayWindow(pScreen
)) {
827 FreeResource(pOc
->resource
, RT_NONE
);
832 rc
= XaceHook(XACE_RESOURCE_ACCESS
, client
,
833 cs
->pOverlayWin
->drawable
.id
,
834 RT_WINDOW
, cs
->pOverlayWin
, RT_NONE
, NULL
,
837 FreeResource(pOc
->resource
, RT_NONE
);
845 cs
= GetCompScreen(screenInfo
.screens
[i
]);
846 overlayWin
->info
[i
].id
= cs
->pOverlayWin
->drawable
.id
;
849 AddResource(overlayWin
->info
[0].id
, XRT_WINDOW
, overlayWin
);
852 cs
= GetCompScreen(screenInfo
.screens
[0]);
854 rep
= (xCompositeGetOverlayWindowReply
) {
856 .sequenceNumber
= client
->sequence
,
858 .overlayWin
= cs
->pOverlayWin
->drawable
.id
861 if (client
->swapped
) {
862 swaps(&rep
.sequenceNumber
);
864 swapl(&rep
.overlayWin
);
866 WriteToClient(client
, sz_xCompositeGetOverlayWindowReply
, &rep
);
872 PanoramiXCompositeReleaseOverlayWindow(ClientPtr client
)
874 REQUEST(xCompositeReleaseOverlayWindowReq
);
877 CompOverlayClientPtr pOc
;
881 REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq
);
883 if ((rc
= dixLookupResourceByType((void **) &win
, stuff
->window
, XRT_WINDOW
,
884 client
, DixUnknownAccess
))) {
885 client
->errorValue
= stuff
->window
;
889 FOR_NSCREENS_BACKWARD(i
) {
890 if ((rc
= dixLookupResourceByType((void **) &pWin
, win
->info
[i
].id
,
892 DixUnknownAccess
))) {
893 client
->errorValue
= stuff
->window
;
896 pScreen
= pWin
->drawable
.pScreen
;
899 * Has client queried a reference to the overlay window
900 * on this screen? If not, generate an error.
902 pOc
= compFindOverlayClient(pWin
->drawable
.pScreen
, client
);
906 /* The delete function will free the client structure */
907 FreeResource(pOc
->resource
, RT_NONE
);
914 PanoramiXCompositeInit(void)
918 for (i
= 0; i
< CompositeNumberRequests
; i
++)
919 PanoramiXSaveCompositeVector
[i
] = ProcCompositeVector
[i
];
921 * Stuff in Xinerama aware request processing hooks
923 ProcCompositeVector
[X_CompositeRedirectWindow
] =
924 PanoramiXCompositeRedirectWindow
;
925 ProcCompositeVector
[X_CompositeRedirectSubwindows
] =
926 PanoramiXCompositeRedirectSubwindows
;
927 ProcCompositeVector
[X_CompositeUnredirectWindow
] =
928 PanoramiXCompositeUnredirectWindow
;
929 ProcCompositeVector
[X_CompositeUnredirectSubwindows
] =
930 PanoramiXCompositeUnredirectSubwindows
;
931 ProcCompositeVector
[X_CompositeNameWindowPixmap
] =
932 PanoramiXCompositeNameWindowPixmap
;
933 ProcCompositeVector
[X_CompositeGetOverlayWindow
] =
934 PanoramiXCompositeGetOverlayWindow
;
935 ProcCompositeVector
[X_CompositeReleaseOverlayWindow
] =
936 PanoramiXCompositeReleaseOverlayWindow
;
940 PanoramiXCompositeReset(void)
944 for (i
= 0; i
< CompositeNumberRequests
; i
++)
945 ProcCompositeVector
[i
] = PanoramiXSaveCompositeVector
[i
];