aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/composite
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-09-12 11:27:51 +0200
committermarha <marha@users.sourceforge.net>2011-09-12 11:27:51 +0200
commitdafebc5bb70303f0b5baf0b087cf4d9a64b5c7f0 (patch)
treebdf833cc6a4fc9035411779e10dd9e8478201885 /xorg-server/composite
parent0b40f5f4b54453a77f4b09c431f8efc6875da61f (diff)
downloadvcxsrv-dafebc5bb70303f0b5baf0b087cf4d9a64b5c7f0.tar.gz
vcxsrv-dafebc5bb70303f0b5baf0b087cf4d9a64b5c7f0.tar.bz2
vcxsrv-dafebc5bb70303f0b5baf0b087cf4d9a64b5c7f0.zip
Synchronised line endinge with release branch
Diffstat (limited to 'xorg-server/composite')
-rw-r--r--xorg-server/composite/compalloc.c1456
-rw-r--r--xorg-server/composite/compext.c1858
-rw-r--r--xorg-server/composite/compint.h672
-rw-r--r--xorg-server/composite/compwindow.c1664
4 files changed, 2825 insertions, 2825 deletions
diff --git a/xorg-server/composite/compalloc.c b/xorg-server/composite/compalloc.c
index e64d1061b..c4430af43 100644
--- a/xorg-server/composite/compalloc.c
+++ b/xorg-server/composite/compalloc.c
@@ -1,728 +1,728 @@
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Copyright © 2003 Keith Packard
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "compint.h"
-
-static void
-compScreenUpdate (ScreenPtr pScreen)
-{
- compCheckTree (pScreen);
- compPaintChildrenToWindow (pScreen->root);
-}
-
-static void
-compBlockHandler (int i,
- pointer blockData,
- pointer pTimeout,
- pointer pReadmask)
-{
- ScreenPtr pScreen = screenInfo.screens[i];
- CompScreenPtr cs = GetCompScreen (pScreen);
-
- pScreen->BlockHandler = cs->BlockHandler;
- compScreenUpdate (pScreen);
- (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
-
- /* Next damage will restore the block handler */
- cs->BlockHandler = NULL;
-}
-
-static void
-compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
-{
- WindowPtr pWin = (WindowPtr) closure;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- CompWindowPtr cw = GetCompWindow (pWin);
-
- if (!cs->BlockHandler) {
- cs->BlockHandler = pScreen->BlockHandler;
- pScreen->BlockHandler = compBlockHandler;
- }
- cw->damaged = TRUE;
-
- /* Mark the ancestors */
- pWin = pWin->parent;
- while (pWin) {
- if (pWin->damagedDescendants)
- break;
- pWin->damagedDescendants = TRUE;
- pWin = pWin->parent;
- }
-}
-
-static void
-compDestroyDamage (DamagePtr pDamage, void *closure)
-{
- WindowPtr pWin = (WindowPtr) closure;
- CompWindowPtr cw = GetCompWindow (pWin);
-
- cw->damage = 0;
-}
-
-static Bool
-compMarkWindows(WindowPtr pWin,
- WindowPtr *ppLayerWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- WindowPtr pLayerWin = pWin;
-
- if (!pWin->viewable)
- return FALSE;
-
- (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
- (*pScreen->MarkWindow)(pLayerWin->parent);
-
- *ppLayerWin = pLayerWin;
-
- return TRUE;
-}
-
-static void
-compHandleMarkedWindows(WindowPtr pWin, WindowPtr pLayerWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
- (*pScreen->HandleExposures)(pLayerWin->parent);
- if (pScreen->PostValidateTree)
- (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
-}
-
-/*
- * Redirect one window for one client
- */
-int
-compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
-{
- CompWindowPtr cw = GetCompWindow (pWin);
- CompClientWindowPtr ccw;
- CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen);
- WindowPtr pLayerWin;
- Bool anyMarked = FALSE;
-
- if (pWin == cs->pOverlayWin) {
- return Success;
- }
-
- if (!pWin->parent)
- return BadMatch;
-
- /*
- * Only one Manual update is allowed
- */
- if (cw && update == CompositeRedirectManual)
- for (ccw = cw->clients; ccw; ccw = ccw->next)
- if (ccw->update == CompositeRedirectManual)
- return BadAccess;
-
- /*
- * Allocate per-client per-window structure
- * The client *could* allocate multiple, but while supported,
- * it is not expected to be common
- */
- ccw = malloc(sizeof (CompClientWindowRec));
- if (!ccw)
- return BadAlloc;
- ccw->id = FakeClientID (pClient->index);
- ccw->update = update;
- /*
- * Now make sure there's a per-window structure to hang this from
- */
- if (!cw)
- {
- cw = calloc (1,sizeof (CompWindowRec));
- if (!cw)
- {
- free(ccw);
- return BadAlloc;
- }
- cw->damage = DamageCreate (compReportDamage,
- compDestroyDamage,
- DamageReportNonEmpty,
- FALSE,
- pWin->drawable.pScreen,
- pWin);
- if (!cw->damage)
- {
- free(ccw);
- free(cw);
- return BadAlloc;
- }
-
- anyMarked = compMarkWindows (pWin, &pLayerWin);
-
- /* Make sure our borderClip is correct for ValidateTree */
- RegionNull(&cw->borderClip);
- RegionCopy(&cw->borderClip, &pWin->borderClip);
- cw->borderClipX = pWin->drawable.x;
- cw->borderClipY = pWin->drawable.y;
- cw->update = CompositeRedirectAutomatic;
- cw->clients = 0;
- cw->oldx = COMP_ORIGIN_INVALID;
- cw->oldy = COMP_ORIGIN_INVALID;
- cw->damageRegistered = FALSE;
- cw->damaged = FALSE;
- cw->pOldPixmap = NullPixmap;
- dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, cw);
- }
- ccw->next = cw->clients;
- cw->clients = ccw;
- if (!AddResource (ccw->id, CompositeClientWindowType, pWin))
- return BadAlloc;
- if (ccw->update == CompositeRedirectManual)
- {
- if (!anyMarked)
- anyMarked = compMarkWindows (pWin, &pLayerWin);
-
- if (cw->damageRegistered)
- {
- DamageUnregister (&pWin->drawable, cw->damage);
- cw->damageRegistered = FALSE;
- }
- cw->update = CompositeRedirectManual;
- }
- else if (cw->update == CompositeRedirectAutomatic && !cw->damageRegistered) {
- if (!anyMarked)
- anyMarked = compMarkWindows (pWin, &pLayerWin);
- }
-
- if (!compCheckRedirect (pWin))
- {
- FreeResource (ccw->id, RT_NONE);
- return BadAlloc;
- }
-
- if (anyMarked)
- compHandleMarkedWindows (pWin, pLayerWin);
-
- return Success;
-}
-
-void
-compRestoreWindow (WindowPtr pWin, PixmapPtr pPixmap)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- WindowPtr pParent = pWin->parent;
-
- if (pParent->drawable.depth == pWin->drawable.depth) {
- GCPtr pGC = GetScratchGC (pWin->drawable.depth, pScreen);
- int bw = (int) pWin->borderWidth;
- int x = bw;
- int y = bw;
- int w = pWin->drawable.width;
- int h = pWin->drawable.height;
-
- if (pGC) {
- ChangeGCVal val;
- val.val = IncludeInferiors;
- ChangeGC (NullClient, pGC, GCSubwindowMode, &val);
- ValidateGC(&pWin->drawable, pGC);
- (*pGC->ops->CopyArea) (&pPixmap->drawable,
- &pWin->drawable,
- pGC,
- x, y, w, h, 0, 0);
- FreeScratchGC (pGC);
- }
- }
-}
-
-/*
- * Free one of the per-client per-window resources, clearing
- * redirect and the per-window pointer as appropriate
- */
-void
-compFreeClientWindow (WindowPtr pWin, XID id)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompWindowPtr cw = GetCompWindow (pWin);
- CompClientWindowPtr ccw, *prev;
- Bool anyMarked = FALSE;
- WindowPtr pLayerWin;
- PixmapPtr pPixmap = NULL;
-
- if (!cw)
- return;
- for (prev = &cw->clients; (ccw = *prev); prev = &ccw->next)
- {
- if (ccw->id == id)
- {
- *prev = ccw->next;
- if (ccw->update == CompositeRedirectManual)
- cw->update = CompositeRedirectAutomatic;
- free(ccw);
- break;
- }
- }
- if (!cw->clients)
- {
- anyMarked = compMarkWindows (pWin, &pLayerWin);
-
- if (pWin->redirectDraw != RedirectDrawNone) {
- pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- compSetParentPixmap (pWin);
- }
-
- if (cw->damage)
- DamageDestroy (cw->damage);
-
- RegionUninit(&cw->borderClip);
-
- dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, NULL);
- free(cw);
- }
- else if (cw->update == CompositeRedirectAutomatic &&
- !cw->damageRegistered && pWin->redirectDraw != RedirectDrawNone)
- {
- anyMarked = compMarkWindows (pWin, &pLayerWin);
-
- DamageRegister (&pWin->drawable, cw->damage);
- cw->damageRegistered = TRUE;
- pWin->redirectDraw = RedirectDrawAutomatic;
- DamageDamageRegion(&pWin->drawable, &pWin->borderSize);
- }
-
- if (anyMarked)
- compHandleMarkedWindows (pWin, pLayerWin);
-
- if (pPixmap) {
- compRestoreWindow (pWin, pPixmap);
- (*pScreen->DestroyPixmap) (pPixmap);
- }
-}
-
-/*
- * This is easy, just free the appropriate resource.
- */
-
-int
-compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
-{
- CompWindowPtr cw = GetCompWindow (pWin);
- CompClientWindowPtr ccw;
-
- if (!cw)
- return BadValue;
-
- for (ccw = cw->clients; ccw; ccw = ccw->next)
- if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index)
- {
- FreeResource (ccw->id, RT_NONE);
- return Success;
- }
- return BadValue;
-}
-
-/*
- * Redirect all subwindows for one client
- */
-
-int
-compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
-{
- CompSubwindowsPtr csw = GetCompSubwindows (pWin);
- CompClientWindowPtr ccw;
- WindowPtr pChild;
-
- /*
- * Only one Manual update is allowed
- */
- if (csw && update == CompositeRedirectManual)
- for (ccw = csw->clients; ccw; ccw = ccw->next)
- if (ccw->update == CompositeRedirectManual)
- return BadAccess;
- /*
- * Allocate per-client per-window structure
- * The client *could* allocate multiple, but while supported,
- * it is not expected to be common
- */
- ccw = malloc(sizeof (CompClientWindowRec));
- if (!ccw)
- return BadAlloc;
- ccw->id = FakeClientID (pClient->index);
- ccw->update = update;
- /*
- * Now make sure there's a per-window structure to hang this from
- */
- if (!csw)
- {
- csw = malloc(sizeof (CompSubwindowsRec));
- if (!csw)
- {
- free(ccw);
- return BadAlloc;
- }
- csw->update = CompositeRedirectAutomatic;
- csw->clients = 0;
- dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, csw);
- }
- /*
- * Redirect all existing windows
- */
- for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
- {
- int ret = compRedirectWindow (pClient, pChild, update);
- if (ret != Success)
- {
- for (pChild = pChild->nextSib; pChild; pChild = pChild->nextSib)
- (void) compUnredirectWindow (pClient, pChild, update);
- if (!csw->clients)
- {
- free(csw);
- dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, 0);
- }
- free(ccw);
- return ret;
- }
- }
- /*
- * Hook into subwindows list
- */
- ccw->next = csw->clients;
- csw->clients = ccw;
- if (!AddResource (ccw->id, CompositeClientSubwindowsType, pWin))
- return BadAlloc;
- if (ccw->update == CompositeRedirectManual)
- {
- csw->update = CompositeRedirectManual;
- /*
- * tell damage extension that damage events for this client are
- * critical output
- */
- DamageExtSetCritical (pClient, TRUE);
- pWin->inhibitBGPaint = TRUE;
- }
- return Success;
-}
-
-/*
- * Free one of the per-client per-subwindows resources,
- * which frees one redirect per subwindow
- */
-void
-compFreeClientSubwindows (WindowPtr pWin, XID id)
-{
- CompSubwindowsPtr csw = GetCompSubwindows (pWin);
- CompClientWindowPtr ccw, *prev;
- WindowPtr pChild;
-
- if (!csw)
- return;
- for (prev = &csw->clients; (ccw = *prev); prev = &ccw->next)
- {
- if (ccw->id == id)
- {
- ClientPtr pClient = clients[CLIENT_ID(id)];
-
- *prev = ccw->next;
- if (ccw->update == CompositeRedirectManual)
- {
- /*
- * tell damage extension that damage events for this client are
- * critical output
- */
- DamageExtSetCritical (pClient, FALSE);
- csw->update = CompositeRedirectAutomatic;
- pWin->inhibitBGPaint = FALSE;
- if (pWin->mapped)
- (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, TRUE);
- }
-
- /*
- * Unredirect all existing subwindows
- */
- for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
- (void) compUnredirectWindow (pClient, pChild, ccw->update);
-
- free(ccw);
- break;
- }
- }
-
- /*
- * Check if all of the per-client records are gone
- */
- if (!csw->clients)
- {
- dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, NULL);
- free(csw);
- }
-}
-
-/*
- * This is easy, just free the appropriate resource.
- */
-
-int
-compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
-{
- CompSubwindowsPtr csw = GetCompSubwindows (pWin);
- CompClientWindowPtr ccw;
-
- if (!csw)
- return BadValue;
- for (ccw = csw->clients; ccw; ccw = ccw->next)
- if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index)
- {
- FreeResource (ccw->id, RT_NONE);
- return Success;
- }
- return BadValue;
-}
-
-/*
- * Add redirection information for one subwindow (during reparent)
- */
-
-int
-compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin)
-{
- CompSubwindowsPtr csw = GetCompSubwindows (pParent);
- CompClientWindowPtr ccw;
-
- if (!csw)
- return Success;
- for (ccw = csw->clients; ccw; ccw = ccw->next)
- {
- int ret = compRedirectWindow (clients[CLIENT_ID(ccw->id)],
- pWin, ccw->update);
- if (ret != Success)
- return ret;
- }
- return Success;
-}
-
-/*
- * Remove redirection information for one subwindow (during reparent)
- */
-
-int
-compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin)
-{
- CompSubwindowsPtr csw = GetCompSubwindows (pParent);
- CompClientWindowPtr ccw;
-
- if (!csw)
- return Success;
- for (ccw = csw->clients; ccw; ccw = ccw->next)
- {
- int ret = compUnredirectWindow (clients[CLIENT_ID(ccw->id)],
- pWin, ccw->update);
- if (ret != Success)
- return ret;
- }
- return Success;
-}
-
-static PixmapPtr
-compNewPixmap (WindowPtr pWin, int x, int y, int w, int h)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- WindowPtr pParent = pWin->parent;
- PixmapPtr pPixmap;
-
- pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, pWin->drawable.depth,
- CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
-
- if (!pPixmap)
- return 0;
-
- pPixmap->screen_x = x;
- pPixmap->screen_y = y;
-
- if (pParent->drawable.depth == pWin->drawable.depth)
- {
- GCPtr pGC = GetScratchGC (pWin->drawable.depth, pScreen);
-
- if (pGC)
- {
- ChangeGCVal val;
- val.val = IncludeInferiors;
- ChangeGC (NullClient, pGC, GCSubwindowMode, &val);
- ValidateGC(&pPixmap->drawable, pGC);
- (*pGC->ops->CopyArea) (&pParent->drawable,
- &pPixmap->drawable,
- pGC,
- x - pParent->drawable.x,
- y - pParent->drawable.y,
- w, h, 0, 0);
- FreeScratchGC (pGC);
- }
- }
- else
- {
- PictFormatPtr pSrcFormat = compWindowFormat (pParent);
- PictFormatPtr pDstFormat = compWindowFormat (pWin);
- XID inferiors = IncludeInferiors;
- int error;
-
- PicturePtr pSrcPicture = CreatePicture (None,
- &pParent->drawable,
- pSrcFormat,
- CPSubwindowMode,
- &inferiors,
- serverClient, &error);
-
- PicturePtr pDstPicture = CreatePicture (None,
- &pPixmap->drawable,
- pDstFormat,
- 0, 0,
- serverClient, &error);
-
- if (pSrcPicture && pDstPicture)
- {
- CompositePicture (PictOpSrc,
- pSrcPicture,
- NULL,
- pDstPicture,
- x - pParent->drawable.x,
- y - pParent->drawable.y,
- 0, 0, 0, 0, w, h);
- }
- if (pSrcPicture)
- FreePicture (pSrcPicture, 0);
- if (pDstPicture)
- FreePicture (pDstPicture, 0);
- }
- return pPixmap;
-}
-
-Bool
-compAllocPixmap (WindowPtr pWin)
-{
- int bw = (int) pWin->borderWidth;
- int x = pWin->drawable.x - bw;
- int y = pWin->drawable.y - bw;
- int w = pWin->drawable.width + (bw << 1);
- int h = pWin->drawable.height + (bw << 1);
- PixmapPtr pPixmap = compNewPixmap (pWin, x, y, w, h);
- CompWindowPtr cw = GetCompWindow (pWin);
-
- if (!pPixmap)
- return FALSE;
- if (cw->update == CompositeRedirectAutomatic)
- pWin->redirectDraw = RedirectDrawAutomatic;
- else
- pWin->redirectDraw = RedirectDrawManual;
-
- compSetPixmap (pWin, pPixmap);
- cw->oldx = COMP_ORIGIN_INVALID;
- cw->oldy = COMP_ORIGIN_INVALID;
- cw->damageRegistered = FALSE;
- if (cw->update == CompositeRedirectAutomatic)
- {
- DamageRegister (&pWin->drawable, cw->damage);
- cw->damageRegistered = TRUE;
- }
- return TRUE;
-}
-
-void
-compSetParentPixmap (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- PixmapPtr pParentPixmap;
- CompWindowPtr cw = GetCompWindow (pWin);
-
- if (cw->damageRegistered)
- {
- DamageUnregister (&pWin->drawable, cw->damage);
- cw->damageRegistered = FALSE;
- DamageEmpty (cw->damage);
- }
- /*
- * Move the parent-constrained border clip region back into
- * the window so that ValidateTree will handle the unmap
- * case correctly. Unmap adds the window borderClip to the
- * parent exposed area; regions beyond the parent cause crashes
- */
- RegionCopy(&pWin->borderClip, &cw->borderClip);
- pParentPixmap = (*pScreen->GetWindowPixmap) (pWin->parent);
- pWin->redirectDraw = RedirectDrawNone;
- compSetPixmap (pWin, pParentPixmap);
-}
-
-/*
- * Make sure the pixmap is the right size and offset. Allocate a new
- * pixmap to change size, adjust origin to change offset, leaving the
- * old pixmap in cw->pOldPixmap so bits can be recovered
- */
-Bool
-compReallocPixmap (WindowPtr pWin, int draw_x, int draw_y,
- unsigned int w, unsigned int h, int bw)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- PixmapPtr pOld = (*pScreen->GetWindowPixmap) (pWin);
- PixmapPtr pNew;
- CompWindowPtr cw = GetCompWindow (pWin);
- int pix_x, pix_y;
- int pix_w, pix_h;
-
- assert (cw && pWin->redirectDraw != RedirectDrawNone);
- cw->oldx = pOld->screen_x;
- cw->oldy = pOld->screen_y;
- pix_x = draw_x - bw;
- pix_y = draw_y - bw;
- pix_w = w + (bw << 1);
- pix_h = h + (bw << 1);
- if (pix_w != pOld->drawable.width || pix_h != pOld->drawable.height)
- {
- pNew = compNewPixmap (pWin, pix_x, pix_y, pix_w, pix_h);
- if (!pNew)
- return FALSE;
- cw->pOldPixmap = pOld;
- compSetPixmap (pWin, pNew);
- }
- else
- {
- pNew = pOld;
- cw->pOldPixmap = 0;
- }
- pNew->screen_x = pix_x;
- pNew->screen_y = pix_y;
- return TRUE;
-}
+/*
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "compint.h"
+
+static void
+compScreenUpdate (ScreenPtr pScreen)
+{
+ compCheckTree (pScreen);
+ compPaintChildrenToWindow (pScreen->root);
+}
+
+static void
+compBlockHandler (int i,
+ pointer blockData,
+ pointer pTimeout,
+ pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[i];
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->BlockHandler = cs->BlockHandler;
+ compScreenUpdate (pScreen);
+ (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
+
+ /* Next damage will restore the block handler */
+ cs->BlockHandler = NULL;
+}
+
+static void
+compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
+{
+ WindowPtr pWin = (WindowPtr) closure;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (!cs->BlockHandler) {
+ cs->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = compBlockHandler;
+ }
+ cw->damaged = TRUE;
+
+ /* Mark the ancestors */
+ pWin = pWin->parent;
+ while (pWin) {
+ if (pWin->damagedDescendants)
+ break;
+ pWin->damagedDescendants = TRUE;
+ pWin = pWin->parent;
+ }
+}
+
+static void
+compDestroyDamage (DamagePtr pDamage, void *closure)
+{
+ WindowPtr pWin = (WindowPtr) closure;
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ cw->damage = 0;
+}
+
+static Bool
+compMarkWindows(WindowPtr pWin,
+ WindowPtr *ppLayerWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pLayerWin = pWin;
+
+ if (!pWin->viewable)
+ return FALSE;
+
+ (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
+ (*pScreen->MarkWindow)(pLayerWin->parent);
+
+ *ppLayerWin = pLayerWin;
+
+ return TRUE;
+}
+
+static void
+compHandleMarkedWindows(WindowPtr pWin, WindowPtr pLayerWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+ if (pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
+}
+
+/*
+ * Redirect one window for one client
+ */
+int
+compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompClientWindowPtr ccw;
+ CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen);
+ WindowPtr pLayerWin;
+ Bool anyMarked = FALSE;
+
+ if (pWin == cs->pOverlayWin) {
+ return Success;
+ }
+
+ if (!pWin->parent)
+ return BadMatch;
+
+ /*
+ * Only one Manual update is allowed
+ */
+ if (cw && update == CompositeRedirectManual)
+ for (ccw = cw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == CompositeRedirectManual)
+ return BadAccess;
+
+ /*
+ * Allocate per-client per-window structure
+ * The client *could* allocate multiple, but while supported,
+ * it is not expected to be common
+ */
+ ccw = malloc(sizeof (CompClientWindowRec));
+ if (!ccw)
+ return BadAlloc;
+ ccw->id = FakeClientID (pClient->index);
+ ccw->update = update;
+ /*
+ * Now make sure there's a per-window structure to hang this from
+ */
+ if (!cw)
+ {
+ cw = calloc (1,sizeof (CompWindowRec));
+ if (!cw)
+ {
+ free(ccw);
+ return BadAlloc;
+ }
+ cw->damage = DamageCreate (compReportDamage,
+ compDestroyDamage,
+ DamageReportNonEmpty,
+ FALSE,
+ pWin->drawable.pScreen,
+ pWin);
+ if (!cw->damage)
+ {
+ free(ccw);
+ free(cw);
+ return BadAlloc;
+ }
+
+ anyMarked = compMarkWindows (pWin, &pLayerWin);
+
+ /* Make sure our borderClip is correct for ValidateTree */
+ RegionNull(&cw->borderClip);
+ RegionCopy(&cw->borderClip, &pWin->borderClip);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+ cw->update = CompositeRedirectAutomatic;
+ cw->clients = 0;
+ cw->oldx = COMP_ORIGIN_INVALID;
+ cw->oldy = COMP_ORIGIN_INVALID;
+ cw->damageRegistered = FALSE;
+ cw->damaged = FALSE;
+ cw->pOldPixmap = NullPixmap;
+ dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, cw);
+ }
+ ccw->next = cw->clients;
+ cw->clients = ccw;
+ if (!AddResource (ccw->id, CompositeClientWindowType, pWin))
+ return BadAlloc;
+ if (ccw->update == CompositeRedirectManual)
+ {
+ if (!anyMarked)
+ anyMarked = compMarkWindows (pWin, &pLayerWin);
+
+ if (cw->damageRegistered)
+ {
+ DamageUnregister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = FALSE;
+ }
+ cw->update = CompositeRedirectManual;
+ }
+ else if (cw->update == CompositeRedirectAutomatic && !cw->damageRegistered) {
+ if (!anyMarked)
+ anyMarked = compMarkWindows (pWin, &pLayerWin);
+ }
+
+ if (!compCheckRedirect (pWin))
+ {
+ FreeResource (ccw->id, RT_NONE);
+ return BadAlloc;
+ }
+
+ if (anyMarked)
+ compHandleMarkedWindows (pWin, pLayerWin);
+
+ return Success;
+}
+
+void
+compRestoreWindow (WindowPtr pWin, PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pParent = pWin->parent;
+
+ if (pParent->drawable.depth == pWin->drawable.depth) {
+ GCPtr pGC = GetScratchGC (pWin->drawable.depth, pScreen);
+ int bw = (int) pWin->borderWidth;
+ int x = bw;
+ int y = bw;
+ int w = pWin->drawable.width;
+ int h = pWin->drawable.height;
+
+ if (pGC) {
+ ChangeGCVal val;
+ val.val = IncludeInferiors;
+ ChangeGC (NullClient, pGC, GCSubwindowMode, &val);
+ ValidateGC(&pWin->drawable, pGC);
+ (*pGC->ops->CopyArea) (&pPixmap->drawable,
+ &pWin->drawable,
+ pGC,
+ x, y, w, h, 0, 0);
+ FreeScratchGC (pGC);
+ }
+ }
+}
+
+/*
+ * Free one of the per-client per-window resources, clearing
+ * redirect and the per-window pointer as appropriate
+ */
+void
+compFreeClientWindow (WindowPtr pWin, XID id)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompClientWindowPtr ccw, *prev;
+ Bool anyMarked = FALSE;
+ WindowPtr pLayerWin;
+ PixmapPtr pPixmap = NULL;
+
+ if (!cw)
+ return;
+ for (prev = &cw->clients; (ccw = *prev); prev = &ccw->next)
+ {
+ if (ccw->id == id)
+ {
+ *prev = ccw->next;
+ if (ccw->update == CompositeRedirectManual)
+ cw->update = CompositeRedirectAutomatic;
+ free(ccw);
+ break;
+ }
+ }
+ if (!cw->clients)
+ {
+ anyMarked = compMarkWindows (pWin, &pLayerWin);
+
+ if (pWin->redirectDraw != RedirectDrawNone) {
+ pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ compSetParentPixmap (pWin);
+ }
+
+ if (cw->damage)
+ DamageDestroy (cw->damage);
+
+ RegionUninit(&cw->borderClip);
+
+ dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, NULL);
+ free(cw);
+ }
+ else if (cw->update == CompositeRedirectAutomatic &&
+ !cw->damageRegistered && pWin->redirectDraw != RedirectDrawNone)
+ {
+ anyMarked = compMarkWindows (pWin, &pLayerWin);
+
+ DamageRegister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = TRUE;
+ pWin->redirectDraw = RedirectDrawAutomatic;
+ DamageDamageRegion(&pWin->drawable, &pWin->borderSize);
+ }
+
+ if (anyMarked)
+ compHandleMarkedWindows (pWin, pLayerWin);
+
+ if (pPixmap) {
+ compRestoreWindow (pWin, pPixmap);
+ (*pScreen->DestroyPixmap) (pPixmap);
+ }
+}
+
+/*
+ * This is easy, just free the appropriate resource.
+ */
+
+int
+compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompClientWindowPtr ccw;
+
+ if (!cw)
+ return BadValue;
+
+ for (ccw = cw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index)
+ {
+ FreeResource (ccw->id, RT_NONE);
+ return Success;
+ }
+ return BadValue;
+}
+
+/*
+ * Redirect all subwindows for one client
+ */
+
+int
+compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin);
+ CompClientWindowPtr ccw;
+ WindowPtr pChild;
+
+ /*
+ * Only one Manual update is allowed
+ */
+ if (csw && update == CompositeRedirectManual)
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == CompositeRedirectManual)
+ return BadAccess;
+ /*
+ * Allocate per-client per-window structure
+ * The client *could* allocate multiple, but while supported,
+ * it is not expected to be common
+ */
+ ccw = malloc(sizeof (CompClientWindowRec));
+ if (!ccw)
+ return BadAlloc;
+ ccw->id = FakeClientID (pClient->index);
+ ccw->update = update;
+ /*
+ * Now make sure there's a per-window structure to hang this from
+ */
+ if (!csw)
+ {
+ csw = malloc(sizeof (CompSubwindowsRec));
+ if (!csw)
+ {
+ free(ccw);
+ return BadAlloc;
+ }
+ csw->update = CompositeRedirectAutomatic;
+ csw->clients = 0;
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, csw);
+ }
+ /*
+ * Redirect all existing windows
+ */
+ for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+ {
+ int ret = compRedirectWindow (pClient, pChild, update);
+ if (ret != Success)
+ {
+ for (pChild = pChild->nextSib; pChild; pChild = pChild->nextSib)
+ (void) compUnredirectWindow (pClient, pChild, update);
+ if (!csw->clients)
+ {
+ free(csw);
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, 0);
+ }
+ free(ccw);
+ return ret;
+ }
+ }
+ /*
+ * Hook into subwindows list
+ */
+ ccw->next = csw->clients;
+ csw->clients = ccw;
+ if (!AddResource (ccw->id, CompositeClientSubwindowsType, pWin))
+ return BadAlloc;
+ if (ccw->update == CompositeRedirectManual)
+ {
+ csw->update = CompositeRedirectManual;
+ /*
+ * tell damage extension that damage events for this client are
+ * critical output
+ */
+ DamageExtSetCritical (pClient, TRUE);
+ pWin->inhibitBGPaint = TRUE;
+ }
+ return Success;
+}
+
+/*
+ * Free one of the per-client per-subwindows resources,
+ * which frees one redirect per subwindow
+ */
+void
+compFreeClientSubwindows (WindowPtr pWin, XID id)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin);
+ CompClientWindowPtr ccw, *prev;
+ WindowPtr pChild;
+
+ if (!csw)
+ return;
+ for (prev = &csw->clients; (ccw = *prev); prev = &ccw->next)
+ {
+ if (ccw->id == id)
+ {
+ ClientPtr pClient = clients[CLIENT_ID(id)];
+
+ *prev = ccw->next;
+ if (ccw->update == CompositeRedirectManual)
+ {
+ /*
+ * tell damage extension that damage events for this client are
+ * critical output
+ */
+ DamageExtSetCritical (pClient, FALSE);
+ csw->update = CompositeRedirectAutomatic;
+ pWin->inhibitBGPaint = FALSE;
+ if (pWin->mapped)
+ (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, TRUE);
+ }
+
+ /*
+ * Unredirect all existing subwindows
+ */
+ for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+ (void) compUnredirectWindow (pClient, pChild, ccw->update);
+
+ free(ccw);
+ break;
+ }
+ }
+
+ /*
+ * Check if all of the per-client records are gone
+ */
+ if (!csw->clients)
+ {
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, NULL);
+ free(csw);
+ }
+}
+
+/*
+ * This is easy, just free the appropriate resource.
+ */
+
+int
+compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin);
+ CompClientWindowPtr ccw;
+
+ if (!csw)
+ return BadValue;
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index)
+ {
+ FreeResource (ccw->id, RT_NONE);
+ return Success;
+ }
+ return BadValue;
+}
+
+/*
+ * Add redirection information for one subwindow (during reparent)
+ */
+
+int
+compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pParent);
+ CompClientWindowPtr ccw;
+
+ if (!csw)
+ return Success;
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ {
+ int ret = compRedirectWindow (clients[CLIENT_ID(ccw->id)],
+ pWin, ccw->update);
+ if (ret != Success)
+ return ret;
+ }
+ return Success;
+}
+
+/*
+ * Remove redirection information for one subwindow (during reparent)
+ */
+
+int
+compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pParent);
+ CompClientWindowPtr ccw;
+
+ if (!csw)
+ return Success;
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ {
+ int ret = compUnredirectWindow (clients[CLIENT_ID(ccw->id)],
+ pWin, ccw->update);
+ if (ret != Success)
+ return ret;
+ }
+ return Success;
+}
+
+static PixmapPtr
+compNewPixmap (WindowPtr pWin, int x, int y, int w, int h)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pParent = pWin->parent;
+ PixmapPtr pPixmap;
+
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, pWin->drawable.depth,
+ CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
+
+ if (!pPixmap)
+ return 0;
+
+ pPixmap->screen_x = x;
+ pPixmap->screen_y = y;
+
+ if (pParent->drawable.depth == pWin->drawable.depth)
+ {
+ GCPtr pGC = GetScratchGC (pWin->drawable.depth, pScreen);
+
+ if (pGC)
+ {
+ ChangeGCVal val;
+ val.val = IncludeInferiors;
+ ChangeGC (NullClient, pGC, GCSubwindowMode, &val);
+ ValidateGC(&pPixmap->drawable, pGC);
+ (*pGC->ops->CopyArea) (&pParent->drawable,
+ &pPixmap->drawable,
+ pGC,
+ x - pParent->drawable.x,
+ y - pParent->drawable.y,
+ w, h, 0, 0);
+ FreeScratchGC (pGC);
+ }
+ }
+ else
+ {
+ PictFormatPtr pSrcFormat = compWindowFormat (pParent);
+ PictFormatPtr pDstFormat = compWindowFormat (pWin);
+ XID inferiors = IncludeInferiors;
+ int error;
+
+ PicturePtr pSrcPicture = CreatePicture (None,
+ &pParent->drawable,
+ pSrcFormat,
+ CPSubwindowMode,
+ &inferiors,
+ serverClient, &error);
+
+ PicturePtr pDstPicture = CreatePicture (None,
+ &pPixmap->drawable,
+ pDstFormat,
+ 0, 0,
+ serverClient, &error);
+
+ if (pSrcPicture && pDstPicture)
+ {
+ CompositePicture (PictOpSrc,
+ pSrcPicture,
+ NULL,
+ pDstPicture,
+ x - pParent->drawable.x,
+ y - pParent->drawable.y,
+ 0, 0, 0, 0, w, h);
+ }
+ if (pSrcPicture)
+ FreePicture (pSrcPicture, 0);
+ if (pDstPicture)
+ FreePicture (pDstPicture, 0);
+ }
+ return pPixmap;
+}
+
+Bool
+compAllocPixmap (WindowPtr pWin)
+{
+ int bw = (int) pWin->borderWidth;
+ int x = pWin->drawable.x - bw;
+ int y = pWin->drawable.y - bw;
+ int w = pWin->drawable.width + (bw << 1);
+ int h = pWin->drawable.height + (bw << 1);
+ PixmapPtr pPixmap = compNewPixmap (pWin, x, y, w, h);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (!pPixmap)
+ return FALSE;
+ if (cw->update == CompositeRedirectAutomatic)
+ pWin->redirectDraw = RedirectDrawAutomatic;
+ else
+ pWin->redirectDraw = RedirectDrawManual;
+
+ compSetPixmap (pWin, pPixmap);
+ cw->oldx = COMP_ORIGIN_INVALID;
+ cw->oldy = COMP_ORIGIN_INVALID;
+ cw->damageRegistered = FALSE;
+ if (cw->update == CompositeRedirectAutomatic)
+ {
+ DamageRegister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = TRUE;
+ }
+ return TRUE;
+}
+
+void
+compSetParentPixmap (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pParentPixmap;
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (cw->damageRegistered)
+ {
+ DamageUnregister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = FALSE;
+ DamageEmpty (cw->damage);
+ }
+ /*
+ * Move the parent-constrained border clip region back into
+ * the window so that ValidateTree will handle the unmap
+ * case correctly. Unmap adds the window borderClip to the
+ * parent exposed area; regions beyond the parent cause crashes
+ */
+ RegionCopy(&pWin->borderClip, &cw->borderClip);
+ pParentPixmap = (*pScreen->GetWindowPixmap) (pWin->parent);
+ pWin->redirectDraw = RedirectDrawNone;
+ compSetPixmap (pWin, pParentPixmap);
+}
+
+/*
+ * Make sure the pixmap is the right size and offset. Allocate a new
+ * pixmap to change size, adjust origin to change offset, leaving the
+ * old pixmap in cw->pOldPixmap so bits can be recovered
+ */
+Bool
+compReallocPixmap (WindowPtr pWin, int draw_x, int draw_y,
+ unsigned int w, unsigned int h, int bw)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pOld = (*pScreen->GetWindowPixmap) (pWin);
+ PixmapPtr pNew;
+ CompWindowPtr cw = GetCompWindow (pWin);
+ int pix_x, pix_y;
+ int pix_w, pix_h;
+
+ assert (cw && pWin->redirectDraw != RedirectDrawNone);
+ cw->oldx = pOld->screen_x;
+ cw->oldy = pOld->screen_y;
+ pix_x = draw_x - bw;
+ pix_y = draw_y - bw;
+ pix_w = w + (bw << 1);
+ pix_h = h + (bw << 1);
+ if (pix_w != pOld->drawable.width || pix_h != pOld->drawable.height)
+ {
+ pNew = compNewPixmap (pWin, pix_x, pix_y, pix_w, pix_h);
+ if (!pNew)
+ return FALSE;
+ cw->pOldPixmap = pOld;
+ compSetPixmap (pWin, pNew);
+ }
+ else
+ {
+ pNew = pOld;
+ cw->pOldPixmap = 0;
+ }
+ pNew->screen_x = pix_x;
+ pNew->screen_y = pix_y;
+ return TRUE;
+}
diff --git a/xorg-server/composite/compext.c b/xorg-server/composite/compext.c
index 711236bbf..e0d8e75e4 100644
--- a/xorg-server/composite/compext.c
+++ b/xorg-server/composite/compext.c
@@ -1,929 +1,929 @@
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Copyright © 2003 Keith Packard
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "compint.h"
-#include "xace.h"
-#include "protocol-versions.h"
-
-static CARD8 CompositeReqCode;
-static DevPrivateKeyRec CompositeClientPrivateKeyRec;
-#define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec)
-RESTYPE CompositeClientWindowType;
-RESTYPE CompositeClientSubwindowsType;
-RESTYPE CompositeClientOverlayType;
-
-typedef struct _CompositeClient {
- int major_version;
- int minor_version;
-} CompositeClientRec, *CompositeClientPtr;
-
-#define GetCompositeClient(pClient) ((CompositeClientPtr) \
- dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey))
-
-static void
-CompositeClientCallback (CallbackListPtr *list,
- pointer closure,
- pointer data)
-{
- NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
- ClientPtr pClient = clientinfo->client;
- CompositeClientPtr pCompositeClient = GetCompositeClient (pClient);
-
- pCompositeClient->major_version = 0;
- pCompositeClient->minor_version = 0;
-}
-
-static int
-FreeCompositeClientWindow (pointer value, XID ccwid)
-{
- WindowPtr pWin = value;
-
- compFreeClientWindow (pWin, ccwid);
- return Success;
-}
-
-static int
-FreeCompositeClientSubwindows (pointer value, XID ccwid)
-{
- WindowPtr pWin = value;
-
- compFreeClientSubwindows (pWin, ccwid);
- return Success;
-}
-
-static int
-FreeCompositeClientOverlay (pointer value, XID ccwid)
-{
- CompOverlayClientPtr pOc = (CompOverlayClientPtr) value;
-
- compFreeOverlayClient (pOc);
- return Success;
-}
-
-static int
-ProcCompositeQueryVersion (ClientPtr client)
-{
- CompositeClientPtr pCompositeClient = GetCompositeClient (client);
- xCompositeQueryVersionReply rep;
- register int n;
- REQUEST(xCompositeQueryVersionReq);
-
- REQUEST_SIZE_MATCH(xCompositeQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- if (stuff->majorVersion < SERVER_COMPOSITE_MAJOR_VERSION) {
- rep.majorVersion = stuff->majorVersion;
- rep.minorVersion = stuff->minorVersion;
- } else {
- rep.majorVersion = SERVER_COMPOSITE_MAJOR_VERSION;
- rep.minorVersion = SERVER_COMPOSITE_MINOR_VERSION;
- }
- pCompositeClient->major_version = rep.majorVersion;
- pCompositeClient->minor_version = rep.minorVersion;
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.majorVersion, n);
- swapl(&rep.minorVersion, n);
- }
- WriteToClient(client, sizeof(xCompositeQueryVersionReply), (char *)&rep);
- return Success;
-}
-
-#define VERIFY_WINDOW(pWindow, wid, client, mode) \
- do { \
- int err; \
- err = dixLookupResourceByType((pointer *) &pWindow, wid, \
- RT_WINDOW, client, mode); \
- if (err != Success) { \
- client->errorValue = wid; \
- return err; \
- } \
- } while (0)
-
-static int
-ProcCompositeRedirectWindow (ClientPtr client)
-{
- WindowPtr pWin;
- REQUEST(xCompositeRedirectWindowReq);
-
- REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
- VERIFY_WINDOW(pWin, stuff->window, client,
- DixSetAttrAccess|DixManageAccess|DixBlendAccess);
-
- return compRedirectWindow (client, pWin, stuff->update);
-}
-
-static int
-ProcCompositeRedirectSubwindows (ClientPtr client)
-{
- WindowPtr pWin;
- REQUEST(xCompositeRedirectSubwindowsReq);
-
- REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
- VERIFY_WINDOW(pWin, stuff->window, client,
- DixSetAttrAccess|DixManageAccess|DixBlendAccess);
-
- return compRedirectSubwindows (client, pWin, stuff->update);
-}
-
-static int
-ProcCompositeUnredirectWindow (ClientPtr client)
-{
- WindowPtr pWin;
- REQUEST(xCompositeUnredirectWindowReq);
-
- REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
- VERIFY_WINDOW(pWin, stuff->window, client,
- DixSetAttrAccess|DixManageAccess|DixBlendAccess);
-
- return compUnredirectWindow (client, pWin, stuff->update);
-}
-
-static int
-ProcCompositeUnredirectSubwindows (ClientPtr client)
-{
- WindowPtr pWin;
- REQUEST(xCompositeUnredirectSubwindowsReq);
-
- REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
- VERIFY_WINDOW(pWin, stuff->window, client,
- DixSetAttrAccess|DixManageAccess|DixBlendAccess);
-
- return compUnredirectSubwindows (client, pWin, stuff->update);
-}
-
-static int
-ProcCompositeCreateRegionFromBorderClip (ClientPtr client)
-{
- WindowPtr pWin;
- CompWindowPtr cw;
- RegionPtr pBorderClip, pRegion;
- REQUEST(xCompositeCreateRegionFromBorderClipReq);
-
- REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
- VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
- LEGAL_NEW_RESOURCE (stuff->region, client);
-
- cw = GetCompWindow (pWin);
- if (cw)
- pBorderClip = &cw->borderClip;
- else
- pBorderClip = &pWin->borderClip;
- pRegion = XFixesRegionCopy (pBorderClip);
- if (!pRegion)
- return BadAlloc;
- RegionTranslate(pRegion, -pWin->drawable.x, -pWin->drawable.y);
-
- if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
- return BadAlloc;
-
- return Success;
-}
-
-static int
-ProcCompositeNameWindowPixmap (ClientPtr client)
-{
- WindowPtr pWin;
- CompWindowPtr cw;
- PixmapPtr pPixmap;
- int rc;
- REQUEST(xCompositeNameWindowPixmapReq);
-
- REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
- VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
-
- if (!pWin->viewable)
- return BadMatch;
-
- LEGAL_NEW_RESOURCE (stuff->pixmap, client);
-
- cw = GetCompWindow (pWin);
- if (!cw)
- return BadMatch;
-
- pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
- if (!pPixmap)
- return BadMatch;
-
- /* security creation/labeling check */
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, RT_PIXMAP,
- pPixmap, RT_WINDOW, pWin, DixCreateAccess);
- if (rc != Success)
- return rc;
-
- ++pPixmap->refcnt;
-
- if (!AddResource (stuff->pixmap, RT_PIXMAP, (pointer) pPixmap))
- return BadAlloc;
-
- return Success;
-}
-
-
-static int
-ProcCompositeGetOverlayWindow (ClientPtr client)
-{
- REQUEST(xCompositeGetOverlayWindowReq);
- xCompositeGetOverlayWindowReply rep;
- WindowPtr pWin;
- ScreenPtr pScreen;
- CompScreenPtr cs;
- CompOverlayClientPtr pOc;
- int rc;
-
- REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
- VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
- pScreen = pWin->drawable.pScreen;
-
- /*
- * Create an OverlayClient structure to mark this client's
- * interest in the overlay window
- */
- pOc = compCreateOverlayClient(pScreen, client);
- if (pOc == NULL)
- return BadAlloc;
-
- /*
- * Make sure the overlay window exists
- */
- cs = GetCompScreen(pScreen);
- if (cs->pOverlayWin == NULL)
- if (!compCreateOverlayWindow(pScreen))
- {
- FreeResource (pOc->resource, RT_NONE);
- return BadAlloc;
- }
-
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, cs->pOverlayWin->drawable.id,
- RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, DixGetAttrAccess);
- if (rc != Success)
- {
- FreeResource (pOc->resource, RT_NONE);
- return rc;
- }
-
- 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 Success;
-}
-
-static int
-ProcCompositeReleaseOverlayWindow (ClientPtr client)
-{
- REQUEST(xCompositeReleaseOverlayWindowReq);
- WindowPtr pWin;
- ScreenPtr pScreen;
- CompOverlayClientPtr pOc;
-
- REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq);
- VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
- pScreen = pWin->drawable.pScreen;
-
- /*
- * Has client queried a reference to the overlay window
- * on this screen? If not, generate an error.
- */
- pOc = compFindOverlayClient (pWin->drawable.pScreen, client);
- if (pOc == NULL)
- return BadMatch;
-
- /* The delete function will free the client structure */
- FreeResource (pOc->resource, RT_NONE);
-
- return Success;
-}
-
-static int (*ProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
- ProcCompositeQueryVersion,
- ProcCompositeRedirectWindow,
- ProcCompositeRedirectSubwindows,
- ProcCompositeUnredirectWindow,
- ProcCompositeUnredirectSubwindows,
- ProcCompositeCreateRegionFromBorderClip,
- ProcCompositeNameWindowPixmap,
- ProcCompositeGetOverlayWindow,
- ProcCompositeReleaseOverlayWindow,
-};
-
-static int
-ProcCompositeDispatch (ClientPtr client)
-{
- REQUEST(xReq);
-
- if (stuff->data < CompositeNumberRequests)
- return (*ProcCompositeVector[stuff->data]) (client);
- else
- return BadRequest;
-}
-
-static int
-SProcCompositeQueryVersion (ClientPtr client)
-{
- int n;
- REQUEST(xCompositeQueryVersionReq);
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCompositeQueryVersionReq);
- swapl(&stuff->majorVersion, n);
- swapl(&stuff->minorVersion, n);
- return (*ProcCompositeVector[stuff->compositeReqType]) (client);
-}
-
-static int
-SProcCompositeRedirectWindow (ClientPtr client)
-{
- int n;
- REQUEST(xCompositeRedirectWindowReq);
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
- swapl (&stuff->window, n);
- return (*ProcCompositeVector[stuff->compositeReqType]) (client);
-}
-
-static int
-SProcCompositeRedirectSubwindows (ClientPtr client)
-{
- int n;
- REQUEST(xCompositeRedirectSubwindowsReq);
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
- swapl (&stuff->window, n);
- return (*ProcCompositeVector[stuff->compositeReqType]) (client);
-}
-
-static int
-SProcCompositeUnredirectWindow (ClientPtr client)
-{
- int n;
- REQUEST(xCompositeUnredirectWindowReq);
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
- swapl (&stuff->window, n);
- return (*ProcCompositeVector[stuff->compositeReqType]) (client);
-}
-
-static int
-SProcCompositeUnredirectSubwindows (ClientPtr client)
-{
- int n;
- REQUEST(xCompositeUnredirectSubwindowsReq);
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
- swapl (&stuff->window, n);
- return (*ProcCompositeVector[stuff->compositeReqType]) (client);
-}
-
-static int
-SProcCompositeCreateRegionFromBorderClip (ClientPtr client)
-{
- int n;
- REQUEST(xCompositeCreateRegionFromBorderClipReq);
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
- swapl (&stuff->region, n);
- swapl (&stuff->window, n);
- return (*ProcCompositeVector[stuff->compositeReqType]) (client);
-}
-
-static int
-SProcCompositeNameWindowPixmap (ClientPtr client)
-{
- int n;
- REQUEST(xCompositeNameWindowPixmapReq);
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
- swapl (&stuff->window, n);
- swapl (&stuff->pixmap, n);
- return (*ProcCompositeVector[stuff->compositeReqType]) (client);
-}
-
-static 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);
-}
-
-static 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);
-}
-
-static int (*SProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
- SProcCompositeQueryVersion,
- SProcCompositeRedirectWindow,
- SProcCompositeRedirectSubwindows,
- SProcCompositeUnredirectWindow,
- SProcCompositeUnredirectSubwindows,
- SProcCompositeCreateRegionFromBorderClip,
- SProcCompositeNameWindowPixmap,
- SProcCompositeGetOverlayWindow,
- SProcCompositeReleaseOverlayWindow,
-};
-
-static int
-SProcCompositeDispatch (ClientPtr client)
-{
- REQUEST(xReq);
-
- if (stuff->data < CompositeNumberRequests)
- return (*SProcCompositeVector[stuff->data]) (client);
- else
- return BadRequest;
-}
-
-void
-CompositeExtensionInit (void)
-{
- ExtensionEntry *extEntry;
- int s;
-
- /* Assume initialization is going to fail */
- noCompositeExtension = TRUE;
-
- for (s = 0; s < screenInfo.numScreens; s++) {
- ScreenPtr pScreen = screenInfo.screens[s];
- VisualPtr vis;
-
- /* Composite on 8bpp pseudocolor root windows appears to fail, so
- * just disable it on anything pseudocolor for safety.
- */
- for (vis = pScreen->visuals; vis->vid != pScreen->rootVisual; vis++)
- ;
- if ((vis->class | DynamicClass) == PseudoColor)
- return;
-
- /* Ensure that Render is initialized, which is required for automatic
- * compositing.
- */
- if (GetPictureScreenIfSet(pScreen) == NULL)
- return;
- }
-
- CompositeClientWindowType = CreateNewResourceType
- (FreeCompositeClientWindow, "CompositeClientWindow");
- if (!CompositeClientWindowType)
- return;
-
- CompositeClientSubwindowsType = CreateNewResourceType
- (FreeCompositeClientSubwindows, "CompositeClientSubwindows");
- if (!CompositeClientSubwindowsType)
- return;
-
- CompositeClientOverlayType = CreateNewResourceType
- (FreeCompositeClientOverlay, "CompositeClientOverlay");
- if (!CompositeClientOverlayType)
- return;
-
- if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec, PRIVATE_CLIENT,
- sizeof(CompositeClientRec)))
- return;
-
- if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0))
- return;
-
- for (s = 0; s < screenInfo.numScreens; s++)
- if (!compScreenInit (screenInfo.screens[s]))
- return;
-
- extEntry = AddExtension (COMPOSITE_NAME, 0, 0,
- ProcCompositeDispatch, SProcCompositeDispatch,
- NULL, StandardMinorOpcode);
- if (!extEntry)
- return;
- CompositeReqCode = (CARD8) extEntry->base;
-
- miRegisterRedirectBorderClipProc (compSetRedirectBorderClip,
- compGetRedirectBorderClip);
-
- /* Initialization succeeded */
- noCompositeExtension = FALSE;
-}
-
-#ifdef PANORAMIX
-#include "panoramiXsrv.h"
-
-int (*PanoramiXSaveCompositeVector[CompositeNumberRequests]) (ClientPtr);
-
-static int
-PanoramiXCompositeRedirectWindow (ClientPtr client)
-{
- PanoramiXRes *win;
- int rc = 0, j;
- REQUEST(xCompositeRedirectWindowReq);
-
- REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
-
- if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
- client, DixUnknownAccess))) {
- client->errorValue = stuff->window;
- return rc;
- }
-
- FOR_NSCREENS_FORWARD(j) {
- stuff->window = win->info[j].id;
- rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
- if (rc != Success) break;
- }
-
- return rc;
-}
-
-static int
-PanoramiXCompositeRedirectSubwindows (ClientPtr client)
-{
- PanoramiXRes *win;
- int rc = 0, j;
- REQUEST(xCompositeRedirectSubwindowsReq);
-
- REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
-
- if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
- client, DixUnknownAccess))) {
- client->errorValue = stuff->window;
- return rc;
- }
-
- FOR_NSCREENS_FORWARD(j) {
- stuff->window = win->info[j].id;
- rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
- if (rc != Success) break;
- }
-
- return rc;
-}
-
-static int
-PanoramiXCompositeUnredirectWindow (ClientPtr client)
-{
- PanoramiXRes *win;
- int rc = 0, j;
- REQUEST(xCompositeUnredirectWindowReq);
-
- REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
-
- if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
- client, DixUnknownAccess))) {
- client->errorValue = stuff->window;
- return rc;
- }
-
- FOR_NSCREENS_FORWARD(j) {
- stuff->window = win->info[j].id;
- rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
- if (rc != Success) break;
- }
-
- return rc;
-}
-
-static int
-PanoramiXCompositeUnredirectSubwindows (ClientPtr client)
-{
- PanoramiXRes *win;
- int rc = 0, j;
- REQUEST(xCompositeUnredirectSubwindowsReq);
-
- REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
-
- if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
- client, DixUnknownAccess))) {
- client->errorValue = stuff->window;
- return rc;
- }
-
- FOR_NSCREENS_FORWARD(j) {
- stuff->window = win->info[j].id;
- rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
- if (rc != Success) break;
- }
-
- return rc;
-}
-
-static int
-PanoramiXCompositeNameWindowPixmap (ClientPtr client)
-{
- WindowPtr pWin;
- CompWindowPtr cw;
- PixmapPtr pPixmap;
- int rc;
- PanoramiXRes *win, *newPix;
- int i;
- REQUEST(xCompositeNameWindowPixmapReq);
-
- REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
-
- if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
- client, DixUnknownAccess))) {
- client->errorValue = stuff->window;
- return rc;
- }
-
- LEGAL_NEW_RESOURCE (stuff->pixmap, client);
-
- if(!(newPix = malloc(sizeof(PanoramiXRes))))
- return BadAlloc;
-
- newPix->type = XRT_PIXMAP;
- newPix->u.pix.shared = FALSE;
- panoramix_setup_ids(newPix, client, stuff->pixmap);
-
- FOR_NSCREENS(i) {
- rc = dixLookupResourceByType ((void **) &pWin, win->info[i].id,
- RT_WINDOW, client, DixGetAttrAccess);
- if (rc != Success)
- {
- client->errorValue = stuff->window;
- free (newPix);
- return rc;
- }
-
- if (!pWin->viewable)
- {
- free (newPix);
- return BadMatch;
- }
-
- cw = GetCompWindow (pWin);
- if (!cw)
- {
- free (newPix);
- return BadMatch;
- }
-
- pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
- if (!pPixmap)
- {
- free (newPix);
- return BadMatch;
- }
-
- if (!AddResource (newPix->info[i].id, RT_PIXMAP,
- (pointer) pPixmap))
- return BadAlloc;
-
- ++pPixmap->refcnt;
- }
-
- if (!AddResource (stuff->pixmap, XRT_PIXMAP, (pointer) newPix))
- return BadAlloc;
-
- return Success;
-}
-
-
-static int
-PanoramiXCompositeGetOverlayWindow (ClientPtr client)
-{
- REQUEST(xCompositeGetOverlayWindowReq);
- xCompositeGetOverlayWindowReply rep;
- WindowPtr pWin;
- ScreenPtr pScreen;
- CompScreenPtr cs;
- CompOverlayClientPtr pOc;
- int rc;
- PanoramiXRes *win, *overlayWin = NULL;
- int i;
-
- REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
-
- if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
- client, DixUnknownAccess))) {
- client->errorValue = stuff->window;
- return rc;
- }
-
- cs = GetCompScreen(screenInfo.screens[0]);
- if (!cs->pOverlayWin)
- {
- if(!(overlayWin = malloc(sizeof(PanoramiXRes))))
- return BadAlloc;
-
- overlayWin->type = XRT_WINDOW;
- overlayWin->u.win.root = FALSE;
- }
-
- FOR_NSCREENS_BACKWARD(i) {
- rc = dixLookupResourceByType((pointer *)&pWin, win->info[i].id,
- RT_WINDOW, client, DixGetAttrAccess);
- if (rc != Success)
- {
- client->errorValue = stuff->window;
- return rc;
- }
- pScreen = pWin->drawable.pScreen;
-
- /*
- * Create an OverlayClient structure to mark this client's
- * interest in the overlay window
- */
- pOc = compCreateOverlayClient(pScreen, client);
- if (pOc == NULL)
- return BadAlloc;
-
- /*
- * Make sure the overlay window exists
- */
- cs = GetCompScreen(pScreen);
- if (cs->pOverlayWin == NULL)
- if (!compCreateOverlayWindow(pScreen))
- {
- FreeResource (pOc->resource, RT_NONE);
- return BadAlloc;
- }
-
- rc = XaceHook(XACE_RESOURCE_ACCESS, client,
- cs->pOverlayWin->drawable.id,
- RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL,
- DixGetAttrAccess);
- if (rc != Success)
- {
- FreeResource (pOc->resource, RT_NONE);
- return rc;
- }
- }
-
- if (overlayWin)
- {
- FOR_NSCREENS(i) {
- cs = GetCompScreen(screenInfo.screens[i]);
- overlayWin->info[i].id = cs->pOverlayWin->drawable.id;
- }
-
- AddResource(overlayWin->info[0].id, XRT_WINDOW, overlayWin);
- }
-
- cs = GetCompScreen(screenInfo.screens[0]);
-
- 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 Success;
-}
-
-static int
-PanoramiXCompositeReleaseOverlayWindow (ClientPtr client)
-{
- REQUEST(xCompositeReleaseOverlayWindowReq);
- WindowPtr pWin;
- ScreenPtr pScreen;
- CompOverlayClientPtr pOc;
- PanoramiXRes *win;
- int i, rc;
-
- REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq);
-
- if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
- client, DixUnknownAccess))) {
- client->errorValue = stuff->window;
- return rc;
- }
-
- FOR_NSCREENS_BACKWARD(i) {
- if ((rc = dixLookupResourceByType((void **)&pWin, win->info[i].id,
- XRT_WINDOW, client,
- DixUnknownAccess))) {
- client->errorValue = stuff->window;
- return rc;
- }
- pScreen = pWin->drawable.pScreen;
-
- /*
- * Has client queried a reference to the overlay window
- * on this screen? If not, generate an error.
- */
- pOc = compFindOverlayClient (pWin->drawable.pScreen, client);
- if (pOc == NULL)
- return BadMatch;
-
- /* The delete function will free the client structure */
- FreeResource (pOc->resource, RT_NONE);
- }
-
- return Success;
-}
-
-void
-PanoramiXCompositeInit (void)
-{
- int i;
-
- for (i = 0; i < CompositeNumberRequests; i++)
- PanoramiXSaveCompositeVector[i] = ProcCompositeVector[i];
- /*
- * Stuff in Xinerama aware request processing hooks
- */
- ProcCompositeVector[X_CompositeRedirectWindow] =
- PanoramiXCompositeRedirectWindow;
- ProcCompositeVector[X_CompositeRedirectSubwindows] =
- PanoramiXCompositeRedirectSubwindows;
- ProcCompositeVector[X_CompositeUnredirectWindow] =
- PanoramiXCompositeUnredirectWindow;
- ProcCompositeVector[X_CompositeUnredirectSubwindows] =
- PanoramiXCompositeUnredirectSubwindows;
- ProcCompositeVector[X_CompositeNameWindowPixmap] =
- PanoramiXCompositeNameWindowPixmap;
- ProcCompositeVector[X_CompositeGetOverlayWindow] =
- PanoramiXCompositeGetOverlayWindow;
- ProcCompositeVector[X_CompositeReleaseOverlayWindow] =
- PanoramiXCompositeReleaseOverlayWindow;
-}
-
-void
-PanoramiXCompositeReset (void)
-{
- int i;
-
- for (i = 0; i < CompositeNumberRequests; i++)
- ProcCompositeVector[i] = PanoramiXSaveCompositeVector[i];
-}
-
-#endif
+/*
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "compint.h"
+#include "xace.h"
+#include "protocol-versions.h"
+
+static CARD8 CompositeReqCode;
+static DevPrivateKeyRec CompositeClientPrivateKeyRec;
+#define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec)
+RESTYPE CompositeClientWindowType;
+RESTYPE CompositeClientSubwindowsType;
+RESTYPE CompositeClientOverlayType;
+
+typedef struct _CompositeClient {
+ int major_version;
+ int minor_version;
+} CompositeClientRec, *CompositeClientPtr;
+
+#define GetCompositeClient(pClient) ((CompositeClientPtr) \
+ dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey))
+
+static void
+CompositeClientCallback (CallbackListPtr *list,
+ pointer closure,
+ pointer data)
+{
+ NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
+ ClientPtr pClient = clientinfo->client;
+ CompositeClientPtr pCompositeClient = GetCompositeClient (pClient);
+
+ pCompositeClient->major_version = 0;
+ pCompositeClient->minor_version = 0;
+}
+
+static int
+FreeCompositeClientWindow (pointer value, XID ccwid)
+{
+ WindowPtr pWin = value;
+
+ compFreeClientWindow (pWin, ccwid);
+ return Success;
+}
+
+static int
+FreeCompositeClientSubwindows (pointer value, XID ccwid)
+{
+ WindowPtr pWin = value;
+
+ compFreeClientSubwindows (pWin, ccwid);
+ return Success;
+}
+
+static int
+FreeCompositeClientOverlay (pointer value, XID ccwid)
+{
+ CompOverlayClientPtr pOc = (CompOverlayClientPtr) value;
+
+ compFreeOverlayClient (pOc);
+ return Success;
+}
+
+static int
+ProcCompositeQueryVersion (ClientPtr client)
+{
+ CompositeClientPtr pCompositeClient = GetCompositeClient (client);
+ xCompositeQueryVersionReply rep;
+ register int n;
+ REQUEST(xCompositeQueryVersionReq);
+
+ REQUEST_SIZE_MATCH(xCompositeQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ if (stuff->majorVersion < SERVER_COMPOSITE_MAJOR_VERSION) {
+ rep.majorVersion = stuff->majorVersion;
+ rep.minorVersion = stuff->minorVersion;
+ } else {
+ rep.majorVersion = SERVER_COMPOSITE_MAJOR_VERSION;
+ rep.minorVersion = SERVER_COMPOSITE_MINOR_VERSION;
+ }
+ pCompositeClient->major_version = rep.majorVersion;
+ pCompositeClient->minor_version = rep.minorVersion;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.majorVersion, n);
+ swapl(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xCompositeQueryVersionReply), (char *)&rep);
+ return Success;
+}
+
+#define VERIFY_WINDOW(pWindow, wid, client, mode) \
+ do { \
+ int err; \
+ err = dixLookupResourceByType((pointer *) &pWindow, wid, \
+ RT_WINDOW, client, mode); \
+ if (err != Success) { \
+ client->errorValue = wid; \
+ return err; \
+ } \
+ } while (0)
+
+static int
+ProcCompositeRedirectWindow (ClientPtr client)
+{
+ WindowPtr pWin;
+ REQUEST(xCompositeRedirectWindowReq);
+
+ REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
+ VERIFY_WINDOW(pWin, stuff->window, client,
+ DixSetAttrAccess|DixManageAccess|DixBlendAccess);
+
+ return compRedirectWindow (client, pWin, stuff->update);
+}
+
+static int
+ProcCompositeRedirectSubwindows (ClientPtr client)
+{
+ WindowPtr pWin;
+ REQUEST(xCompositeRedirectSubwindowsReq);
+
+ REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
+ VERIFY_WINDOW(pWin, stuff->window, client,
+ DixSetAttrAccess|DixManageAccess|DixBlendAccess);
+
+ return compRedirectSubwindows (client, pWin, stuff->update);
+}
+
+static int
+ProcCompositeUnredirectWindow (ClientPtr client)
+{
+ WindowPtr pWin;
+ REQUEST(xCompositeUnredirectWindowReq);
+
+ REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
+ VERIFY_WINDOW(pWin, stuff->window, client,
+ DixSetAttrAccess|DixManageAccess|DixBlendAccess);
+
+ return compUnredirectWindow (client, pWin, stuff->update);
+}
+
+static int
+ProcCompositeUnredirectSubwindows (ClientPtr client)
+{
+ WindowPtr pWin;
+ REQUEST(xCompositeUnredirectSubwindowsReq);
+
+ REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
+ VERIFY_WINDOW(pWin, stuff->window, client,
+ DixSetAttrAccess|DixManageAccess|DixBlendAccess);
+
+ return compUnredirectSubwindows (client, pWin, stuff->update);
+}
+
+static int
+ProcCompositeCreateRegionFromBorderClip (ClientPtr client)
+{
+ WindowPtr pWin;
+ CompWindowPtr cw;
+ RegionPtr pBorderClip, pRegion;
+ REQUEST(xCompositeCreateRegionFromBorderClipReq);
+
+ REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
+ VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
+ LEGAL_NEW_RESOURCE (stuff->region, client);
+
+ cw = GetCompWindow (pWin);
+ if (cw)
+ pBorderClip = &cw->borderClip;
+ else
+ pBorderClip = &pWin->borderClip;
+ pRegion = XFixesRegionCopy (pBorderClip);
+ if (!pRegion)
+ return BadAlloc;
+ RegionTranslate(pRegion, -pWin->drawable.x, -pWin->drawable.y);
+
+ if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
+ return BadAlloc;
+
+ return Success;
+}
+
+static int
+ProcCompositeNameWindowPixmap (ClientPtr client)
+{
+ WindowPtr pWin;
+ CompWindowPtr cw;
+ PixmapPtr pPixmap;
+ int rc;
+ REQUEST(xCompositeNameWindowPixmapReq);
+
+ REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
+ VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
+
+ if (!pWin->viewable)
+ return BadMatch;
+
+ LEGAL_NEW_RESOURCE (stuff->pixmap, client);
+
+ cw = GetCompWindow (pWin);
+ if (!cw)
+ return BadMatch;
+
+ pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
+ if (!pPixmap)
+ return BadMatch;
+
+ /* security creation/labeling check */
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, RT_PIXMAP,
+ pPixmap, RT_WINDOW, pWin, DixCreateAccess);
+ if (rc != Success)
+ return rc;
+
+ ++pPixmap->refcnt;
+
+ if (!AddResource (stuff->pixmap, RT_PIXMAP, (pointer) pPixmap))
+ return BadAlloc;
+
+ return Success;
+}
+
+
+static int
+ProcCompositeGetOverlayWindow (ClientPtr client)
+{
+ REQUEST(xCompositeGetOverlayWindowReq);
+ xCompositeGetOverlayWindowReply rep;
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ CompScreenPtr cs;
+ CompOverlayClientPtr pOc;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
+ VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
+ pScreen = pWin->drawable.pScreen;
+
+ /*
+ * Create an OverlayClient structure to mark this client's
+ * interest in the overlay window
+ */
+ pOc = compCreateOverlayClient(pScreen, client);
+ if (pOc == NULL)
+ return BadAlloc;
+
+ /*
+ * Make sure the overlay window exists
+ */
+ cs = GetCompScreen(pScreen);
+ if (cs->pOverlayWin == NULL)
+ if (!compCreateOverlayWindow(pScreen))
+ {
+ FreeResource (pOc->resource, RT_NONE);
+ return BadAlloc;
+ }
+
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cs->pOverlayWin->drawable.id,
+ RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, DixGetAttrAccess);
+ if (rc != Success)
+ {
+ FreeResource (pOc->resource, RT_NONE);
+ return rc;
+ }
+
+ 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 Success;
+}
+
+static int
+ProcCompositeReleaseOverlayWindow (ClientPtr client)
+{
+ REQUEST(xCompositeReleaseOverlayWindowReq);
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ CompOverlayClientPtr pOc;
+
+ REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq);
+ VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
+ pScreen = pWin->drawable.pScreen;
+
+ /*
+ * Has client queried a reference to the overlay window
+ * on this screen? If not, generate an error.
+ */
+ pOc = compFindOverlayClient (pWin->drawable.pScreen, client);
+ if (pOc == NULL)
+ return BadMatch;
+
+ /* The delete function will free the client structure */
+ FreeResource (pOc->resource, RT_NONE);
+
+ return Success;
+}
+
+static int (*ProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
+ ProcCompositeQueryVersion,
+ ProcCompositeRedirectWindow,
+ ProcCompositeRedirectSubwindows,
+ ProcCompositeUnredirectWindow,
+ ProcCompositeUnredirectSubwindows,
+ ProcCompositeCreateRegionFromBorderClip,
+ ProcCompositeNameWindowPixmap,
+ ProcCompositeGetOverlayWindow,
+ ProcCompositeReleaseOverlayWindow,
+};
+
+static int
+ProcCompositeDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+
+ if (stuff->data < CompositeNumberRequests)
+ return (*ProcCompositeVector[stuff->data]) (client);
+ else
+ return BadRequest;
+}
+
+static int
+SProcCompositeQueryVersion (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeQueryVersionReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeQueryVersionReq);
+ swapl(&stuff->majorVersion, n);
+ swapl(&stuff->minorVersion, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeRedirectWindow (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeRedirectWindowReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
+ swapl (&stuff->window, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeRedirectSubwindows (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeRedirectSubwindowsReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
+ swapl (&stuff->window, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeUnredirectWindow (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeUnredirectWindowReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
+ swapl (&stuff->window, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeUnredirectSubwindows (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeUnredirectSubwindowsReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
+ swapl (&stuff->window, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeCreateRegionFromBorderClip (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeCreateRegionFromBorderClipReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
+ swapl (&stuff->region, n);
+ swapl (&stuff->window, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeNameWindowPixmap (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeNameWindowPixmapReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
+ swapl (&stuff->window, n);
+ swapl (&stuff->pixmap, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static 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);
+}
+
+static 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);
+}
+
+static int (*SProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
+ SProcCompositeQueryVersion,
+ SProcCompositeRedirectWindow,
+ SProcCompositeRedirectSubwindows,
+ SProcCompositeUnredirectWindow,
+ SProcCompositeUnredirectSubwindows,
+ SProcCompositeCreateRegionFromBorderClip,
+ SProcCompositeNameWindowPixmap,
+ SProcCompositeGetOverlayWindow,
+ SProcCompositeReleaseOverlayWindow,
+};
+
+static int
+SProcCompositeDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+
+ if (stuff->data < CompositeNumberRequests)
+ return (*SProcCompositeVector[stuff->data]) (client);
+ else
+ return BadRequest;
+}
+
+void
+CompositeExtensionInit (void)
+{
+ ExtensionEntry *extEntry;
+ int s;
+
+ /* Assume initialization is going to fail */
+ noCompositeExtension = TRUE;
+
+ for (s = 0; s < screenInfo.numScreens; s++) {
+ ScreenPtr pScreen = screenInfo.screens[s];
+ VisualPtr vis;
+
+ /* Composite on 8bpp pseudocolor root windows appears to fail, so
+ * just disable it on anything pseudocolor for safety.
+ */
+ for (vis = pScreen->visuals; vis->vid != pScreen->rootVisual; vis++)
+ ;
+ if ((vis->class | DynamicClass) == PseudoColor)
+ return;
+
+ /* Ensure that Render is initialized, which is required for automatic
+ * compositing.
+ */
+ if (GetPictureScreenIfSet(pScreen) == NULL)
+ return;
+ }
+
+ CompositeClientWindowType = CreateNewResourceType
+ (FreeCompositeClientWindow, "CompositeClientWindow");
+ if (!CompositeClientWindowType)
+ return;
+
+ CompositeClientSubwindowsType = CreateNewResourceType
+ (FreeCompositeClientSubwindows, "CompositeClientSubwindows");
+ if (!CompositeClientSubwindowsType)
+ return;
+
+ CompositeClientOverlayType = CreateNewResourceType
+ (FreeCompositeClientOverlay, "CompositeClientOverlay");
+ if (!CompositeClientOverlayType)
+ return;
+
+ if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec, PRIVATE_CLIENT,
+ sizeof(CompositeClientRec)))
+ return;
+
+ if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0))
+ return;
+
+ for (s = 0; s < screenInfo.numScreens; s++)
+ if (!compScreenInit (screenInfo.screens[s]))
+ return;
+
+ extEntry = AddExtension (COMPOSITE_NAME, 0, 0,
+ ProcCompositeDispatch, SProcCompositeDispatch,
+ NULL, StandardMinorOpcode);
+ if (!extEntry)
+ return;
+ CompositeReqCode = (CARD8) extEntry->base;
+
+ miRegisterRedirectBorderClipProc (compSetRedirectBorderClip,
+ compGetRedirectBorderClip);
+
+ /* Initialization succeeded */
+ noCompositeExtension = FALSE;
+}
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+
+int (*PanoramiXSaveCompositeVector[CompositeNumberRequests]) (ClientPtr);
+
+static int
+PanoramiXCompositeRedirectWindow (ClientPtr client)
+{
+ PanoramiXRes *win;
+ int rc = 0, j;
+ REQUEST(xCompositeRedirectWindowReq);
+
+ REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
+
+ if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
+ client, DixUnknownAccess))) {
+ client->errorValue = stuff->window;
+ return rc;
+ }
+
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->window = win->info[j].id;
+ rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
+ if (rc != Success) break;
+ }
+
+ return rc;
+}
+
+static int
+PanoramiXCompositeRedirectSubwindows (ClientPtr client)
+{
+ PanoramiXRes *win;
+ int rc = 0, j;
+ REQUEST(xCompositeRedirectSubwindowsReq);
+
+ REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
+
+ if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
+ client, DixUnknownAccess))) {
+ client->errorValue = stuff->window;
+ return rc;
+ }
+
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->window = win->info[j].id;
+ rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
+ if (rc != Success) break;
+ }
+
+ return rc;
+}
+
+static int
+PanoramiXCompositeUnredirectWindow (ClientPtr client)
+{
+ PanoramiXRes *win;
+ int rc = 0, j;
+ REQUEST(xCompositeUnredirectWindowReq);
+
+ REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
+
+ if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
+ client, DixUnknownAccess))) {
+ client->errorValue = stuff->window;
+ return rc;
+ }
+
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->window = win->info[j].id;
+ rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
+ if (rc != Success) break;
+ }
+
+ return rc;
+}
+
+static int
+PanoramiXCompositeUnredirectSubwindows (ClientPtr client)
+{
+ PanoramiXRes *win;
+ int rc = 0, j;
+ REQUEST(xCompositeUnredirectSubwindowsReq);
+
+ REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
+
+ if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
+ client, DixUnknownAccess))) {
+ client->errorValue = stuff->window;
+ return rc;
+ }
+
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->window = win->info[j].id;
+ rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
+ if (rc != Success) break;
+ }
+
+ return rc;
+}
+
+static int
+PanoramiXCompositeNameWindowPixmap (ClientPtr client)
+{
+ WindowPtr pWin;
+ CompWindowPtr cw;
+ PixmapPtr pPixmap;
+ int rc;
+ PanoramiXRes *win, *newPix;
+ int i;
+ REQUEST(xCompositeNameWindowPixmapReq);
+
+ REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
+
+ if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
+ client, DixUnknownAccess))) {
+ client->errorValue = stuff->window;
+ return rc;
+ }
+
+ LEGAL_NEW_RESOURCE (stuff->pixmap, client);
+
+ if(!(newPix = malloc(sizeof(PanoramiXRes))))
+ return BadAlloc;
+
+ newPix->type = XRT_PIXMAP;
+ newPix->u.pix.shared = FALSE;
+ panoramix_setup_ids(newPix, client, stuff->pixmap);
+
+ FOR_NSCREENS(i) {
+ rc = dixLookupResourceByType ((void **) &pWin, win->info[i].id,
+ RT_WINDOW, client, DixGetAttrAccess);
+ if (rc != Success)
+ {
+ client->errorValue = stuff->window;
+ free (newPix);
+ return rc;
+ }
+
+ if (!pWin->viewable)
+ {
+ free (newPix);
+ return BadMatch;
+ }
+
+ cw = GetCompWindow (pWin);
+ if (!cw)
+ {
+ free (newPix);
+ return BadMatch;
+ }
+
+ pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
+ if (!pPixmap)
+ {
+ free (newPix);
+ return BadMatch;
+ }
+
+ if (!AddResource (newPix->info[i].id, RT_PIXMAP,
+ (pointer) pPixmap))
+ return BadAlloc;
+
+ ++pPixmap->refcnt;
+ }
+
+ if (!AddResource (stuff->pixmap, XRT_PIXMAP, (pointer) newPix))
+ return BadAlloc;
+
+ return Success;
+}
+
+
+static int
+PanoramiXCompositeGetOverlayWindow (ClientPtr client)
+{
+ REQUEST(xCompositeGetOverlayWindowReq);
+ xCompositeGetOverlayWindowReply rep;
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ CompScreenPtr cs;
+ CompOverlayClientPtr pOc;
+ int rc;
+ PanoramiXRes *win, *overlayWin = NULL;
+ int i;
+
+ REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
+
+ if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
+ client, DixUnknownAccess))) {
+ client->errorValue = stuff->window;
+ return rc;
+ }
+
+ cs = GetCompScreen(screenInfo.screens[0]);
+ if (!cs->pOverlayWin)
+ {
+ if(!(overlayWin = malloc(sizeof(PanoramiXRes))))
+ return BadAlloc;
+
+ overlayWin->type = XRT_WINDOW;
+ overlayWin->u.win.root = FALSE;
+ }
+
+ FOR_NSCREENS_BACKWARD(i) {
+ rc = dixLookupResourceByType((pointer *)&pWin, win->info[i].id,
+ RT_WINDOW, client, DixGetAttrAccess);
+ if (rc != Success)
+ {
+ client->errorValue = stuff->window;
+ return rc;
+ }
+ pScreen = pWin->drawable.pScreen;
+
+ /*
+ * Create an OverlayClient structure to mark this client's
+ * interest in the overlay window
+ */
+ pOc = compCreateOverlayClient(pScreen, client);
+ if (pOc == NULL)
+ return BadAlloc;
+
+ /*
+ * Make sure the overlay window exists
+ */
+ cs = GetCompScreen(pScreen);
+ if (cs->pOverlayWin == NULL)
+ if (!compCreateOverlayWindow(pScreen))
+ {
+ FreeResource (pOc->resource, RT_NONE);
+ return BadAlloc;
+ }
+
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client,
+ cs->pOverlayWin->drawable.id,
+ RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL,
+ DixGetAttrAccess);
+ if (rc != Success)
+ {
+ FreeResource (pOc->resource, RT_NONE);
+ return rc;
+ }
+ }
+
+ if (overlayWin)
+ {
+ FOR_NSCREENS(i) {
+ cs = GetCompScreen(screenInfo.screens[i]);
+ overlayWin->info[i].id = cs->pOverlayWin->drawable.id;
+ }
+
+ AddResource(overlayWin->info[0].id, XRT_WINDOW, overlayWin);
+ }
+
+ cs = GetCompScreen(screenInfo.screens[0]);
+
+ 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 Success;
+}
+
+static int
+PanoramiXCompositeReleaseOverlayWindow (ClientPtr client)
+{
+ REQUEST(xCompositeReleaseOverlayWindowReq);
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ CompOverlayClientPtr pOc;
+ PanoramiXRes *win;
+ int i, rc;
+
+ REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq);
+
+ if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW,
+ client, DixUnknownAccess))) {
+ client->errorValue = stuff->window;
+ return rc;
+ }
+
+ FOR_NSCREENS_BACKWARD(i) {
+ if ((rc = dixLookupResourceByType((void **)&pWin, win->info[i].id,
+ XRT_WINDOW, client,
+ DixUnknownAccess))) {
+ client->errorValue = stuff->window;
+ return rc;
+ }
+ pScreen = pWin->drawable.pScreen;
+
+ /*
+ * Has client queried a reference to the overlay window
+ * on this screen? If not, generate an error.
+ */
+ pOc = compFindOverlayClient (pWin->drawable.pScreen, client);
+ if (pOc == NULL)
+ return BadMatch;
+
+ /* The delete function will free the client structure */
+ FreeResource (pOc->resource, RT_NONE);
+ }
+
+ return Success;
+}
+
+void
+PanoramiXCompositeInit (void)
+{
+ int i;
+
+ for (i = 0; i < CompositeNumberRequests; i++)
+ PanoramiXSaveCompositeVector[i] = ProcCompositeVector[i];
+ /*
+ * Stuff in Xinerama aware request processing hooks
+ */
+ ProcCompositeVector[X_CompositeRedirectWindow] =
+ PanoramiXCompositeRedirectWindow;
+ ProcCompositeVector[X_CompositeRedirectSubwindows] =
+ PanoramiXCompositeRedirectSubwindows;
+ ProcCompositeVector[X_CompositeUnredirectWindow] =
+ PanoramiXCompositeUnredirectWindow;
+ ProcCompositeVector[X_CompositeUnredirectSubwindows] =
+ PanoramiXCompositeUnredirectSubwindows;
+ ProcCompositeVector[X_CompositeNameWindowPixmap] =
+ PanoramiXCompositeNameWindowPixmap;
+ ProcCompositeVector[X_CompositeGetOverlayWindow] =
+ PanoramiXCompositeGetOverlayWindow;
+ ProcCompositeVector[X_CompositeReleaseOverlayWindow] =
+ PanoramiXCompositeReleaseOverlayWindow;
+}
+
+void
+PanoramiXCompositeReset (void)
+{
+ int i;
+
+ for (i = 0; i < CompositeNumberRequests; i++)
+ ProcCompositeVector[i] = PanoramiXSaveCompositeVector[i];
+}
+
+#endif
diff --git a/xorg-server/composite/compint.h b/xorg-server/composite/compint.h
index 3fef1b93b..bb5335d70 100644
--- a/xorg-server/composite/compint.h
+++ b/xorg-server/composite/compint.h
@@ -1,336 +1,336 @@
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Copyright © 2003 Keith Packard
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _COMPINT_H_
-#define _COMPINT_H_
-
-#include "misc.h"
-#include "scrnintstr.h"
-#include "os.h"
-#include "regionstr.h"
-#include "validate.h"
-#include "windowstr.h"
-#include "input.h"
-#include "resource.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "dixstruct.h"
-#include "gcstruct.h"
-#include "servermd.h"
-#include "dixevents.h"
-#include "globals.h"
-#include "picturestr.h"
-#include "extnsionst.h"
-#include "privates.h"
-#include "mi.h"
-#include "damage.h"
-#include "damageextint.h"
-#include "xfixes.h"
-#include <X11/extensions/compositeproto.h>
-#include <assert.h>
-
-/*
- * enable this for debugging
-
- #define COMPOSITE_DEBUG
- */
-
-typedef struct _CompClientWindow {
- struct _CompClientWindow *next;
- XID id;
- int update;
-} CompClientWindowRec, *CompClientWindowPtr;
-
-typedef struct _CompWindow {
- RegionRec borderClip;
- DamagePtr damage; /* for automatic update mode */
- Bool damageRegistered;
- Bool damaged;
- int update;
- CompClientWindowPtr clients;
- int oldx;
- int oldy;
- PixmapPtr pOldPixmap;
- int borderClipX, borderClipY;
-} CompWindowRec, *CompWindowPtr;
-
-#define COMP_ORIGIN_INVALID 0x80000000
-
-typedef struct _CompSubwindows {
- int update;
- CompClientWindowPtr clients;
-} CompSubwindowsRec, *CompSubwindowsPtr;
-
-#ifndef COMP_INCLUDE_RGB24_VISUAL
-#define COMP_INCLUDE_RGB24_VISUAL 0
-#endif
-
-typedef struct _CompOverlayClientRec *CompOverlayClientPtr;
-
-typedef struct _CompOverlayClientRec {
- CompOverlayClientPtr pNext;
- ClientPtr pClient;
- ScreenPtr pScreen;
- XID resource;
-} CompOverlayClientRec;
-
-typedef struct _CompScreen {
- PositionWindowProcPtr PositionWindow;
- CopyWindowProcPtr CopyWindow;
- CreateWindowProcPtr CreateWindow;
- DestroyWindowProcPtr DestroyWindow;
- RealizeWindowProcPtr RealizeWindow;
- UnrealizeWindowProcPtr UnrealizeWindow;
- ClipNotifyProcPtr ClipNotify;
- /*
- * Called from ConfigureWindow, these
- * three track changes to the offscreen storage
- * geometry
- */
- ConfigNotifyProcPtr ConfigNotify;
- MoveWindowProcPtr MoveWindow;
- ResizeWindowProcPtr ResizeWindow;
- ChangeBorderWidthProcPtr ChangeBorderWidth;
- /*
- * Reparenting has an effect on Subwindows redirect
- */
- ReparentWindowProcPtr ReparentWindow;
-
- /*
- * Colormaps for new visuals better not get installed
- */
- InstallColormapProcPtr InstallColormap;
-
- /*
- * Fake backing store via automatic redirection
- */
- ChangeWindowAttributesProcPtr ChangeWindowAttributes;
-
- ScreenBlockHandlerProcPtr BlockHandler;
- CloseScreenProcPtr CloseScreen;
- int numAlternateVisuals;
- VisualID *alternateVisuals;
-
- WindowPtr pOverlayWin;
- Window overlayWid;
- CompOverlayClientPtr pOverlayClients;
-
- GetImageProcPtr GetImage;
- SourceValidateProcPtr SourceValidate;
-} CompScreenRec, *CompScreenPtr;
-
-extern DevPrivateKeyRec CompScreenPrivateKeyRec;
-#define CompScreenPrivateKey (&CompScreenPrivateKeyRec)
-
-extern DevPrivateKeyRec CompWindowPrivateKeyRec;
-#define CompWindowPrivateKey (&CompWindowPrivateKeyRec)
-
-extern DevPrivateKeyRec CompSubwindowsPrivateKeyRec;
-#define CompSubwindowsPrivateKey (&CompSubwindowsPrivateKeyRec)
-
-#define GetCompScreen(s) ((CompScreenPtr) \
- dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey))
-#define GetCompWindow(w) ((CompWindowPtr) \
- dixLookupPrivate(&(w)->devPrivates, CompWindowPrivateKey))
-#define GetCompSubwindows(w) ((CompSubwindowsPtr) \
- dixLookupPrivate(&(w)->devPrivates, CompSubwindowsPrivateKey))
-
-extern RESTYPE CompositeClientWindowType;
-extern RESTYPE CompositeClientSubwindowsType;
-extern RESTYPE CompositeClientOverlayType;
-
-/*
- * compalloc.c
- */
-
-Bool
-compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
-
-void
-compFreeClientWindow (WindowPtr pWin, XID id);
-
-int
-compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
-
-int
-compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
-
-void
-compFreeClientSubwindows (WindowPtr pWin, XID id);
-
-int
-compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
-
-int
-compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
-
-int
-compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
-
-Bool
-compAllocPixmap (WindowPtr pWin);
-
-void
-compSetParentPixmap (WindowPtr pWin);
-
-void
-compRestoreWindow (WindowPtr pWin, PixmapPtr pPixmap);
-
-Bool
-compReallocPixmap (WindowPtr pWin, int x, int y,
- unsigned int w, unsigned int h, int bw);
-
-/*
- * compext.c
- */
-
-void
-CompositeExtensionInit (void);
-
-/*
- * compinit.c
- */
-
-Bool
-compScreenInit (ScreenPtr pScreen);
-
-/*
- * compoverlay.c
- */
-
-void
-compFreeOverlayClient (CompOverlayClientPtr pOcToDel);
-
-CompOverlayClientPtr
-compFindOverlayClient (ScreenPtr pScreen, ClientPtr pClient);
-
-CompOverlayClientPtr
-compCreateOverlayClient (ScreenPtr pScreen, ClientPtr pClient);
-
-Bool
-compCreateOverlayWindow (ScreenPtr pScreen);
-
-void
-compDestroyOverlayWindow (ScreenPtr pScreen);
-
-/*
- * compwindow.c
- */
-
-#ifdef COMPOSITE_DEBUG
-void
-compCheckTree (ScreenPtr pScreen);
-#else
-#define compCheckTree(s)
-#endif
-
-PictFormatPtr
-compWindowFormat (WindowPtr pWin);
-
-void
-compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap);
-
-Bool
-compCheckRedirect (WindowPtr pWin);
-
-Bool
-compPositionWindow (WindowPtr pWin, int x, int y);
-
-Bool
-compRealizeWindow (WindowPtr pWin);
-
-Bool
-compUnrealizeWindow (WindowPtr pWin);
-
-void
-compClipNotify (WindowPtr pWin, int dx, int dy);
-
-void
-compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind);
-
-void
-compResizeWindow (WindowPtr pWin, int x, int y,
- unsigned int w, unsigned int h, WindowPtr pSib);
-
-void
-compChangeBorderWidth (WindowPtr pWin, unsigned int border_width);
-
-void
-compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent);
-
-Bool
-compCreateWindow (WindowPtr pWin);
-
-Bool
-compDestroyWindow (WindowPtr pWin);
-
-void
-compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion);
-
-RegionPtr
-compGetRedirectBorderClip (WindowPtr pWin);
-
-void
-compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
-
-void
-compPaintChildrenToWindow (WindowPtr pWin);
-
-WindowPtr
-CompositeRealChildHead (WindowPtr pWin);
-
-int
-DeleteWindowNoInputDevices(pointer value, XID wid);
-
-int
-compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
- int bw, WindowPtr pSib);
-
-void PanoramiXCompositeInit (void);
-void PanoramiXCompositeReset (void);
-
-#endif /* _COMPINT_H_ */
+/*
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _COMPINT_H_
+#define _COMPINT_H_
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "dixevents.h"
+#include "globals.h"
+#include "picturestr.h"
+#include "extnsionst.h"
+#include "privates.h"
+#include "mi.h"
+#include "damage.h"
+#include "damageextint.h"
+#include "xfixes.h"
+#include <X11/extensions/compositeproto.h>
+#include <assert.h>
+
+/*
+ * enable this for debugging
+
+ #define COMPOSITE_DEBUG
+ */
+
+typedef struct _CompClientWindow {
+ struct _CompClientWindow *next;
+ XID id;
+ int update;
+} CompClientWindowRec, *CompClientWindowPtr;
+
+typedef struct _CompWindow {
+ RegionRec borderClip;
+ DamagePtr damage; /* for automatic update mode */
+ Bool damageRegistered;
+ Bool damaged;
+ int update;
+ CompClientWindowPtr clients;
+ int oldx;
+ int oldy;
+ PixmapPtr pOldPixmap;
+ int borderClipX, borderClipY;
+} CompWindowRec, *CompWindowPtr;
+
+#define COMP_ORIGIN_INVALID 0x80000000
+
+typedef struct _CompSubwindows {
+ int update;
+ CompClientWindowPtr clients;
+} CompSubwindowsRec, *CompSubwindowsPtr;
+
+#ifndef COMP_INCLUDE_RGB24_VISUAL
+#define COMP_INCLUDE_RGB24_VISUAL 0
+#endif
+
+typedef struct _CompOverlayClientRec *CompOverlayClientPtr;
+
+typedef struct _CompOverlayClientRec {
+ CompOverlayClientPtr pNext;
+ ClientPtr pClient;
+ ScreenPtr pScreen;
+ XID resource;
+} CompOverlayClientRec;
+
+typedef struct _CompScreen {
+ PositionWindowProcPtr PositionWindow;
+ CopyWindowProcPtr CopyWindow;
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ ClipNotifyProcPtr ClipNotify;
+ /*
+ * Called from ConfigureWindow, these
+ * three track changes to the offscreen storage
+ * geometry
+ */
+ ConfigNotifyProcPtr ConfigNotify;
+ MoveWindowProcPtr MoveWindow;
+ ResizeWindowProcPtr ResizeWindow;
+ ChangeBorderWidthProcPtr ChangeBorderWidth;
+ /*
+ * Reparenting has an effect on Subwindows redirect
+ */
+ ReparentWindowProcPtr ReparentWindow;
+
+ /*
+ * Colormaps for new visuals better not get installed
+ */
+ InstallColormapProcPtr InstallColormap;
+
+ /*
+ * Fake backing store via automatic redirection
+ */
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+
+ ScreenBlockHandlerProcPtr BlockHandler;
+ CloseScreenProcPtr CloseScreen;
+ int numAlternateVisuals;
+ VisualID *alternateVisuals;
+
+ WindowPtr pOverlayWin;
+ Window overlayWid;
+ CompOverlayClientPtr pOverlayClients;
+
+ GetImageProcPtr GetImage;
+ SourceValidateProcPtr SourceValidate;
+} CompScreenRec, *CompScreenPtr;
+
+extern DevPrivateKeyRec CompScreenPrivateKeyRec;
+#define CompScreenPrivateKey (&CompScreenPrivateKeyRec)
+
+extern DevPrivateKeyRec CompWindowPrivateKeyRec;
+#define CompWindowPrivateKey (&CompWindowPrivateKeyRec)
+
+extern DevPrivateKeyRec CompSubwindowsPrivateKeyRec;
+#define CompSubwindowsPrivateKey (&CompSubwindowsPrivateKeyRec)
+
+#define GetCompScreen(s) ((CompScreenPtr) \
+ dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey))
+#define GetCompWindow(w) ((CompWindowPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompWindowPrivateKey))
+#define GetCompSubwindows(w) ((CompSubwindowsPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompSubwindowsPrivateKey))
+
+extern RESTYPE CompositeClientWindowType;
+extern RESTYPE CompositeClientSubwindowsType;
+extern RESTYPE CompositeClientOverlayType;
+
+/*
+ * compalloc.c
+ */
+
+Bool
+compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
+
+void
+compFreeClientWindow (WindowPtr pWin, XID id);
+
+int
+compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
+
+int
+compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
+
+void
+compFreeClientSubwindows (WindowPtr pWin, XID id);
+
+int
+compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
+
+int
+compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
+
+int
+compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
+
+Bool
+compAllocPixmap (WindowPtr pWin);
+
+void
+compSetParentPixmap (WindowPtr pWin);
+
+void
+compRestoreWindow (WindowPtr pWin, PixmapPtr pPixmap);
+
+Bool
+compReallocPixmap (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, int bw);
+
+/*
+ * compext.c
+ */
+
+void
+CompositeExtensionInit (void);
+
+/*
+ * compinit.c
+ */
+
+Bool
+compScreenInit (ScreenPtr pScreen);
+
+/*
+ * compoverlay.c
+ */
+
+void
+compFreeOverlayClient (CompOverlayClientPtr pOcToDel);
+
+CompOverlayClientPtr
+compFindOverlayClient (ScreenPtr pScreen, ClientPtr pClient);
+
+CompOverlayClientPtr
+compCreateOverlayClient (ScreenPtr pScreen, ClientPtr pClient);
+
+Bool
+compCreateOverlayWindow (ScreenPtr pScreen);
+
+void
+compDestroyOverlayWindow (ScreenPtr pScreen);
+
+/*
+ * compwindow.c
+ */
+
+#ifdef COMPOSITE_DEBUG
+void
+compCheckTree (ScreenPtr pScreen);
+#else
+#define compCheckTree(s)
+#endif
+
+PictFormatPtr
+compWindowFormat (WindowPtr pWin);
+
+void
+compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap);
+
+Bool
+compCheckRedirect (WindowPtr pWin);
+
+Bool
+compPositionWindow (WindowPtr pWin, int x, int y);
+
+Bool
+compRealizeWindow (WindowPtr pWin);
+
+Bool
+compUnrealizeWindow (WindowPtr pWin);
+
+void
+compClipNotify (WindowPtr pWin, int dx, int dy);
+
+void
+compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind);
+
+void
+compResizeWindow (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib);
+
+void
+compChangeBorderWidth (WindowPtr pWin, unsigned int border_width);
+
+void
+compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent);
+
+Bool
+compCreateWindow (WindowPtr pWin);
+
+Bool
+compDestroyWindow (WindowPtr pWin);
+
+void
+compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion);
+
+RegionPtr
+compGetRedirectBorderClip (WindowPtr pWin);
+
+void
+compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
+void
+compPaintChildrenToWindow (WindowPtr pWin);
+
+WindowPtr
+CompositeRealChildHead (WindowPtr pWin);
+
+int
+DeleteWindowNoInputDevices(pointer value, XID wid);
+
+int
+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
+ int bw, WindowPtr pSib);
+
+void PanoramiXCompositeInit (void);
+void PanoramiXCompositeReset (void);
+
+#endif /* _COMPINT_H_ */
diff --git a/xorg-server/composite/compwindow.c b/xorg-server/composite/compwindow.c
index 967e992c9..d2a866d6f 100644
--- a/xorg-server/composite/compwindow.c
+++ b/xorg-server/composite/compwindow.c
@@ -1,832 +1,832 @@
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Copyright © 2003 Keith Packard
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "compint.h"
-
-#ifdef PANORAMIX
-#include "panoramiXsrv.h"
-#endif
-
-#ifdef COMPOSITE_DEBUG
-static int
-compCheckWindow (WindowPtr pWin, pointer data)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- PixmapPtr pWinPixmap = (*pScreen->GetWindowPixmap) (pWin);
- PixmapPtr pParentPixmap = pWin->parent ? (*pScreen->GetWindowPixmap) (pWin->parent) : 0;
- PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen);
-
- if (!pWin->parent)
- {
- assert (pWin->redirectDraw == RedirectDrawNone);
- assert (pWinPixmap == pScreenPixmap);
- }
- else if (pWin->redirectDraw != RedirectDrawNone)
- {
- assert (pWinPixmap != pParentPixmap);
- assert (pWinPixmap != pScreenPixmap);
- }
- else
- {
- assert (pWinPixmap == pParentPixmap);
- }
- assert (0 < pWinPixmap->refcnt && pWinPixmap->refcnt < 3);
- assert (0 < pScreenPixmap->refcnt && pScreenPixmap->refcnt < 3);
- if (pParentPixmap)
- assert (0 <= pParentPixmap->refcnt && pParentPixmap->refcnt < 3);
- return WT_WALKCHILDREN;
-}
-
-void
-compCheckTree (ScreenPtr pScreen)
-{
- WalkTree (pScreen, compCheckWindow, 0);
-}
-#endif
-
-typedef struct _compPixmapVisit {
- WindowPtr pWindow;
- PixmapPtr pPixmap;
-} CompPixmapVisitRec, *CompPixmapVisitPtr;
-
-static Bool
-compRepaintBorder (ClientPtr pClient, pointer closure)
-{
- WindowPtr pWindow;
- int rc = dixLookupWindow(&pWindow, (XID)(intptr_t)closure, pClient, DixWriteAccess);
-
- if (rc == Success) {
- RegionRec exposed;
-
- RegionNull(&exposed);
- RegionSubtract(&exposed, &pWindow->borderClip, &pWindow->winSize);
- miPaintWindow(pWindow, &exposed, PW_BORDER);
- RegionUninit(&exposed);
- }
- return TRUE;
-}
-
-static int
-compSetPixmapVisitWindow (WindowPtr pWindow, pointer data)
-{
- CompPixmapVisitPtr pVisit = (CompPixmapVisitPtr) data;
- ScreenPtr pScreen = pWindow->drawable.pScreen;
-
- if (pWindow != pVisit->pWindow && pWindow->redirectDraw != RedirectDrawNone)
- return WT_DONTWALKCHILDREN;
- (*pScreen->SetWindowPixmap) (pWindow, pVisit->pPixmap);
- /*
- * Recompute winSize and borderSize. This is duplicate effort
- * when resizing pixmaps, but necessary when changing redirection.
- * Might be nice to fix this.
- */
- SetWinSize (pWindow);
- SetBorderSize (pWindow);
- if (HasBorder (pWindow))
- QueueWorkProc (compRepaintBorder, serverClient,
- (pointer)(intptr_t) pWindow->drawable.id);
- return WT_WALKCHILDREN;
-}
-
-void
-compSetPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
-{
- CompPixmapVisitRec visitRec;
-
- visitRec.pWindow = pWindow;
- visitRec.pPixmap = pPixmap;
- TraverseTree (pWindow, compSetPixmapVisitWindow, (pointer) &visitRec);
- compCheckTree (pWindow->drawable.pScreen);
-}
-
-Bool
-compCheckRedirect (WindowPtr pWin)
-{
- CompWindowPtr cw = GetCompWindow (pWin);
- CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen);
- Bool should;
-
- should = pWin->realized && (pWin->drawable.class != InputOnly) &&
- (cw != NULL) && (pWin->parent != NULL);
-
- /* Never redirect the overlay window */
- if (cs->pOverlayWin != NULL) {
- if (pWin == cs->pOverlayWin) {
- should = FALSE;
- }
- }
-
- if (should != (pWin->redirectDraw != RedirectDrawNone))
- {
- if (should)
- return compAllocPixmap (pWin);
- else {
- ScreenPtr pScreen = pWin->drawable.pScreen;
- PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- compSetParentPixmap (pWin);
- compRestoreWindow (pWin, pPixmap);
- (*pScreen->DestroyPixmap) (pPixmap);
- }
- } else if (should) {
- if (cw->update == CompositeRedirectAutomatic)
- pWin->redirectDraw = RedirectDrawAutomatic;
- else
- pWin->redirectDraw = RedirectDrawManual;
- }
- return TRUE;
-}
-
-static int
-updateOverlayWindow(ScreenPtr pScreen)
-{
- CompScreenPtr cs;
- WindowPtr pWin; /* overlay window */
- XID vlist[2];
- int w = pScreen->width;
- int h = pScreen->height;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension)
- {
- w = PanoramiXPixWidth;
- h = PanoramiXPixHeight;
- }
-#endif
-
- cs = GetCompScreen(pScreen);
- if ((pWin = cs->pOverlayWin) != NULL) {
- if ((pWin->drawable.width == w) &&
- (pWin->drawable.height == h))
- return Success;
-
- /* Let's resize the overlay window. */
- vlist[0] = w;
- vlist[1] = h;
- return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin));
- }
-
- /* Let's be on the safe side and not assume an overlay window is always allocated. */
- return Success;
-}
-
-Bool
-compPositionWindow (WindowPtr pWin, int x, int y)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- Bool ret = TRUE;
-
- pScreen->PositionWindow = cs->PositionWindow;
- /*
- * "Shouldn't need this as all possible places should be wrapped
- *
- compCheckRedirect (pWin);
- */
-#ifdef COMPOSITE_DEBUG
- if ((pWin->redirectDraw != RedirectDrawNone) !=
- (pWin->viewable && (GetCompWindow(pWin) != NULL)))
- OsAbort ();
-#endif
- if (pWin->redirectDraw != RedirectDrawNone)
- {
- PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- int bw = wBorderWidth (pWin);
- int nx = pWin->drawable.x - bw;
- int ny = pWin->drawable.y - bw;
-
- if (pPixmap->screen_x != nx || pPixmap->screen_y != ny)
- {
- pPixmap->screen_x = nx;
- pPixmap->screen_y = ny;
- pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- }
- }
-
- if (!(*pScreen->PositionWindow) (pWin, x, y))
- ret = FALSE;
- cs->PositionWindow = pScreen->PositionWindow;
- pScreen->PositionWindow = compPositionWindow;
- compCheckTree (pWin->drawable.pScreen);
- if (updateOverlayWindow(pScreen) != Success)
- ret = FALSE;
- return ret;
-}
-
-Bool
-compRealizeWindow (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- Bool ret = TRUE;
-
- pScreen->RealizeWindow = cs->RealizeWindow;
- compCheckRedirect (pWin);
- if (!(*pScreen->RealizeWindow) (pWin))
- ret = FALSE;
- cs->RealizeWindow = pScreen->RealizeWindow;
- pScreen->RealizeWindow = compRealizeWindow;
- compCheckTree (pWin->drawable.pScreen);
- return ret;
-}
-
-Bool
-compUnrealizeWindow (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- Bool ret = TRUE;
-
- pScreen->UnrealizeWindow = cs->UnrealizeWindow;
- compCheckRedirect (pWin);
- if (!(*pScreen->UnrealizeWindow) (pWin))
- ret = FALSE;
- cs->UnrealizeWindow = pScreen->UnrealizeWindow;
- pScreen->UnrealizeWindow = compUnrealizeWindow;
- compCheckTree (pWin->drawable.pScreen);
- return ret;
-}
-
-/*
- * Called after the borderClip for the window has settled down
- * We use this to make sure our extra borderClip has the right origin
- */
-
-void
-compClipNotify (WindowPtr pWin, int dx, int dy)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- CompWindowPtr cw = GetCompWindow (pWin);
-
- if (cw)
- {
- if (cw->borderClipX != pWin->drawable.x ||
- cw->borderClipY != pWin->drawable.y)
- {
- RegionTranslate(&cw->borderClip,
- pWin->drawable.x - cw->borderClipX,
- pWin->drawable.y - cw->borderClipY);
- cw->borderClipX = pWin->drawable.x;
- cw->borderClipY = pWin->drawable.y;
- }
- }
- if (cs->ClipNotify)
- {
- pScreen->ClipNotify = cs->ClipNotify;
- (*pScreen->ClipNotify) (pWin, dx, dy);
- cs->ClipNotify = pScreen->ClipNotify;
- pScreen->ClipNotify = compClipNotify;
- }
-}
-
-/*
- * Returns TRUE if the window needs server-provided automatic redirect,
- * which is true if the child and parent aren't both regular or ARGB visuals
- */
-
-static Bool
-compIsAlternateVisual (ScreenPtr pScreen,
- XID visual)
-{
- CompScreenPtr cs = GetCompScreen (pScreen);
- int i;
-
- for (i = 0; i < cs->numAlternateVisuals; i++)
- if (cs->alternateVisuals[i] == visual)
- return TRUE;
- return FALSE;
-}
-
-static Bool
-compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
-{
- if (pParent)
- {
- ScreenPtr pScreen = pWin->drawable.pScreen;
- XID winVisual = wVisual (pWin);
- XID parentVisual = wVisual (pParent);
-
- if (winVisual != parentVisual &&
- (compIsAlternateVisual (pScreen, winVisual) ||
- compIsAlternateVisual (pScreen, parentVisual)))
- return TRUE;
- }
- return FALSE;
-}
-
-static void compFreeOldPixmap(WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- if (pWin->redirectDraw != RedirectDrawNone)
- {
- CompWindowPtr cw = GetCompWindow (pWin);
- if (cw->pOldPixmap)
- {
- (*pScreen->DestroyPixmap) (cw->pOldPixmap);
- cw->pOldPixmap = NullPixmap;
- }
- }
-}
-void
-compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
-
- pScreen->MoveWindow = cs->MoveWindow;
- (*pScreen->MoveWindow) (pWin, x, y, pSib, kind);
- cs->MoveWindow = pScreen->MoveWindow;
- pScreen->MoveWindow = compMoveWindow;
-
- compFreeOldPixmap(pWin);
- compCheckTree (pScreen);
-}
-
-void
-compResizeWindow (WindowPtr pWin, int x, int y,
- unsigned int w, unsigned int h, WindowPtr pSib)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
-
- pScreen->ResizeWindow = cs->ResizeWindow;
- (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
- cs->ResizeWindow = pScreen->ResizeWindow;
- pScreen->ResizeWindow = compResizeWindow;
-
- compFreeOldPixmap(pWin);
- compCheckTree (pWin->drawable.pScreen);
-}
-
-void
-compChangeBorderWidth (WindowPtr pWin, unsigned int bw)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
-
- pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
- (*pScreen->ChangeBorderWidth) (pWin, bw);
- cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
- pScreen->ChangeBorderWidth = compChangeBorderWidth;
-
- compFreeOldPixmap(pWin);
- compCheckTree (pWin->drawable.pScreen);
-}
-
-void
-compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
-
- pScreen->ReparentWindow = cs->ReparentWindow;
- /*
- * Remove any implicit redirect due to synthesized visual
- */
- if (compImplicitRedirect (pWin, pPriorParent))
- compUnredirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
- /*
- * Handle subwindows redirection
- */
- compUnredirectOneSubwindow (pPriorParent, pWin);
- compRedirectOneSubwindow (pWin->parent, pWin);
- /*
- * Add any implict redirect due to synthesized visual
- */
- if (compImplicitRedirect (pWin, pWin->parent))
- compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
-
- /*
- * Allocate any necessary redirect pixmap
- * (this actually should never be true; pWin is always unmapped)
- */
- compCheckRedirect (pWin);
-
- /*
- * Reset pixmap pointers as appropriate
- */
- if (pWin->parent && pWin->redirectDraw == RedirectDrawNone)
- compSetPixmap (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
- /*
- * Call down to next function
- */
- if (pScreen->ReparentWindow)
- (*pScreen->ReparentWindow) (pWin, pPriorParent);
- cs->ReparentWindow = pScreen->ReparentWindow;
- pScreen->ReparentWindow = compReparentWindow;
- compCheckTree (pWin->drawable.pScreen);
-}
-
-void
-compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- int dx = 0, dy = 0;
-
- if (pWin->redirectDraw != RedirectDrawNone)
- {
- PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- CompWindowPtr cw = GetCompWindow (pWin);
-
- assert (cw->oldx != COMP_ORIGIN_INVALID);
- assert (cw->oldy != COMP_ORIGIN_INVALID);
- if (cw->pOldPixmap)
- {
- /*
- * Ok, the old bits are available in pOldPixmap and
- * need to be copied to pNewPixmap.
- */
- RegionRec rgnDst;
- PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- GCPtr pGC;
-
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
- RegionTranslate(prgnSrc, -dx, -dy);
-
- RegionNull(&rgnDst);
-
- RegionIntersect(&rgnDst,
- &pWin->borderClip, prgnSrc);
-
- RegionTranslate(&rgnDst,
- -pPixmap->screen_x, -pPixmap->screen_y);
-
- dx = dx + pPixmap->screen_x - cw->oldx;
- dy = dy + pPixmap->screen_y - cw->oldy;
- pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
- if (pGC)
- {
- BoxPtr pBox = RegionRects (&rgnDst);
- int nBox = RegionNumRects (&rgnDst);
-
- ValidateGC(&pPixmap->drawable, pGC);
- while (nBox--)
- {
- (void) (*pGC->ops->CopyArea) (&cw->pOldPixmap->drawable,
- &pPixmap->drawable,
- pGC,
- pBox->x1 + dx, pBox->y1 + dy,
- pBox->x2 - pBox->x1,
- pBox->y2 - pBox->y1,
- pBox->x1, pBox->y1);
- pBox++;
- }
- FreeScratchGC (pGC);
- }
- return;
- }
- dx = pPixmap->screen_x - cw->oldx;
- dy = pPixmap->screen_y - cw->oldy;
- ptOldOrg.x += dx;
- ptOldOrg.y += dy;
- }
-
- pScreen->CopyWindow = cs->CopyWindow;
- if (ptOldOrg.x != pWin->drawable.x || ptOldOrg.y != pWin->drawable.y)
- {
- if (dx || dy)
- RegionTranslate(prgnSrc, dx, dy);
- (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
- if (dx || dy)
- RegionTranslate(prgnSrc, -dx, -dy);
- }
- else
- {
- ptOldOrg.x -= dx;
- ptOldOrg.y -= dy;
- RegionTranslate(prgnSrc,
- pWin->drawable.x - ptOldOrg.x,
- pWin->drawable.y - ptOldOrg.y);
- DamageDamageRegion(&pWin->drawable, prgnSrc);
- }
- cs->CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = compCopyWindow;
- compCheckTree (pWin->drawable.pScreen);
-}
-
-Bool
-compCreateWindow (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- Bool ret;
-
- pScreen->CreateWindow = cs->CreateWindow;
- ret = (*pScreen->CreateWindow) (pWin);
- if (pWin->parent && ret)
- {
- CompSubwindowsPtr csw = GetCompSubwindows (pWin->parent);
- CompClientWindowPtr ccw;
-
- (*pScreen->SetWindowPixmap) (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
- if (csw)
- for (ccw = csw->clients; ccw; ccw = ccw->next)
- compRedirectWindow (clients[CLIENT_ID(ccw->id)],
- pWin, ccw->update);
- if (compImplicitRedirect (pWin, pWin->parent))
- compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
- }
- cs->CreateWindow = pScreen->CreateWindow;
- pScreen->CreateWindow = compCreateWindow;
- compCheckTree (pWin->drawable.pScreen);
- return ret;
-}
-
-Bool
-compDestroyWindow (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- CompWindowPtr cw;
- CompSubwindowsPtr csw;
- Bool ret;
-
- pScreen->DestroyWindow = cs->DestroyWindow;
- while ((cw = GetCompWindow (pWin)))
- FreeResource (cw->clients->id, RT_NONE);
- while ((csw = GetCompSubwindows (pWin)))
- FreeResource (csw->clients->id, RT_NONE);
-
- if (pWin->redirectDraw != RedirectDrawNone) {
- PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- compSetParentPixmap (pWin);
- (*pScreen->DestroyPixmap) (pPixmap);
- }
- ret = (*pScreen->DestroyWindow) (pWin);
- cs->DestroyWindow = pScreen->DestroyWindow;
- pScreen->DestroyWindow = compDestroyWindow;
-/* compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/
- return ret;
-}
-
-void
-compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion)
-{
- CompWindowPtr cw = GetCompWindow (pWin);
- RegionRec damage;
-
- RegionNull(&damage);
- /*
- * Align old border clip with new border clip
- */
- RegionTranslate(&cw->borderClip,
- pWin->drawable.x - cw->borderClipX,
- pWin->drawable.y - cw->borderClipY);
- /*
- * Compute newly visible portion of window for repaint
- */
- RegionSubtract(&damage, pRegion, &cw->borderClip);
- /*
- * Report that as damaged so it will be redrawn
- */
- DamageDamageRegion(&pWin->drawable, &damage);
- RegionUninit(&damage);
- /*
- * Save the new border clip region
- */
- RegionCopy(&cw->borderClip, pRegion);
- cw->borderClipX = pWin->drawable.x;
- cw->borderClipY = pWin->drawable.y;
-}
-
-RegionPtr
-compGetRedirectBorderClip (WindowPtr pWin)
-{
- CompWindowPtr cw = GetCompWindow (pWin);
-
- return &cw->borderClip;
-}
-
-static VisualPtr
-compGetWindowVisual (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- VisualID vid = wVisual (pWin);
- int i;
-
- for (i = 0; i < pScreen->numVisuals; i++)
- if (pScreen->visuals[i].vid == vid)
- return &pScreen->visuals[i];
- return 0;
-}
-
-PictFormatPtr
-compWindowFormat (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- return PictureMatchVisual (pScreen, pWin->drawable.depth,
- compGetWindowVisual (pWin));
-}
-
-static void
-compWindowUpdateAutomatic (WindowPtr pWin)
-{
- CompWindowPtr cw = GetCompWindow (pWin);
- ScreenPtr pScreen = pWin->drawable.pScreen;
- WindowPtr pParent = pWin->parent;
- PixmapPtr pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin);
- PictFormatPtr pSrcFormat = compWindowFormat (pWin);
- PictFormatPtr pDstFormat = compWindowFormat (pWin->parent);
- int error;
- RegionPtr pRegion = DamageRegion (cw->damage);
- PicturePtr pSrcPicture = CreatePicture (0, &pSrcPixmap->drawable,
- pSrcFormat,
- 0, 0,
- serverClient,
- &error);
- XID subwindowMode = IncludeInferiors;
- PicturePtr pDstPicture = CreatePicture (0, &pParent->drawable,
- pDstFormat,
- CPSubwindowMode,
- &subwindowMode,
- serverClient,
- &error);
-
- /*
- * First move the region from window to screen coordinates
- */
- RegionTranslate(pRegion,
- pWin->drawable.x, pWin->drawable.y);
-
- /*
- * Clip against the "real" border clip
- */
- RegionIntersect(pRegion, pRegion, &cw->borderClip);
-
- /*
- * Now translate from screen to dest coordinates
- */
- RegionTranslate(pRegion,
- -pParent->drawable.x, -pParent->drawable.y);
-
- /*
- * Clip the picture
- */
- SetPictureClipRegion (pDstPicture, 0, 0, pRegion);
-
- /*
- * And paint
- */
- CompositePicture (PictOpSrc,
- pSrcPicture,
- 0,
- pDstPicture,
- 0, 0, /* src_x, src_y */
- 0, 0, /* msk_x, msk_y */
- pSrcPixmap->screen_x - pParent->drawable.x,
- pSrcPixmap->screen_y - pParent->drawable.y,
- pSrcPixmap->drawable.width,
- pSrcPixmap->drawable.height);
- FreePicture (pSrcPicture, 0);
- FreePicture (pDstPicture, 0);
- /*
- * Empty the damage region. This has the nice effect of
- * rendering the translations above harmless
- */
- DamageEmpty (cw->damage);
-}
-
-static void
-compPaintWindowToParent (WindowPtr pWin)
-{
- compPaintChildrenToWindow (pWin);
-
- if (pWin->redirectDraw != RedirectDrawNone)
- {
- CompWindowPtr cw = GetCompWindow(pWin);
-
- if (cw->damaged)
- {
- compWindowUpdateAutomatic (pWin);
- cw->damaged = FALSE;
- }
- }
-}
-
-void
-compPaintChildrenToWindow (WindowPtr pWin)
-{
- WindowPtr pChild;
-
- if (!pWin->damagedDescendants)
- return;
-
- for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
- compPaintWindowToParent (pChild);
-
- pWin->damagedDescendants = FALSE;
-}
-
-WindowPtr
-CompositeRealChildHead (WindowPtr pWin)
-{
- WindowPtr pChild, pChildBefore;
- CompScreenPtr cs;
-
- if (!pWin->parent &&
- (screenIsSaved == SCREEN_SAVER_ON) &&
- (HasSaverWindow (pWin->drawable.pScreen))) {
-
- /* 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;
- }
-}
-
-int
-compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
- int bw, WindowPtr pSib)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- CompScreenPtr cs = GetCompScreen (pScreen);
- Bool ret = 0;
- WindowPtr pParent = pWin->parent;
- int draw_x, draw_y;
- Bool alloc_ret;
-
- if (cs->ConfigNotify)
- {
- pScreen->ConfigNotify = cs->ConfigNotify;
- ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
- cs->ConfigNotify = pScreen->ConfigNotify;
- pScreen->ConfigNotify = compConfigNotify;
-
- if (ret)
- return ret;
- }
-
- if (pWin->redirectDraw == RedirectDrawNone)
- return Success;
-
- compCheckTree (pScreen);
-
- draw_x = pParent->drawable.x + x + bw;
- draw_y = pParent->drawable.y + y + bw;
- alloc_ret = compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
-
- if (alloc_ret == FALSE)
- return BadAlloc;
- return Success;
-}
+/*
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "compint.h"
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#endif
+
+#ifdef COMPOSITE_DEBUG
+static int
+compCheckWindow (WindowPtr pWin, pointer data)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pWinPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ PixmapPtr pParentPixmap = pWin->parent ? (*pScreen->GetWindowPixmap) (pWin->parent) : 0;
+ PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+
+ if (!pWin->parent)
+ {
+ assert (pWin->redirectDraw == RedirectDrawNone);
+ assert (pWinPixmap == pScreenPixmap);
+ }
+ else if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ assert (pWinPixmap != pParentPixmap);
+ assert (pWinPixmap != pScreenPixmap);
+ }
+ else
+ {
+ assert (pWinPixmap == pParentPixmap);
+ }
+ assert (0 < pWinPixmap->refcnt && pWinPixmap->refcnt < 3);
+ assert (0 < pScreenPixmap->refcnt && pScreenPixmap->refcnt < 3);
+ if (pParentPixmap)
+ assert (0 <= pParentPixmap->refcnt && pParentPixmap->refcnt < 3);
+ return WT_WALKCHILDREN;
+}
+
+void
+compCheckTree (ScreenPtr pScreen)
+{
+ WalkTree (pScreen, compCheckWindow, 0);
+}
+#endif
+
+typedef struct _compPixmapVisit {
+ WindowPtr pWindow;
+ PixmapPtr pPixmap;
+} CompPixmapVisitRec, *CompPixmapVisitPtr;
+
+static Bool
+compRepaintBorder (ClientPtr pClient, pointer closure)
+{
+ WindowPtr pWindow;
+ int rc = dixLookupWindow(&pWindow, (XID)(intptr_t)closure, pClient, DixWriteAccess);
+
+ if (rc == Success) {
+ RegionRec exposed;
+
+ RegionNull(&exposed);
+ RegionSubtract(&exposed, &pWindow->borderClip, &pWindow->winSize);
+ miPaintWindow(pWindow, &exposed, PW_BORDER);
+ RegionUninit(&exposed);
+ }
+ return TRUE;
+}
+
+static int
+compSetPixmapVisitWindow (WindowPtr pWindow, pointer data)
+{
+ CompPixmapVisitPtr pVisit = (CompPixmapVisitPtr) data;
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+
+ if (pWindow != pVisit->pWindow && pWindow->redirectDraw != RedirectDrawNone)
+ return WT_DONTWALKCHILDREN;
+ (*pScreen->SetWindowPixmap) (pWindow, pVisit->pPixmap);
+ /*
+ * Recompute winSize and borderSize. This is duplicate effort
+ * when resizing pixmaps, but necessary when changing redirection.
+ * Might be nice to fix this.
+ */
+ SetWinSize (pWindow);
+ SetBorderSize (pWindow);
+ if (HasBorder (pWindow))
+ QueueWorkProc (compRepaintBorder, serverClient,
+ (pointer)(intptr_t) pWindow->drawable.id);
+ return WT_WALKCHILDREN;
+}
+
+void
+compSetPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
+{
+ CompPixmapVisitRec visitRec;
+
+ visitRec.pWindow = pWindow;
+ visitRec.pPixmap = pPixmap;
+ TraverseTree (pWindow, compSetPixmapVisitWindow, (pointer) &visitRec);
+ compCheckTree (pWindow->drawable.pScreen);
+}
+
+Bool
+compCheckRedirect (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen);
+ Bool should;
+
+ should = pWin->realized && (pWin->drawable.class != InputOnly) &&
+ (cw != NULL) && (pWin->parent != NULL);
+
+ /* Never redirect the overlay window */
+ if (cs->pOverlayWin != NULL) {
+ if (pWin == cs->pOverlayWin) {
+ should = FALSE;
+ }
+ }
+
+ if (should != (pWin->redirectDraw != RedirectDrawNone))
+ {
+ if (should)
+ return compAllocPixmap (pWin);
+ else {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ compSetParentPixmap (pWin);
+ compRestoreWindow (pWin, pPixmap);
+ (*pScreen->DestroyPixmap) (pPixmap);
+ }
+ } else if (should) {
+ if (cw->update == CompositeRedirectAutomatic)
+ pWin->redirectDraw = RedirectDrawAutomatic;
+ else
+ pWin->redirectDraw = RedirectDrawManual;
+ }
+ return TRUE;
+}
+
+static int
+updateOverlayWindow(ScreenPtr pScreen)
+{
+ CompScreenPtr cs;
+ WindowPtr pWin; /* overlay window */
+ XID vlist[2];
+ int w = pScreen->width;
+ int h = pScreen->height;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension)
+ {
+ w = PanoramiXPixWidth;
+ h = PanoramiXPixHeight;
+ }
+#endif
+
+ cs = GetCompScreen(pScreen);
+ if ((pWin = cs->pOverlayWin) != NULL) {
+ if ((pWin->drawable.width == w) &&
+ (pWin->drawable.height == h))
+ return Success;
+
+ /* Let's resize the overlay window. */
+ vlist[0] = w;
+ vlist[1] = h;
+ return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin));
+ }
+
+ /* Let's be on the safe side and not assume an overlay window is always allocated. */
+ return Success;
+}
+
+Bool
+compPositionWindow (WindowPtr pWin, int x, int y)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->PositionWindow = cs->PositionWindow;
+ /*
+ * "Shouldn't need this as all possible places should be wrapped
+ *
+ compCheckRedirect (pWin);
+ */
+#ifdef COMPOSITE_DEBUG
+ if ((pWin->redirectDraw != RedirectDrawNone) !=
+ (pWin->viewable && (GetCompWindow(pWin) != NULL)))
+ OsAbort ();
+#endif
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ int bw = wBorderWidth (pWin);
+ int nx = pWin->drawable.x - bw;
+ int ny = pWin->drawable.y - bw;
+
+ if (pPixmap->screen_x != nx || pPixmap->screen_y != ny)
+ {
+ pPixmap->screen_x = nx;
+ pPixmap->screen_y = ny;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ }
+
+ if (!(*pScreen->PositionWindow) (pWin, x, y))
+ ret = FALSE;
+ cs->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = compPositionWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ if (updateOverlayWindow(pScreen) != Success)
+ ret = FALSE;
+ return ret;
+}
+
+Bool
+compRealizeWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->RealizeWindow = cs->RealizeWindow;
+ compCheckRedirect (pWin);
+ if (!(*pScreen->RealizeWindow) (pWin))
+ ret = FALSE;
+ cs->RealizeWindow = pScreen->RealizeWindow;
+ pScreen->RealizeWindow = compRealizeWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compUnrealizeWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->UnrealizeWindow = cs->UnrealizeWindow;
+ compCheckRedirect (pWin);
+ if (!(*pScreen->UnrealizeWindow) (pWin))
+ ret = FALSE;
+ cs->UnrealizeWindow = pScreen->UnrealizeWindow;
+ pScreen->UnrealizeWindow = compUnrealizeWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+/*
+ * Called after the borderClip for the window has settled down
+ * We use this to make sure our extra borderClip has the right origin
+ */
+
+void
+compClipNotify (WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (cw)
+ {
+ if (cw->borderClipX != pWin->drawable.x ||
+ cw->borderClipY != pWin->drawable.y)
+ {
+ RegionTranslate(&cw->borderClip,
+ pWin->drawable.x - cw->borderClipX,
+ pWin->drawable.y - cw->borderClipY);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+ }
+ }
+ if (cs->ClipNotify)
+ {
+ pScreen->ClipNotify = cs->ClipNotify;
+ (*pScreen->ClipNotify) (pWin, dx, dy);
+ cs->ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = compClipNotify;
+ }
+}
+
+/*
+ * Returns TRUE if the window needs server-provided automatic redirect,
+ * which is true if the child and parent aren't both regular or ARGB visuals
+ */
+
+static Bool
+compIsAlternateVisual (ScreenPtr pScreen,
+ XID visual)
+{
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int i;
+
+ for (i = 0; i < cs->numAlternateVisuals; i++)
+ if (cs->alternateVisuals[i] == visual)
+ return TRUE;
+ return FALSE;
+}
+
+static Bool
+compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
+{
+ if (pParent)
+ {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XID winVisual = wVisual (pWin);
+ XID parentVisual = wVisual (pParent);
+
+ if (winVisual != parentVisual &&
+ (compIsAlternateVisual (pScreen, winVisual) ||
+ compIsAlternateVisual (pScreen, parentVisual)))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void compFreeOldPixmap(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ CompWindowPtr cw = GetCompWindow (pWin);
+ if (cw->pOldPixmap)
+ {
+ (*pScreen->DestroyPixmap) (cw->pOldPixmap);
+ cw->pOldPixmap = NullPixmap;
+ }
+ }
+}
+void
+compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->MoveWindow = cs->MoveWindow;
+ (*pScreen->MoveWindow) (pWin, x, y, pSib, kind);
+ cs->MoveWindow = pScreen->MoveWindow;
+ pScreen->MoveWindow = compMoveWindow;
+
+ compFreeOldPixmap(pWin);
+ compCheckTree (pScreen);
+}
+
+void
+compResizeWindow (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->ResizeWindow = cs->ResizeWindow;
+ (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
+ cs->ResizeWindow = pScreen->ResizeWindow;
+ pScreen->ResizeWindow = compResizeWindow;
+
+ compFreeOldPixmap(pWin);
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compChangeBorderWidth (WindowPtr pWin, unsigned int bw)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
+ (*pScreen->ChangeBorderWidth) (pWin, bw);
+ cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
+ pScreen->ChangeBorderWidth = compChangeBorderWidth;
+
+ compFreeOldPixmap(pWin);
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->ReparentWindow = cs->ReparentWindow;
+ /*
+ * Remove any implicit redirect due to synthesized visual
+ */
+ if (compImplicitRedirect (pWin, pPriorParent))
+ compUnredirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+ /*
+ * Handle subwindows redirection
+ */
+ compUnredirectOneSubwindow (pPriorParent, pWin);
+ compRedirectOneSubwindow (pWin->parent, pWin);
+ /*
+ * Add any implict redirect due to synthesized visual
+ */
+ if (compImplicitRedirect (pWin, pWin->parent))
+ compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+
+ /*
+ * Allocate any necessary redirect pixmap
+ * (this actually should never be true; pWin is always unmapped)
+ */
+ compCheckRedirect (pWin);
+
+ /*
+ * Reset pixmap pointers as appropriate
+ */
+ if (pWin->parent && pWin->redirectDraw == RedirectDrawNone)
+ compSetPixmap (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
+ /*
+ * Call down to next function
+ */
+ if (pScreen->ReparentWindow)
+ (*pScreen->ReparentWindow) (pWin, pPriorParent);
+ cs->ReparentWindow = pScreen->ReparentWindow;
+ pScreen->ReparentWindow = compReparentWindow;
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int dx = 0, dy = 0;
+
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ assert (cw->oldx != COMP_ORIGIN_INVALID);
+ assert (cw->oldy != COMP_ORIGIN_INVALID);
+ if (cw->pOldPixmap)
+ {
+ /*
+ * Ok, the old bits are available in pOldPixmap and
+ * need to be copied to pNewPixmap.
+ */
+ RegionRec rgnDst;
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ GCPtr pGC;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ RegionTranslate(prgnSrc, -dx, -dy);
+
+ RegionNull(&rgnDst);
+
+ RegionIntersect(&rgnDst,
+ &pWin->borderClip, prgnSrc);
+
+ RegionTranslate(&rgnDst,
+ -pPixmap->screen_x, -pPixmap->screen_y);
+
+ dx = dx + pPixmap->screen_x - cw->oldx;
+ dy = dy + pPixmap->screen_y - cw->oldy;
+ pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+ if (pGC)
+ {
+ BoxPtr pBox = RegionRects (&rgnDst);
+ int nBox = RegionNumRects (&rgnDst);
+
+ ValidateGC(&pPixmap->drawable, pGC);
+ while (nBox--)
+ {
+ (void) (*pGC->ops->CopyArea) (&cw->pOldPixmap->drawable,
+ &pPixmap->drawable,
+ pGC,
+ pBox->x1 + dx, pBox->y1 + dy,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1,
+ pBox->x1, pBox->y1);
+ pBox++;
+ }
+ FreeScratchGC (pGC);
+ }
+ return;
+ }
+ dx = pPixmap->screen_x - cw->oldx;
+ dy = pPixmap->screen_y - cw->oldy;
+ ptOldOrg.x += dx;
+ ptOldOrg.y += dy;
+ }
+
+ pScreen->CopyWindow = cs->CopyWindow;
+ if (ptOldOrg.x != pWin->drawable.x || ptOldOrg.y != pWin->drawable.y)
+ {
+ if (dx || dy)
+ RegionTranslate(prgnSrc, dx, dy);
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
+ if (dx || dy)
+ RegionTranslate(prgnSrc, -dx, -dy);
+ }
+ else
+ {
+ ptOldOrg.x -= dx;
+ ptOldOrg.y -= dy;
+ RegionTranslate(prgnSrc,
+ pWin->drawable.x - ptOldOrg.x,
+ pWin->drawable.y - ptOldOrg.y);
+ DamageDamageRegion(&pWin->drawable, prgnSrc);
+ }
+ cs->CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = compCopyWindow;
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+Bool
+compCreateWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret;
+
+ pScreen->CreateWindow = cs->CreateWindow;
+ ret = (*pScreen->CreateWindow) (pWin);
+ if (pWin->parent && ret)
+ {
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin->parent);
+ CompClientWindowPtr ccw;
+
+ (*pScreen->SetWindowPixmap) (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
+ if (csw)
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ compRedirectWindow (clients[CLIENT_ID(ccw->id)],
+ pWin, ccw->update);
+ if (compImplicitRedirect (pWin, pWin->parent))
+ compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+ }
+ cs->CreateWindow = pScreen->CreateWindow;
+ pScreen->CreateWindow = compCreateWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compDestroyWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw;
+ CompSubwindowsPtr csw;
+ Bool ret;
+
+ pScreen->DestroyWindow = cs->DestroyWindow;
+ while ((cw = GetCompWindow (pWin)))
+ FreeResource (cw->clients->id, RT_NONE);
+ while ((csw = GetCompSubwindows (pWin)))
+ FreeResource (csw->clients->id, RT_NONE);
+
+ if (pWin->redirectDraw != RedirectDrawNone) {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ compSetParentPixmap (pWin);
+ (*pScreen->DestroyPixmap) (pPixmap);
+ }
+ ret = (*pScreen->DestroyWindow) (pWin);
+ cs->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = compDestroyWindow;
+/* compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/
+ return ret;
+}
+
+void
+compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ RegionRec damage;
+
+ RegionNull(&damage);
+ /*
+ * Align old border clip with new border clip
+ */
+ RegionTranslate(&cw->borderClip,
+ pWin->drawable.x - cw->borderClipX,
+ pWin->drawable.y - cw->borderClipY);
+ /*
+ * Compute newly visible portion of window for repaint
+ */
+ RegionSubtract(&damage, pRegion, &cw->borderClip);
+ /*
+ * Report that as damaged so it will be redrawn
+ */
+ DamageDamageRegion(&pWin->drawable, &damage);
+ RegionUninit(&damage);
+ /*
+ * Save the new border clip region
+ */
+ RegionCopy(&cw->borderClip, pRegion);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+}
+
+RegionPtr
+compGetRedirectBorderClip (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ return &cw->borderClip;
+}
+
+static VisualPtr
+compGetWindowVisual (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ VisualID vid = wVisual (pWin);
+ int i;
+
+ for (i = 0; i < pScreen->numVisuals; i++)
+ if (pScreen->visuals[i].vid == vid)
+ return &pScreen->visuals[i];
+ return 0;
+}
+
+PictFormatPtr
+compWindowFormat (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ return PictureMatchVisual (pScreen, pWin->drawable.depth,
+ compGetWindowVisual (pWin));
+}
+
+static void
+compWindowUpdateAutomatic (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pParent = pWin->parent;
+ PixmapPtr pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ PictFormatPtr pSrcFormat = compWindowFormat (pWin);
+ PictFormatPtr pDstFormat = compWindowFormat (pWin->parent);
+ int error;
+ RegionPtr pRegion = DamageRegion (cw->damage);
+ PicturePtr pSrcPicture = CreatePicture (0, &pSrcPixmap->drawable,
+ pSrcFormat,
+ 0, 0,
+ serverClient,
+ &error);
+ XID subwindowMode = IncludeInferiors;
+ PicturePtr pDstPicture = CreatePicture (0, &pParent->drawable,
+ pDstFormat,
+ CPSubwindowMode,
+ &subwindowMode,
+ serverClient,
+ &error);
+
+ /*
+ * First move the region from window to screen coordinates
+ */
+ RegionTranslate(pRegion,
+ pWin->drawable.x, pWin->drawable.y);
+
+ /*
+ * Clip against the "real" border clip
+ */
+ RegionIntersect(pRegion, pRegion, &cw->borderClip);
+
+ /*
+ * Now translate from screen to dest coordinates
+ */
+ RegionTranslate(pRegion,
+ -pParent->drawable.x, -pParent->drawable.y);
+
+ /*
+ * Clip the picture
+ */
+ SetPictureClipRegion (pDstPicture, 0, 0, pRegion);
+
+ /*
+ * And paint
+ */
+ CompositePicture (PictOpSrc,
+ pSrcPicture,
+ 0,
+ pDstPicture,
+ 0, 0, /* src_x, src_y */
+ 0, 0, /* msk_x, msk_y */
+ pSrcPixmap->screen_x - pParent->drawable.x,
+ pSrcPixmap->screen_y - pParent->drawable.y,
+ pSrcPixmap->drawable.width,
+ pSrcPixmap->drawable.height);
+ FreePicture (pSrcPicture, 0);
+ FreePicture (pDstPicture, 0);
+ /*
+ * Empty the damage region. This has the nice effect of
+ * rendering the translations above harmless
+ */
+ DamageEmpty (cw->damage);
+}
+
+static void
+compPaintWindowToParent (WindowPtr pWin)
+{
+ compPaintChildrenToWindow (pWin);
+
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ CompWindowPtr cw = GetCompWindow(pWin);
+
+ if (cw->damaged)
+ {
+ compWindowUpdateAutomatic (pWin);
+ cw->damaged = FALSE;
+ }
+ }
+}
+
+void
+compPaintChildrenToWindow (WindowPtr pWin)
+{
+ WindowPtr pChild;
+
+ if (!pWin->damagedDescendants)
+ return;
+
+ for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+ compPaintWindowToParent (pChild);
+
+ pWin->damagedDescendants = FALSE;
+}
+
+WindowPtr
+CompositeRealChildHead (WindowPtr pWin)
+{
+ WindowPtr pChild, pChildBefore;
+ CompScreenPtr cs;
+
+ if (!pWin->parent &&
+ (screenIsSaved == SCREEN_SAVER_ON) &&
+ (HasSaverWindow (pWin->drawable.pScreen))) {
+
+ /* 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;
+ }
+}
+
+int
+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
+ int bw, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = 0;
+ WindowPtr pParent = pWin->parent;
+ int draw_x, draw_y;
+ Bool alloc_ret;
+
+ if (cs->ConfigNotify)
+ {
+ pScreen->ConfigNotify = cs->ConfigNotify;
+ ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+ cs->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = compConfigNotify;
+
+ if (ret)
+ return ret;
+ }
+
+ if (pWin->redirectDraw == RedirectDrawNone)
+ return Success;
+
+ compCheckTree (pScreen);
+
+ draw_x = pParent->drawable.x + x + bw;
+ draw_y = pParent->drawable.y + y + bw;
+ alloc_ret = compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
+
+ if (alloc_ret == FALSE)
+ return BadAlloc;
+ return Success;
+}