summaryrefslogtreecommitdiff
path: root/xserver/dix/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'xserver/dix/window.c')
-rw-r--r--xserver/dix/window.c623
1 files changed, 349 insertions, 274 deletions
diff --git a/xserver/dix/window.c b/xserver/dix/window.c
index 834c26b12..84690472b 100644
--- a/xserver/dix/window.c
+++ b/xserver/dix/window.c
@@ -110,6 +110,7 @@ Equipment Corporation.
#include "validate.h"
#include "windowstr.h"
#include "input.h"
+#include "inputstr.h"
#include "resource.h"
#include "colormapst.h"
#include "cursorstr.h"
@@ -122,10 +123,8 @@ Equipment Corporation.
#endif
#include "dixevents.h"
#include "globals.h"
+#include "mi.h" /* miPaintWindow */
-#ifdef XAPPGROUP
-#include "appgroup.h"
-#endif
#include "privates.h"
#include "xace.h"
@@ -136,16 +135,28 @@ Equipment Corporation.
* GetWindowAttributes, DeleteWindow, DestroySubWindows,
* HandleSaveSet, ReparentWindow, MapWindow, MapSubWindows,
* UnmapWindow, UnmapSubWindows, ConfigureWindow, CirculateWindow,
- *
+ * ChangeWindowDeviceCursor
******/
static unsigned char _back_lsb[4] = {0x88, 0x22, 0x44, 0x11};
static unsigned char _back_msb[4] = {0x11, 0x44, 0x22, 0x88};
+static Bool WindowParentHasDeviceCursor(WindowPtr pWin,
+ DeviceIntPtr pDev,
+ CursorPtr pCurs);
+static Bool
+WindowSeekDeviceCursor(WindowPtr pWin,
+ DeviceIntPtr pDev,
+ DevCursNodePtr* pNode,
+ DevCursNodePtr* pPrev);
+
_X_EXPORT int screenIsSaved = SCREEN_SAVER_OFF;
_X_EXPORT ScreenSaverStuffRec savedScreenInfo[MAXSCREENS];
+static int FocusPrivatesKeyIndex;
+_X_EXPORT DevPrivateKey FocusPrivatesKey = &FocusPrivatesKeyIndex;
+
static Bool TileScreenSaver(int i, int kind);
@@ -169,9 +180,6 @@ static Bool TileScreenSaver(int i, int kind);
#define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent))
-_X_EXPORT int numSaveUndersViewable = 0;
-_X_EXPORT int deltaSaveUndersViewable = 0;
-
#ifdef DEBUG
/******
* PrintWindowTree
@@ -187,8 +195,9 @@ PrintChildren(WindowPtr p1, int indent)
while (p1)
{
p2 = p1->firstChild;
- for (i=0; i<indent; i++) ErrorF( " ");
- ErrorF( "%lx\n", p1->drawable.id);
+ ErrorF("[dix] ");
+ for (i=0; i<indent; i++) ErrorF(" ");
+ ErrorF("%lx\n", p1->drawable.id);
miPrintRegion(&p1->clipList);
PrintChildren(p2, indent+4);
p1 = p1->nextSib;
@@ -203,7 +212,7 @@ PrintWindowTree(void)
for (i=0; i<screenInfo.numScreens; i++)
{
- ErrorF( "WINDOW %d\n", i);
+ ErrorF("[dix] WINDOW %d\n", i);
pWin = WindowTable[i];
miPrintRegion(&pWin->clipList);
p1 = pWin->firstChild;
@@ -258,8 +267,6 @@ int defaultBackingStore = NotUseful;
/* hack to force no backing store */
Bool disableBackingStore = FALSE;
Bool enableBackingStore = FALSE;
-/* hack to force no save unders */
-Bool disableSaveUnders = FALSE;
static void
SetWindowToDefaults(WindowPtr pWin)
@@ -292,6 +299,10 @@ SetWindowToDefaults(WindowPtr pWin)
pWin->forcedBS = FALSE;
pWin->redirectDraw = RedirectDrawNone;
pWin->forcedBG = FALSE;
+
+#ifdef ROOTLESS
+ pWin->rootlessUnhittable = FALSE;
+#endif
}
static void
@@ -387,14 +398,24 @@ CreateRootWindow(ScreenPtr pScreen)
pWin->optional->userProps = NULL;
pWin->optional->backingBitPlanes = ~0L;
pWin->optional->backingPixel = 0;
-#ifdef SHAPE
pWin->optional->boundingShape = NULL;
pWin->optional->clipShape = NULL;
pWin->optional->inputShape = NULL;
-#endif
-#ifdef XINPUT
pWin->optional->inputMasks = NULL;
-#endif
+ pWin->optional->deviceCursors = NULL;
+ pWin->optional->geMasks = (GenericClientMasksPtr)xcalloc(1, sizeof(GenericClientMasksRec));
+ if (!pWin->optional->geMasks)
+ {
+ xfree(pWin->optional);
+ return FALSE;
+ }
+
+ pWin->optional->access.perm = NULL;
+ pWin->optional->access.deny = NULL;
+ pWin->optional->access.nperm = 0;
+ pWin->optional->access.ndeny = 0;
+ pWin->optional->access.defaultRule = 0;
+
pWin->optional->colormap = pScreen->defColormap;
pWin->optional->visual = pScreen->rootVisual;
@@ -440,20 +461,7 @@ CreateRootWindow(ScreenPtr pScreen)
if (enableBackingStore)
pScreen->backingStoreSupport = Always;
-#ifdef DO_SAVE_UNDERS
- if ((pScreen->backingStoreSupport != NotUseful) &&
- (pScreen->saveUnderSupport == NotUseful))
- {
- /*
- * If the screen has backing-store but no save-unders, let the
- * clients know we can support save-unders using backing-store.
- */
- pScreen->saveUnderSupport = USE_DIX_SAVE_UNDERS;
- }
-#endif /* DO_SAVE_UNDERS */
-
- if (disableSaveUnders)
- pScreen->saveUnderSupport = NotUseful;
+ pScreen->saveUnderSupport = NotUseful;
return TRUE;
}
@@ -472,15 +480,15 @@ InitRootWindow(WindowPtr pWin)
pWin->optional->cursor = rootCursor;
rootCursor->refcnt++;
- if (!blackRoot && !whiteRoot) {
+
+ if (party_like_its_1989) {
MakeRootTile(pWin);
backFlag |= CWBackPixmap;
- }
- else {
- if (blackRoot)
- pWin->background.pixel = pScreen->blackPixel;
- else
+ } else {
+ if (whiteRoot)
pWin->background.pixel = pScreen->whitePixel;
+ else
+ pWin->background.pixel = pScreen->blackPixel;
backFlag |= CWBackPixel;
}
@@ -600,14 +608,6 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
if (!ancwopt)
ancwopt = FindWindowWithOptional(pParent)->optional;
if (visual == CopyFromParent) {
-#ifdef XAPPGROUP
- VisualID ag_visual;
-
- if (client->appgroup && !pParent->parent &&
- (ag_visual = XagRootVisual (client)))
- visual = ag_visual;
- else
-#endif
visual = ancwopt->visual;
}
@@ -797,6 +797,8 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
static void
DisposeWindowOptional (WindowPtr pWin)
{
+ GenericMaskPtr gmask = NULL, next = NULL;
+
if (!pWin->optional)
return;
/*
@@ -810,6 +812,37 @@ DisposeWindowOptional (WindowPtr pWin)
}
else
pWin->cursorIsNone = TRUE;
+
+ if (pWin->optional->deviceCursors)
+ {
+ DevCursorList pList;
+ DevCursorList pPrev;
+ pList = pWin->optional->deviceCursors;
+ while(pList)
+ {
+ if (pList->cursor)
+ FreeCursor(pList->cursor, (XID)0);
+ pPrev = pList;
+ pList = pList->next;
+ xfree(pPrev);
+ }
+ pWin->optional->deviceCursors = NULL;
+ }
+
+ xfree(pWin->optional->access.perm);
+ xfree(pWin->optional->access.deny);
+
+ /* Remove generic event mask allocations */
+ if (pWin->optional->geMasks)
+ gmask = pWin->optional->geMasks->geClients;
+ while(gmask)
+ {
+ next = gmask->next;
+ xfree(gmask);
+ gmask = next;
+ }
+ xfree (pWin->optional->geMasks);
+
xfree (pWin->optional);
pWin->optional = NULL;
}
@@ -826,14 +859,12 @@ FreeWindowResources(WindowPtr pWin)
REGION_UNINIT(pScreen, &pWin->winSize);
REGION_UNINIT(pScreen, &pWin->borderClip);
REGION_UNINIT(pScreen, &pWin->borderSize);
-#ifdef SHAPE
if (wBoundingShape (pWin))
REGION_DESTROY(pScreen, wBoundingShape (pWin));
if (wClipShape (pWin))
REGION_DESTROY(pScreen, wClipShape (pWin));
if (wInputShape (pWin))
REGION_DESTROY(pScreen, wInputShape (pWin));
-#endif
if (pWin->borderIsPixel == FALSE)
(*pScreen->DestroyPixmap)(pWin->border.pixmap);
if (pWin->backgroundState == BackgroundPixmap)
@@ -873,10 +904,6 @@ CrushTree(WindowPtr pWin)
}
FreeResource(pChild->drawable.id, RT_WINDOW);
pSib = pChild->nextSib;
-#ifdef DO_SAVE_UNDERS
- if (pChild->saveUnder && pChild->viewable)
- deltaSaveUndersViewable--;
-#endif
pChild->viewable = FALSE;
if (pChild->realized)
{
@@ -934,6 +961,7 @@ DeleteWindow(pointer value, XID wid)
if (pWin->prevSib)
pWin->prevSib->nextSib = pWin->nextSib;
}
+ xfree(dixLookupPrivate(&pWin->devPrivates, FocusPrivatesKey));
dixFreePrivates(pWin->devPrivates);
xfree(pWin);
return Success;
@@ -981,7 +1009,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
Pixmap pixID;
CursorPtr pCursor, pOldCursor;
Cursor cursorID;
- WindowPtr pChild, pLayerWin;
+ WindowPtr pChild;
Colormap cmap;
ColormapPtr pCmap;
xEvent xE;
@@ -1040,7 +1068,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
}
else
{
- rc = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
+ rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP,
client, DixReadAccess);
if (rc == Success)
{
@@ -1100,7 +1128,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
pixID = pWin->parent->border.pixmap->drawable.id;
}
}
- rc = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
+ rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP,
client, DixReadAccess);
if (rc == Success)
{
@@ -1202,47 +1230,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
client->errorValue = val;
goto PatchUp;
}
-#ifdef DO_SAVE_UNDERS
- if (pWin->parent && (pWin->saveUnder != val) && (pWin->viewable) &&
- DO_SAVE_UNDERS(pWin))
- {
- /*
- * Re-check all siblings and inferiors for obscurity or
- * exposition (hee hee).
- */
- if (pWin->saveUnder)
- deltaSaveUndersViewable--;
- else
- deltaSaveUndersViewable++;
- pWin->saveUnder = val;
-
- if (pWin->firstChild)
- {
- pLayerWin = (*pScreen->GetLayerWindow)(pWin);
- if ((*pScreen->ChangeSaveUnder)(pLayerWin->parent, pWin->nextSib))
- (*pScreen->PostChangeSaveUnder)(pLayerWin->parent,
- pWin->nextSib);
- }
- else
- {
- if ((*pScreen->ChangeSaveUnder)(pWin, pWin->nextSib))
- (*pScreen->PostChangeSaveUnder)(pWin,
- pWin->nextSib);
- }
- }
- else
- {
- /* If we're changing the saveUnder attribute of the root
- * window, all we do is set pWin->saveUnder so that
- * GetWindowAttributes returns the right value. We don't
- * do the "normal" save-under processing (as above).
- * Hope that doesn't cause any problems.
- */
- pWin->saveUnder = val;
- }
-#else
pWin->saveUnder = val;
-#endif /* DO_SAVE_UNDERS */
break;
case CWEventMask:
rc = EventSelectForWindow(pWin, client, (Mask )*pVlist);
@@ -1288,22 +1276,6 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
pVlist++;
if (cmap == CopyFromParent)
{
-#ifdef XAPPGROUP
- Colormap ag_colormap;
- ClientPtr win_owner;
-
- /*
- * win_owner == client for CreateWindow, other clients
- * can ChangeWindowAttributes
- */
- win_owner = clients[CLIENT_ID(pWin->drawable.id)];
-
- if ( win_owner && win_owner->appgroup &&
- !pWin->parent->parent &&
- (ag_colormap = XagDefaultColormap (win_owner)))
- cmap = ag_colormap;
- else
-#endif
if (pWin->parent &&
(!pWin->optional ||
pWin->optional->visual == wVisual (pWin->parent)))
@@ -1318,7 +1290,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
error = BadMatch;
goto PatchUp;
}
- rc = dixLookupResource((pointer *)&pCmap, cmap, RT_COLORMAP,
+ rc = dixLookupResourceByType((pointer *)&pCmap, cmap, RT_COLORMAP,
client, DixUseAccess);
if (rc != Success)
{
@@ -1394,7 +1366,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
}
else
{
- rc = dixLookupResource((pointer *)&pCursor, cursorID,
+ rc = dixLookupResourceByType((pointer *)&pCursor, cursorID,
RT_CURSOR, client, DixUseAccess);
if (rc != Success)
{
@@ -1541,7 +1513,7 @@ GetWindowAttributes(WindowPtr pWin, ClientPtr client, xGetWindowAttributesReply
}
-_X_EXPORT WindowPtr
+WindowPtr
MoveWindowInStack(WindowPtr pWin, WindowPtr pNextSib)
{
WindowPtr pParent = pWin->parent;
@@ -1636,7 +1608,6 @@ CreateUnclippedWinSize (WindowPtr pWin)
box.x2 = pWin->drawable.x + (int) pWin->drawable.width;
box.y2 = pWin->drawable.y + (int) pWin->drawable.height;
pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1);
-#ifdef SHAPE
if (wBoundingShape (pWin) || wClipShape (pWin)) {
ScreenPtr pScreen;
pScreen = pWin->drawable.pScreen;
@@ -1649,11 +1620,10 @@ CreateUnclippedWinSize (WindowPtr pWin)
REGION_INTERSECT(pScreen, pRgn, pRgn, wClipShape (pWin));
REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x, pWin->drawable.y);
}
-#endif
return pRgn;
}
-_X_EXPORT void
+void
SetWinSize (WindowPtr pWin)
{
#ifdef COMPOSITE
@@ -1677,7 +1647,6 @@ SetWinSize (WindowPtr pWin)
pWin->drawable.x, pWin->drawable.y,
(int)pWin->drawable.width,
(int)pWin->drawable.height);
-#ifdef SHAPE
if (wBoundingShape (pWin) || wClipShape (pWin)) {
ScreenPtr pScreen;
pScreen = pWin->drawable.pScreen;
@@ -1693,10 +1662,9 @@ SetWinSize (WindowPtr pWin)
REGION_TRANSLATE(pScreen, &pWin->winSize, pWin->drawable.x,
pWin->drawable.y);
}
-#endif
}
-_X_EXPORT void
+void
SetBorderSize (WindowPtr pWin)
{
int bw;
@@ -1724,7 +1692,6 @@ SetBorderSize (WindowPtr pWin)
pWin->drawable.x - bw, pWin->drawable.y - bw,
(int)(pWin->drawable.width + (bw<<1)),
(int)(pWin->drawable.height + (bw<<1)));
-#ifdef SHAPE
if (wBoundingShape (pWin)) {
ScreenPtr pScreen;
pScreen = pWin->drawable.pScreen;
@@ -1738,7 +1705,6 @@ SetBorderSize (WindowPtr pWin)
REGION_UNION(pScreen, &pWin->borderSize, &pWin->borderSize,
&pWin->winSize);
}
-#endif
} else {
REGION_COPY(pWin->drawable.pScreen, &pWin->borderSize,
&pWin->winSize);
@@ -1802,7 +1768,7 @@ GravityTranslate (int x, int y, int oldx, int oldy,
}
/* XXX need to retile border on each window with ParentRelative origin */
-_X_EXPORT void
+void
ResizeChildrenWinSize(WindowPtr pWin, int dx, int dy, int dw, int dh)
{
ScreenPtr pScreen;
@@ -1929,7 +1895,6 @@ WindowExtents(
return(pBox);
}
-#ifdef SHAPE
#define IS_SHAPED(pWin) (wBoundingShape (pWin) != (RegionPtr) NULL)
static RegionPtr
@@ -1974,7 +1939,6 @@ ShapeOverlap (
REGION_DESTROY(pScreen, pSibRgn);
return ret;
}
-#endif
static Bool
AnyWindowOverlapsMe(
@@ -1992,9 +1956,7 @@ AnyWindowOverlapsMe(
{
sbox = WindowExtents(pSib, &sboxrec);
if (BOXES_OVERLAP(sbox, box)
-#ifdef SHAPE
&& ShapeOverlap (pWin, box, pSib, sbox)
-#endif
)
return(TRUE);
}
@@ -2017,9 +1979,7 @@ IOverlapAnyWindow(
{
sbox = WindowExtents(pSib, &sboxrec);
if (BOXES_OVERLAP(sbox, box)
-#ifdef SHAPE
&& ShapeOverlap (pWin, box, pSib, sbox)
-#endif
)
return(TRUE);
}
@@ -2172,9 +2132,6 @@ ReflectStackChange(
Bool WasViewable = (Bool)pWin->viewable;
Bool anyMarked;
WindowPtr pFirstChange;
-#ifdef DO_SAVE_UNDERS
- Bool dosave = FALSE;
-#endif
WindowPtr pLayerWin;
ScreenPtr pScreen = pWin->drawable.pScreen;
@@ -2189,21 +2146,11 @@ ReflectStackChange(
anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange,
&pLayerWin);
if (pLayerWin != pWin) pFirstChange = pLayerWin;
-#ifdef DO_SAVE_UNDERS
- if (DO_SAVE_UNDERS(pWin))
- {
- dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange);
- }
-#endif /* DO_SAVE_UNDERS */
if (anyMarked)
{
(*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, kind);
(*pScreen->HandleExposures)(pLayerWin->parent);
}
-#ifdef DO_SAVE_UNDERS
- if (dosave)
- (*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange);
-#endif /* DO_SAVE_UNDERS */
if (anyMarked && pWin->drawable.pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, kind);
}
@@ -2232,10 +2179,6 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
h = pWin->drawable.height,
bw = pWin->borderWidth;
int rc, action, smode = Above;
-#ifdef XAPPGROUP
- ClientPtr win_owner;
- ClientPtr ag_leader = NULL;
-#endif
xEvent event;
if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask))
@@ -2331,17 +2274,9 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
else
pSib = pWin->nextSib;
-#ifdef XAPPGROUP
- win_owner = clients[CLIENT_ID(pWin->drawable.id)];
- ag_leader = XagLeader (win_owner);
-#endif
if ((!pWin->overrideRedirect) &&
(RedirectSend(pParent)
-#ifdef XAPPGROUP
- || (win_owner->appgroup && ag_leader &&
- XagIsControlledRoot (client, pParent))
-#endif
))
{
event.u.u.type = ConfigureRequest;
@@ -2366,16 +2301,6 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
event.u.configureRequest.height = h;
event.u.configureRequest.borderWidth = bw;
event.u.configureRequest.valueMask = mask;
-#ifdef XAPPGROUP
- /* make sure if the ag_leader maps the window it goes to the wm */
- if (ag_leader && ag_leader != client &&
- XagIsControlledRoot (client, pParent)) {
- event.u.configureRequest.parent = XagId (win_owner);
- (void) TryClientEvents (ag_leader, &event, 1,
- NoEventMask, NoEventMask, NullGrab);
- return Success;
- }
-#endif
event.u.configureRequest.parent = pParent->drawable.id;
if (MaybeDeliverEventsToClient(pParent, &event, 1,
SubstructureRedirectMask, client) == 1)
@@ -2676,10 +2601,6 @@ RealizeTree(WindowPtr pWin)
if (pChild->mapped)
{
pChild->realized = TRUE;
-#ifdef DO_SAVE_UNDERS
- if (pChild->saveUnder)
- deltaSaveUndersViewable++;
-#endif
pChild->viewable = (pChild->drawable.class == InputOutput);
(* Realize)(pChild);
if (pChild->firstChild)
@@ -2734,9 +2655,6 @@ MapWindow(WindowPtr pWin, ClientPtr client)
ScreenPtr pScreen;
WindowPtr pParent;
-#ifdef DO_SAVE_UNDERS
- Bool dosave = FALSE;
-#endif
WindowPtr pLayerWin;
if (pWin->mapped)
@@ -2752,31 +2670,13 @@ MapWindow(WindowPtr pWin, ClientPtr client)
{
xEvent event;
Bool anyMarked;
-#ifdef XAPPGROUP
- ClientPtr win_owner = clients[CLIENT_ID(pWin->drawable.id)];
- ClientPtr ag_leader = XagLeader (win_owner);
-#endif
if ((!pWin->overrideRedirect) &&
(RedirectSend(pParent)
-#ifdef XAPPGROUP
- || (win_owner->appgroup && ag_leader &&
- XagIsControlledRoot (client, pParent))
-#endif
))
{
event.u.u.type = MapRequest;
event.u.mapRequest.window = pWin->drawable.id;
-#ifdef XAPPGROUP
- /* make sure if the ag_leader maps the window it goes to the wm */
- if (ag_leader && ag_leader != client &&
- XagIsControlledRoot (client, pParent)) {
- event.u.mapRequest.parent = XagId (win_owner);
- (void) TryClientEvents (ag_leader, &event, 1,
- NoEventMask, NoEventMask, NullGrab);
- return Success;
- }
-#endif
event.u.mapRequest.parent = pParent->drawable.id;
if (MaybeDeliverEventsToClient(pParent, &event, 1,
@@ -2800,21 +2700,11 @@ MapWindow(WindowPtr pWin, ClientPtr client)
{
anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
&pLayerWin);
-#ifdef DO_SAVE_UNDERS
- if (DO_SAVE_UNDERS(pWin))
- {
- dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib);
- }
-#endif /* DO_SAVE_UNDERS */
if (anyMarked)
{
(*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTMap);
(*pScreen->HandleExposures)(pLayerWin->parent);
}
-#ifdef DO_SAVE_UNDERS
- if (dosave)
- (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
-#endif /* DO_SAVE_UNDERS */
if (anyMarked && pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTMap);
}
@@ -2854,17 +2744,11 @@ MapSubwindows(WindowPtr pParent, ClientPtr client)
{
WindowPtr pWin;
WindowPtr pFirstMapped = NullWindow;
-#ifdef DO_SAVE_UNDERS
- WindowPtr pFirstSaveUndered = NullWindow;
-#endif
ScreenPtr pScreen;
Mask parentRedirect;
Mask parentNotify;
xEvent event;
Bool anyMarked;
-#ifdef DO_SAVE_UNDERS
- Bool dosave = FALSE;
-#endif
WindowPtr pLayerWin;
pScreen = pParent->drawable.pScreen;
@@ -2904,12 +2788,6 @@ MapSubwindows(WindowPtr pParent, ClientPtr client)
{
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
(WindowPtr *)NULL);
-#ifdef DO_SAVE_UNDERS
- if (DO_SAVE_UNDERS(pWin))
- {
- dosave = TRUE;
- }
-#endif /* DO_SAVE_UNDERS */
}
}
}
@@ -2926,38 +2804,9 @@ MapSubwindows(WindowPtr pParent, ClientPtr client)
}
if (anyMarked)
{
-#ifdef DO_SAVE_UNDERS
- if (pLayerWin->parent != pParent)
- {
- if (dosave || (DO_SAVE_UNDERS(pLayerWin)))
- {
- dosave = (*pScreen->ChangeSaveUnder)(pLayerWin,
- pLayerWin);
- }
- }
- else if (dosave)
- {
- dosave = FALSE;
- for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib)
- {
- if (DO_SAVE_UNDERS(pWin))
- {
- dosave |= (*pScreen->ChangeSaveUnder)(pWin,
- pWin->nextSib);
- if (dosave && !pFirstSaveUndered)
- pFirstSaveUndered = pWin;
- }
- }
- }
-#endif /* DO_SAVE_UNDERS */
(*pScreen->ValidateTree)(pLayerWin->parent, pFirstMapped, VTMap);
(*pScreen->HandleExposures)(pLayerWin->parent);
}
-#ifdef DO_SAVE_UNDERS
- if (dosave)
- (*pScreen->PostChangeSaveUnder)(pLayerWin,
- pFirstSaveUndered->nextSib);
-#endif /* DO_SAVE_UNDERS */
if (anyMarked && pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(pLayerWin->parent, pFirstMapped,
VTMap);
@@ -2997,10 +2846,6 @@ UnrealizeTree(
DeleteWindowFromAnyEvents(pChild, FALSE);
if (pChild->viewable)
{
-#ifdef DO_SAVE_UNDERS
- if (pChild->saveUnder)
- deltaSaveUndersViewable--;
-#endif
pChild->viewable = FALSE;
(* MarkUnrealizedWindow)(pChild, pWin, fromConfigure);
pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
@@ -3061,16 +2906,6 @@ UnmapWindow(WindowPtr pWin, Bool fromConfigure)
(*pScreen->ValidateTree)(pLayerWin->parent, pWin, VTUnmap);
(*pScreen->HandleExposures)(pLayerWin->parent);
}
-#ifdef DO_SAVE_UNDERS
- if (DO_SAVE_UNDERS(pWin))
- {
- if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib) )
- {
- (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
- }
- }
- pWin->DIXsaveUnder = FALSE;
-#endif /* DO_SAVE_UNDERS */
if (!fromConfigure && pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(pLayerWin->parent, pWin, VTUnmap);
}
@@ -3126,9 +2961,6 @@ UnmapSubwindows(WindowPtr pWin)
UnrealizeTree(pChild, FALSE);
if (wasViewable)
{
-#ifdef DO_SAVE_UNDERS
- pChild->DIXsaveUnder = FALSE;
-#endif /* DO_SAVE_UNDERS */
}
}
}
@@ -3158,13 +2990,6 @@ UnmapSubwindows(WindowPtr pWin)
(*pScreen->ValidateTree)(pLayerWin->parent, pHead, VTUnmap);
(*pScreen->HandleExposures)(pLayerWin->parent);
}
-#ifdef DO_SAVE_UNDERS
- if (DO_SAVE_UNDERS(pWin))
- {
- if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin))
- (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
- }
-#endif /* DO_SAVE_UNDERS */
if (anyMarked && pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(pLayerWin->parent, pHead, VTUnmap);
}
@@ -3196,6 +3021,11 @@ HandleSaveSet(ClientPtr client)
{
if (pParent != pWin->parent)
{
+#ifdef XFIXES
+ /* unmap first so that ReparentWindow doesn't remap */
+ if (!SaveSetShouldMap (client->saveSet[j]))
+ UnmapWindow(pWin, FALSE);
+#endif
ReparentWindow(pWin, pParent,
pWin->drawable.x - wBorderWidth (pWin) - pParent->drawable.x,
pWin->drawable.y - wBorderWidth (pWin) - pParent->drawable.y,
@@ -3204,7 +3034,7 @@ HandleSaveSet(ClientPtr client)
pWin->mapped = FALSE;
}
#ifdef XFIXES
- if (SaveSetRemap (client->saveSet[j]))
+ if (SaveSetShouldMap (client->saveSet[j]))
#endif
MapWindow(pWin, client);
}
@@ -3254,13 +3084,15 @@ NotClippedByChildren(WindowPtr pWin)
return(pReg);
}
-_X_EXPORT void
+void
SendVisibilityNotify(WindowPtr pWin)
{
xEvent event;
#ifndef NO_XINERAMA_PORT
unsigned int visibility = pWin->visibility;
#endif
+ if (!MapUnmapEventsEnabled(pWin))
+ return;
#ifdef PANORAMIX
/* This is not quite correct yet, but it's close */
if(!noPanoramiXExtension) {
@@ -3337,8 +3169,6 @@ dixSaveScreens(ClientPtr client, int on, int mode)
if (on == SCREEN_SAVER_FORCER)
{
- UpdateCurrentTimeIf();
- lastDeviceEventTime = currentTime;
if (mode == ScreenSaverReset)
what = SCREEN_SAVER_OFF;
else
@@ -3614,18 +3444,31 @@ CheckWindowOptionalNeed (WindowPtr w)
return;
if (optional->backingPixel != 0)
return;
-#ifdef SHAPE
if (optional->boundingShape != NULL)
return;
if (optional->clipShape != NULL)
return;
if (optional->inputShape != NULL)
return;
-#endif
-#ifdef XINPUT
if (optional->inputMasks != NULL)
return;
-#endif
+ if (optional->deviceCursors != NULL)
+ {
+ DevCursNodePtr pNode = optional->deviceCursors;
+ while(pNode)
+ {
+ if (pNode->cursor != None)
+ return;
+ pNode = pNode->next;
+ }
+ }
+ if (optional->access.nperm != 0 ||
+ optional->access.ndeny != 0)
+ return;
+
+ if (optional->geMasks != NULL)
+ return;
+
parentOptional = FindWindowWithOptional(w)->optional;
if (optional->visual != parentOptional->visual)
return;
@@ -3663,14 +3506,30 @@ MakeWindowOptional (WindowPtr pWin)
optional->userProps = NULL;
optional->backingBitPlanes = ~0L;
optional->backingPixel = 0;
-#ifdef SHAPE
optional->boundingShape = NULL;
optional->clipShape = NULL;
optional->inputShape = NULL;
-#endif
-#ifdef XINPUT
optional->inputMasks = NULL;
-#endif
+ optional->deviceCursors = NULL;
+
+ optional->geMasks =
+ (GenericClientMasksPtr)xalloc(sizeof(GenericClientMasksRec));
+ if (!optional->geMasks)
+ {
+ xfree(optional);
+ return FALSE;
+ } else {
+ int i;
+ optional->geMasks->geClients = 0;
+ for (i = 0; i < MAXEXTENSIONS; i++)
+ optional->geMasks->eventMasks[i] = 0;
+ }
+
+ optional->access.nperm = 0;
+ optional->access.ndeny = 0;
+ optional->access.perm = NULL;
+ optional->access.deny = NULL;
+ optional->access.defaultRule = 0;
parentOptional = FindWindowWithOptional(pWin)->optional;
optional->visual = parentOptional->visual;
if (!pWin->cursorIsNone)
@@ -3687,6 +3546,222 @@ MakeWindowOptional (WindowPtr pWin)
return TRUE;
}
+/*
+ * Changes the cursor struct for the given device and the given window.
+ * A cursor that does not have a device cursor set will use whatever the
+ * standard cursor is for the window. If all devices have a cursor set,
+ * changing the window cursor (e.g. using XDefineCursor()) will not have any
+ * visible effect. Only when one of the device cursors is set to None again,
+ * this device's cursor will display the changed standard cursor.
+ *
+ * CursorIsNone of the window struct is NOT modified if you set a device
+ * cursor.
+ *
+ * Assumption: If there is a node for a device in the list, the device has a
+ * cursor. If the cursor is set to None, it is inherited by the parent.
+ */
+_X_EXPORT int
+ChangeWindowDeviceCursor(WindowPtr pWin,
+ DeviceIntPtr pDev,
+ CursorPtr pCursor)
+{
+ DevCursNodePtr pNode, pPrev;
+ CursorPtr pOldCursor = NULL;
+ ScreenPtr pScreen;
+ WindowPtr pChild;
+
+ if (!pWin->optional && !MakeWindowOptional(pWin))
+ return BadAlloc;
+
+ /* 1) Check if window has device cursor set
+ * Yes: 1.1) swap cursor with given cursor if parent does not have same
+ * cursor, free old cursor
+ * 1.2) free old cursor, use parent cursor
+ * No: 1.1) add node to beginning of list.
+ * 1.2) add cursor to node if parent does not have same cursor
+ * 1.3) use parent cursor if parent does not have same cursor
+ * 2) Patch up children if child has a devcursor
+ * 2.1) if child has cursor None, it inherited from parent, set to old
+ * cursor
+ * 2.2) if child has same cursor as new cursor, remove and set to None
+ */
+
+ pScreen = pWin->drawable.pScreen;
+
+ if (WindowSeekDeviceCursor(pWin, pDev, &pNode, &pPrev))
+ {
+ /* has device cursor */
+
+ if (pNode->cursor == pCursor)
+ return Success;
+
+ pOldCursor = pNode->cursor;
+
+ if (!pCursor) /* remove from list */
+ {
+ if(pPrev)
+ pPrev->next = pNode->next;
+ else
+ /* first item in list */
+ pWin->optional->deviceCursors = pNode->next;
+
+ xfree(pNode);
+ return Success;
+ }
+
+ } else
+ {
+ /* no device cursor yet */
+ DevCursNodePtr pNewNode;
+
+ if (!pCursor)
+ return Success;
+
+ pNewNode = (DevCursNodePtr)xalloc(sizeof(DevCursNodeRec));
+ pNewNode->dev = pDev;
+ pNewNode->next = pWin->optional->deviceCursors;
+ pWin->optional->deviceCursors = pNewNode;
+ pNode = pNewNode;
+
+ }
+
+ if (pCursor && WindowParentHasDeviceCursor(pWin, pDev, pCursor))
+ pNode->cursor = None;
+ else
+ {
+ pNode->cursor = pCursor;
+ pCursor->refcnt++;
+ }
+
+ pNode = pPrev = NULL;
+ /* fix up children */
+ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
+ {
+ if (WindowSeekDeviceCursor(pChild, pDev, &pNode, &pPrev))
+ {
+ if (pNode->cursor == None) /* inherited from parent */
+ {
+ pNode->cursor = pOldCursor;
+ pOldCursor->refcnt++;
+ } else if (pNode->cursor == pCursor)
+ {
+ pNode->cursor = None;
+ FreeCursor(pCursor, (Cursor)0); /* fix up refcnt */
+ }
+ }
+ }
+
+ if (pWin->realized)
+ WindowHasNewCursor(pWin);
+
+ if (pOldCursor)
+ FreeCursor(pOldCursor, (Cursor)0);
+
+ /* FIXME: We SHOULD check for an error value here XXX
+ (comment taken from ChangeWindowAttributes) */
+ (*pScreen->ChangeWindowAttributes)(pWin, CWCursor);
+
+ return Success;
+}
+
+/* Get device cursor for given device or None if none is set */
+_X_EXPORT CursorPtr
+WindowGetDeviceCursor(WindowPtr pWin, DeviceIntPtr pDev)
+{
+ DevCursorList pList;
+
+ if (!pWin->optional || !pWin->optional->deviceCursors)
+ return NULL;
+
+ pList = pWin->optional->deviceCursors;
+
+ while(pList)
+ {
+ if (pList->dev == pDev)
+ {
+ if (pList->cursor == None) /* inherited from parent */
+ return WindowGetDeviceCursor(pWin->parent, pDev);
+ else
+ return pList->cursor;
+ }
+ pList = pList->next;
+ }
+ return NULL;
+}
+
+/* Searches for a DevCursorNode for the given window and device. If one is
+ * found, return True and set pNode and pPrev to the node and to the node
+ * before the node respectively. Otherwise return False.
+ * If the device is the first in list, pPrev is set to NULL.
+ */
+static Bool
+WindowSeekDeviceCursor(WindowPtr pWin,
+ DeviceIntPtr pDev,
+ DevCursNodePtr* pNode,
+ DevCursNodePtr* pPrev)
+{
+ DevCursorList pList;
+
+ if (!pWin->optional)
+ return FALSE;
+
+ pList = pWin->optional->deviceCursors;
+
+ if (pList && pList->dev == pDev)
+ {
+ *pNode = pList;
+ *pPrev = NULL;
+ return TRUE;
+ }
+
+ while(pList)
+ {
+ if (pList->next)
+ {
+ if (pList->next->dev == pDev)
+ {
+ *pNode = pList->next;
+ *pPrev = pList;
+ return TRUE;
+ }
+ }
+ pList = pList->next;
+ }
+ return FALSE;
+}
+
+/* Return True if a parent has the same device cursor set or False if
+ * otherwise
+ */
+static Bool
+WindowParentHasDeviceCursor(WindowPtr pWin,
+ DeviceIntPtr pDev,
+ CursorPtr pCursor)
+{
+ WindowPtr pParent;
+ DevCursNodePtr pParentNode, pParentPrev;
+
+ pParent = pWin->parent;
+ while(pParent)
+ {
+ if (WindowSeekDeviceCursor(pParent, pDev,
+ &pParentNode, &pParentPrev))
+ {
+ /* if there is a node in the list, the win has a dev cursor */
+ if (!pParentNode->cursor) /* inherited. loop needs to cont. */
+ {
+ } else if (pParentNode->cursor == pCursor) /* inherit */
+ return TRUE;
+ else /* different cursor */
+ return FALSE;
+ }
+ else
+ /* parent does not have a device cursor for our device */
+ return FALSE;
+ }
+ return FALSE;
+}
+
#ifndef NOLOGOHACK
static void
DrawLogo(WindowPtr pWin)