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>
52 #include "panoramiXsrv.h"
56 * Delete the given overlay client list element from its screen list.
59 compFreeOverlayClient(CompOverlayClientPtr pOcToDel
)
61 ScreenPtr pScreen
= pOcToDel
->pScreen
;
62 CompScreenPtr cs
= GetCompScreen(pScreen
);
63 CompOverlayClientPtr
*pPrev
, pOc
;
65 for (pPrev
= &cs
->pOverlayClients
; (pOc
= *pPrev
); pPrev
= &pOc
->pNext
) {
66 if (pOc
== pOcToDel
) {
73 /* Destroy overlay window when there are no more clients using it */
74 if (cs
->pOverlayClients
== NULL
)
75 compDestroyOverlayWindow(pScreen
);
79 * Return the client's first overlay client rec from the given screen
82 compFindOverlayClient(ScreenPtr pScreen
, ClientPtr pClient
)
84 CompScreenPtr cs
= GetCompScreen(pScreen
);
85 CompOverlayClientPtr pOc
;
87 for (pOc
= cs
->pOverlayClients
; pOc
!= NULL
; pOc
= pOc
->pNext
)
88 if (pOc
->pClient
== pClient
)
95 * Create an overlay client object for the given client
98 compCreateOverlayClient(ScreenPtr pScreen
, ClientPtr pClient
)
100 CompScreenPtr cs
= GetCompScreen(pScreen
);
101 CompOverlayClientPtr pOc
;
103 pOc
= (CompOverlayClientPtr
) malloc(sizeof(CompOverlayClientRec
));
107 pOc
->pClient
= pClient
;
108 pOc
->pScreen
= pScreen
;
109 pOc
->resource
= FakeClientID(pClient
->index
);
110 pOc
->pNext
= cs
->pOverlayClients
;
111 cs
->pOverlayClients
= pOc
;
114 * Create a resource for this element so it can be deleted
115 * when the client goes away.
117 if (!AddResource(pOc
->resource
, CompositeClientOverlayType
, (pointer
) pOc
))
124 * Create the overlay window and map it
127 compCreateOverlayWindow(ScreenPtr pScreen
)
129 CompScreenPtr cs
= GetCompScreen(pScreen
);
130 WindowPtr pRoot
= pScreen
->root
;
132 XID attrs
[] = { None
, TRUE
}; /* backPixmap, overrideRedirect */
134 int w
= pScreen
->width
;
135 int h
= pScreen
->height
;
139 if (!noPanoramiXExtension
) {
142 w
= PanoramiXPixWidth
;
143 h
= PanoramiXPixHeight
;
147 pWin
= cs
->pOverlayWin
=
148 CreateWindow(cs
->overlayWid
, pRoot
, x
, y
, w
, h
, 0,
149 InputOutput
, CWBackPixmap
| CWOverrideRedirect
, &attrs
[0],
150 pRoot
->drawable
.depth
,
151 serverClient
, pScreen
->rootVisual
, &result
);
155 if (!AddResource(pWin
->drawable
.id
, RT_WINDOW
, (pointer
) pWin
))
158 MapWindow(pWin
, serverClient
);
164 * Destroy the overlay window
167 compDestroyOverlayWindow(ScreenPtr pScreen
)
169 CompScreenPtr cs
= GetCompScreen(pScreen
);
171 cs
->pOverlayWin
= NullWindow
;
172 FreeResource(cs
->overlayWid
, RT_NONE
);