diff options
Diffstat (limited to 'composite')
-rw-r--r-- | composite/compalloc.c | 25 | ||||
-rw-r--r-- | composite/compext.c | 301 | ||||
-rw-r--r-- | composite/compinit.c | 33 | ||||
-rw-r--r-- | composite/compint.h | 54 | ||||
-rw-r--r-- | composite/compwindow.c | 51 |
5 files changed, 463 insertions, 1 deletions
diff --git a/composite/compalloc.c b/composite/compalloc.c index 1deef685c..5bbf0a279 100644 --- a/composite/compalloc.c +++ b/composite/compalloc.c @@ -1,6 +1,26 @@ /* * $Id$ * + * Copyright © 2006 Sun Microsystems + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Sun Microsystems not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -58,6 +78,11 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update) CompWindowPtr cw = GetCompWindow (pWin); CompClientWindowPtr ccw; Bool wasMapped = pWin->mapped; + CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen); + + if (pWin == cs->pOverlayWin) { + return Success; + } /* * Only one Manual update is allowed diff --git a/composite/compext.c b/composite/compext.c index 8b1d45403..cc9b665f7 100644 --- a/composite/compext.c +++ b/composite/compext.c @@ -1,6 +1,27 @@ /* * $Id$ * + * + * Copyright © 2006 Sun Microsystems + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Sun Microsystems not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -32,6 +53,10 @@ static CARD8 CompositeReqCode; int CompositeClientPrivateIndex; RESTYPE CompositeClientWindowType; RESTYPE CompositeClientSubwindowsType; +RESTYPE CompositeClientOverlayType; + +static void deleteCompOverlayClient (CompOverlayClientPtr pOcToDel, + ScreenPtr pScreen); typedef struct _CompositeClient { int major_version; @@ -77,6 +102,26 @@ FreeCompositeClientSubwindows (pointer value, XID ccwid) } static int +FreeCompositeClientOverlay (pointer value, XID ccwid) +{ + CompOverlayClientPtr pOc = (CompOverlayClientPtr) value; + ScreenPtr pScreen = pOc->pScreen; + CompScreenPtr cs; + + deleteCompOverlayClient(pOc, pScreen); + + /* Unmap overlay window when there are no more clients using it */ + cs = GetCompScreen(pScreen); + if (cs->pOverlayClients == NULL) { + if (cs->pOverlayWin != NULL) { + UnmapWindow(cs->pOverlayWin, FALSE); + } + } + + return Success; +} + +static int ProcCompositeQueryVersion (ClientPtr client) { CompositeClientPtr pCompositeClient = GetCompositeClient (client); @@ -243,6 +288,229 @@ ProcCompositeNameWindowPixmap (ClientPtr client) return(client->noClientException); } + +/* + * Routines for manipulating the per-screen overlay clients list. + * This list indicates which clients have called GetOverlayWindow + * for this screen. + */ + +/* Return the screen's overlay client list element for the given client */ +static CompOverlayClientPtr +findCompOverlayClient (ClientPtr pClient, ScreenPtr pScreen) +{ + CompScreenPtr cs = GetCompScreen(pScreen); + CompOverlayClientPtr pOc; + + for (pOc = cs->pOverlayClients; pOc != NULL; pOc = pOc->pNext) { + if (pOc->pClient == pClient) { + return pOc; + } + } + + return NULL; +} + +static int +createCompOverlayClient (ClientPtr pClient, ScreenPtr pScreen) +{ + CompScreenPtr cs = GetCompScreen(pScreen); + CompOverlayClientPtr pOc; + + pOc = (CompOverlayClientPtr) xalloc(sizeof(CompOverlayClientRec)); + if (pOc == NULL) { + return BadAlloc; + } + pOc->pClient = pClient; + pOc->pScreen = pScreen; + pOc->resource = FakeClientID(pClient->index); + pOc->pNext = cs->pOverlayClients; + cs->pOverlayClients = pOc; + + /* + * Create a resource for this element so it can be deleted + * when the client goes away. + */ + if (!AddResource (pOc->resource, CompositeClientOverlayType, + (pointer) pOc)) { + xfree(pOc); + return BadAlloc; + } + + return Success; +} + +/* + * Delete the given overlay client list element from its screen list. + */ +static void +deleteCompOverlayClient (CompOverlayClientPtr pOcToDel, ScreenPtr pScreen) +{ + CompScreenPtr cs = GetCompScreen(pScreen); + CompOverlayClientPtr pOc, pNext; + CompOverlayClientPtr pOcLast = NULL; + + pOc = cs->pOverlayClients; + while (pOc != NULL) { + pNext = pOc->pNext; + if (pOc == pOcToDel) { + xfree(pOc); + if (pOcLast == NULL) { + cs->pOverlayClients = pNext; + } else { + pOcLast->pNext = pNext; + } + break; + } + pOcLast = pOc; + pOc = pNext; + } +} + +/* + * Delete all the hide-counts list elements for this screen. + */ +void +deleteCompOverlayClientsForScreen (ScreenPtr pScreen) +{ + CompScreenPtr cs = GetCompScreen(pScreen); + CompOverlayClientPtr pOc, pTmp; + + pOc = cs->pOverlayClients; + while (pOc != NULL) { + pTmp = pOc->pNext; + FreeResource(pOc->resource, 0); + pOc = pTmp; + } + cs->pOverlayClients = NULL; +} + +/* +** If necessary, create the overlay window. And map it +** Note: I found it excessively difficult to destroy this window +** during compCloseScreen; DeleteWindow can't be called because +** the input devices are already shut down. So we are going to +** just allocate an overlay window once per screen per X server +** invocation. +*/ + +static WindowPtr +createOverlayWindow (ScreenPtr pScreen) +{ + int wid = FakeClientID(0); + WindowPtr pWin; + XID overrideRedirect = TRUE; + int result; + + pWin = CreateWindow ( + wid, WindowTable[pScreen->myNum], + 0, 0, pScreen->width, pScreen->height, 0, + InputOutput, CWOverrideRedirect, &overrideRedirect, + WindowTable[pScreen->myNum]->drawable.depth, + serverClient, pScreen->rootVisual, &result); + if (pWin == NULL) { + return NULL; + } + + if (!AddResource(wid, RT_WINDOW, (pointer)pWin)) { + DeleteWindow(pWin, None); + return NULL; + } + + return pWin; +} + +int +ProcCompositeGetOverlayWindow (ClientPtr client) +{ + REQUEST(xCompositeGetOverlayWindowReq); + xCompositeGetOverlayWindowReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + CompScreenPtr cs; + CompOverlayClientPtr pOc; + + REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); + pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW); + if (!pWin) + { + client->errorValue = stuff->window; + return BadWindow; + } + pScreen = pWin->drawable.pScreen; + + cs = GetCompScreen(pScreen); + if (cs->pOverlayWin == NULL) { + cs->pOverlayWin = createOverlayWindow(pScreen); + if (cs->pOverlayWin == NULL) { + return BadAlloc; + } + } + MapWindow(cs->pOverlayWin, serverClient); + + /* Record that client is using this overlay window */ + pOc = findCompOverlayClient(client, pScreen); + if (pOc == NULL) { + int ret = createCompOverlayClient(client, pScreen); + if (ret != Success) { + return ret; + } + } + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.overlayWin = cs->pOverlayWin->drawable.id; + + if (client->swapped) + { + int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.overlayWin, n); + } + (void) WriteToClient(client, sz_xCompositeGetOverlayWindowReply, (char *)&rep); + + return client->noClientException; +} + +int +ProcCompositeReleaseOverlayWindow (ClientPtr client) +{ + REQUEST(xCompositeReleaseOverlayWindowReq); + WindowPtr pWin; + ScreenPtr pScreen; + CompOverlayClientPtr pOc; + CompScreenPtr cs; + + REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq); + pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW); + if (!pWin) + { + client->errorValue = stuff->window; + return BadWindow; + } + pScreen = pWin->drawable.pScreen; + + /* + * Has client queried a reference to the overlay window + * on this screen? If not, generate an error. + */ + pOc = findCompOverlayClient(client, pWin->drawable.pScreen); + if (pOc == NULL) { + return BadMatch; + } + + deleteCompOverlayClient(pOc, pOc->pScreen); + + cs = GetCompScreen(pScreen); + if (cs->pOverlayClients == NULL) { + UnmapWindow(cs->pOverlayWin, FALSE); + } + + return client->noClientException; +} + int (*ProcCompositeVector[CompositeNumberRequests])(ClientPtr) = { ProcCompositeQueryVersion, ProcCompositeRedirectWindow, @@ -251,6 +519,8 @@ int (*ProcCompositeVector[CompositeNumberRequests])(ClientPtr) = { ProcCompositeUnredirectSubwindows, ProcCompositeCreateRegionFromBorderClip, ProcCompositeNameWindowPixmap, + ProcCompositeGetOverlayWindow, + ProcCompositeReleaseOverlayWindow, }; static int @@ -351,6 +621,30 @@ SProcCompositeNameWindowPixmap (ClientPtr client) return (*ProcCompositeVector[stuff->compositeReqType]) (client); } +int +SProcCompositeGetOverlayWindow (ClientPtr client) +{ + int n; + REQUEST(xCompositeGetOverlayWindowReq); + + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); + swapl(&stuff->window, n); + return (*ProcCompositeVector[stuff->compositeReqType]) (client); +} + +int +SProcCompositeReleaseOverlayWindow (ClientPtr client) +{ + int n; + REQUEST(xCompositeReleaseOverlayWindowReq); + + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq); + swapl(&stuff->window, n); + return (*ProcCompositeVector[stuff->compositeReqType]) (client); +} + int (*SProcCompositeVector[CompositeNumberRequests])(ClientPtr) = { SProcCompositeQueryVersion, SProcCompositeRedirectWindow, @@ -359,6 +653,8 @@ int (*SProcCompositeVector[CompositeNumberRequests])(ClientPtr) = { SProcCompositeUnredirectSubwindows, SProcCompositeCreateRegionFromBorderClip, SProcCompositeNameWindowPixmap, + SProcCompositeGetOverlayWindow, + SProcCompositeReleaseOverlayWindow, }; static int @@ -386,6 +682,10 @@ CompositeExtensionInit (void) if (!CompositeClientSubwindowsType) return; + CompositeClientOverlayType = CreateNewResourceType (FreeCompositeClientOverlay); + if (!CompositeClientOverlayType) + return; + CompositeClientPrivateIndex = AllocateClientPrivateIndex (); if (!AllocateClientPrivate (CompositeClientPrivateIndex, sizeof (CompositeClientRec))) @@ -400,7 +700,6 @@ CompositeExtensionInit (void) return; CompositeReqCode = (CARD8) extEntry->base; - for (s = 0; s < screenInfo.numScreens; s++) if (!compScreenInit (screenInfo.screens[s])) return; diff --git a/composite/compinit.c b/composite/compinit.c index 07048dbb6..e74e38248 100644 --- a/composite/compinit.c +++ b/composite/compinit.c @@ -1,6 +1,26 @@ /* * $Id$ * + * Copyright © 2006 Sun Microsystems + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Sun Microsystems not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -33,6 +53,7 @@ int CompWindowPrivateIndex; int CompSubwindowsPrivateIndex; int CompGeneration; + static Bool compCloseScreen (int index, ScreenPtr pScreen) { @@ -55,6 +76,15 @@ compCloseScreen (int index, ScreenPtr pScreen) pScreen->CreateWindow = cs->CreateWindow; pScreen->CopyWindow = cs->CopyWindow; pScreen->PositionWindow = cs->PositionWindow; + + deleteCompOverlayClientsForScreen(pScreen); + + /* + ** Note: no need to call DeleteWindow; the server has + ** already destroyed it. + */ + cs->pOverlayWin = NULL; + xfree (cs); pScreen->devPrivates[CompScreenPrivateIndex].ptr = 0; ret = (*pScreen->CloseScreen) (index, pScreen); @@ -333,6 +363,8 @@ compScreenInit (ScreenPtr pScreen) return FALSE; cs->damaged = FALSE; + cs->pOverlayWin = NULL; + cs->pOverlayClients = NULL; if (!compAddAlternateVisuals (pScreen, cs)) { @@ -386,5 +418,6 @@ compScreenInit (ScreenPtr pScreen) pScreen->CloseScreen = compCloseScreen; pScreen->devPrivates[CompScreenPrivateIndex].ptr = (pointer) cs; + return TRUE; } diff --git a/composite/compint.h b/composite/compint.h index 88f0e6899..9395512b4 100644 --- a/composite/compint.h +++ b/composite/compint.h @@ -1,6 +1,26 @@ /* * $Id$ * + * Copyright © 2006 Sun Microsystems + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Sun Microsystems not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -95,6 +115,15 @@ typedef struct _CompSubwindows { #define NUM_COMP_ALTERNATE_VISUALS 1 #endif +typedef struct _CompOverlayClientRec *CompOverlayClientPtr; + +typedef struct _CompOverlayClientRec { + CompOverlayClientPtr pNext; + ClientPtr pClient; + ScreenPtr pScreen; + XID resource; +} CompOverlayClientRec; + typedef struct _CompScreen { PositionWindowProcPtr PositionWindow; CopyWindowProcPtr CopyWindow; @@ -126,6 +155,10 @@ typedef struct _CompScreen { CloseScreenProcPtr CloseScreen; Bool damaged; XID alternateVisuals[NUM_COMP_ALTERNATE_VISUALS]; + + WindowPtr pOverlayWin; + CompOverlayClientPtr pOverlayClients; + } CompScreenRec, *CompScreenPtr; extern int CompScreenPrivateIndex; @@ -257,4 +290,25 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc); void compWindowUpdate (WindowPtr pWin); +void +deleteCompOverlayClientsForScreen (ScreenPtr pScreen); + +int +ProcCompositeGetOverlayWindow (ClientPtr client); + +int +ProcCompositeReleaseOverlayWindow (ClientPtr client); + +int +SProcCompositeGetOverlayWindow (ClientPtr client); + +int +SProcCompositeReleaseOverlayWindow (ClientPtr client); + +WindowPtr +CompositeRealChildHead (WindowPtr pWin); + +int +DeleteWindowNoInputDevices(pointer value, XID wid); + #endif /* _COMPINT_H_ */ diff --git a/composite/compwindow.c b/composite/compwindow.c index 2f5e83cda..1f8409698 100644 --- a/composite/compwindow.c +++ b/composite/compwindow.c @@ -1,6 +1,26 @@ /* * $Id$ * + * Copyright © 2006 Sun Microsystems + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Sun Microsystems not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Sun Microsystems makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -753,3 +773,34 @@ compWindowUpdate (WindowPtr pWin) } } } + +WindowPtr +CompositeRealChildHead (WindowPtr pWin) +{ + WindowPtr pChild, pChildBefore; + CompScreenPtr cs; + + if (!pWin->parent && + (screenIsSaved == SCREEN_SAVER_ON) && + (HasSaverWindow (pWin->drawable.pScreen->myNum))) { + + /* First child is the screen saver; see if next child is the overlay */ + pChildBefore = pWin->firstChild; + pChild = pChildBefore->nextSib; + + } else { + pChildBefore = NullWindow; + pChild = pWin->firstChild; + } + + if (!pChild) { + return NullWindow; + } + + cs = GetCompScreen(pWin->drawable.pScreen); + if (pChild == cs->pOverlayWin) { + return pChild; + } else { + return pChildBefore; + } +} |