2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright (c) 2006, Red Hat, Inc.
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
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:
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
The above copyright notice and this permission notice (including the next
|
|
|
|
paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
Software.
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
2010-07-27 13:02:24 -06:00
|
|
|
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.
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice 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 OPEN GROUP 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.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall
|
|
|
|
not be used in advertising or otherwise to promote the sale, use or
|
|
|
|
other dealings in this Software without prior written authorization
|
|
|
|
from The Open Group.
|
|
|
|
|
|
|
|
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
2006-11-26 11:13:41 -07:00
|
|
|
provided that the above copyright notice appear in all copies and that
|
2015-09-16 13:10:19 -06:00
|
|
|
both that copyright notice and this permission notice appear in
|
2006-11-26 11:13:41 -07:00
|
|
|
supporting documentation, and that the name of Digital not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
2015-09-16 13:10:19 -06:00
|
|
|
software without specific, written prior permission.
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL 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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The panoramix components contained the following notice */
|
|
|
|
/*****************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice 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
|
|
|
|
DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
|
|
|
|
BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of Digital Equipment Corporation
|
|
|
|
shall not be used in advertising or otherwise to promote the sale, use or other
|
|
|
|
dealings in this Software without prior written authorization from Digital
|
|
|
|
Equipment Corporation.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "misc.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "os.h"
|
|
|
|
#include "regionstr.h"
|
|
|
|
#include "validate.h"
|
|
|
|
#include "windowstr.h"
|
2011-11-05 07:32:40 -06:00
|
|
|
#include "propertyst.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "input.h"
|
2009-09-06 13:44:18 -06:00
|
|
|
#include "inputstr.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "resource.h"
|
|
|
|
#include "colormapst.h"
|
|
|
|
#include "cursorstr.h"
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "gcstruct.h"
|
|
|
|
#include "servermd.h"
|
2011-11-05 07:32:40 -06:00
|
|
|
#include "mivalidate.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
#include "panoramiX.h"
|
|
|
|
#include "panoramiXsrv.h"
|
|
|
|
#endif
|
|
|
|
#include "dixevents.h"
|
|
|
|
#include "globals.h"
|
2012-06-10 07:21:05 -06:00
|
|
|
#include "mi.h" /* miPaintWindow */
|
2011-11-05 07:32:40 -06:00
|
|
|
#ifdef COMPOSITE
|
|
|
|
#include "compint.h"
|
|
|
|
#endif
|
2013-12-08 03:53:01 -07:00
|
|
|
#include "selection.h"
|
2016-05-29 06:02:34 -06:00
|
|
|
#include "inpututils.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "privates.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "xace.h"
|
2012-06-10 07:21:05 -06:00
|
|
|
#include "exevents.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#include <X11/Xatom.h> /* must come after server includes */
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/******
|
2015-09-16 13:10:19 -06:00
|
|
|
* Window stuff for server
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
|
|
|
* CreateRootWindow, CreateWindow, ChangeWindowAttributes,
|
|
|
|
* GetWindowAttributes, DeleteWindow, DestroySubWindows,
|
|
|
|
* HandleSaveSet, ReparentWindow, MapWindow, MapSubWindows,
|
|
|
|
* UnmapWindow, UnmapSubWindows, ConfigureWindow, CirculateWindow,
|
2009-09-06 13:44:18 -06:00
|
|
|
* ChangeWindowDeviceCursor
|
2006-11-26 11:13:41 -07:00
|
|
|
******/
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
Bool bgNoneRoot = FALSE;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
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
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowSeekDeviceCursor(WindowPtr pWin,
|
|
|
|
DeviceIntPtr pDev,
|
|
|
|
DevCursNodePtr * pNode, DevCursNodePtr * pPrev);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int screenIsSaved = SCREEN_SAVER_OFF;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
static Bool TileScreenSaver(ScreenPtr pScreen, int kind);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
|
|
|
|
CWDontPropagate | CWOverrideRedirect | CWCursor )
|
|
|
|
|
|
|
|
#define BOXES_OVERLAP(b1, b2) \
|
|
|
|
(!( ((b1)->x2 <= (b2)->x1) || \
|
|
|
|
( ((b1)->x1 >= (b2)->x2)) || \
|
|
|
|
( ((b1)->y2 <= (b2)->y1)) || \
|
|
|
|
( ((b1)->y1 >= (b2)->y2)) ) )
|
|
|
|
|
|
|
|
#define RedirectSend(pWin) \
|
|
|
|
((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureRedirectMask)
|
|
|
|
|
|
|
|
#define SubSend(pWin) \
|
|
|
|
((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureNotifyMask)
|
|
|
|
|
|
|
|
#define StrSend(pWin) \
|
|
|
|
((pWin->eventMask|wOtherEventMasks(pWin)) & StructureNotifyMask)
|
|
|
|
|
|
|
|
#define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent))
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
#ifdef COMPOSITE
|
|
|
|
static const char *overlay_win_name = "<composite overlay>";
|
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
static const char *
|
|
|
|
get_window_name(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2011-11-05 07:32:40 -06:00
|
|
|
#define WINDOW_NAME_BUF_LEN 512
|
|
|
|
PropertyPtr prop;
|
|
|
|
static char buf[WINDOW_NAME_BUF_LEN];
|
|
|
|
int len;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
#ifdef COMPOSITE
|
|
|
|
CompScreenPtr comp_screen = GetCompScreen(pWin->drawable.pScreen);
|
|
|
|
|
|
|
|
if (comp_screen && pWin == comp_screen->pOverlayWin)
|
|
|
|
return overlay_win_name;
|
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (prop = wUserProps(pWin); prop; prop = prop->next) {
|
2011-11-05 07:32:40 -06:00
|
|
|
if (prop->propertyName == XA_WM_NAME && prop->type == XA_STRING &&
|
2012-06-10 07:21:05 -06:00
|
|
|
prop->data) {
|
2011-11-05 07:32:40 -06:00
|
|
|
len = min(prop->size, WINDOW_NAME_BUF_LEN - 1);
|
|
|
|
memcpy(buf, prop->data, len);
|
|
|
|
buf[len] = '\0';
|
|
|
|
return buf;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
#undef WINDOW_NAME_BUF_LEN
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
log_window_info(WindowPtr pWin, int depth)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int i;
|
2011-11-05 07:32:40 -06:00
|
|
|
const char *win_name, *visibility;
|
|
|
|
BoxPtr rects;
|
|
|
|
|
|
|
|
for (i = 0; i < (depth << 2); i++)
|
|
|
|
ErrorF(" ");
|
|
|
|
|
|
|
|
win_name = get_window_name(pWin);
|
|
|
|
ErrorF("win 0x%.8x (%s), [%d, %d] to [%d, %d]",
|
2014-09-27 11:52:59 -06:00
|
|
|
(unsigned) pWin->drawable.id,
|
2011-11-05 07:32:40 -06:00
|
|
|
win_name ? win_name : "no name",
|
|
|
|
pWin->drawable.x, pWin->drawable.y,
|
|
|
|
pWin->drawable.x + pWin->drawable.width,
|
|
|
|
pWin->drawable.y + pWin->drawable.height);
|
|
|
|
|
|
|
|
if (pWin->overrideRedirect)
|
|
|
|
ErrorF(" (override redirect)");
|
|
|
|
#ifdef COMPOSITE
|
|
|
|
if (pWin->redirectDraw)
|
|
|
|
ErrorF(" (%s compositing: pixmap %x)",
|
|
|
|
(pWin->redirectDraw == RedirectDrawAutomatic) ?
|
2012-06-10 07:21:05 -06:00
|
|
|
"automatic" : "manual",
|
2016-05-29 06:02:34 -06:00
|
|
|
(unsigned) pWin->drawable.pScreen->GetWindowPixmap(pWin)->drawable.id);
|
2011-11-05 07:32:40 -06:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (pWin->visibility) {
|
2011-11-05 07:32:40 -06:00
|
|
|
case VisibilityUnobscured:
|
2012-06-10 07:21:05 -06:00
|
|
|
visibility = "unobscured";
|
|
|
|
break;
|
2011-11-05 07:32:40 -06:00
|
|
|
case VisibilityPartiallyObscured:
|
2012-06-10 07:21:05 -06:00
|
|
|
visibility = "partially obscured";
|
|
|
|
break;
|
2011-11-05 07:32:40 -06:00
|
|
|
case VisibilityFullyObscured:
|
2012-06-10 07:21:05 -06:00
|
|
|
visibility = "fully obscured";
|
|
|
|
break;
|
2011-11-05 07:32:40 -06:00
|
|
|
case VisibilityNotViewable:
|
2012-06-10 07:21:05 -06:00
|
|
|
visibility = "unviewable";
|
|
|
|
break;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
ErrorF(", %s", visibility);
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (RegionNotEmpty(&pWin->clipList)) {
|
2011-11-05 07:32:40 -06:00
|
|
|
ErrorF(", clip list:");
|
2016-05-29 06:02:34 -06:00
|
|
|
rects = RegionRects(&pWin->clipList);
|
|
|
|
for (i = 0; i < RegionNumRects(&pWin->clipList); i++)
|
2011-11-05 07:32:40 -06:00
|
|
|
ErrorF(" [(%d, %d) to (%d, %d)]",
|
2012-06-10 07:21:05 -06:00
|
|
|
rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);
|
2011-11-05 07:32:40 -06:00
|
|
|
ErrorF("; extents [(%d, %d) to (%d, %d)]",
|
|
|
|
pWin->clipList.extents.x1, pWin->clipList.extents.y1,
|
|
|
|
pWin->clipList.extents.x2, pWin->clipList.extents.y2);
|
|
|
|
}
|
|
|
|
|
|
|
|
ErrorF("\n");
|
|
|
|
}
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
static const char*
|
|
|
|
grab_grabtype_to_text(GrabPtr pGrab)
|
|
|
|
{
|
|
|
|
switch (pGrab->grabtype) {
|
|
|
|
case XI2:
|
|
|
|
return "xi2";
|
|
|
|
case CORE:
|
|
|
|
return "core";
|
|
|
|
default:
|
|
|
|
return "xi1";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char*
|
|
|
|
grab_type_to_text(GrabPtr pGrab)
|
|
|
|
{
|
|
|
|
switch (pGrab->type) {
|
|
|
|
case ButtonPress:
|
|
|
|
return "ButtonPress";
|
|
|
|
case KeyPress:
|
|
|
|
return "KeyPress";
|
|
|
|
case XI_Enter:
|
|
|
|
return "XI_Enter";
|
|
|
|
case XI_FocusIn:
|
|
|
|
return "XI_FocusIn";
|
|
|
|
default:
|
|
|
|
return "unknown?!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
log_grab_info(void *value, XID id, void *cdata)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
GrabPtr pGrab = (GrabPtr)value;
|
|
|
|
|
|
|
|
ErrorF(" grab 0x%lx (%s), type '%s' on window 0x%lx\n",
|
|
|
|
(unsigned long) pGrab->resource,
|
|
|
|
grab_grabtype_to_text(pGrab),
|
|
|
|
grab_type_to_text(pGrab),
|
|
|
|
(unsigned long) pGrab->window->drawable.id);
|
|
|
|
ErrorF(" detail %d (mask %lu), modifiersDetail %d (mask %lu)\n",
|
|
|
|
pGrab->detail.exact,
|
|
|
|
pGrab->detail.pMask ? (unsigned long) *(pGrab->detail.pMask) : 0,
|
|
|
|
pGrab->modifiersDetail.exact,
|
|
|
|
pGrab->modifiersDetail.pMask ?
|
|
|
|
(unsigned long) *(pGrab->modifiersDetail.pMask) :
|
|
|
|
(unsigned long) 0);
|
|
|
|
ErrorF(" device '%s' (%d), modifierDevice '%s' (%d)\n",
|
|
|
|
pGrab->device->name, pGrab->device->id,
|
|
|
|
pGrab->modifierDevice->name, pGrab->modifierDevice->id);
|
|
|
|
if (pGrab->grabtype == CORE) {
|
|
|
|
ErrorF(" core event mask 0x%lx\n",
|
|
|
|
(unsigned long) pGrab->eventMask);
|
|
|
|
}
|
|
|
|
else if (pGrab->grabtype == XI) {
|
|
|
|
ErrorF(" xi1 event mask 0x%lx\n",
|
|
|
|
(unsigned long) pGrab->eventMask);
|
|
|
|
}
|
|
|
|
else if (pGrab->grabtype == XI2) {
|
|
|
|
for (i = 0; i < xi2mask_num_masks(pGrab->xi2mask); i++) {
|
|
|
|
const unsigned char *mask;
|
|
|
|
int print;
|
|
|
|
|
|
|
|
print = 0;
|
|
|
|
for (j = 0; j < XI2MASKSIZE; j++) {
|
|
|
|
mask = xi2mask_get_one_mask(pGrab->xi2mask, i);
|
|
|
|
if (mask[j]) {
|
|
|
|
print = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!print)
|
|
|
|
continue;
|
|
|
|
ErrorF(" xi2 event mask 0x");
|
|
|
|
for (j = 0; j < xi2mask_mask_size(pGrab->xi2mask); j++)
|
|
|
|
ErrorF("%x ", mask[j]);
|
|
|
|
ErrorF("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ErrorF(" owner-events %s, kb %d ptr %d, confine 0x%lx, cursor 0x%lx\n",
|
|
|
|
pGrab->ownerEvents ? "true" : "false",
|
|
|
|
pGrab->keyboardMode, pGrab->pointerMode,
|
|
|
|
pGrab->confineTo ? (unsigned long) pGrab->confineTo->drawable.id : 0,
|
|
|
|
pGrab->cursor ? (unsigned long) pGrab->cursor->id : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PrintPassiveGrabs(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
LocalClientCredRec *lcc;
|
|
|
|
pid_t clientpid;
|
|
|
|
const char *cmdname;
|
|
|
|
const char *cmdargs;
|
|
|
|
|
|
|
|
ErrorF("Printing all currently registered grabs\n");
|
|
|
|
|
|
|
|
for (i = 1; i < currentMaxClients; i++) {
|
|
|
|
if (!clients[i] || clients[i]->clientState != ClientStateRunning)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
clientpid = GetClientPid(clients[i]);
|
|
|
|
cmdname = GetClientCmdName(clients[i]);
|
|
|
|
cmdargs = GetClientCmdArgs(clients[i]);
|
|
|
|
if ((clientpid > 0) && (cmdname != NULL)) {
|
|
|
|
ErrorF(" Printing all registered grabs of client pid %ld %s %s\n",
|
|
|
|
(long) clientpid, cmdname, cmdargs ? cmdargs : "");
|
|
|
|
} else {
|
|
|
|
if (GetLocalClientCreds(clients[i], &lcc) == -1) {
|
|
|
|
ErrorF(" GetLocalClientCreds() failed\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ErrorF(" Printing all registered grabs of client pid %ld uid %ld gid %ld\n",
|
|
|
|
(lcc->fieldsSet & LCC_PID_SET) ? (long) lcc->pid : 0,
|
|
|
|
(lcc->fieldsSet & LCC_UID_SET) ? (long) lcc->euid : 0,
|
|
|
|
(lcc->fieldsSet & LCC_GID_SET) ? (long) lcc->egid : 0);
|
|
|
|
FreeLocalClientCreds(lcc);
|
|
|
|
}
|
|
|
|
|
|
|
|
FindClientResourcesByType(clients[i], RT_PASSIVEGRAB, log_grab_info, NULL);
|
|
|
|
}
|
|
|
|
ErrorF("End list of registered passive grabs\n");
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
void
|
|
|
|
PrintWindowTree(void)
|
|
|
|
{
|
|
|
|
int scrnum, depth;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
WindowPtr pWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (scrnum = 0; scrnum < screenInfo.numScreens; scrnum++) {
|
2011-11-05 07:32:40 -06:00
|
|
|
pScreen = screenInfo.screens[scrnum];
|
|
|
|
ErrorF("[dix] Dumping windows for screen %d (pixmap %x):\n", scrnum,
|
2014-09-27 11:52:59 -06:00
|
|
|
(unsigned) pScreen->GetScreenPixmap(pScreen)->drawable.id);
|
2011-11-05 07:32:40 -06:00
|
|
|
pWin = pScreen->root;
|
|
|
|
depth = 1;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (pWin) {
|
2011-11-05 07:32:40 -06:00
|
|
|
log_window_info(pWin, depth);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWin->firstChild) {
|
2011-11-05 07:32:40 -06:00
|
|
|
pWin = pWin->firstChild;
|
|
|
|
depth++;
|
|
|
|
continue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
while (pWin && !pWin->nextSib) {
|
2011-11-05 07:32:40 -06:00
|
|
|
pWin = pWin->parent;
|
|
|
|
depth--;
|
|
|
|
}
|
|
|
|
if (!pWin)
|
|
|
|
break;
|
|
|
|
pWin = pWin->nextSib;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2014-09-27 11:52:59 -06:00
|
|
|
TraverseTree(WindowPtr pWin, VisitWindowProcPtr func, void *data)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
int result;
|
|
|
|
WindowPtr pChild;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!(pChild = pWin))
|
2012-06-10 07:21:05 -06:00
|
|
|
return WT_NOMATCH;
|
|
|
|
while (1) {
|
|
|
|
result = (*func) (pChild, data);
|
|
|
|
if (result == WT_STOPWALKING)
|
|
|
|
return WT_STOPWALKING;
|
|
|
|
if ((result == WT_WALKCHILDREN) && pChild->firstChild) {
|
|
|
|
pChild = pChild->firstChild;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
while (!pChild->nextSib && (pChild != pWin))
|
|
|
|
pChild = pChild->parent;
|
|
|
|
if (pChild == pWin)
|
|
|
|
break;
|
|
|
|
pChild = pChild->nextSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return WT_NOMATCH;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****
|
|
|
|
* WalkTree
|
|
|
|
* Walk the window tree, for SCREEN, preforming FUNC(pWin, data) on
|
|
|
|
* each window. If FUNC returns WT_WALKCHILDREN, traverse the children,
|
|
|
|
* if it returns WT_DONTWALKCHILDREN, dont. If it returns WT_STOPWALKING
|
|
|
|
* exit WalkTree. Does depth-first traverse.
|
|
|
|
*****/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2014-09-27 11:52:59 -06:00
|
|
|
WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, void *data)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return (TraverseTree(pScreen->root, func, data));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* hack for forcing backing store on all windows */
|
2012-06-10 07:21:05 -06:00
|
|
|
int defaultBackingStore = NotUseful;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* hack to force no backing store */
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool disableBackingStore = FALSE;
|
|
|
|
Bool enableBackingStore = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
2007-11-24 10:55:21 -07:00
|
|
|
SetWindowToDefaults(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
pWin->prevSib = NullWindow;
|
|
|
|
pWin->firstChild = NullWindow;
|
|
|
|
pWin->lastChild = NullWindow;
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
pWin->valdata = NULL;
|
|
|
|
pWin->optional = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
pWin->cursorIsNone = TRUE;
|
|
|
|
|
|
|
|
pWin->backingStore = NotUseful;
|
2015-09-16 13:10:19 -06:00
|
|
|
pWin->backStorage = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->mapped = FALSE; /* off */
|
|
|
|
pWin->realized = FALSE; /* off */
|
2006-11-26 11:13:41 -07:00
|
|
|
pWin->viewable = FALSE;
|
|
|
|
pWin->visibility = VisibilityNotViewable;
|
|
|
|
pWin->overrideRedirect = FALSE;
|
|
|
|
pWin->saveUnder = FALSE;
|
|
|
|
|
|
|
|
pWin->bitGravity = ForgetGravity;
|
|
|
|
pWin->winGravity = NorthWestGravity;
|
|
|
|
|
|
|
|
pWin->eventMask = 0;
|
|
|
|
pWin->deliverableEvents = 0;
|
|
|
|
pWin->dontPropagate = 0;
|
|
|
|
pWin->forcedBS = FALSE;
|
2007-11-24 10:55:21 -07:00
|
|
|
pWin->redirectDraw = RedirectDrawNone;
|
2008-11-02 08:26:08 -07:00
|
|
|
pWin->forcedBG = FALSE;
|
2016-05-29 06:02:34 -06:00
|
|
|
pWin->unhittable = FALSE;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
#ifdef COMPOSITE
|
|
|
|
pWin->damagedDescendants = FALSE;
|
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
MakeRootTile(WindowPtr pWin)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
|
|
|
GCPtr pGC;
|
|
|
|
unsigned char back[128];
|
|
|
|
int len = BitmapBytePad(sizeof(long));
|
2007-11-24 10:55:21 -07:00
|
|
|
unsigned char *from, *to;
|
|
|
|
int i, j;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->background.pixmap = (*pScreen->CreatePixmap) (pScreen, 4, 4,
|
|
|
|
pScreen->rootDepth, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pWin->backgroundState = BackgroundPixmap;
|
|
|
|
pGC = GetScratchGC(pScreen->rootDepth, pScreen);
|
|
|
|
if (!pWin->background.pixmap || !pGC)
|
2012-06-10 07:21:05 -06:00
|
|
|
FatalError("could not create root tile");
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ChangeGCVal attributes[2];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
attributes[0].val = pScreen->whitePixel;
|
|
|
|
attributes[1].val = pScreen->blackPixel;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) ChangeGC(NullClient, pGC, GCForeground | GCBackground,
|
|
|
|
attributes);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
ValidateGC((DrawablePtr) pWin->background.pixmap, pGC);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
from = (screenInfo.bitmapBitOrder == LSBFirst) ? _back_lsb : _back_msb;
|
|
|
|
to = back;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 4; i > 0; i--, from++)
|
|
|
|
for (j = len; j > 0; j--)
|
|
|
|
*to++ = *from;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pGC->ops->PutImage) ((DrawablePtr) pWin->background.pixmap, pGC, 1,
|
|
|
|
0, 0, len, 4, 0, XYBitmap, (char *) back);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeScratchGC(pGC);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****
|
|
|
|
* CreateRootWindow
|
|
|
|
* Makes a window at initialization time for specified screen
|
|
|
|
*****/
|
|
|
|
|
|
|
|
Bool
|
|
|
|
CreateRootWindow(ScreenPtr pScreen)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr pWin;
|
|
|
|
BoxRec box;
|
2006-11-26 11:13:41 -07:00
|
|
|
PixmapFormatRec *format;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
pWin = dixAllocateScreenObjectWithPrivates(pScreen, WindowRec, PRIVATE_WINDOW);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pWin)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pScreen->screensaver.pWindow = NULL;
|
|
|
|
pScreen->screensaver.wid = FakeClientID(0);
|
|
|
|
pScreen->screensaver.ExternalScreenSaver = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
screenIsSaved = SCREEN_SAVER_OFF;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pScreen->root = pWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pWin->drawable.pScreen = pScreen;
|
|
|
|
pWin->drawable.type = DRAWABLE_WINDOW;
|
|
|
|
|
|
|
|
pWin->drawable.depth = pScreen->rootDepth;
|
|
|
|
for (format = screenInfo.formats;
|
2012-06-10 07:21:05 -06:00
|
|
|
format->depth != pScreen->rootDepth; format++);
|
2006-11-26 11:13:41 -07:00
|
|
|
pWin->drawable.bitsPerPixel = format->bitsPerPixel;
|
|
|
|
|
|
|
|
pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
|
|
|
|
|
|
|
pWin->parent = NullWindow;
|
|
|
|
SetWindowToDefaults(pWin);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->optional = malloc(sizeof(WindowOptRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pWin->optional)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pWin->optional->dontPropagateMask = 0;
|
|
|
|
pWin->optional->otherEventMasks = 0;
|
|
|
|
pWin->optional->otherClients = NULL;
|
|
|
|
pWin->optional->passiveGrabs = NULL;
|
|
|
|
pWin->optional->userProps = NULL;
|
|
|
|
pWin->optional->backingBitPlanes = ~0L;
|
|
|
|
pWin->optional->backingPixel = 0;
|
|
|
|
pWin->optional->boundingShape = NULL;
|
|
|
|
pWin->optional->clipShape = NULL;
|
|
|
|
pWin->optional->inputShape = NULL;
|
|
|
|
pWin->optional->inputMasks = NULL;
|
2009-09-06 13:44:18 -06:00
|
|
|
pWin->optional->deviceCursors = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
pWin->optional->colormap = pScreen->defColormap;
|
|
|
|
pWin->optional->visual = pScreen->rootVisual;
|
|
|
|
|
|
|
|
pWin->nextSib = NullWindow;
|
|
|
|
|
|
|
|
pWin->drawable.id = FakeClientID(0);
|
|
|
|
|
|
|
|
pWin->origin.x = pWin->origin.y = 0;
|
|
|
|
pWin->drawable.height = pScreen->height;
|
|
|
|
pWin->drawable.width = pScreen->width;
|
|
|
|
pWin->drawable.x = pWin->drawable.y = 0;
|
|
|
|
|
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = pScreen->width;
|
|
|
|
box.y2 = pScreen->height;
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionInit(&pWin->clipList, &box, 1);
|
|
|
|
RegionInit(&pWin->winSize, &box, 1);
|
|
|
|
RegionInit(&pWin->borderSize, &box, 1);
|
|
|
|
RegionInit(&pWin->borderClip, &box, 1);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pWin->drawable.class = InputOutput;
|
|
|
|
pWin->optional->visual = pScreen->rootVisual;
|
|
|
|
|
|
|
|
pWin->backgroundState = BackgroundPixel;
|
|
|
|
pWin->background.pixel = pScreen->whitePixel;
|
|
|
|
|
|
|
|
pWin->borderIsPixel = TRUE;
|
|
|
|
pWin->border.pixel = pScreen->blackPixel;
|
|
|
|
pWin->borderWidth = 0;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
/* security creation/labeling check
|
|
|
|
*/
|
|
|
|
if (XaceHook(XACE_RESOURCE_ACCESS, serverClient, pWin->drawable.id,
|
2012-06-10 07:21:05 -06:00
|
|
|
RT_WINDOW, pWin, RT_NONE, NULL, DixCreateAccess))
|
|
|
|
return FALSE;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!AddResource(pWin->drawable.id, RT_WINDOW, (void *) pWin))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (disableBackingStore)
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->backingStoreSupport = NotUseful;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (enableBackingStore)
|
2014-05-02 13:27:46 -06:00
|
|
|
pScreen->backingStoreSupport = WhenMapped;
|
|
|
|
#ifdef COMPOSITE
|
|
|
|
if (noCompositeExtension)
|
|
|
|
pScreen->backingStoreSupport = NotUseful;
|
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
pScreen->saveUnderSupport = NotUseful;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
InitRootWindow(WindowPtr pWin)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
|
|
|
int backFlag = CWBorderPixel | CWCursor | CWBackingStore;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(*pScreen->CreateWindow) (pWin))
|
|
|
|
return; /* XXX */
|
|
|
|
(*pScreen->PositionWindow) (pWin, 0, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pWin->cursorIsNone = FALSE;
|
2013-09-28 09:36:30 -06:00
|
|
|
pWin->optional->cursor = RefCursor(rootCursor);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (party_like_its_1989) {
|
2006-11-26 11:13:41 -07:00
|
|
|
MakeRootTile(pWin);
|
|
|
|
backFlag |= CWBackPixmap;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else if (pScreen->canDoBGNoneRoot && bgNoneRoot) {
|
2011-11-05 07:32:40 -06:00
|
|
|
pWin->backgroundState = XaceBackgroundNoneState(pWin);
|
|
|
|
pWin->background.pixel = pScreen->whitePixel;
|
|
|
|
backFlag |= CWBackPixmap;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2011-11-05 07:32:40 -06:00
|
|
|
pWin->backgroundState = BackgroundPixel;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (whiteRoot)
|
2006-11-26 11:13:41 -07:00
|
|
|
pWin->background.pixel = pScreen->whitePixel;
|
2009-09-06 13:44:18 -06:00
|
|
|
else
|
|
|
|
pWin->background.pixel = pScreen->blackPixel;
|
2006-11-26 11:13:41 -07:00
|
|
|
backFlag |= CWBackPixel;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pWin->backingStore = defaultBackingStore;
|
|
|
|
pWin->forcedBS = (defaultBackingStore != NotUseful);
|
|
|
|
/* We SHOULD check for an error value here XXX */
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->ChangeWindowAttributes) (pWin, backFlag);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
MapWindow(pWin, serverClient);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the region to the intersection of the rectangle and the
|
|
|
|
* window's winSize. The window is typically the parent of the
|
|
|
|
* window from which the region came.
|
|
|
|
*/
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
ClippedRegionFromBox(WindowPtr pWin, RegionPtr Rgn, int x, int y, int w, int h)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
BoxRec box = *RegionExtents(&pWin->winSize);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* we do these calculations to avoid overflows */
|
|
|
|
if (x > box.x1)
|
2012-06-10 07:21:05 -06:00
|
|
|
box.x1 = x;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (y > box.y1)
|
2012-06-10 07:21:05 -06:00
|
|
|
box.y1 = y;
|
2006-11-26 11:13:41 -07:00
|
|
|
x += w;
|
|
|
|
if (x < box.x2)
|
2012-06-10 07:21:05 -06:00
|
|
|
box.x2 = x;
|
2006-11-26 11:13:41 -07:00
|
|
|
y += h;
|
|
|
|
if (y < box.y2)
|
2012-06-10 07:21:05 -06:00
|
|
|
box.y2 = y;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (box.x1 > box.x2)
|
2012-06-10 07:21:05 -06:00
|
|
|
box.x2 = box.x1;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (box.y1 > box.y2)
|
2012-06-10 07:21:05 -06:00
|
|
|
box.y2 = box.y1;
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionReset(Rgn, &box);
|
|
|
|
RegionIntersect(Rgn, Rgn, &pWin->winSize);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static RealChildHeadProc realChildHeadProc = NULL;
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
RegisterRealChildHeadProc(RealChildHeadProc proc)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
realChildHeadProc = proc;
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowPtr
|
2007-11-24 10:55:21 -07:00
|
|
|
RealChildHead(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (realChildHeadProc) {
|
2012-06-10 07:21:05 -06:00
|
|
|
return realChildHeadProc(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pWin->parent &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(screenIsSaved == SCREEN_SAVER_ON) &&
|
|
|
|
(HasSaverWindow(pWin->drawable.pScreen)))
|
|
|
|
return pWin->firstChild;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return NullWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****
|
|
|
|
* CreateWindow
|
2015-09-16 13:10:19 -06:00
|
|
|
* Makes a window in response to client request
|
2006-11-26 11:13:41 -07:00
|
|
|
*****/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
WindowPtr
|
2007-11-24 10:55:21 -07:00
|
|
|
CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
|
|
|
|
unsigned h, unsigned bw, unsigned class, Mask vmask, XID *vlist,
|
2006-11-26 11:13:41 -07:00
|
|
|
int depth, ClientPtr client, VisualID visual, int *error)
|
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
WindowPtr pHead;
|
2007-11-24 10:55:21 -07:00
|
|
|
ScreenPtr pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
int idepth, ivisual;
|
|
|
|
Bool fOK;
|
|
|
|
DepthPtr pDepth;
|
|
|
|
PixmapFormatRec *format;
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowOptPtr ancwopt;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (class == CopyFromParent)
|
2012-06-10 07:21:05 -06:00
|
|
|
class = pParent->drawable.class;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((class != InputOutput) && (class != InputOnly)) {
|
|
|
|
*error = BadValue;
|
|
|
|
client->errorValue = class;
|
|
|
|
return NullWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((class != InputOnly) && (pParent->drawable.class == InputOnly)) {
|
|
|
|
*error = BadMatch;
|
|
|
|
return NullWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((class == InputOnly) && ((bw != 0) || (depth != 0))) {
|
|
|
|
*error = BadMatch;
|
|
|
|
return NullWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pScreen = pParent->drawable.pScreen;
|
|
|
|
if ((class == InputOutput) && (depth == 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
depth = pParent->drawable.depth;
|
2006-11-26 11:13:41 -07:00
|
|
|
ancwopt = pParent->optional;
|
|
|
|
if (!ancwopt)
|
2012-06-10 07:21:05 -06:00
|
|
|
ancwopt = FindWindowWithOptional(pParent)->optional;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (visual == CopyFromParent) {
|
2012-06-10 07:21:05 -06:00
|
|
|
visual = ancwopt->visual;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Find out if the depth and visual are acceptable for this Screen */
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth)) {
|
|
|
|
fOK = FALSE;
|
|
|
|
for (idepth = 0; idepth < pScreen->numDepths; idepth++) {
|
2013-06-07 11:28:45 -06:00
|
|
|
pDepth = (DepthPtr) &pScreen->allowedDepths[idepth];
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((depth == pDepth->depth) || (depth == 0)) {
|
|
|
|
for (ivisual = 0; ivisual < pDepth->numVids; ivisual++) {
|
|
|
|
if (visual == pDepth->vids[ivisual]) {
|
|
|
|
fOK = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fOK == FALSE) {
|
|
|
|
*error = BadMatch;
|
|
|
|
return NullWindow;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (((vmask & (CWBorderPixmap | CWBorderPixel)) == 0) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(class != InputOnly) && (depth != pParent->drawable.depth)) {
|
|
|
|
*error = BadMatch;
|
|
|
|
return NullWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (((vmask & CWColormap) == 0) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(class != InputOnly) &&
|
|
|
|
((visual != ancwopt->visual) || (ancwopt->colormap == None))) {
|
|
|
|
*error = BadMatch;
|
|
|
|
return NullWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
pWin = dixAllocateScreenObjectWithPrivates(pScreen, WindowRec, PRIVATE_WINDOW);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pWin) {
|
|
|
|
*error = BadAlloc;
|
|
|
|
return NullWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
pWin->drawable = pParent->drawable;
|
|
|
|
pWin->drawable.depth = depth;
|
|
|
|
if (depth == pParent->drawable.depth)
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel;
|
|
|
|
else {
|
|
|
|
for (format = screenInfo.formats; format->depth != depth; format++);
|
|
|
|
pWin->drawable.bitsPerPixel = format->bitsPerPixel;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (class == InputOnly)
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->drawable.type = (short) UNDRAWABLE_WINDOW;
|
2006-11-26 11:13:41 -07:00
|
|
|
pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
|
|
|
|
|
|
|
pWin->drawable.id = wid;
|
|
|
|
pWin->drawable.class = class;
|
|
|
|
|
|
|
|
pWin->parent = pParent;
|
|
|
|
SetWindowToDefaults(pWin);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (visual != ancwopt->visual) {
|
|
|
|
if (!MakeWindowOptional(pWin)) {
|
|
|
|
dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
|
|
|
|
*error = BadAlloc;
|
|
|
|
return NullWindow;
|
|
|
|
}
|
|
|
|
pWin->optional->visual = visual;
|
|
|
|
pWin->optional->colormap = None;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pWin->borderWidth = bw;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
/* security creation/labeling check
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
2008-11-02 08:26:08 -07:00
|
|
|
*error = XaceHook(XACE_RESOURCE_ACCESS, client, wid, RT_WINDOW, pWin,
|
2012-06-10 07:21:05 -06:00
|
|
|
RT_WINDOW, pWin->parent,
|
|
|
|
DixCreateAccess | DixSetAttrAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (*error != Success) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
|
|
|
|
return NullWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pWin->backgroundState = XaceBackgroundNoneState(pWin);
|
|
|
|
pWin->background.pixel = pScreen->whitePixel;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
pWin->borderIsPixel = pParent->borderIsPixel;
|
|
|
|
pWin->border = pParent->border;
|
|
|
|
if (pWin->borderIsPixel == FALSE)
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->border.pixmap->refcnt++;
|
|
|
|
|
|
|
|
pWin->origin.x = x + (int) bw;
|
|
|
|
pWin->origin.y = y + (int) bw;
|
2006-11-26 11:13:41 -07:00
|
|
|
pWin->drawable.width = w;
|
|
|
|
pWin->drawable.height = h;
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->drawable.x = pParent->drawable.x + x + (int) bw;
|
|
|
|
pWin->drawable.y = pParent->drawable.y + y + (int) bw;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* set up clip list correctly for unobscured WindowPtr */
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionNull(&pWin->clipList);
|
|
|
|
RegionNull(&pWin->borderClip);
|
|
|
|
RegionNull(&pWin->winSize);
|
|
|
|
RegionNull(&pWin->borderSize);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pHead = RealChildHead(pParent);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pHead) {
|
|
|
|
pWin->nextSib = pHead->nextSib;
|
|
|
|
if (pHead->nextSib)
|
|
|
|
pHead->nextSib->prevSib = pWin;
|
|
|
|
else
|
|
|
|
pParent->lastChild = pWin;
|
|
|
|
pHead->nextSib = pWin;
|
|
|
|
pWin->prevSib = pHead;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
pWin->nextSib = pParent->firstChild;
|
|
|
|
if (pParent->firstChild)
|
|
|
|
pParent->firstChild->prevSib = pWin;
|
|
|
|
else
|
|
|
|
pParent->lastChild = pWin;
|
|
|
|
pParent->firstChild = pWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
SetWinSize(pWin);
|
|
|
|
SetBorderSize(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* We SHOULD check for an error value here XXX */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(*pScreen->CreateWindow) (pWin)) {
|
|
|
|
*error = BadAlloc;
|
|
|
|
DeleteWindow(pWin, None);
|
|
|
|
return NullWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
/* We SHOULD check for an error value here XXX */
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->PositionWindow) (pWin, pWin->drawable.x, pWin->drawable.y);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!(vmask & CWEventMask))
|
2012-06-10 07:21:05 -06:00
|
|
|
RecalculateDeliverableEvents(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (vmask)
|
2012-06-10 07:21:05 -06:00
|
|
|
*error = ChangeWindowAttributes(pWin, vmask, vlist, wClient(pWin));
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
*error = Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (*error != Success) {
|
|
|
|
DeleteWindow(pWin, None);
|
|
|
|
return NullWindow;
|
|
|
|
}
|
|
|
|
if (!(vmask & CWBackingStore) && (defaultBackingStore != NotUseful)) {
|
|
|
|
XID value = defaultBackingStore;
|
|
|
|
|
|
|
|
(void) ChangeWindowAttributes(pWin, CWBackingStore, &value,
|
|
|
|
wClient(pWin));
|
|
|
|
pWin->forcedBS = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SubSend(pParent)) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xEvent event = {
|
|
|
|
.u.createNotify.window = wid,
|
|
|
|
.u.createNotify.parent = pParent->drawable.id,
|
|
|
|
.u.createNotify.x = x,
|
|
|
|
.u.createNotify.y = y,
|
|
|
|
.u.createNotify.width = w,
|
|
|
|
.u.createNotify.height = h,
|
|
|
|
.u.createNotify.borderWidth = bw,
|
|
|
|
.u.createNotify.override = pWin->overrideRedirect
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
event.u.u.type = CreateNotify;
|
|
|
|
DeliverEvents(pParent, &event, 1, NullWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return pWin;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
DisposeWindowOptional(WindowPtr pWin)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
if (!pWin->optional)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* everything is peachy. Delete the optional record
|
|
|
|
* and clean up
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWin->optional->cursor) {
|
|
|
|
FreeCursor(pWin->optional->cursor, (Cursor) 0);
|
|
|
|
pWin->cursorIsNone = FALSE;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->cursorIsNone = TRUE;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWin->optional->deviceCursors) {
|
2009-09-06 13:44:18 -06:00
|
|
|
DevCursorList pList;
|
|
|
|
DevCursorList pPrev;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
pList = pWin->optional->deviceCursors;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (pList) {
|
2009-09-06 13:44:18 -06:00
|
|
|
if (pList->cursor)
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeCursor(pList->cursor, (XID) 0);
|
2009-09-06 13:44:18 -06:00
|
|
|
pPrev = pList;
|
|
|
|
pList = pList->next;
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pPrev);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
pWin->optional->deviceCursors = NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pWin->optional);
|
2007-11-24 10:55:21 -07:00
|
|
|
pWin->optional = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
FreeWindowResources(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DeleteWindowFromAnySaveSet(pWin);
|
|
|
|
DeleteWindowFromAnySelections(pWin);
|
|
|
|
DeleteWindowFromAnyEvents(pWin, TRUE);
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionUninit(&pWin->clipList);
|
|
|
|
RegionUninit(&pWin->winSize);
|
|
|
|
RegionUninit(&pWin->borderClip);
|
|
|
|
RegionUninit(&pWin->borderSize);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (wBoundingShape(pWin))
|
|
|
|
RegionDestroy(wBoundingShape(pWin));
|
|
|
|
if (wClipShape(pWin))
|
|
|
|
RegionDestroy(wClipShape(pWin));
|
|
|
|
if (wInputShape(pWin))
|
|
|
|
RegionDestroy(wInputShape(pWin));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pWin->borderIsPixel == FALSE)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->DestroyPixmap) (pWin->border.pixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pWin->backgroundState == BackgroundPixmap)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->DestroyPixmap) (pWin->background.pixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DeleteAllWindowProperties(pWin);
|
|
|
|
/* We SHOULD check for an error value here XXX */
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->DestroyWindow) (pWin);
|
|
|
|
DisposeWindowOptional(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CrushTree(WindowPtr pWin)
|
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pChild, pSib, pParent;
|
2006-11-26 11:13:41 -07:00
|
|
|
UnrealizeWindowProcPtr UnrealizeWindow;
|
|
|
|
|
|
|
|
if (!(pChild = pWin->firstChild))
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
UnrealizeWindow = pWin->drawable.pScreen->UnrealizeWindow;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (1) {
|
|
|
|
if (pChild->firstChild) {
|
|
|
|
pChild = pChild->firstChild;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
while (1) {
|
|
|
|
pParent = pChild->parent;
|
|
|
|
if (SubStrSend(pChild, pParent)) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xEvent event = { .u.u.type = DestroyNotify };
|
2012-06-10 07:21:05 -06:00
|
|
|
event.u.destroyNotify.window = pChild->drawable.id;
|
|
|
|
DeliverEvents(pChild, &event, 1, NullWindow);
|
|
|
|
}
|
|
|
|
FreeResource(pChild->drawable.id, RT_WINDOW);
|
|
|
|
pSib = pChild->nextSib;
|
|
|
|
pChild->viewable = FALSE;
|
|
|
|
if (pChild->realized) {
|
|
|
|
pChild->realized = FALSE;
|
|
|
|
(*UnrealizeWindow) (pChild);
|
|
|
|
}
|
|
|
|
FreeWindowResources(pChild);
|
|
|
|
dixFreeObjectWithPrivates(pChild, PRIVATE_WINDOW);
|
|
|
|
if ((pChild = pSib))
|
|
|
|
break;
|
|
|
|
pChild = pParent;
|
|
|
|
pChild->firstChild = NullWindow;
|
|
|
|
pChild->lastChild = NullWindow;
|
|
|
|
if (pChild == pWin)
|
|
|
|
return;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*****
|
|
|
|
* DeleteWindow
|
|
|
|
* Deletes child of window then window itself
|
|
|
|
* If wid is None, don't send any events
|
|
|
|
*****/
|
|
|
|
|
|
|
|
int
|
2014-09-27 11:52:59 -06:00
|
|
|
DeleteWindow(void *value, XID wid)
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pParent;
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr pWin = (WindowPtr) value;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
UnmapWindow(pWin, FALSE);
|
|
|
|
|
|
|
|
CrushTree(pWin);
|
|
|
|
|
|
|
|
pParent = pWin->parent;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (wid && pParent && SubStrSend(pWin, pParent)) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xEvent event = { .u.u.type = DestroyNotify };
|
2012-06-10 07:21:05 -06:00
|
|
|
event.u.destroyNotify.window = pWin->drawable.id;
|
|
|
|
DeliverEvents(pWin, &event, 1, NullWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
FreeWindowResources(pWin);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pParent) {
|
|
|
|
if (pParent->firstChild == pWin)
|
|
|
|
pParent->firstChild = pWin->nextSib;
|
|
|
|
if (pParent->lastChild == pWin)
|
|
|
|
pParent->lastChild = pWin->prevSib;
|
|
|
|
if (pWin->nextSib)
|
|
|
|
pWin->nextSib->prevSib = pWin->prevSib;
|
|
|
|
if (pWin->prevSib)
|
|
|
|
pWin->prevSib->nextSib = pWin->nextSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->drawable.pScreen->root = NULL;
|
2010-12-05 08:36:02 -07:00
|
|
|
dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
|
2006-11-26 11:13:41 -07:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
DestroySubwindows(WindowPtr pWin, ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/* XXX
|
|
|
|
* The protocol is quite clear that each window should be
|
|
|
|
* destroyed in turn, however, unmapping all of the first
|
|
|
|
* eliminates most of the calls to ValidateTree. So,
|
|
|
|
* this implementation is incorrect in that all of the
|
|
|
|
* UnmapNotifies occur before all of the DestroyNotifies.
|
|
|
|
* If you care, simply delete the call to UnmapSubwindows.
|
|
|
|
*/
|
|
|
|
UnmapSubwindows(pWin);
|
2008-11-02 08:26:08 -07:00
|
|
|
while (pWin->lastChild) {
|
2012-06-10 07:21:05 -06:00
|
|
|
int rc = XaceHook(XACE_RESOURCE_ACCESS, client,
|
|
|
|
pWin->lastChild->drawable.id, RT_WINDOW,
|
|
|
|
pWin->lastChild, RT_NONE, NULL, DixDestroyAccess);
|
|
|
|
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
FreeResource(pWin->lastChild->drawable.id, RT_NONE);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
static void
|
|
|
|
SetRootWindowBackground(WindowPtr pWin, ScreenPtr pScreen, Mask *index2)
|
|
|
|
{
|
|
|
|
/* following the protocol: "Changing the background of a root window to
|
|
|
|
* None or ParentRelative restores the default background pixmap" */
|
|
|
|
if (bgNoneRoot) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->backgroundState = XaceBackgroundNoneState(pWin);
|
|
|
|
pWin->background.pixel = pScreen->whitePixel;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
else if (party_like_its_1989)
|
2012-06-10 07:21:05 -06:00
|
|
|
MakeRootTile(pWin);
|
2011-11-05 07:32:40 -06:00
|
|
|
else {
|
|
|
|
pWin->backgroundState = BackgroundPixel;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (whiteRoot)
|
|
|
|
pWin->background.pixel = pScreen->whitePixel;
|
|
|
|
else
|
|
|
|
pWin->background.pixel = pScreen->blackPixel;
|
|
|
|
*index2 = CWBackPixel;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*****
|
|
|
|
* ChangeWindowAttributes
|
2015-09-16 13:10:19 -06:00
|
|
|
*
|
2006-11-26 11:13:41 -07:00
|
|
|
* The value-mask specifies which attributes are to be changed; the
|
|
|
|
* value-list contains one value for each one bit in the mask, from least
|
2015-09-16 13:10:19 -06:00
|
|
|
* to most significant bit in the mask.
|
2006-11-26 11:13:41 -07:00
|
|
|
*****/
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
XID *pVlist;
|
2006-11-26 11:13:41 -07:00
|
|
|
PixmapPtr pPixmap;
|
|
|
|
Pixmap pixID;
|
|
|
|
CursorPtr pCursor, pOldCursor;
|
|
|
|
Cursor cursorID;
|
2009-09-06 13:44:18 -06:00
|
|
|
WindowPtr pChild;
|
2006-11-26 11:13:41 -07:00
|
|
|
Colormap cmap;
|
2012-06-10 07:21:05 -06:00
|
|
|
ColormapPtr pCmap;
|
2006-11-26 11:13:41 -07:00
|
|
|
xEvent xE;
|
2008-11-02 08:26:08 -07:00
|
|
|
int error, rc;
|
2007-11-24 10:55:21 -07:00
|
|
|
ScreenPtr pScreen;
|
2008-11-02 08:26:08 -07:00
|
|
|
Mask index2, tmask, vmaskCopy = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
unsigned int val;
|
2008-11-02 08:26:08 -07:00
|
|
|
Bool checkOptional = FALSE, borderRelative = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((pWin->drawable.class == InputOnly) &&
|
|
|
|
(vmask & (~INPUTONLY_LEGAL_MASK)))
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
error = Success;
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
pVlist = vlist;
|
|
|
|
tmask = vmask;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (tmask) {
|
|
|
|
index2 = (Mask) lowbit(tmask);
|
|
|
|
tmask &= ~index2;
|
|
|
|
switch (index2) {
|
|
|
|
case CWBackPixmap:
|
|
|
|
pixID = (Pixmap) * pVlist;
|
|
|
|
pVlist++;
|
|
|
|
if (pWin->backgroundState == ParentRelative)
|
|
|
|
borderRelative = TRUE;
|
|
|
|
if (pixID == None) {
|
|
|
|
if (pWin->backgroundState == BackgroundPixmap)
|
|
|
|
(*pScreen->DestroyPixmap) (pWin->background.pixmap);
|
|
|
|
if (!pWin->parent)
|
|
|
|
SetRootWindowBackground(pWin, pScreen, &index2);
|
|
|
|
else {
|
|
|
|
pWin->backgroundState = XaceBackgroundNoneState(pWin);
|
|
|
|
pWin->background.pixel = pScreen->whitePixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pixID == ParentRelative) {
|
|
|
|
if (pWin->parent &&
|
|
|
|
pWin->drawable.depth != pWin->parent->drawable.depth) {
|
|
|
|
error = BadMatch;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
if (pWin->backgroundState == BackgroundPixmap)
|
|
|
|
(*pScreen->DestroyPixmap) (pWin->background.pixmap);
|
|
|
|
if (!pWin->parent)
|
|
|
|
SetRootWindowBackground(pWin, pScreen, &index2);
|
|
|
|
else
|
|
|
|
pWin->backgroundState = ParentRelative;
|
|
|
|
borderRelative = TRUE;
|
|
|
|
/* Note that the parent's backgroundTile's refcnt is NOT
|
|
|
|
* incremented. */
|
|
|
|
}
|
|
|
|
else {
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pPixmap, pixID,
|
2012-06-10 07:21:05 -06:00
|
|
|
RT_PIXMAP, client, DixReadAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
if ((pPixmap->drawable.depth != pWin->drawable.depth) ||
|
|
|
|
(pPixmap->drawable.pScreen != pScreen)) {
|
|
|
|
error = BadMatch;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
if (pWin->backgroundState == BackgroundPixmap)
|
|
|
|
(*pScreen->DestroyPixmap) (pWin->background.pixmap);
|
|
|
|
pWin->backgroundState = BackgroundPixmap;
|
|
|
|
pWin->background.pixmap = pPixmap;
|
|
|
|
pPixmap->refcnt++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
error = rc;
|
|
|
|
client->errorValue = pixID;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CWBackPixel:
|
|
|
|
if (pWin->backgroundState == ParentRelative)
|
|
|
|
borderRelative = TRUE;
|
|
|
|
if (pWin->backgroundState == BackgroundPixmap)
|
|
|
|
(*pScreen->DestroyPixmap) (pWin->background.pixmap);
|
|
|
|
pWin->backgroundState = BackgroundPixel;
|
|
|
|
pWin->background.pixel = (CARD32) *pVlist;
|
|
|
|
/* background pixel overrides background pixmap,
|
|
|
|
so don't let the ddx layer see both bits */
|
|
|
|
vmaskCopy &= ~CWBackPixmap;
|
|
|
|
pVlist++;
|
|
|
|
break;
|
|
|
|
case CWBorderPixmap:
|
|
|
|
pixID = (Pixmap) * pVlist;
|
|
|
|
pVlist++;
|
|
|
|
if (pixID == CopyFromParent) {
|
|
|
|
if (!pWin->parent ||
|
|
|
|
(pWin->drawable.depth != pWin->parent->drawable.depth)) {
|
|
|
|
error = BadMatch;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
if (pWin->parent->borderIsPixel == TRUE) {
|
|
|
|
if (pWin->borderIsPixel == FALSE)
|
|
|
|
(*pScreen->DestroyPixmap) (pWin->border.pixmap);
|
|
|
|
pWin->border = pWin->parent->border;
|
|
|
|
pWin->borderIsPixel = TRUE;
|
|
|
|
index2 = CWBorderPixel;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pixID = pWin->parent->border.pixmap->drawable.id;
|
|
|
|
}
|
|
|
|
}
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pPixmap, pixID, RT_PIXMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixReadAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
if ((pPixmap->drawable.depth != pWin->drawable.depth) ||
|
|
|
|
(pPixmap->drawable.pScreen != pScreen)) {
|
|
|
|
error = BadMatch;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
if (pWin->borderIsPixel == FALSE)
|
|
|
|
(*pScreen->DestroyPixmap) (pWin->border.pixmap);
|
|
|
|
pWin->borderIsPixel = FALSE;
|
|
|
|
pWin->border.pixmap = pPixmap;
|
|
|
|
pPixmap->refcnt++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
error = rc;
|
|
|
|
client->errorValue = pixID;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CWBorderPixel:
|
|
|
|
if (pWin->borderIsPixel == FALSE)
|
|
|
|
(*pScreen->DestroyPixmap) (pWin->border.pixmap);
|
|
|
|
pWin->borderIsPixel = TRUE;
|
|
|
|
pWin->border.pixel = (CARD32) *pVlist;
|
|
|
|
/* border pixel overrides border pixmap,
|
|
|
|
so don't let the ddx layer see both bits */
|
|
|
|
vmaskCopy &= ~CWBorderPixmap;
|
|
|
|
pVlist++;
|
|
|
|
break;
|
|
|
|
case CWBitGravity:
|
|
|
|
val = (CARD8) *pVlist;
|
|
|
|
pVlist++;
|
|
|
|
if (val > StaticGravity) {
|
|
|
|
error = BadValue;
|
|
|
|
client->errorValue = val;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
pWin->bitGravity = val;
|
|
|
|
break;
|
|
|
|
case CWWinGravity:
|
|
|
|
val = (CARD8) *pVlist;
|
|
|
|
pVlist++;
|
|
|
|
if (val > StaticGravity) {
|
|
|
|
error = BadValue;
|
|
|
|
client->errorValue = val;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
pWin->winGravity = val;
|
|
|
|
break;
|
|
|
|
case CWBackingStore:
|
|
|
|
val = (CARD8) *pVlist;
|
|
|
|
pVlist++;
|
|
|
|
if ((val != NotUseful) && (val != WhenMapped) && (val != Always)) {
|
|
|
|
error = BadValue;
|
|
|
|
client->errorValue = val;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
pWin->backingStore = val;
|
|
|
|
pWin->forcedBS = FALSE;
|
|
|
|
break;
|
|
|
|
case CWBackingPlanes:
|
|
|
|
if (pWin->optional || ((CARD32) *pVlist != (CARD32) ~0L)) {
|
|
|
|
if (!pWin->optional && !MakeWindowOptional(pWin)) {
|
|
|
|
error = BadAlloc;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
pWin->optional->backingBitPlanes = (CARD32) *pVlist;
|
|
|
|
if ((CARD32) *pVlist == (CARD32) ~0L)
|
|
|
|
checkOptional = TRUE;
|
|
|
|
}
|
|
|
|
pVlist++;
|
|
|
|
break;
|
|
|
|
case CWBackingPixel:
|
|
|
|
if (pWin->optional || (CARD32) *pVlist) {
|
|
|
|
if (!pWin->optional && !MakeWindowOptional(pWin)) {
|
|
|
|
error = BadAlloc;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
pWin->optional->backingPixel = (CARD32) *pVlist;
|
|
|
|
if (!*pVlist)
|
|
|
|
checkOptional = TRUE;
|
|
|
|
}
|
|
|
|
pVlist++;
|
|
|
|
break;
|
|
|
|
case CWSaveUnder:
|
|
|
|
val = (BOOL) * pVlist;
|
|
|
|
pVlist++;
|
|
|
|
if ((val != xTrue) && (val != xFalse)) {
|
|
|
|
error = BadValue;
|
|
|
|
client->errorValue = val;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
pWin->saveUnder = val;
|
|
|
|
break;
|
|
|
|
case CWEventMask:
|
|
|
|
rc = EventSelectForWindow(pWin, client, (Mask) *pVlist);
|
|
|
|
if (rc) {
|
|
|
|
error = rc;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
pVlist++;
|
|
|
|
break;
|
|
|
|
case CWDontPropagate:
|
|
|
|
rc = EventSuppressForWindow(pWin, client, (Mask) *pVlist,
|
|
|
|
&checkOptional);
|
|
|
|
if (rc) {
|
|
|
|
error = rc;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
pVlist++;
|
|
|
|
break;
|
|
|
|
case CWOverrideRedirect:
|
|
|
|
val = (BOOL) * pVlist;
|
|
|
|
pVlist++;
|
|
|
|
if ((val != xTrue) && (val != xFalse)) {
|
|
|
|
error = BadValue;
|
|
|
|
client->errorValue = val;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
if (val == xTrue) {
|
|
|
|
rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id,
|
|
|
|
RT_WINDOW, pWin, RT_NONE, NULL, DixGrabAccess);
|
|
|
|
if (rc != Success) {
|
|
|
|
error = rc;
|
|
|
|
client->errorValue = pWin->drawable.id;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pWin->overrideRedirect = val;
|
|
|
|
break;
|
|
|
|
case CWColormap:
|
|
|
|
cmap = (Colormap) * pVlist;
|
|
|
|
pVlist++;
|
|
|
|
if (cmap == CopyFromParent) {
|
|
|
|
if (pWin->parent &&
|
|
|
|
(!pWin->optional ||
|
|
|
|
pWin->optional->visual == wVisual(pWin->parent))) {
|
|
|
|
cmap = wColormap(pWin->parent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cmap = None;
|
|
|
|
}
|
|
|
|
if (cmap == None) {
|
|
|
|
error = BadMatch;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pCmap, cmap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixUseAccess);
|
|
|
|
if (rc != Success) {
|
|
|
|
error = rc;
|
|
|
|
client->errorValue = cmap;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
if (pCmap->pVisual->vid != wVisual(pWin) ||
|
|
|
|
pCmap->pScreen != pScreen) {
|
|
|
|
error = BadMatch;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
if (cmap != wColormap(pWin)) {
|
|
|
|
if (!pWin->optional) {
|
|
|
|
if (!MakeWindowOptional(pWin)) {
|
|
|
|
error = BadAlloc;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pWin->parent && cmap == wColormap(pWin->parent))
|
|
|
|
checkOptional = TRUE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* propagate the original colormap to any children
|
|
|
|
* inheriting it
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (pChild = pWin->firstChild; pChild;
|
|
|
|
pChild = pChild->nextSib) {
|
|
|
|
if (!pChild->optional && !MakeWindowOptional(pChild)) {
|
|
|
|
error = BadAlloc;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pWin->optional->colormap = cmap;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check on any children now matching the new colormap
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (pChild = pWin->firstChild; pChild;
|
|
|
|
pChild = pChild->nextSib) {
|
|
|
|
if (pChild->optional->colormap == cmap)
|
|
|
|
CheckWindowOptionalNeed(pChild);
|
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
xE = (xEvent) {
|
|
|
|
.u.colormap.window = pWin->drawable.id,
|
|
|
|
.u.colormap.colormap = cmap,
|
|
|
|
.u.colormap.new = xTrue,
|
|
|
|
.u.colormap.state = IsMapInstalled(cmap, pWin)
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
xE.u.u.type = ColormapNotify;
|
|
|
|
DeliverEvents(pWin, &xE, 1, NullWindow);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CWCursor:
|
|
|
|
cursorID = (Cursor) * pVlist;
|
|
|
|
pVlist++;
|
|
|
|
/*
|
|
|
|
* install the new
|
|
|
|
*/
|
|
|
|
if (cursorID == None) {
|
|
|
|
if (pWin == pWin->drawable.pScreen->root)
|
|
|
|
pCursor = rootCursor;
|
|
|
|
else
|
|
|
|
pCursor = (CursorPtr) None;
|
|
|
|
}
|
|
|
|
else {
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pCursor, cursorID,
|
2012-06-10 07:21:05 -06:00
|
|
|
RT_CURSOR, client, DixUseAccess);
|
|
|
|
if (rc != Success) {
|
|
|
|
error = rc;
|
|
|
|
client->errorValue = cursorID;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pCursor != wCursor(pWin)) {
|
|
|
|
/*
|
|
|
|
* patch up child windows so they don't lose cursors.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (pChild = pWin->firstChild; pChild;
|
|
|
|
pChild = pChild->nextSib) {
|
|
|
|
if (!pChild->optional && !pChild->cursorIsNone &&
|
|
|
|
!MakeWindowOptional(pChild)) {
|
|
|
|
error = BadAlloc;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pOldCursor = 0;
|
|
|
|
if (pCursor == (CursorPtr) None) {
|
|
|
|
pWin->cursorIsNone = TRUE;
|
|
|
|
if (pWin->optional) {
|
|
|
|
pOldCursor = pWin->optional->cursor;
|
|
|
|
pWin->optional->cursor = (CursorPtr) None;
|
|
|
|
checkOptional = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!pWin->optional) {
|
|
|
|
if (!MakeWindowOptional(pWin)) {
|
|
|
|
error = BadAlloc;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pWin->parent && pCursor == wCursor(pWin->parent))
|
|
|
|
checkOptional = TRUE;
|
|
|
|
pOldCursor = pWin->optional->cursor;
|
2013-09-28 09:36:30 -06:00
|
|
|
pWin->optional->cursor = RefCursor(pCursor);
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->cursorIsNone = FALSE;
|
|
|
|
/*
|
|
|
|
* check on any children now matching the new cursor
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (pChild = pWin->firstChild; pChild;
|
|
|
|
pChild = pChild->nextSib) {
|
|
|
|
if (pChild->optional &&
|
|
|
|
(pChild->optional->cursor == pCursor))
|
|
|
|
CheckWindowOptionalNeed(pChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
CursorVisible = TRUE;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWin->realized)
|
|
|
|
WindowHasNewCursor(pWin);
|
|
|
|
|
|
|
|
/* Can't free cursor until here - old cursor
|
|
|
|
* is needed in WindowHasNewCursor
|
|
|
|
*/
|
|
|
|
if (pOldCursor)
|
|
|
|
FreeCursor(pOldCursor, (Cursor) 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = BadValue;
|
|
|
|
client->errorValue = vmask;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
vmaskCopy |= index2;
|
|
|
|
}
|
|
|
|
PatchUp:
|
2006-11-26 11:13:41 -07:00
|
|
|
if (checkOptional)
|
2012-06-10 07:21:05 -06:00
|
|
|
CheckWindowOptionalNeed(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* We SHOULD check for an error value here XXX */
|
|
|
|
(*pScreen->ChangeWindowAttributes) (pWin, vmaskCopy);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
/*
|
|
|
|
If the border contents have changed, redraw the border.
|
2012-06-10 07:21:05 -06:00
|
|
|
Note that this has to be done AFTER pScreen->ChangeWindowAttributes
|
|
|
|
for the tile to be rotated, and the correct function selected.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
if (((vmaskCopy & (CWBorderPixel | CWBorderPixmap)) || borderRelative)
|
2012-06-10 07:21:05 -06:00
|
|
|
&& pWin->viewable && HasBorder(pWin)) {
|
|
|
|
RegionRec exposed;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionNull(&exposed);
|
|
|
|
RegionSubtract(&exposed, &pWin->borderClip, &pWin->winSize);
|
2016-05-29 06:02:34 -06:00
|
|
|
pWin->drawable.pScreen->PaintWindow(pWin, &exposed, PW_BORDER);
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionUninit(&exposed);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****
|
|
|
|
* GetWindowAttributes
|
|
|
|
* Notice that this is different than ChangeWindowAttributes
|
|
|
|
*****/
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
GetWindowAttributes(WindowPtr pWin, ClientPtr client,
|
|
|
|
xGetWindowAttributesReply * wa)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
wa->type = X_Reply;
|
|
|
|
wa->bitGravity = pWin->bitGravity;
|
|
|
|
wa->winGravity = pWin->winGravity;
|
|
|
|
if (pWin->forcedBS && pWin->backingStore != Always)
|
2012-06-10 07:21:05 -06:00
|
|
|
wa->backingStore = NotUseful;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
wa->backingStore = pWin->backingStore;
|
2010-07-27 13:02:24 -06:00
|
|
|
wa->length = bytes_to_int32(sizeof(xGetWindowAttributesReply) -
|
2012-06-10 07:21:05 -06:00
|
|
|
sizeof(xGenericReply));
|
2006-11-26 11:13:41 -07:00
|
|
|
wa->sequenceNumber = client->sequence;
|
2012-06-10 07:21:05 -06:00
|
|
|
wa->backingBitPlanes = wBackingBitPlanes(pWin);
|
|
|
|
wa->backingPixel = wBackingPixel(pWin);
|
|
|
|
wa->saveUnder = (BOOL) pWin->saveUnder;
|
2006-11-26 11:13:41 -07:00
|
|
|
wa->override = pWin->overrideRedirect;
|
|
|
|
if (!pWin->mapped)
|
2012-06-10 07:21:05 -06:00
|
|
|
wa->mapState = IsUnmapped;
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (pWin->realized)
|
2012-06-10 07:21:05 -06:00
|
|
|
wa->mapState = IsViewable;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
wa->mapState = IsUnviewable;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
wa->colormap = wColormap(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
wa->mapInstalled = (wa->colormap == None) ? xFalse
|
2012-06-10 07:21:05 -06:00
|
|
|
: IsMapInstalled(wa->colormap, pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
wa->yourEventMask = EventMaskForClient(pWin, client);
|
2012-06-10 07:21:05 -06:00
|
|
|
wa->allEventMasks = pWin->eventMask | wOtherEventMasks(pWin);
|
|
|
|
wa->doNotPropagateMask = wDontPropagateMask(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
wa->class = pWin->drawable.class;
|
2012-06-10 07:21:05 -06:00
|
|
|
wa->visualID = wVisual(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
WindowPtr
|
2007-11-24 10:55:21 -07:00
|
|
|
MoveWindowInStack(WindowPtr pWin, WindowPtr pNextSib)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pParent = pWin->parent;
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr pFirstChange = pWin; /* highest window where list changes */
|
|
|
|
|
|
|
|
if (pWin->nextSib != pNextSib) {
|
|
|
|
WindowPtr pOldNextSib = pWin->nextSib;
|
|
|
|
|
|
|
|
if (!pNextSib) { /* move to bottom */
|
|
|
|
if (pParent->firstChild == pWin)
|
|
|
|
pParent->firstChild = pWin->nextSib;
|
|
|
|
/* if (pWin->nextSib) *//* is always True: pNextSib == NULL
|
|
|
|
* and pWin->nextSib != pNextSib
|
|
|
|
* therefore pWin->nextSib != NULL */
|
|
|
|
pFirstChange = pWin->nextSib;
|
|
|
|
pWin->nextSib->prevSib = pWin->prevSib;
|
|
|
|
if (pWin->prevSib)
|
|
|
|
pWin->prevSib->nextSib = pWin->nextSib;
|
|
|
|
pParent->lastChild->nextSib = pWin;
|
|
|
|
pWin->prevSib = pParent->lastChild;
|
|
|
|
pWin->nextSib = NullWindow;
|
|
|
|
pParent->lastChild = pWin;
|
|
|
|
}
|
|
|
|
else if (pParent->firstChild == pNextSib) { /* move to top */
|
|
|
|
pFirstChange = pWin;
|
|
|
|
if (pParent->lastChild == pWin)
|
|
|
|
pParent->lastChild = pWin->prevSib;
|
|
|
|
if (pWin->nextSib)
|
|
|
|
pWin->nextSib->prevSib = pWin->prevSib;
|
|
|
|
if (pWin->prevSib)
|
|
|
|
pWin->prevSib->nextSib = pWin->nextSib;
|
|
|
|
pWin->nextSib = pParent->firstChild;
|
2015-09-16 13:10:19 -06:00
|
|
|
pWin->prevSib = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
pNextSib->prevSib = pWin;
|
|
|
|
pParent->firstChild = pWin;
|
|
|
|
}
|
|
|
|
else { /* move in middle of list */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr pOldNext = pWin->nextSib;
|
|
|
|
|
|
|
|
pFirstChange = NullWindow;
|
|
|
|
if (pParent->firstChild == pWin)
|
|
|
|
pFirstChange = pParent->firstChild = pWin->nextSib;
|
|
|
|
if (pParent->lastChild == pWin) {
|
|
|
|
pFirstChange = pWin;
|
|
|
|
pParent->lastChild = pWin->prevSib;
|
|
|
|
}
|
|
|
|
if (pWin->nextSib)
|
|
|
|
pWin->nextSib->prevSib = pWin->prevSib;
|
|
|
|
if (pWin->prevSib)
|
|
|
|
pWin->prevSib->nextSib = pWin->nextSib;
|
|
|
|
pWin->nextSib = pNextSib;
|
|
|
|
pWin->prevSib = pNextSib->prevSib;
|
|
|
|
if (pNextSib->prevSib)
|
|
|
|
pNextSib->prevSib->nextSib = pWin;
|
|
|
|
pNextSib->prevSib = pWin;
|
|
|
|
if (!pFirstChange) { /* do we know it yet? */
|
|
|
|
pFirstChange = pParent->firstChild; /* no, search from top */
|
|
|
|
while ((pFirstChange != pWin) && (pFirstChange != pOldNext))
|
|
|
|
pFirstChange = pFirstChange->nextSib;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pWin->drawable.pScreen->RestackWindow)
|
|
|
|
(*pWin->drawable.pScreen->RestackWindow) (pWin, pOldNextSib);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ROOTLESS
|
|
|
|
/*
|
|
|
|
* In rootless mode we can't optimize away window restacks.
|
|
|
|
* There may be non-X windows around, so even if the window
|
|
|
|
* is in the correct position from X's point of view,
|
|
|
|
* the underlying window system may want to reorder it.
|
|
|
|
*/
|
|
|
|
else if (pWin->drawable.pScreen->RestackWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pWin->drawable.pScreen->RestackWindow) (pWin, pWin->nextSib);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return pFirstChange;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
SetWinSize(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
#ifdef COMPOSITE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWin->redirectDraw != RedirectDrawNone) {
|
|
|
|
BoxRec box;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Redirected clients get clip list equal to their
|
|
|
|
* own geometry, not clipped to their parent
|
|
|
|
*/
|
|
|
|
box.x1 = pWin->drawable.x;
|
|
|
|
box.y1 = pWin->drawable.y;
|
|
|
|
box.x2 = pWin->drawable.x + pWin->drawable.width;
|
|
|
|
box.y2 = pWin->drawable.y + pWin->drawable.height;
|
|
|
|
RegionReset(&pWin->winSize, &box);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
ClippedRegionFromBox(pWin->parent, &pWin->winSize,
|
|
|
|
pWin->drawable.x, pWin->drawable.y,
|
|
|
|
(int) pWin->drawable.width,
|
|
|
|
(int) pWin->drawable.height);
|
|
|
|
if (wBoundingShape(pWin) || wClipShape(pWin)) {
|
|
|
|
RegionTranslate(&pWin->winSize, -pWin->drawable.x, -pWin->drawable.y);
|
|
|
|
if (wBoundingShape(pWin))
|
|
|
|
RegionIntersect(&pWin->winSize, &pWin->winSize,
|
|
|
|
wBoundingShape(pWin));
|
|
|
|
if (wClipShape(pWin))
|
|
|
|
RegionIntersect(&pWin->winSize, &pWin->winSize, wClipShape(pWin));
|
|
|
|
RegionTranslate(&pWin->winSize, pWin->drawable.x, pWin->drawable.y);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
SetBorderSize(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int bw;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (HasBorder(pWin)) {
|
|
|
|
bw = wBorderWidth(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef COMPOSITE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWin->redirectDraw != RedirectDrawNone) {
|
|
|
|
BoxRec box;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Redirected clients get clip list equal to their
|
|
|
|
* own geometry, not clipped to their parent
|
|
|
|
*/
|
|
|
|
box.x1 = pWin->drawable.x - bw;
|
|
|
|
box.y1 = pWin->drawable.y - bw;
|
|
|
|
box.x2 = pWin->drawable.x + pWin->drawable.width + bw;
|
|
|
|
box.y2 = pWin->drawable.y + pWin->drawable.height + bw;
|
|
|
|
RegionReset(&pWin->borderSize, &box);
|
|
|
|
}
|
|
|
|
else
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
ClippedRegionFromBox(pWin->parent, &pWin->borderSize,
|
|
|
|
pWin->drawable.x - bw, pWin->drawable.y - bw,
|
|
|
|
(int) (pWin->drawable.width + (bw << 1)),
|
|
|
|
(int) (pWin->drawable.height + (bw << 1)));
|
|
|
|
if (wBoundingShape(pWin)) {
|
|
|
|
RegionTranslate(&pWin->borderSize, -pWin->drawable.x,
|
|
|
|
-pWin->drawable.y);
|
|
|
|
RegionIntersect(&pWin->borderSize, &pWin->borderSize,
|
|
|
|
wBoundingShape(pWin));
|
|
|
|
RegionTranslate(&pWin->borderSize, pWin->drawable.x,
|
|
|
|
pWin->drawable.y);
|
|
|
|
RegionUnion(&pWin->borderSize, &pWin->borderSize, &pWin->winSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RegionCopy(&pWin->borderSize, &pWin->winSize);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \param x,y new window position
|
|
|
|
* \param oldx,oldy old window position
|
|
|
|
* \param destx,desty position relative to gravity
|
|
|
|
*/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
GravityTranslate(int x, int y, int oldx, int oldy,
|
|
|
|
int dw, int dh, unsigned gravity, int *destx, int *desty)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
switch (gravity) {
|
|
|
|
case NorthGravity:
|
2012-06-10 07:21:05 -06:00
|
|
|
*destx = x + dw / 2;
|
|
|
|
*desty = y;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case NorthEastGravity:
|
2012-06-10 07:21:05 -06:00
|
|
|
*destx = x + dw;
|
|
|
|
*desty = y;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case WestGravity:
|
2012-06-10 07:21:05 -06:00
|
|
|
*destx = x;
|
|
|
|
*desty = y + dh / 2;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case CenterGravity:
|
2012-06-10 07:21:05 -06:00
|
|
|
*destx = x + dw / 2;
|
|
|
|
*desty = y + dh / 2;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case EastGravity:
|
2012-06-10 07:21:05 -06:00
|
|
|
*destx = x + dw;
|
|
|
|
*desty = y + dh / 2;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case SouthWestGravity:
|
2012-06-10 07:21:05 -06:00
|
|
|
*destx = x;
|
|
|
|
*desty = y + dh;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case SouthGravity:
|
2012-06-10 07:21:05 -06:00
|
|
|
*destx = x + dw / 2;
|
|
|
|
*desty = y + dh;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case SouthEastGravity:
|
2012-06-10 07:21:05 -06:00
|
|
|
*destx = x + dw;
|
|
|
|
*desty = y + dh;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case StaticGravity:
|
2012-06-10 07:21:05 -06:00
|
|
|
*destx = oldx;
|
|
|
|
*desty = oldy;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
*destx = x;
|
|
|
|
*desty = y;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX need to retile border on each window with ParentRelative origin */
|
2009-09-06 13:44:18 -06:00
|
|
|
void
|
2007-11-24 10:55:21 -07:00
|
|
|
ResizeChildrenWinSize(WindowPtr pWin, int dx, int dy, int dw, int dh)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
WindowPtr pSib, pChild;
|
2006-11-26 11:13:41 -07:00
|
|
|
Bool resized = (dw || dh);
|
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (pSib = pWin->firstChild; pSib; pSib = pSib->nextSib) {
|
|
|
|
if (resized && (pSib->winGravity > NorthWestGravity)) {
|
|
|
|
int cwsx, cwsy;
|
|
|
|
|
|
|
|
cwsx = pSib->origin.x;
|
|
|
|
cwsy = pSib->origin.y;
|
|
|
|
GravityTranslate(cwsx, cwsy, cwsx - dx, cwsy - dy, dw, dh,
|
|
|
|
pSib->winGravity, &cwsx, &cwsy);
|
|
|
|
if (cwsx != pSib->origin.x || cwsy != pSib->origin.y) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xEvent event = {
|
|
|
|
.u.gravity.window = pSib->drawable.id,
|
|
|
|
.u.gravity.x = cwsx - wBorderWidth(pSib),
|
|
|
|
.u.gravity.y = cwsy - wBorderWidth(pSib)
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
event.u.u.type = GravityNotify;
|
|
|
|
DeliverEvents(pSib, &event, 1, NullWindow);
|
|
|
|
pSib->origin.x = cwsx;
|
|
|
|
pSib->origin.y = cwsy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pSib->drawable.x = pWin->drawable.x + pSib->origin.x;
|
|
|
|
pSib->drawable.y = pWin->drawable.y + pSib->origin.y;
|
|
|
|
SetWinSize(pSib);
|
|
|
|
SetBorderSize(pSib);
|
|
|
|
(*pScreen->PositionWindow) (pSib, pSib->drawable.x, pSib->drawable.y);
|
|
|
|
|
|
|
|
if ((pChild = pSib->firstChild)) {
|
|
|
|
while (1) {
|
|
|
|
pChild->drawable.x = pChild->parent->drawable.x +
|
|
|
|
pChild->origin.x;
|
|
|
|
pChild->drawable.y = pChild->parent->drawable.y +
|
|
|
|
pChild->origin.y;
|
|
|
|
SetWinSize(pChild);
|
|
|
|
SetBorderSize(pChild);
|
|
|
|
(*pScreen->PositionWindow) (pChild,
|
|
|
|
pChild->drawable.x,
|
|
|
|
pChild->drawable.y);
|
|
|
|
if (pChild->firstChild) {
|
|
|
|
pChild = pChild->firstChild;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
while (!pChild->nextSib && (pChild != pSib))
|
|
|
|
pChild = pChild->parent;
|
|
|
|
if (pChild == pSib)
|
|
|
|
break;
|
|
|
|
pChild = pChild->nextSib;
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GET_INT16(m, f) \
|
|
|
|
if (m & mask) \
|
|
|
|
{ \
|
|
|
|
f = (INT16) *pVlist;\
|
|
|
|
pVlist++; \
|
|
|
|
}
|
|
|
|
#define GET_CARD16(m, f) \
|
|
|
|
if (m & mask) \
|
|
|
|
{ \
|
|
|
|
f = (CARD16) *pVlist;\
|
|
|
|
pVlist++;\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GET_CARD8(m, f) \
|
|
|
|
if (m & mask) \
|
|
|
|
{ \
|
|
|
|
f = (CARD8) *pVlist;\
|
|
|
|
pVlist++;\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ChangeMask ((Mask)(CWX | CWY | CWWidth | CWHeight))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IsSiblingAboveMe
|
2015-09-16 13:10:19 -06:00
|
|
|
* returns Above if pSib above pMe in stack or Below otherwise
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
IsSiblingAboveMe(WindowPtr pMe, WindowPtr pSib)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pWin = pMe->parent->firstChild;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (pWin) {
|
|
|
|
if (pWin == pSib)
|
|
|
|
return Above;
|
|
|
|
else if (pWin == pMe)
|
|
|
|
return Below;
|
|
|
|
pWin = pWin->nextSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return Below;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static BoxPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowExtents(WindowPtr pWin, BoxPtr pBox)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
pBox->x1 = pWin->drawable.x - wBorderWidth(pWin);
|
|
|
|
pBox->y1 = pWin->drawable.y - wBorderWidth(pWin);
|
|
|
|
pBox->x2 = pWin->drawable.x + (int) pWin->drawable.width
|
|
|
|
+ wBorderWidth(pWin);
|
|
|
|
pBox->y2 = pWin->drawable.y + (int) pWin->drawable.height
|
|
|
|
+ wBorderWidth(pWin);
|
2010-12-05 08:36:02 -07:00
|
|
|
return pBox;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
#define IS_SHAPED(pWin) (wBoundingShape (pWin) != NULL)
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static RegionPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
MakeBoundingRegion(WindowPtr pWin, BoxPtr pBox)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionPtr pRgn = RegionCreate(pBox, 1);
|
|
|
|
|
|
|
|
if (wBoundingShape(pWin)) {
|
|
|
|
RegionTranslate(pRgn, -pWin->origin.x, -pWin->origin.y);
|
|
|
|
RegionIntersect(pRgn, pRgn, wBoundingShape(pWin));
|
|
|
|
RegionTranslate(pRgn, pWin->origin.x, pWin->origin.y);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return pRgn;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
ShapeOverlap(WindowPtr pWin, BoxPtr pWinBox, WindowPtr pSib, BoxPtr pSibBox)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionPtr pWinRgn, pSibRgn;
|
|
|
|
Bool ret;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!IS_SHAPED(pWin) && !IS_SHAPED(pSib))
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
|
|
|
pWinRgn = MakeBoundingRegion(pWin, pWinBox);
|
|
|
|
pSibRgn = MakeBoundingRegion(pSib, pSibBox);
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionIntersect(pWinRgn, pWinRgn, pSibRgn);
|
|
|
|
ret = RegionNotEmpty(pWinRgn);
|
|
|
|
RegionDestroy(pWinRgn);
|
|
|
|
RegionDestroy(pSibRgn);
|
2006-11-26 11:13:41 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
AnyWindowOverlapsMe(WindowPtr pWin, WindowPtr pHead, BoxPtr box)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
BoxRec sboxrec;
|
2007-11-24 10:55:21 -07:00
|
|
|
BoxPtr sbox;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (pSib = pWin->prevSib; pSib != pHead; pSib = pSib->prevSib) {
|
|
|
|
if (pSib->mapped) {
|
|
|
|
sbox = WindowExtents(pSib, &sboxrec);
|
|
|
|
if (BOXES_OVERLAP(sbox, box)
|
2013-06-07 11:28:45 -06:00
|
|
|
&& ShapeOverlap(pWin, box, pSib, sbox))
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
IOverlapAnyWindow(WindowPtr pWin, BoxPtr box)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
BoxRec sboxrec;
|
2007-11-24 10:55:21 -07:00
|
|
|
BoxPtr sbox;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (pSib = pWin->nextSib; pSib; pSib = pSib->nextSib) {
|
|
|
|
if (pSib->mapped) {
|
|
|
|
sbox = WindowExtents(pSib, &sboxrec);
|
|
|
|
if (BOXES_OVERLAP(sbox, box)
|
2013-06-07 11:28:45 -06:00
|
|
|
&& ShapeOverlap(pWin, box, pSib, sbox))
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-09-16 13:10:19 -06:00
|
|
|
* WhereDoIGoInTheStack()
|
2006-11-26 11:13:41 -07:00
|
|
|
* Given pWin and pSib and the relationshipe smode, return
|
|
|
|
* the window that pWin should go ABOVE.
|
|
|
|
* If a pSib is specified:
|
|
|
|
* Above: pWin is placed just above pSib
|
|
|
|
* Below: pWin is placed just below pSib
|
|
|
|
* TopIf: if pSib occludes pWin, then pWin is placed
|
|
|
|
* at the top of the stack
|
2015-09-16 13:10:19 -06:00
|
|
|
* BottomIf: if pWin occludes pSib, then pWin is
|
2006-11-26 11:13:41 -07:00
|
|
|
* placed at the bottom of the stack
|
|
|
|
* Opposite: if pSib occludes pWin, then pWin is placed at the
|
|
|
|
* top of the stack, else if pWin occludes pSib, then
|
|
|
|
* pWin is placed at the bottom of the stack
|
|
|
|
*
|
|
|
|
* If pSib is NULL:
|
|
|
|
* Above: pWin is placed at the top of the stack
|
|
|
|
* Below: pWin is placed at the bottom of the stack
|
|
|
|
* TopIf: if any sibling occludes pWin, then pWin is placed at
|
|
|
|
* the top of the stack
|
|
|
|
* BottomIf: if pWin occludes any sibline, then pWin is placed at
|
|
|
|
* the bottom of the stack
|
|
|
|
* Opposite: if any sibling occludes pWin, then pWin is placed at
|
|
|
|
* the top of the stack, else if pWin occludes any
|
|
|
|
* sibling, then pWin is placed at the bottom of the stack
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static WindowPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
WhereDoIGoInTheStack(WindowPtr pWin,
|
|
|
|
WindowPtr pSib,
|
|
|
|
short x,
|
|
|
|
short y, unsigned short w, unsigned short h, int smode)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
BoxRec box;
|
|
|
|
WindowPtr pHead, pFirst;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((pWin == pWin->parent->firstChild) && (pWin == pWin->parent->lastChild))
|
2015-09-16 13:10:19 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
pHead = RealChildHead(pWin->parent);
|
|
|
|
pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild;
|
|
|
|
box.x1 = x;
|
|
|
|
box.y1 = y;
|
2012-06-10 07:21:05 -06:00
|
|
|
box.x2 = x + (int) w;
|
|
|
|
box.y2 = y + (int) h;
|
|
|
|
switch (smode) {
|
|
|
|
case Above:
|
|
|
|
if (pSib)
|
|
|
|
return pSib;
|
|
|
|
else if (pWin == pFirst)
|
|
|
|
return pWin->nextSib;
|
|
|
|
else
|
|
|
|
return pFirst;
|
|
|
|
case Below:
|
|
|
|
if (pSib)
|
|
|
|
if (pSib->nextSib != pWin)
|
|
|
|
return pSib->nextSib;
|
|
|
|
else
|
|
|
|
return pWin->nextSib;
|
|
|
|
else
|
|
|
|
return NullWindow;
|
|
|
|
case TopIf:
|
|
|
|
if ((!pWin->mapped || (pSib && !pSib->mapped)))
|
|
|
|
return pWin->nextSib;
|
|
|
|
else if (pSib) {
|
|
|
|
if ((IsSiblingAboveMe(pWin, pSib) == Above) &&
|
|
|
|
(RegionContainsRect(&pSib->borderSize, &box) != rgnOUT))
|
|
|
|
return pFirst;
|
|
|
|
else
|
|
|
|
return pWin->nextSib;
|
|
|
|
}
|
|
|
|
else if (AnyWindowOverlapsMe(pWin, pHead, &box))
|
|
|
|
return pFirst;
|
|
|
|
else
|
|
|
|
return pWin->nextSib;
|
|
|
|
case BottomIf:
|
|
|
|
if ((!pWin->mapped || (pSib && !pSib->mapped)))
|
|
|
|
return pWin->nextSib;
|
|
|
|
else if (pSib) {
|
|
|
|
if ((IsSiblingAboveMe(pWin, pSib) == Below) &&
|
|
|
|
(RegionContainsRect(&pSib->borderSize, &box) != rgnOUT))
|
|
|
|
return NullWindow;
|
|
|
|
else
|
|
|
|
return pWin->nextSib;
|
|
|
|
}
|
|
|
|
else if (IOverlapAnyWindow(pWin, &box))
|
|
|
|
return NullWindow;
|
|
|
|
else
|
|
|
|
return pWin->nextSib;
|
|
|
|
case Opposite:
|
|
|
|
if ((!pWin->mapped || (pSib && !pSib->mapped)))
|
|
|
|
return pWin->nextSib;
|
|
|
|
else if (pSib) {
|
|
|
|
if (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT) {
|
|
|
|
if (IsSiblingAboveMe(pWin, pSib) == Above)
|
|
|
|
return pFirst;
|
|
|
|
else
|
|
|
|
return NullWindow;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return pWin->nextSib;
|
|
|
|
}
|
|
|
|
else if (AnyWindowOverlapsMe(pWin, pHead, &box)) {
|
|
|
|
/* If I'm occluded, I can't possibly be the first child
|
|
|
|
* if (pWin == pWin->parent->firstChild)
|
|
|
|
* return pWin->nextSib;
|
|
|
|
*/
|
|
|
|
return pFirst;
|
|
|
|
}
|
|
|
|
else if (IOverlapAnyWindow(pWin, &box))
|
|
|
|
return NullWindow;
|
|
|
|
else
|
|
|
|
return pWin->nextSib;
|
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
/* should never happen; make something up. */
|
|
|
|
return pWin->nextSib;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
ReflectStackChange(WindowPtr pWin, WindowPtr pSib, VTKind kind)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/* Note that pSib might be NULL */
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool WasViewable = (Bool) pWin->viewable;
|
2006-11-26 11:13:41 -07:00
|
|
|
Bool anyMarked;
|
|
|
|
WindowPtr pFirstChange;
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr pLayerWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
|
|
|
|
|
|
|
/* if this is a root window, can't be restacked */
|
|
|
|
if (!pWin->parent)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pFirstChange = MoveWindowInStack(pWin, pSib);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (WasViewable) {
|
|
|
|
anyMarked = (*pScreen->MarkOverlappedWindows) (pWin, pFirstChange,
|
|
|
|
&pLayerWin);
|
|
|
|
if (pLayerWin != pWin)
|
|
|
|
pFirstChange = pLayerWin;
|
|
|
|
if (anyMarked) {
|
|
|
|
(*pScreen->ValidateTree) (pLayerWin->parent, pFirstChange, kind);
|
|
|
|
(*pScreen->HandleExposures) (pLayerWin->parent);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (pWin->drawable.pScreen->PostValidateTree)
|
|
|
|
(*pScreen->PostValidateTree) (pLayerWin->parent, pFirstChange,
|
|
|
|
kind);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (pWin->realized)
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowsRestructured();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****
|
|
|
|
* ConfigureWindow
|
|
|
|
*****/
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
#define RESTACK_WIN 0
|
|
|
|
#define MOVE_WIN 1
|
|
|
|
#define RESIZE_WIN 2
|
|
|
|
#define REBORDER_WIN 3
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pSib = NullWindow;
|
|
|
|
WindowPtr pParent = pWin->parent;
|
2006-11-26 11:13:41 -07:00
|
|
|
Window sibwid = 0;
|
|
|
|
Mask index2, tmask;
|
2007-11-24 10:55:21 -07:00
|
|
|
XID *pVlist;
|
2012-06-10 07:21:05 -06:00
|
|
|
short x, y, beforeX, beforeY;
|
2006-11-26 11:13:41 -07:00
|
|
|
unsigned short w = pWin->drawable.width,
|
2012-06-10 07:21:05 -06:00
|
|
|
h = pWin->drawable.height, bw = pWin->borderWidth;
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc, action, smode = Above;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
if ((pWin->drawable.class == InputOnly) && (mask & CWBorderWidth))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if ((mask & CWSibling) && !(mask & CWStackMode))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pVlist = vlist;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pParent) {
|
|
|
|
x = pWin->drawable.x - pParent->drawable.x - (int) bw;
|
|
|
|
y = pWin->drawable.y - pParent->drawable.y - (int) bw;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
x = pWin->drawable.x;
|
|
|
|
y = pWin->drawable.y;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
beforeX = x;
|
|
|
|
beforeY = y;
|
2012-06-10 07:21:05 -06:00
|
|
|
action = RESTACK_WIN;
|
|
|
|
if ((mask & (CWX | CWY)) && (!(mask & (CWHeight | CWWidth)))) {
|
|
|
|
GET_INT16(CWX, x);
|
|
|
|
GET_INT16(CWY, y);
|
|
|
|
action = MOVE_WIN;
|
|
|
|
}
|
|
|
|
/* or should be resized */
|
|
|
|
else if (mask & (CWX | CWY | CWWidth | CWHeight)) {
|
|
|
|
GET_INT16(CWX, x);
|
|
|
|
GET_INT16(CWY, y);
|
|
|
|
GET_CARD16(CWWidth, w);
|
|
|
|
GET_CARD16(CWHeight, h);
|
|
|
|
if (!w || !h) {
|
|
|
|
client->errorValue = 0;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
action = RESIZE_WIN;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
tmask = mask & ~ChangeMask;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (tmask) {
|
|
|
|
index2 = (Mask) lowbit(tmask);
|
|
|
|
tmask &= ~index2;
|
|
|
|
switch (index2) {
|
|
|
|
case CWBorderWidth:
|
|
|
|
GET_CARD16(CWBorderWidth, bw);
|
|
|
|
break;
|
|
|
|
case CWSibling:
|
|
|
|
sibwid = (Window) *pVlist;
|
|
|
|
pVlist++;
|
|
|
|
rc = dixLookupWindow(&pSib, sibwid, client, DixGetAttrAccess);
|
|
|
|
if (rc != Success) {
|
|
|
|
client->errorValue = sibwid;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
if (pSib->parent != pParent)
|
|
|
|
return BadMatch;
|
|
|
|
if (pSib == pWin)
|
|
|
|
return BadMatch;
|
|
|
|
break;
|
|
|
|
case CWStackMode:
|
|
|
|
GET_CARD8(CWStackMode, smode);
|
|
|
|
if ((smode != TopIf) && (smode != BottomIf) &&
|
|
|
|
(smode != Opposite) && (smode != Above) && (smode != Below)) {
|
|
|
|
client->errorValue = smode;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
client->errorValue = mask;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* root really can't be reconfigured, so just return */
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pParent)
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Figure out if the window should be moved. Doesnt
|
|
|
|
make the changes to the window if event sent */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (mask & CWStackMode)
|
2012-06-10 07:21:05 -06:00
|
|
|
pSib = WhereDoIGoInTheStack(pWin, pSib, pParent->drawable.x + x,
|
|
|
|
pParent->drawable.y + y,
|
|
|
|
w + (bw << 1), h + (bw << 1), smode);
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
pSib = pWin->nextSib;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
if ((!pWin->overrideRedirect) && (RedirectSend(pParent))) {
|
|
|
|
xEvent event = {
|
|
|
|
.u.configureRequest.window = pWin->drawable.id,
|
|
|
|
.u.configureRequest.sibling = (mask & CWSibling) ? sibwid : None,
|
|
|
|
.u.configureRequest.x = x,
|
|
|
|
.u.configureRequest.y = y,
|
|
|
|
.u.configureRequest.width = w,
|
|
|
|
.u.configureRequest.height = h,
|
|
|
|
.u.configureRequest.borderWidth = bw,
|
|
|
|
.u.configureRequest.valueMask = mask,
|
|
|
|
.u.configureRequest.parent = pParent->drawable.id
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
event.u.u.type = ConfigureRequest;
|
2013-06-07 11:28:45 -06:00
|
|
|
event.u.u.detail = (mask & CWStackMode) ? smode : Above;
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!noPanoramiXExtension && (!pParent || !pParent->parent)) {
|
2010-12-05 08:36:02 -07:00
|
|
|
event.u.configureRequest.x += screenInfo.screens[0]->x;
|
|
|
|
event.u.configureRequest.y += screenInfo.screens[0]->y;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
if (MaybeDeliverEventsToClient(pParent, &event, 1,
|
|
|
|
SubstructureRedirectMask, client) == 1)
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (action == RESIZE_WIN) {
|
|
|
|
Bool size_change = (w != pWin->drawable.width)
|
|
|
|
|| (h != pWin->drawable.height);
|
|
|
|
|
|
|
|
if (size_change &&
|
|
|
|
((pWin->eventMask | wOtherEventMasks(pWin)) & ResizeRedirectMask)) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xEvent eventT = {
|
|
|
|
.u.resizeRequest.window = pWin->drawable.id,
|
|
|
|
.u.resizeRequest.width = w,
|
|
|
|
.u.resizeRequest.height = h
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
eventT.u.u.type = ResizeRequest;
|
|
|
|
if (MaybeDeliverEventsToClient(pWin, &eventT, 1,
|
|
|
|
ResizeRedirectMask, client) == 1) {
|
|
|
|
/* if event is delivered, leave the actual size alone. */
|
|
|
|
w = pWin->drawable.width;
|
|
|
|
h = pWin->drawable.height;
|
|
|
|
size_change = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!size_change) {
|
|
|
|
if (mask & (CWX | CWY))
|
|
|
|
action = MOVE_WIN;
|
|
|
|
else if (mask & (CWStackMode | CWBorderWidth))
|
|
|
|
action = RESTACK_WIN;
|
|
|
|
else /* really nothing to do */
|
|
|
|
return (Success);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (action == RESIZE_WIN)
|
2012-06-10 07:21:05 -06:00
|
|
|
/* we've already checked whether there's really a size change */
|
|
|
|
goto ActuallyDoSomething;
|
2006-11-26 11:13:41 -07:00
|
|
|
if ((mask & CWX) && (x != beforeX))
|
2012-06-10 07:21:05 -06:00
|
|
|
goto ActuallyDoSomething;
|
2006-11-26 11:13:41 -07:00
|
|
|
if ((mask & CWY) && (y != beforeY))
|
2012-06-10 07:21:05 -06:00
|
|
|
goto ActuallyDoSomething;
|
|
|
|
if ((mask & CWBorderWidth) && (bw != wBorderWidth(pWin)))
|
|
|
|
goto ActuallyDoSomething;
|
|
|
|
if (mask & CWStackMode) {
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifndef ROOTLESS
|
|
|
|
/* See above for why we always reorder in rootless mode. */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWin->nextSib != pSib)
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
goto ActuallyDoSomething;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
ActuallyDoSomething:
|
|
|
|
if (pWin->drawable.pScreen->ConfigNotify) {
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret =
|
|
|
|
(*pWin->drawable.pScreen->ConfigNotify) (pWin, x, y, w, h, bw,
|
|
|
|
pSib);
|
|
|
|
if (ret) {
|
|
|
|
client->errorValue = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (SubStrSend(pWin, pParent)) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xEvent event = {
|
|
|
|
.u.configureNotify.window = pWin->drawable.id,
|
|
|
|
.u.configureNotify.aboveSibling = pSib ? pSib->drawable.id : None,
|
|
|
|
.u.configureNotify.x = x,
|
|
|
|
.u.configureNotify.y = y,
|
|
|
|
.u.configureNotify.width = w,
|
|
|
|
.u.configureNotify.height = h,
|
|
|
|
.u.configureNotify.borderWidth = bw,
|
|
|
|
.u.configureNotify.override = pWin->overrideRedirect
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
event.u.u.type = ConfigureNotify;
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!noPanoramiXExtension && (!pParent || !pParent->parent)) {
|
|
|
|
event.u.configureNotify.x += screenInfo.screens[0]->x;
|
|
|
|
event.u.configureNotify.y += screenInfo.screens[0]->y;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
DeliverEvents(pWin, &event, 1, NullWindow);
|
|
|
|
}
|
|
|
|
if (mask & CWBorderWidth) {
|
|
|
|
if (action == RESTACK_WIN) {
|
|
|
|
action = MOVE_WIN;
|
|
|
|
pWin->borderWidth = bw;
|
|
|
|
}
|
|
|
|
else if ((action == MOVE_WIN) &&
|
|
|
|
(beforeX + wBorderWidth(pWin) == x + (int) bw) &&
|
|
|
|
(beforeY + wBorderWidth(pWin) == y + (int) bw)) {
|
|
|
|
action = REBORDER_WIN;
|
|
|
|
(*pWin->drawable.pScreen->ChangeBorderWidth) (pWin, bw);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pWin->borderWidth = bw;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (action == MOVE_WIN)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pWin->drawable.pScreen->MoveWindow) (pWin, x, y, pSib,
|
|
|
|
(mask & CWBorderWidth) ? VTOther
|
|
|
|
: VTMove);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (action == RESIZE_WIN)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pWin->drawable.pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (mask & CWStackMode)
|
2012-06-10 07:21:05 -06:00
|
|
|
ReflectStackChange(pWin, pSib, VTOther);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (action != RESTACK_WIN)
|
2012-06-10 07:21:05 -06:00
|
|
|
CheckCursorConfinement(pWin);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
#undef RESTACK_WIN
|
|
|
|
#undef MOVE_WIN
|
|
|
|
#undef RESIZE_WIN
|
|
|
|
#undef REBORDER_WIN
|
|
|
|
}
|
|
|
|
|
|
|
|
/******
|
|
|
|
*
|
|
|
|
* CirculateWindow
|
|
|
|
* For RaiseLowest, raises the lowest mapped child (if any) that is
|
|
|
|
* obscured by another child to the top of the stack. For LowerHighest,
|
|
|
|
* lowers the highest mapped child (if any) that is obscuring another
|
2015-09-16 13:10:19 -06:00
|
|
|
* child to the bottom of the stack. Exposure processing is performed
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
|
|
|
******/
|
|
|
|
|
|
|
|
int
|
|
|
|
CirculateWindow(WindowPtr pParent, int direction, ClientPtr client)
|
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pWin, pHead, pFirst;
|
2006-11-26 11:13:41 -07:00
|
|
|
xEvent event;
|
|
|
|
BoxRec box;
|
|
|
|
|
|
|
|
pHead = RealChildHead(pParent);
|
|
|
|
pFirst = pHead ? pHead->nextSib : pParent->firstChild;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (direction == RaiseLowest) {
|
|
|
|
for (pWin = pParent->lastChild;
|
|
|
|
(pWin != pHead) &&
|
|
|
|
!(pWin->mapped &&
|
|
|
|
AnyWindowOverlapsMe(pWin, pHead, WindowExtents(pWin, &box)));
|
|
|
|
pWin = pWin->prevSib);
|
|
|
|
if (pWin == pHead)
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
for (pWin = pFirst;
|
|
|
|
pWin &&
|
|
|
|
!(pWin->mapped &&
|
|
|
|
IOverlapAnyWindow(pWin, WindowExtents(pWin, &box)));
|
|
|
|
pWin = pWin->nextSib);
|
|
|
|
if (!pWin)
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
event = (xEvent) {
|
|
|
|
.u.circulate.window = pWin->drawable.id,
|
|
|
|
.u.circulate.parent = pParent->drawable.id,
|
|
|
|
.u.circulate.event = pParent->drawable.id,
|
|
|
|
.u.circulate.place = (direction == RaiseLowest) ?
|
|
|
|
PlaceOnTop : PlaceOnBottom,
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (RedirectSend(pParent)) {
|
|
|
|
event.u.u.type = CirculateRequest;
|
|
|
|
if (MaybeDeliverEventsToClient(pParent, &event, 1,
|
|
|
|
SubstructureRedirectMask, client) == 1)
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
event.u.u.type = CirculateNotify;
|
|
|
|
DeliverEvents(pWin, &event, 1, NullWindow);
|
|
|
|
ReflectStackChange(pWin,
|
2012-06-10 07:21:05 -06:00
|
|
|
(direction == RaiseLowest) ? pFirst : NullWindow,
|
|
|
|
VTStack);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
CompareWIDs(WindowPtr pWin, void *value)
|
2012-06-10 07:21:05 -06:00
|
|
|
{ /* must conform to VisitWindowProcPtr */
|
|
|
|
Window *wid = (Window *) value;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pWin->drawable.id == *wid)
|
2012-06-10 07:21:05 -06:00
|
|
|
return WT_STOPWALKING;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return WT_WALKCHILDREN;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****
|
|
|
|
* ReparentWindow
|
|
|
|
*****/
|
|
|
|
|
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
ReparentWindow(WindowPtr pWin, WindowPtr pParent,
|
2006-11-26 11:13:41 -07:00
|
|
|
int x, int y, ClientPtr client)
|
|
|
|
{
|
|
|
|
WindowPtr pPrev, pPriorParent;
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool WasMapped = (Bool) (pWin->mapped);
|
2006-11-26 11:13:41 -07:00
|
|
|
xEvent event;
|
2012-06-10 07:21:05 -06:00
|
|
|
int bw = wBorderWidth(pWin);
|
2007-11-24 10:55:21 -07:00
|
|
|
ScreenPtr pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
2014-09-27 11:52:59 -06:00
|
|
|
if (TraverseTree(pWin, CompareWIDs, (void *) &pParent->drawable.id) ==
|
2012-06-10 07:21:05 -06:00
|
|
|
WT_STOPWALKING)
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!MakeWindowOptional(pWin))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (WasMapped)
|
2012-06-10 07:21:05 -06:00
|
|
|
UnmapWindow(pWin, FALSE);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
event = (xEvent) {
|
|
|
|
.u.reparent.window = pWin->drawable.id,
|
|
|
|
.u.reparent.parent = pParent->drawable.id,
|
|
|
|
.u.reparent.x = x,
|
|
|
|
.u.reparent.y = y,
|
|
|
|
.u.reparent.override = pWin->overrideRedirect
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
event.u.u.type = ReparentNotify;
|
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!noPanoramiXExtension && !pParent->parent) {
|
|
|
|
event.u.reparent.x += screenInfo.screens[0]->x;
|
|
|
|
event.u.reparent.y += screenInfo.screens[0]->y;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
DeliverEvents(pWin, &event, 1, pParent);
|
|
|
|
|
|
|
|
/* take out of sibling chain */
|
|
|
|
|
|
|
|
pPriorParent = pPrev = pWin->parent;
|
|
|
|
if (pPrev->firstChild == pWin)
|
2012-06-10 07:21:05 -06:00
|
|
|
pPrev->firstChild = pWin->nextSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pPrev->lastChild == pWin)
|
2012-06-10 07:21:05 -06:00
|
|
|
pPrev->lastChild = pWin->prevSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pWin->nextSib)
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->nextSib->prevSib = pWin->prevSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pWin->prevSib)
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->prevSib->nextSib = pWin->nextSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* insert at begining of pParent */
|
|
|
|
pWin->parent = pParent;
|
|
|
|
pPrev = RealChildHead(pParent);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pPrev) {
|
|
|
|
pWin->nextSib = pPrev->nextSib;
|
|
|
|
if (pPrev->nextSib)
|
|
|
|
pPrev->nextSib->prevSib = pWin;
|
|
|
|
else
|
|
|
|
pParent->lastChild = pWin;
|
|
|
|
pPrev->nextSib = pWin;
|
|
|
|
pWin->prevSib = pPrev;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
pWin->nextSib = pParent->firstChild;
|
|
|
|
pWin->prevSib = NullWindow;
|
|
|
|
if (pParent->firstChild)
|
|
|
|
pParent->firstChild->prevSib = pWin;
|
|
|
|
else
|
|
|
|
pParent->lastChild = pWin;
|
|
|
|
pParent->firstChild = pWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pWin->origin.x = x + bw;
|
|
|
|
pWin->origin.y = y + bw;
|
|
|
|
pWin->drawable.x = x + bw + pParent->drawable.x;
|
|
|
|
pWin->drawable.y = y + bw + pParent->drawable.y;
|
|
|
|
|
|
|
|
/* clip to parent */
|
2012-06-10 07:21:05 -06:00
|
|
|
SetWinSize(pWin);
|
|
|
|
SetBorderSize(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pScreen->ReparentWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->ReparentWindow) (pWin, pPriorParent);
|
|
|
|
(*pScreen->PositionWindow) (pWin, pWin->drawable.x, pWin->drawable.y);
|
2006-11-26 11:13:41 -07:00
|
|
|
ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
CheckWindowOptionalNeed(pWin);
|
|
|
|
|
|
|
|
if (WasMapped)
|
2012-06-10 07:21:05 -06:00
|
|
|
MapWindow(pWin, client);
|
2006-11-26 11:13:41 -07:00
|
|
|
RecalculateDeliverableEvents(pWin);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
RealizeTree(WindowPtr pWin)
|
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pChild;
|
2006-11-26 11:13:41 -07:00
|
|
|
RealizeWindowProcPtr Realize;
|
|
|
|
|
|
|
|
Realize = pWin->drawable.pScreen->RealizeWindow;
|
|
|
|
pChild = pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (1) {
|
|
|
|
if (pChild->mapped) {
|
|
|
|
pChild->realized = TRUE;
|
|
|
|
pChild->viewable = (pChild->drawable.class == InputOutput);
|
|
|
|
(*Realize) (pChild);
|
|
|
|
if (pChild->firstChild) {
|
|
|
|
pChild = pChild->firstChild;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!pChild->nextSib && (pChild != pWin))
|
|
|
|
pChild = pChild->parent;
|
|
|
|
if (pChild == pWin)
|
|
|
|
return;
|
|
|
|
pChild = pChild->nextSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
static Bool
|
|
|
|
MaybeDeliverMapRequest(WindowPtr pWin, WindowPtr pParent, ClientPtr client)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
xEvent event = {
|
|
|
|
.u.mapRequest.window = pWin->drawable.id,
|
|
|
|
.u.mapRequest.parent = pParent->drawable.id
|
|
|
|
};
|
|
|
|
event.u.u.type = MapRequest;
|
|
|
|
|
|
|
|
return MaybeDeliverEventsToClient(pParent, &event, 1,
|
|
|
|
SubstructureRedirectMask,
|
|
|
|
client) == 1;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
static void
|
|
|
|
DeliverMapNotify(WindowPtr pWin)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
xEvent event = {
|
|
|
|
.u.mapNotify.window = pWin->drawable.id,
|
|
|
|
.u.mapNotify.override = pWin->overrideRedirect,
|
|
|
|
};
|
|
|
|
event.u.u.type = MapNotify;
|
|
|
|
DeliverEvents(pWin, &event, 1, NullWindow);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*****
|
|
|
|
* MapWindow
|
|
|
|
* If some other client has selected SubStructureReDirect on the parent
|
|
|
|
* and override-redirect is xFalse, then a MapRequest event is generated,
|
|
|
|
* but the window remains unmapped. Otherwise, the window is mapped and a
|
|
|
|
* MapNotify event is generated.
|
|
|
|
*****/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
MapWindow(WindowPtr pWin, ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
ScreenPtr pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pParent;
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr pLayerWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pWin->mapped)
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
/* general check for permission to map window */
|
2008-11-02 08:26:08 -07:00
|
|
|
if (XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, RT_WINDOW,
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin, RT_NONE, NULL, DixShowAccess) != Success)
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((pParent = pWin->parent)) {
|
|
|
|
Bool anyMarked;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
if ((!pWin->overrideRedirect) && (RedirectSend(pParent)))
|
|
|
|
if (MaybeDeliverMapRequest(pWin, pParent, client))
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
|
|
|
|
|
|
|
pWin->mapped = TRUE;
|
2013-06-07 11:28:45 -06:00
|
|
|
if (SubStrSend(pWin, pParent))
|
|
|
|
DeliverMapNotify(pWin);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (!pParent->realized)
|
|
|
|
return Success;
|
|
|
|
RealizeTree(pWin);
|
|
|
|
if (pWin->viewable) {
|
|
|
|
anyMarked = (*pScreen->MarkOverlappedWindows) (pWin, pWin,
|
|
|
|
&pLayerWin);
|
|
|
|
if (anyMarked) {
|
|
|
|
(*pScreen->ValidateTree) (pLayerWin->parent, pLayerWin, VTMap);
|
|
|
|
(*pScreen->HandleExposures) (pLayerWin->parent);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (pScreen->PostValidateTree)
|
|
|
|
(*pScreen->PostValidateTree) (pLayerWin->parent, pLayerWin,
|
|
|
|
VTMap);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
WindowsRestructured();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
RegionRec temp;
|
|
|
|
|
|
|
|
pWin->mapped = TRUE;
|
|
|
|
pWin->realized = TRUE; /* for roots */
|
|
|
|
pWin->viewable = pWin->drawable.class == InputOutput;
|
|
|
|
/* We SHOULD check for an error value here XXX */
|
|
|
|
(*pScreen->RealizeWindow) (pWin);
|
|
|
|
if (pScreen->ClipNotify)
|
|
|
|
(*pScreen->ClipNotify) (pWin, 0, 0);
|
|
|
|
if (pScreen->PostValidateTree)
|
|
|
|
(*pScreen->PostValidateTree) (NullWindow, pWin, VTMap);
|
|
|
|
RegionNull(&temp);
|
|
|
|
RegionCopy(&temp, &pWin->clipList);
|
2015-09-16 13:10:19 -06:00
|
|
|
(*pScreen->WindowExposures) (pWin, &temp);
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionUninit(&temp);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****
|
|
|
|
* MapSubwindows
|
|
|
|
* Performs a MapWindow all unmapped children of the window, in top
|
|
|
|
* to bottom stacking order.
|
|
|
|
*****/
|
|
|
|
|
|
|
|
void
|
2007-11-24 10:55:21 -07:00
|
|
|
MapSubwindows(WindowPtr pParent, ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr pWin;
|
|
|
|
WindowPtr pFirstMapped = NullWindow;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
Mask parentRedirect;
|
|
|
|
Mask parentNotify;
|
|
|
|
Bool anyMarked;
|
|
|
|
WindowPtr pLayerWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pScreen = pParent->drawable.pScreen;
|
|
|
|
parentRedirect = RedirectSend(pParent);
|
|
|
|
parentNotify = SubSend(pParent);
|
|
|
|
anyMarked = FALSE;
|
2012-06-10 07:21:05 -06:00
|
|
|
for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib) {
|
|
|
|
if (!pWin->mapped) {
|
2013-06-07 11:28:45 -06:00
|
|
|
if (parentRedirect && !pWin->overrideRedirect)
|
|
|
|
if (MaybeDeliverMapRequest(pWin, pParent, client))
|
2012-06-10 07:21:05 -06:00
|
|
|
continue;
|
|
|
|
|
|
|
|
pWin->mapped = TRUE;
|
2013-06-07 11:28:45 -06:00
|
|
|
if (parentNotify || StrSend(pWin))
|
|
|
|
DeliverMapNotify(pWin);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (!pFirstMapped)
|
|
|
|
pFirstMapped = pWin;
|
|
|
|
if (pParent->realized) {
|
|
|
|
RealizeTree(pWin);
|
|
|
|
if (pWin->viewable) {
|
|
|
|
anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin, pWin,
|
2015-09-16 13:10:19 -06:00
|
|
|
NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pFirstMapped) {
|
|
|
|
pLayerWin = (*pScreen->GetLayerWindow) (pParent);
|
|
|
|
if (pLayerWin->parent != pParent) {
|
|
|
|
anyMarked |= (*pScreen->MarkOverlappedWindows) (pLayerWin,
|
2015-09-16 13:10:19 -06:00
|
|
|
pLayerWin, NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
pFirstMapped = pLayerWin;
|
|
|
|
}
|
|
|
|
if (anyMarked) {
|
|
|
|
(*pScreen->ValidateTree) (pLayerWin->parent, pFirstMapped, VTMap);
|
|
|
|
(*pScreen->HandleExposures) (pLayerWin->parent);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (pScreen->PostValidateTree)
|
|
|
|
(*pScreen->PostValidateTree) (pLayerWin->parent, pFirstMapped,
|
|
|
|
VTMap);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
WindowsRestructured();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
UnrealizeTree(WindowPtr pWin, Bool fromConfigure)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pChild;
|
2006-11-26 11:13:41 -07:00
|
|
|
UnrealizeWindowProcPtr Unrealize;
|
|
|
|
MarkUnrealizedWindowProcPtr MarkUnrealizedWindow;
|
|
|
|
|
|
|
|
Unrealize = pWin->drawable.pScreen->UnrealizeWindow;
|
|
|
|
MarkUnrealizedWindow = pWin->drawable.pScreen->MarkUnrealizedWindow;
|
|
|
|
pChild = pWin;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (1) {
|
|
|
|
if (pChild->realized) {
|
|
|
|
pChild->realized = FALSE;
|
|
|
|
pChild->visibility = VisibilityNotViewable;
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!noPanoramiXExtension && !pChild->drawable.pScreen->myNum) {
|
|
|
|
PanoramiXRes *win;
|
2014-09-27 11:52:59 -06:00
|
|
|
int rc = dixLookupResourceByType((void **) &win,
|
2012-06-10 07:21:05 -06:00
|
|
|
pChild->drawable.id,
|
|
|
|
XRT_WINDOW,
|
|
|
|
serverClient, DixWriteAccess);
|
|
|
|
|
|
|
|
if (rc == Success)
|
|
|
|
win->u.win.visibility = VisibilityNotViewable;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
(*Unrealize) (pChild);
|
2013-06-07 11:28:45 -06:00
|
|
|
DeleteWindowFromAnyEvents(pChild, FALSE);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pChild->viewable) {
|
|
|
|
pChild->viewable = FALSE;
|
|
|
|
(*MarkUnrealizedWindow) (pChild, pWin, fromConfigure);
|
|
|
|
pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
|
|
|
}
|
|
|
|
if (pChild->firstChild) {
|
|
|
|
pChild = pChild->firstChild;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!pChild->nextSib && (pChild != pWin))
|
|
|
|
pChild = pChild->parent;
|
|
|
|
if (pChild == pWin)
|
|
|
|
return;
|
|
|
|
pChild = pChild->nextSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
static void
|
|
|
|
DeliverUnmapNotify(WindowPtr pWin, Bool fromConfigure)
|
|
|
|
{
|
|
|
|
xEvent event = {
|
|
|
|
.u.unmapNotify.window = pWin->drawable.id,
|
|
|
|
.u.unmapNotify.fromConfigure = fromConfigure
|
|
|
|
};
|
|
|
|
event.u.u.type = UnmapNotify;
|
|
|
|
DeliverEvents(pWin, &event, 1, NullWindow);
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*****
|
|
|
|
* UnmapWindow
|
|
|
|
* If the window is already unmapped, this request has no effect.
|
|
|
|
* Otherwise, the window is unmapped and an UnMapNotify event is
|
|
|
|
* generated. Cannot unmap a root window.
|
|
|
|
*****/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2007-11-24 10:55:21 -07:00
|
|
|
UnmapWindow(WindowPtr pWin, Bool fromConfigure)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pParent;
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool wasRealized = (Bool) pWin->realized;
|
|
|
|
Bool wasViewable = (Bool) pWin->viewable;
|
2006-11-26 11:13:41 -07:00
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
|
|
|
WindowPtr pLayerWin = pWin;
|
|
|
|
|
|
|
|
if ((!pWin->mapped) || (!(pParent = pWin->parent)))
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2013-06-07 11:28:45 -06:00
|
|
|
if (SubStrSend(pWin, pParent))
|
|
|
|
DeliverUnmapNotify(pWin, fromConfigure);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (wasViewable && !fromConfigure) {
|
|
|
|
pWin->valdata = UnmapValData;
|
|
|
|
(*pScreen->MarkOverlappedWindows) (pWin, pWin->nextSib, &pLayerWin);
|
|
|
|
(*pScreen->MarkWindow) (pLayerWin->parent);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
pWin->mapped = FALSE;
|
|
|
|
if (wasRealized)
|
2012-06-10 07:21:05 -06:00
|
|
|
UnrealizeTree(pWin, fromConfigure);
|
|
|
|
if (wasViewable) {
|
|
|
|
if (!fromConfigure) {
|
|
|
|
(*pScreen->ValidateTree) (pLayerWin->parent, pWin, VTUnmap);
|
|
|
|
(*pScreen->HandleExposures) (pLayerWin->parent);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (pScreen->PostValidateTree)
|
|
|
|
(*pScreen->PostValidateTree) (pLayerWin->parent, pWin, VTUnmap);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (wasRealized && !fromConfigure) {
|
|
|
|
WindowsRestructured();
|
|
|
|
WindowGone(pWin);
|
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****
|
|
|
|
* UnmapSubwindows
|
|
|
|
* Performs an UnmapWindow request with the specified mode on all mapped
|
|
|
|
* children of the window, in bottom to top stacking order.
|
|
|
|
*****/
|
|
|
|
|
|
|
|
void
|
2007-11-24 10:55:21 -07:00
|
|
|
UnmapSubwindows(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pChild, pHead;
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool wasRealized = (Bool) pWin->realized;
|
|
|
|
Bool wasViewable = (Bool) pWin->viewable;
|
2006-11-26 11:13:41 -07:00
|
|
|
Bool anyMarked = FALSE;
|
|
|
|
Mask parentNotify;
|
|
|
|
WindowPtr pLayerWin = NULL;
|
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
|
|
|
|
|
|
|
if (!pWin->firstChild)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
parentNotify = SubSend(pWin);
|
|
|
|
pHead = RealChildHead(pWin);
|
|
|
|
|
|
|
|
if (wasViewable)
|
2012-06-10 07:21:05 -06:00
|
|
|
pLayerWin = (*pScreen->GetLayerWindow) (pWin);
|
|
|
|
|
|
|
|
for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) {
|
|
|
|
if (pChild->mapped) {
|
2013-06-07 11:28:45 -06:00
|
|
|
if (parentNotify || StrSend(pChild))
|
|
|
|
DeliverUnmapNotify(pChild, xFalse);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pChild->viewable) {
|
|
|
|
pChild->valdata = UnmapValData;
|
|
|
|
anyMarked = TRUE;
|
|
|
|
}
|
|
|
|
pChild->mapped = FALSE;
|
|
|
|
if (pChild->realized)
|
|
|
|
UnrealizeTree(pChild, FALSE);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (wasViewable) {
|
|
|
|
if (anyMarked) {
|
|
|
|
if (pLayerWin->parent == pWin)
|
|
|
|
(*pScreen->MarkWindow) (pWin);
|
|
|
|
else {
|
|
|
|
WindowPtr ptmp;
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
(*pScreen->MarkOverlappedWindows) (pWin, pLayerWin, NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->MarkWindow) (pLayerWin->parent);
|
|
|
|
|
|
|
|
/* Windows between pWin and pLayerWin may not have been marked */
|
|
|
|
ptmp = pWin;
|
|
|
|
|
|
|
|
while (ptmp != pLayerWin->parent) {
|
|
|
|
(*pScreen->MarkWindow) (ptmp);
|
|
|
|
ptmp = ptmp->parent;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
pHead = pWin->firstChild;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
(*pScreen->ValidateTree) (pLayerWin->parent, pHead, VTUnmap);
|
|
|
|
(*pScreen->HandleExposures) (pLayerWin->parent);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (pScreen->PostValidateTree)
|
|
|
|
(*pScreen->PostValidateTree) (pLayerWin->parent, pHead,
|
|
|
|
VTUnmap);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (wasRealized) {
|
|
|
|
WindowsRestructured();
|
|
|
|
WindowGone(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-11-24 10:55:21 -07:00
|
|
|
HandleSaveSet(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pParent, pWin;
|
|
|
|
int j;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (j = 0; j < client->numSaved; j++) {
|
|
|
|
pWin = SaveSetWindow(client->saveSet[j]);
|
|
|
|
if (SaveSetToRoot(client->saveSet[j]))
|
|
|
|
pParent = pWin->drawable.pScreen->root;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pParent = pWin->parent;
|
|
|
|
while (pParent && (wClient(pParent) == client))
|
|
|
|
pParent = pParent->parent;
|
|
|
|
}
|
|
|
|
if (pParent) {
|
|
|
|
if (pParent != pWin->parent) {
|
|
|
|
/* unmap first so that ReparentWindow doesn't remap */
|
|
|
|
if (!SaveSetShouldMap(client->saveSet[j]))
|
|
|
|
UnmapWindow(pWin, FALSE);
|
|
|
|
ReparentWindow(pWin, pParent,
|
|
|
|
pWin->drawable.x - wBorderWidth(pWin) -
|
|
|
|
pParent->drawable.x,
|
|
|
|
pWin->drawable.y - wBorderWidth(pWin) -
|
|
|
|
pParent->drawable.y, client);
|
|
|
|
if (!pWin->realized && pWin->mapped)
|
|
|
|
pWin->mapped = FALSE;
|
|
|
|
}
|
|
|
|
if (SaveSetShouldMap(client->saveSet[j]))
|
|
|
|
MapWindow(pWin, client);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
free(client->saveSet);
|
2006-11-26 11:13:41 -07:00
|
|
|
client->numSaved = 0;
|
2015-09-16 13:10:19 -06:00
|
|
|
client->saveSet = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \param x,y in root
|
|
|
|
*/
|
|
|
|
Bool
|
2007-11-24 10:55:21 -07:00
|
|
|
PointInWindowIsVisible(WindowPtr pWin, int x, int y)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
BoxRec box;
|
|
|
|
|
|
|
|
if (!pWin->realized)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
|
|
|
if (RegionContainsPoint(&pWin->borderClip, x, y, &box)
|
|
|
|
&& (!wInputShape(pWin) ||
|
|
|
|
RegionContainsPoint(wInputShape(pWin),
|
|
|
|
x - pWin->drawable.x,
|
|
|
|
y - pWin->drawable.y, &box)))
|
|
|
|
return TRUE;
|
2010-12-05 08:36:02 -07:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
RegionPtr
|
2007-11-24 10:55:21 -07:00
|
|
|
NotClippedByChildren(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionPtr pReg = RegionCreate(NullBox, 1);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pWin->parent ||
|
2012-06-10 07:21:05 -06:00
|
|
|
screenIsSaved != SCREEN_SAVER_ON ||
|
|
|
|
!HasSaverWindow(pWin->drawable.pScreen)) {
|
|
|
|
RegionIntersect(pReg, &pWin->borderClip, &pWin->winSize);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return pReg;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
void
|
2006-11-26 11:13:41 -07:00
|
|
|
SendVisibilityNotify(WindowPtr pWin)
|
|
|
|
{
|
|
|
|
xEvent event;
|
|
|
|
unsigned int visibility = pWin->visibility;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
/* This is not quite correct yet, but it's close */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!noPanoramiXExtension) {
|
|
|
|
PanoramiXRes *win;
|
|
|
|
WindowPtr pWin2;
|
|
|
|
int rc, i, Scrnum;
|
|
|
|
|
|
|
|
Scrnum = pWin->drawable.pScreen->myNum;
|
|
|
|
|
|
|
|
win = PanoramiXFindIDByScrnum(XRT_WINDOW, pWin->drawable.id, Scrnum);
|
|
|
|
|
|
|
|
if (!win || (win->u.win.visibility == visibility))
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (visibility) {
|
|
|
|
case VisibilityUnobscured:
|
|
|
|
FOR_NSCREENS(i) {
|
|
|
|
if (i == Scrnum)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rc = dixLookupWindow(&pWin2, win->info[i].id, serverClient,
|
|
|
|
DixWriteAccess);
|
|
|
|
|
|
|
|
if (rc == Success) {
|
|
|
|
if (pWin2->visibility == VisibilityPartiallyObscured)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!i)
|
|
|
|
pWin = pWin2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VisibilityPartiallyObscured:
|
|
|
|
if (Scrnum) {
|
|
|
|
rc = dixLookupWindow(&pWin2, win->info[0].id, serverClient,
|
|
|
|
DixWriteAccess);
|
|
|
|
if (rc == Success)
|
|
|
|
pWin = pWin2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VisibilityFullyObscured:
|
|
|
|
FOR_NSCREENS(i) {
|
|
|
|
if (i == Scrnum)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rc = dixLookupWindow(&pWin2, win->info[i].id, serverClient,
|
|
|
|
DixWriteAccess);
|
|
|
|
|
|
|
|
if (rc == Success) {
|
|
|
|
if (pWin2->visibility != VisibilityFullyObscured)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!i)
|
|
|
|
pWin = pWin2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
win->u.win.visibility = visibility;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
event = (xEvent) {
|
|
|
|
.u.visibility.window = pWin->drawable.id,
|
|
|
|
.u.visibility.state = visibility
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
event.u.u.type = VisibilityNotify;
|
|
|
|
DeliverEvents(pWin, &event, 1, NullWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RANDOM_WIDTH 32
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2008-11-02 08:26:08 -07:00
|
|
|
dixSaveScreens(ClientPtr client, int on, int mode)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
int rc, i, what, type;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (on == SCREEN_SAVER_FORCER) {
|
|
|
|
if (mode == ScreenSaverReset)
|
|
|
|
what = SCREEN_SAVER_OFF;
|
|
|
|
else
|
|
|
|
what = SCREEN_SAVER_ON;
|
|
|
|
type = what;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
what = on;
|
|
|
|
type = what;
|
|
|
|
if (what == screenIsSaved)
|
|
|
|
type = SCREEN_SAVER_CYCLE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i],
|
|
|
|
DixShowAccess | DixHideAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[i];
|
|
|
|
|
|
|
|
if (on == SCREEN_SAVER_FORCER)
|
|
|
|
(*pScreen->SaveScreen) (pScreen, on);
|
|
|
|
if (pScreen->screensaver.ExternalScreenSaver) {
|
|
|
|
if ((*pScreen->screensaver.ExternalScreenSaver)
|
|
|
|
(pScreen, type, on == SCREEN_SAVER_FORCER))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (type == screenIsSaved)
|
|
|
|
continue;
|
|
|
|
switch (type) {
|
|
|
|
case SCREEN_SAVER_OFF:
|
|
|
|
if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED) {
|
|
|
|
(*pScreen->SaveScreen) (pScreen, what);
|
|
|
|
}
|
|
|
|
else if (HasSaverWindow(pScreen)) {
|
|
|
|
pScreen->screensaver.pWindow = NullWindow;
|
|
|
|
FreeResource(pScreen->screensaver.wid, RT_NONE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCREEN_SAVER_CYCLE:
|
|
|
|
if (pScreen->screensaver.blanked == SCREEN_IS_TILED) {
|
|
|
|
WindowPtr pWin = pScreen->screensaver.pWindow;
|
|
|
|
|
|
|
|
/* make it look like screen saver is off, so that
|
|
|
|
* NotClippedByChildren will compute a clip list
|
2016-05-29 06:02:34 -06:00
|
|
|
* for the root window, so PaintWindow works
|
2012-06-10 07:21:05 -06:00
|
|
|
*/
|
|
|
|
screenIsSaved = SCREEN_SAVER_OFF;
|
|
|
|
(*pWin->drawable.pScreen->MoveWindow) (pWin,
|
|
|
|
(short) (-
|
|
|
|
(rand() %
|
|
|
|
RANDOM_WIDTH)),
|
|
|
|
(short) (-
|
|
|
|
(rand() %
|
|
|
|
RANDOM_WIDTH)),
|
|
|
|
pWin->nextSib, VTMove);
|
|
|
|
screenIsSaved = SCREEN_SAVER_ON;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Call the DDX saver in case it wants to do something
|
|
|
|
* at cycle time
|
|
|
|
*/
|
|
|
|
else if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED) {
|
|
|
|
(*pScreen->SaveScreen) (pScreen, type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCREEN_SAVER_ON:
|
|
|
|
if (ScreenSaverBlanking != DontPreferBlanking) {
|
|
|
|
if ((*pScreen->SaveScreen) (pScreen, what)) {
|
|
|
|
pScreen->screensaver.blanked = SCREEN_IS_BLANKED;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((ScreenSaverAllowExposures != DontAllowExposures) &&
|
|
|
|
TileScreenSaver(pScreen, SCREEN_IS_BLACK)) {
|
|
|
|
pScreen->screensaver.blanked = SCREEN_IS_BLACK;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((ScreenSaverAllowExposures != DontAllowExposures) &&
|
|
|
|
TileScreenSaver(pScreen, SCREEN_IS_TILED)) {
|
|
|
|
pScreen->screensaver.blanked = SCREEN_IS_TILED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pScreen->screensaver.blanked = SCREEN_ISNT_SAVED;
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
screenIsSaved = what;
|
2010-07-27 13:02:24 -06:00
|
|
|
if (mode == ScreenSaverReset) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (on == SCREEN_SAVER_FORCER) {
|
2013-06-07 11:28:45 -06:00
|
|
|
DeviceIntPtr dev;
|
2012-06-10 07:21:05 -06:00
|
|
|
UpdateCurrentTimeIf();
|
2013-06-07 11:28:45 -06:00
|
|
|
nt_list_for_each_entry(dev, inputInfo.devices, next)
|
2013-12-08 03:53:01 -07:00
|
|
|
NoticeTime(dev, currentTime);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
SetScreenSaverTimer();
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2008-11-02 08:26:08 -07:00
|
|
|
SaveScreens(int on, int mode)
|
|
|
|
{
|
|
|
|
return dixSaveScreens(serverClient, on, mode);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-12-05 08:36:02 -07:00
|
|
|
TileScreenSaver(ScreenPtr pScreen, int kind)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int j;
|
|
|
|
int result;
|
|
|
|
XID attributes[3];
|
|
|
|
Mask mask;
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr pWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
CursorMetricRec cm;
|
|
|
|
unsigned char *srcbits, *mskbits;
|
|
|
|
CursorPtr cursor;
|
2012-06-10 07:21:05 -06:00
|
|
|
XID cursorID = 0;
|
|
|
|
int attri;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
mask = 0;
|
|
|
|
attri = 0;
|
|
|
|
switch (kind) {
|
|
|
|
case SCREEN_IS_TILED:
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (pScreen->root->backgroundState) {
|
|
|
|
case BackgroundPixel:
|
|
|
|
attributes[attri++] = pScreen->root->background.pixel;
|
|
|
|
mask |= CWBackPixel;
|
|
|
|
break;
|
|
|
|
case BackgroundPixmap:
|
|
|
|
attributes[attri++] = None;
|
|
|
|
mask |= CWBackPixmap;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case SCREEN_IS_BLACK:
|
2012-06-10 07:21:05 -06:00
|
|
|
attributes[attri++] = pScreen->root->drawable.pScreen->blackPixel;
|
|
|
|
mask |= CWBackPixel;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
mask |= CWOverrideRedirect;
|
|
|
|
attributes[attri++] = xTrue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* create a blank cursor
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
cm.width = 16;
|
|
|
|
cm.height = 16;
|
|
|
|
cm.xhot = 8;
|
|
|
|
cm.yhot = 8;
|
|
|
|
srcbits = malloc(BitmapBytePad(32) * 16);
|
|
|
|
mskbits = malloc(BitmapBytePad(32) * 16);
|
|
|
|
if (!srcbits || !mskbits) {
|
|
|
|
free(srcbits);
|
|
|
|
free(mskbits);
|
|
|
|
cursor = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
for (j = 0; j < BitmapBytePad(32) * 16; j++)
|
|
|
|
srcbits[j] = mskbits[j] = 0x0;
|
|
|
|
result = AllocARGBCursor(srcbits, mskbits, NULL, &cm, 0, 0, 0, 0, 0, 0,
|
|
|
|
&cursor, serverClient, (XID) 0);
|
|
|
|
if (cursor) {
|
|
|
|
cursorID = FakeClientID(0);
|
2014-09-27 11:52:59 -06:00
|
|
|
if (AddResource(cursorID, RT_CURSOR, (void *) cursor)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
attributes[attri] = cursorID;
|
|
|
|
mask |= CWCursor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cursor = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
free(srcbits);
|
|
|
|
free(mskbits);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pWin = pScreen->screensaver.pWindow =
|
2012-06-10 07:21:05 -06:00
|
|
|
CreateWindow(pScreen->screensaver.wid,
|
|
|
|
pScreen->root,
|
|
|
|
-RANDOM_WIDTH, -RANDOM_WIDTH,
|
|
|
|
(unsigned short) pScreen->width + RANDOM_WIDTH,
|
|
|
|
(unsigned short) pScreen->height + RANDOM_WIDTH,
|
|
|
|
0, InputOutput, mask, attributes, 0, serverClient,
|
|
|
|
wVisual(pScreen->root), &result);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (cursor)
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeResource(cursorID, RT_NONE);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!pWin)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!AddResource(pWin->drawable.id, RT_WINDOW,
|
2014-09-27 11:52:59 -06:00
|
|
|
(void *) pScreen->screensaver.pWindow))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (mask & CWBackPixmap) {
|
|
|
|
MakeRootTile(pWin);
|
|
|
|
(*pWin->drawable.pScreen->ChangeWindowAttributes) (pWin, CWBackPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
MapWindow(pWin, serverClient);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FindWindowWithOptional
|
|
|
|
*
|
|
|
|
* search ancestors of the given window for an entry containing
|
|
|
|
* a WindowOpt structure. Assumptions: some parent will
|
|
|
|
* contain the structure.
|
|
|
|
*/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
WindowPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
FindWindowWithOptional(WindowPtr w)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
do
|
2012-06-10 07:21:05 -06:00
|
|
|
w = w->parent;
|
2006-11-26 11:13:41 -07:00
|
|
|
while (!w->optional);
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CheckWindowOptionalNeed
|
|
|
|
*
|
|
|
|
* check each optional entry in the given window to see if
|
|
|
|
* the value is satisfied by the default rules. If so,
|
|
|
|
* release the optional record
|
|
|
|
*/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
CheckWindowOptionalNeed(WindowPtr w)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowOptPtr optional;
|
|
|
|
WindowOptPtr parentOptional;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!w->parent || !w->optional)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
optional = w->optional;
|
|
|
|
if (optional->dontPropagateMask != DontPropagateMasks[w->dontPropagate])
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (optional->otherEventMasks != 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (optional->otherClients != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (optional->passiveGrabs != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (optional->userProps != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2015-09-16 13:10:19 -06:00
|
|
|
if (optional->backingBitPlanes != (CARD32)~0L)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (optional->backingPixel != 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (optional->boundingShape != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (optional->clipShape != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (optional->inputShape != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (optional->inputMasks != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
if (optional->deviceCursors != NULL) {
|
2009-09-06 13:44:18 -06:00
|
|
|
DevCursNodePtr pNode = optional->deviceCursors;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
while (pNode) {
|
2009-09-06 13:44:18 -06:00
|
|
|
if (pNode->cursor != None)
|
|
|
|
return;
|
|
|
|
pNode = pNode->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
parentOptional = FindWindowWithOptional(w)->optional;
|
|
|
|
if (optional->visual != parentOptional->visual)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (optional->cursor != None &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(optional->cursor != parentOptional->cursor || w->parent->cursorIsNone))
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (optional->colormap != parentOptional->colormap)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
DisposeWindowOptional(w);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MakeWindowOptional
|
|
|
|
*
|
|
|
|
* create an optional record and initialize it with the default
|
|
|
|
* values.
|
|
|
|
*/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
MakeWindowOptional(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowOptPtr optional;
|
|
|
|
WindowOptPtr parentOptional;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pWin->optional)
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
|
|
|
optional = malloc(sizeof(WindowOptRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!optional)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
optional->dontPropagateMask = DontPropagateMasks[pWin->dontPropagate];
|
|
|
|
optional->otherEventMasks = 0;
|
|
|
|
optional->otherClients = NULL;
|
|
|
|
optional->passiveGrabs = NULL;
|
|
|
|
optional->userProps = NULL;
|
|
|
|
optional->backingBitPlanes = ~0L;
|
|
|
|
optional->backingPixel = 0;
|
|
|
|
optional->boundingShape = NULL;
|
|
|
|
optional->clipShape = NULL;
|
|
|
|
optional->inputShape = NULL;
|
|
|
|
optional->inputMasks = NULL;
|
2009-09-06 13:44:18 -06:00
|
|
|
optional->deviceCursors = NULL;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
parentOptional = FindWindowWithOptional(pWin)->optional;
|
|
|
|
optional->visual = parentOptional->visual;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pWin->cursorIsNone) {
|
2013-09-28 09:36:30 -06:00
|
|
|
optional->cursor = RefCursor(parentOptional->cursor);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
optional->cursor = None;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
optional->colormap = parentOptional->colormap;
|
|
|
|
pWin->optional = optional;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/*
|
|
|
|
* 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.
|
2015-09-16 13:10:19 -06:00
|
|
|
*
|
2009-09-06 13:44:18 -06:00
|
|
|
* CursorIsNone of the window struct is NOT modified if you set a device
|
2015-09-16 13:10:19 -06:00
|
|
|
* cursor.
|
2009-09-06 13:44:18 -06:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ChangeWindowDeviceCursor(WindowPtr pWin, DeviceIntPtr pDev, CursorPtr pCursor)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (WindowSeekDeviceCursor(pWin, pDev, &pNode, &pPrev)) {
|
2009-09-06 13:44:18 -06:00
|
|
|
/* has device cursor */
|
|
|
|
|
|
|
|
if (pNode->cursor == pCursor)
|
|
|
|
return Success;
|
|
|
|
|
|
|
|
pOldCursor = pNode->cursor;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pCursor) { /* remove from list */
|
|
|
|
if (pPrev)
|
|
|
|
pPrev->next = pNode->next;
|
|
|
|
else
|
|
|
|
/* first item in list */
|
|
|
|
pWin->optional->deviceCursors = pNode->next;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pNode);
|
2010-07-27 13:02:24 -06:00
|
|
|
goto out;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2009-09-06 13:44:18 -06:00
|
|
|
/* no device cursor yet */
|
|
|
|
DevCursNodePtr pNewNode;
|
|
|
|
|
|
|
|
if (!pCursor)
|
|
|
|
return Success;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pNewNode = malloc(sizeof(DevCursNodeRec));
|
2009-09-06 13:44:18 -06:00
|
|
|
pNewNode->dev = pDev;
|
|
|
|
pNewNode->next = pWin->optional->deviceCursors;
|
|
|
|
pWin->optional->deviceCursors = pNewNode;
|
|
|
|
pNode = pNewNode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pCursor && WindowParentHasDeviceCursor(pWin, pDev, pCursor))
|
|
|
|
pNode->cursor = None;
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2013-09-28 09:36:30 -06:00
|
|
|
pNode->cursor = RefCursor(pCursor);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
pNode = pPrev = NULL;
|
|
|
|
/* fix up children */
|
2012-06-10 07:21:05 -06:00
|
|
|
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) {
|
|
|
|
if (WindowSeekDeviceCursor(pChild, pDev, &pNode, &pPrev)) {
|
|
|
|
if (pNode->cursor == None) { /* inherited from parent */
|
2013-09-28 09:36:30 -06:00
|
|
|
pNode->cursor = RefCursor(pOldCursor);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else if (pNode->cursor == pCursor) {
|
2009-09-06 13:44:18 -06:00
|
|
|
pNode->cursor = None;
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeCursor(pCursor, (Cursor) 0); /* fix up refcnt */
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
out:
|
2014-05-02 13:27:46 -06:00
|
|
|
CursorVisible = TRUE;
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (pWin->realized)
|
|
|
|
WindowHasNewCursor(pWin);
|
|
|
|
|
|
|
|
if (pOldCursor)
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeCursor(pOldCursor, (Cursor) 0);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
/* FIXME: We SHOULD check for an error value here XXX
|
2009-09-06 13:44:18 -06:00
|
|
|
(comment taken from ChangeWindowAttributes) */
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->ChangeWindowAttributes) (pWin, CWCursor);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get device cursor for given device or None if none is set */
|
2010-07-27 13:02:24 -06:00
|
|
|
CursorPtr
|
2009-09-06 13:44:18 -06:00
|
|
|
WindowGetDeviceCursor(WindowPtr pWin, DeviceIntPtr pDev)
|
|
|
|
{
|
|
|
|
DevCursorList pList;
|
|
|
|
|
|
|
|
if (!pWin->optional || !pWin->optional->deviceCursors)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pList = pWin->optional->deviceCursors;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
while (pList) {
|
|
|
|
if (pList->dev == pDev) {
|
|
|
|
if (pList->cursor == None) /* inherited from parent */
|
2009-09-06 13:44:18 -06:00
|
|
|
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.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool
|
|
|
|
WindowSeekDeviceCursor(WindowPtr pWin,
|
|
|
|
DeviceIntPtr pDev,
|
|
|
|
DevCursNodePtr * pNode, DevCursNodePtr * pPrev)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
DevCursorList pList;
|
|
|
|
|
|
|
|
if (!pWin->optional)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pList = pWin->optional->deviceCursors;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pList && pList->dev == pDev) {
|
2009-09-06 13:44:18 -06:00
|
|
|
*pNode = pList;
|
|
|
|
*pPrev = NULL;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
while (pList) {
|
|
|
|
if (pList->next) {
|
|
|
|
if (pList->next->dev == pDev) {
|
2009-09-06 13:44:18 -06:00
|
|
|
*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
|
2015-09-16 13:10:19 -06:00
|
|
|
* otherwise
|
2012-06-10 07:21:05 -06:00
|
|
|
*/
|
|
|
|
static Bool
|
|
|
|
WindowParentHasDeviceCursor(WindowPtr pWin,
|
|
|
|
DeviceIntPtr pDev, CursorPtr pCursor)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
WindowPtr pParent;
|
|
|
|
DevCursNodePtr pParentNode, pParentPrev;
|
|
|
|
|
|
|
|
pParent = pWin->parent;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (pParent) {
|
|
|
|
if (WindowSeekDeviceCursor(pParent, pDev, &pParentNode, &pParentPrev)) {
|
2009-09-06 13:44:18 -06:00
|
|
|
/* if there is a node in the list, the win has a dev cursor */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pParentNode->cursor) /* inherited. */
|
2010-12-21 13:10:44 -07:00
|
|
|
pParent = pParent->parent;
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (pParentNode->cursor == pCursor) /* inherit */
|
2009-09-06 13:44:18 -06:00
|
|
|
return TRUE;
|
2012-06-10 07:21:05 -06:00
|
|
|
else /* different cursor */
|
2009-09-06 13:44:18 -06:00
|
|
|
return FALSE;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else
|
2009-09-06 13:44:18 -06:00
|
|
|
/* parent does not have a device cursor for our device */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/*
|
|
|
|
* SetRootClip --
|
|
|
|
* Enable or disable rendering to the screen by
|
|
|
|
* setting the root clip list and revalidating
|
|
|
|
* all of the windows
|
|
|
|
*/
|
|
|
|
void
|
2016-05-29 06:02:34 -06:00
|
|
|
SetRootClip(ScreenPtr pScreen, int enable)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr pWin = pScreen->root;
|
|
|
|
WindowPtr pChild;
|
|
|
|
Bool WasViewable;
|
|
|
|
Bool anyMarked = FALSE;
|
|
|
|
WindowPtr pLayerWin;
|
|
|
|
BoxRec box;
|
2016-05-29 06:02:34 -06:00
|
|
|
enum RootClipMode mode = enable;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
if (!pWin)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
WasViewable = (Bool) (pWin->viewable);
|
|
|
|
if (WasViewable) {
|
|
|
|
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) {
|
|
|
|
(void) (*pScreen->MarkOverlappedWindows) (pChild,
|
|
|
|
pChild, &pLayerWin);
|
|
|
|
}
|
|
|
|
(*pScreen->MarkWindow) (pWin);
|
|
|
|
anyMarked = TRUE;
|
|
|
|
if (pWin->valdata) {
|
|
|
|
if (HasBorder(pWin)) {
|
|
|
|
RegionPtr borderVisible;
|
|
|
|
|
|
|
|
borderVisible = RegionCreate(NullBox, 1);
|
|
|
|
RegionSubtract(borderVisible,
|
|
|
|
&pWin->borderClip, &pWin->winSize);
|
|
|
|
pWin->valdata->before.borderVisible = borderVisible;
|
|
|
|
}
|
|
|
|
pWin->valdata->before.resized = TRUE;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
if (mode != ROOT_CLIP_NONE) {
|
|
|
|
pWin->drawable.width = pScreen->width;
|
|
|
|
pWin->drawable.height = pScreen->height;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = pScreen->width;
|
|
|
|
box.y2 = pScreen->height;
|
2016-05-29 06:02:34 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionInit(&pWin->winSize, &box, 1);
|
|
|
|
RegionInit(&pWin->borderSize, &box, 1);
|
2016-05-29 06:02:34 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Use REGION_BREAK to avoid optimizations in ValidateTree
|
|
|
|
* that assume the root borderClip can't change well, normally
|
|
|
|
* it doesn't...)
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionBreak(&pWin->clipList);
|
2016-05-29 06:02:34 -06:00
|
|
|
|
|
|
|
/* For INPUT_ONLY, empty the borderClip so no rendering will ever
|
|
|
|
* be attempted to the screen pixmap (only redirected windows),
|
|
|
|
* but we keep borderSize as full regardless. */
|
|
|
|
if (WasViewable && mode == ROOT_CLIP_FULL)
|
|
|
|
RegionReset(&pWin->borderClip, &box);
|
|
|
|
else
|
|
|
|
RegionEmpty(&pWin->borderClip);
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
RegionEmpty(&pWin->borderClip);
|
|
|
|
RegionBreak(&pWin->clipList);
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (WasViewable) {
|
|
|
|
if (pWin->firstChild) {
|
|
|
|
anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin->firstChild,
|
|
|
|
pWin->firstChild,
|
2015-09-16 13:10:19 -06:00
|
|
|
NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
(*pScreen->MarkWindow) (pWin);
|
|
|
|
anyMarked = TRUE;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
if (anyMarked) {
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->ValidateTree) (pWin, NullWindow, VTOther);
|
|
|
|
(*pScreen->HandleExposures) (pWin);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (pScreen->PostValidateTree)
|
|
|
|
(*pScreen->PostValidateTree) (pWin, NullWindow, VTOther);
|
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
if (pWin->realized)
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowsRestructured();
|
2011-11-05 07:32:40 -06:00
|
|
|
FlushAllOutput();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
|
|
|
|
VisualPtr
|
|
|
|
WindowGetVisual(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;
|
|
|
|
}
|