2 * Copyright © 2006 Sun Microsystems, Inc. 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 * Delete the given overlay client list element from its screen list.
55 compFreeOverlayClient (CompOverlayClientPtr pOcToDel)
57 ScreenPtr pScreen = pOcToDel->pScreen;
58 CompScreenPtr cs = GetCompScreen (pScreen);
59 CompOverlayClientPtr *pPrev, pOc;
61 for (pPrev = &cs->pOverlayClients; (pOc = *pPrev); pPrev = &pOc->pNext)
63 if (pOc == pOcToDel) {
70 /* Destroy overlay window when there are no more clients using it */
71 if (cs->pOverlayClients == NULL)
72 compDestroyOverlayWindow (pScreen);
76 * Return the client's first overlay client rec from the given screen
79 compFindOverlayClient (ScreenPtr pScreen, ClientPtr pClient)
81 CompScreenPtr cs = GetCompScreen(pScreen);
82 CompOverlayClientPtr pOc;
84 for (pOc = cs->pOverlayClients; pOc != NULL; pOc = pOc->pNext)
85 if (pOc->pClient == pClient)
92 * Create an overlay client object for the given client
95 compCreateOverlayClient (ScreenPtr pScreen, ClientPtr pClient)
97 CompScreenPtr cs = GetCompScreen(pScreen);
98 CompOverlayClientPtr pOc;
100 pOc = (CompOverlayClientPtr) malloc(sizeof(CompOverlayClientRec));
104 pOc->pClient = pClient;
105 pOc->pScreen = pScreen;
106 pOc->resource = FakeClientID(pClient->index);
107 pOc->pNext = cs->pOverlayClients;
108 cs->pOverlayClients = pOc;
111 * Create a resource for this element so it can be deleted
112 * when the client goes away.
114 if (!AddResource (pOc->resource, CompositeClientOverlayType, (pointer) pOc))
121 * Create the overlay window and map it
124 compCreateOverlayWindow (ScreenPtr pScreen)
126 CompScreenPtr cs = GetCompScreen(pScreen);
127 WindowPtr pRoot = pScreen->root;
129 XID attrs[] = { None, TRUE }; /* backPixmap, overrideRedirect */
132 pWin = cs->pOverlayWin =
133 CreateWindow (cs->overlayWid, pRoot,
134 0, 0, pScreen->width, pScreen->height, 0,
135 InputOutput, CWBackPixmap | CWOverrideRedirect, &attrs[0],
136 pRoot->drawable.depth,
137 serverClient, pScreen->rootVisual, &result);
141 if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer)pWin))
144 MapWindow(pWin, serverClient);
150 * Destroy the overlay window
153 compDestroyOverlayWindow (ScreenPtr pScreen)
155 CompScreenPtr cs = GetCompScreen(pScreen);
157 cs->pOverlayWin = NullWindow;
158 FreeResource (cs->overlayWid, RT_NONE);