2010-07-27 13:02:24 -06:00
|
|
|
|
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.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
2010-12-05 08:36:02 -07:00
|
|
|
#include <X11/extensions/shapeconst.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "regionstr.h"
|
|
|
|
#include "region.h"
|
|
|
|
#include "mi.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "pixmapstr.h"
|
|
|
|
#include "mivalidate.h"
|
2014-09-27 11:52:59 -06:00
|
|
|
#include "inputstr.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2009-09-06 13:44:18 -06:00
|
|
|
miClearToBackground(WindowPtr pWin,
|
2012-06-10 07:21:05 -06:00
|
|
|
int x, int y, int w, int h, Bool generateExposures)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
BoxRec box;
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionRec reg;
|
|
|
|
BoxPtr extents;
|
|
|
|
int x1, y1, x2, y2;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* compute everything using ints to avoid overflow */
|
|
|
|
|
|
|
|
x1 = pWin->drawable.x + x;
|
|
|
|
y1 = pWin->drawable.y + y;
|
|
|
|
if (w)
|
|
|
|
x2 = x1 + (int) w;
|
|
|
|
else
|
|
|
|
x2 = x1 + (int) pWin->drawable.width - (int) x;
|
|
|
|
if (h)
|
2012-06-10 07:21:05 -06:00
|
|
|
y2 = y1 + h;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
|
|
|
y2 = y1 + (int) pWin->drawable.height - (int) y;
|
|
|
|
|
|
|
|
extents = &pWin->clipList.extents;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* clip the resulting rectangle to the window clipList extents. This
|
|
|
|
* makes sure that the result will fit in a box, given that the
|
|
|
|
* screen is < 32768 on a side.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (x1 < extents->x1)
|
2012-06-10 07:21:05 -06:00
|
|
|
x1 = extents->x1;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (x2 > extents->x2)
|
2012-06-10 07:21:05 -06:00
|
|
|
x2 = extents->x2;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (y1 < extents->y1)
|
2012-06-10 07:21:05 -06:00
|
|
|
y1 = extents->y1;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (y2 > extents->y2)
|
2012-06-10 07:21:05 -06:00
|
|
|
y2 = extents->y2;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (x2 <= x1 || y2 <= y1) {
|
|
|
|
x2 = x1 = 0;
|
|
|
|
y2 = y1 = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
box.x1 = x1;
|
|
|
|
box.x2 = x2;
|
|
|
|
box.y1 = y1;
|
|
|
|
box.y2 = y2;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionInit(®, &box, 1);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionIntersect(®, ®, &pWin->clipList);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (generateExposures)
|
2015-09-16 13:10:19 -06:00
|
|
|
(*pWin->drawable.pScreen->WindowExposures) (pWin, ®);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (pWin->backgroundState != None)
|
2016-05-29 06:02:34 -06:00
|
|
|
pWin->drawable.pScreen->PaintWindow(pWin, ®, PW_BACKGROUND);
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionUninit(®);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-09-06 13:44:18 -06:00
|
|
|
miMarkWindow(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
ValidatePtr val;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pWin->valdata)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
val = (ValidatePtr) xnfalloc(sizeof(ValidateRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
val->before.oldAbsCorner.x = pWin->drawable.x;
|
|
|
|
val->before.oldAbsCorner.y = pWin->drawable.y;
|
|
|
|
val->before.borderVisible = NullRegion;
|
|
|
|
val->before.resized = FALSE;
|
|
|
|
pWin->valdata = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2009-09-06 13:44:18 -06:00
|
|
|
miMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst, WindowPtr *ppLayerWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
BoxPtr box;
|
|
|
|
WindowPtr pChild, pLast;
|
2006-11-26 11:13:41 -07:00
|
|
|
Bool anyMarked = FALSE;
|
|
|
|
MarkWindowProcPtr MarkWindow = pWin->drawable.pScreen->MarkWindow;
|
|
|
|
|
|
|
|
/* single layered systems are easy */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (ppLayerWin)
|
|
|
|
*ppLayerWin = pWin;
|
|
|
|
|
|
|
|
if (pWin == pFirst) {
|
|
|
|
/* Blindly mark pWin and all of its inferiors. This is a slight
|
|
|
|
* overkill if there are mapped windows that outside pWin's border,
|
|
|
|
* but it's better than wasting time on RectIn checks.
|
|
|
|
*/
|
|
|
|
pChild = pWin;
|
|
|
|
while (1) {
|
|
|
|
if (pChild->viewable) {
|
|
|
|
if (RegionBroken(&pChild->winSize))
|
|
|
|
SetWinSize(pChild);
|
|
|
|
if (RegionBroken(&pChild->borderSize))
|
|
|
|
SetBorderSize(pChild);
|
|
|
|
(*MarkWindow) (pChild);
|
|
|
|
if (pChild->firstChild) {
|
|
|
|
pChild = pChild->firstChild;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!pChild->nextSib && (pChild != pWin))
|
|
|
|
pChild = pChild->parent;
|
|
|
|
if (pChild == pWin)
|
|
|
|
break;
|
|
|
|
pChild = pChild->nextSib;
|
|
|
|
}
|
|
|
|
anyMarked = TRUE;
|
|
|
|
pFirst = pFirst->nextSib;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((pChild = pFirst)) {
|
|
|
|
box = RegionExtents(&pWin->borderSize);
|
|
|
|
pLast = pChild->parent->lastChild;
|
|
|
|
while (1) {
|
|
|
|
if (pChild->viewable) {
|
|
|
|
if (RegionBroken(&pChild->winSize))
|
|
|
|
SetWinSize(pChild);
|
|
|
|
if (RegionBroken(&pChild->borderSize))
|
|
|
|
SetBorderSize(pChild);
|
|
|
|
if (RegionContainsRect(&pChild->borderSize, box)) {
|
|
|
|
(*MarkWindow) (pChild);
|
|
|
|
anyMarked = TRUE;
|
|
|
|
if (pChild->firstChild) {
|
|
|
|
pChild = pChild->firstChild;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!pChild->nextSib && (pChild != pLast))
|
|
|
|
pChild = pChild->parent;
|
|
|
|
if (pChild == pLast)
|
|
|
|
break;
|
|
|
|
pChild = pChild->nextSib;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (anyMarked)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*MarkWindow) (pWin->parent);
|
2006-11-26 11:13:41 -07:00
|
|
|
return anyMarked;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****
|
|
|
|
* miHandleValidateExposures(pWin)
|
|
|
|
* starting at pWin, draw background in any windows that have exposure
|
|
|
|
* regions, translate the regions, restore any backing store,
|
|
|
|
* and then send any regions still exposed to the client
|
|
|
|
*****/
|
2009-09-06 13:44:18 -06:00
|
|
|
void
|
|
|
|
miHandleValidateExposures(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pChild;
|
|
|
|
ValidatePtr val;
|
2006-11-26 11:13:41 -07:00
|
|
|
WindowExposuresProcPtr WindowExposures;
|
|
|
|
|
|
|
|
pChild = pWin;
|
|
|
|
WindowExposures = pChild->drawable.pScreen->WindowExposures;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (1) {
|
|
|
|
if ((val = pChild->valdata)) {
|
|
|
|
if (RegionNotEmpty(&val->after.borderExposed))
|
2016-05-29 06:02:34 -06:00
|
|
|
pWin->drawable.pScreen->PaintWindow(pChild,
|
|
|
|
&val->after.borderExposed,
|
|
|
|
PW_BORDER);
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionUninit(&val->after.borderExposed);
|
2015-09-16 13:10:19 -06:00
|
|
|
(*WindowExposures) (pChild, &val->after.exposed);
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionUninit(&val->after.exposed);
|
|
|
|
free(val);
|
|
|
|
pChild->valdata = NULL;
|
|
|
|
if (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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-09-06 13:44:18 -06:00
|
|
|
miMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pNextSib, VTKind kind)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
WindowPtr pParent;
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool WasViewable = (Bool) (pWin->viewable);
|
2006-11-26 11:13:41 -07:00
|
|
|
short bw;
|
|
|
|
RegionPtr oldRegion = NULL;
|
|
|
|
DDXPointRec oldpt;
|
|
|
|
Bool anyMarked = FALSE;
|
2007-11-24 10:55:21 -07:00
|
|
|
ScreenPtr pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
WindowPtr windowToValidate;
|
|
|
|
WindowPtr pLayerWin;
|
|
|
|
|
|
|
|
/* if this is a root window, can't be moved */
|
|
|
|
if (!(pParent = pWin->parent))
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreen = pWin->drawable.pScreen;
|
2012-06-10 07:21:05 -06:00
|
|
|
bw = wBorderWidth(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
oldpt.x = pWin->drawable.x;
|
|
|
|
oldpt.y = pWin->drawable.y;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (WasViewable) {
|
|
|
|
oldRegion = RegionCreate(NullBox, 1);
|
|
|
|
RegionCopy(oldRegion, &pWin->borderClip);
|
|
|
|
anyMarked = (*pScreen->MarkOverlappedWindows) (pWin, pWin, &pLayerWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->origin.x = x + (int) bw;
|
|
|
|
pWin->origin.y = y + (int) bw;
|
|
|
|
x = pWin->drawable.x = pParent->drawable.x + x + (int) bw;
|
|
|
|
y = 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
|
|
|
SetWinSize(pWin);
|
|
|
|
SetBorderSize(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->PositionWindow) (pWin, x, y);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
windowToValidate = MoveWindowInStack(pWin, pNextSib);
|
|
|
|
|
|
|
|
ResizeChildrenWinSize(pWin, x - oldpt.x, y - oldpt.y, 0, 0);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (WasViewable) {
|
|
|
|
if (pLayerWin == pWin)
|
|
|
|
anyMarked |= (*pScreen->MarkOverlappedWindows)
|
|
|
|
(pWin, windowToValidate, NULL);
|
|
|
|
else
|
|
|
|
anyMarked |= (*pScreen->MarkOverlappedWindows)
|
|
|
|
(pWin, pLayerWin, NULL);
|
|
|
|
|
|
|
|
if (anyMarked) {
|
|
|
|
(*pScreen->ValidateTree) (pLayerWin->parent, NullWindow, kind);
|
|
|
|
(*pWin->drawable.pScreen->CopyWindow) (pWin, oldpt, oldRegion);
|
|
|
|
RegionDestroy(oldRegion);
|
|
|
|
/* XXX need to retile border if ParentRelative origin */
|
|
|
|
(*pScreen->HandleExposures) (pLayerWin->parent);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (pScreen->PostValidateTree)
|
|
|
|
(*pScreen->PostValidateTree) (pLayerWin->parent, NULL, 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
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* pValid is a region of the screen which has been
|
|
|
|
* successfully copied -- recomputed exposed regions for affected windows
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
miRecomputeExposures(WindowPtr pWin, void *value)
|
2012-06-10 07:21:05 -06:00
|
|
|
{ /* must conform to VisitWindowProcPtr */
|
|
|
|
RegionPtr pValid = (RegionPtr) value;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWin->valdata) {
|
2009-09-06 13:44:18 -06:00
|
|
|
#ifdef COMPOSITE
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
* Redirected windows are not affected by parent window
|
|
|
|
* gravity manipulations, so don't recompute their
|
|
|
|
* exposed areas here.
|
|
|
|
*/
|
|
|
|
if (pWin->redirectDraw != RedirectDrawNone)
|
|
|
|
return WT_DONTWALKCHILDREN;
|
2009-09-06 13:44:18 -06:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
* compute exposed regions of this window
|
|
|
|
*/
|
|
|
|
RegionSubtract(&pWin->valdata->after.exposed, &pWin->clipList, pValid);
|
|
|
|
/*
|
|
|
|
* compute exposed regions of the border
|
|
|
|
*/
|
|
|
|
RegionSubtract(&pWin->valdata->after.borderExposed,
|
|
|
|
&pWin->borderClip, &pWin->winSize);
|
|
|
|
RegionSubtract(&pWin->valdata->after.borderExposed,
|
|
|
|
&pWin->valdata->after.borderExposed, pValid);
|
|
|
|
return WT_WALKCHILDREN;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return WT_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-09-16 13:10:19 -06:00
|
|
|
miResizeWindow(WindowPtr pWin, int x, int y, unsigned int w, unsigned int h,
|
|
|
|
WindowPtr pSib)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
WindowPtr pParent;
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool WasViewable = (Bool) (pWin->viewable);
|
|
|
|
unsigned short width = pWin->drawable.width, height = pWin->drawable.height;
|
|
|
|
short oldx = pWin->drawable.x, oldy = pWin->drawable.y;
|
|
|
|
int bw = wBorderWidth(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
short dw, dh;
|
|
|
|
DDXPointRec oldpt;
|
|
|
|
RegionPtr oldRegion = NULL;
|
|
|
|
Bool anyMarked = FALSE;
|
2007-11-24 10:55:21 -07:00
|
|
|
ScreenPtr pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
WindowPtr pFirstChange;
|
2007-11-24 10:55:21 -07:00
|
|
|
WindowPtr pChild;
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionPtr gravitate[StaticGravity + 1];
|
2007-11-24 10:55:21 -07:00
|
|
|
unsigned g;
|
2012-06-10 07:21:05 -06:00
|
|
|
int nx, ny; /* destination x,y */
|
|
|
|
int newx, newy; /* new inner window position */
|
|
|
|
RegionPtr pRegion = NULL;
|
|
|
|
RegionPtr destClip; /* portions of destination already written */
|
|
|
|
RegionPtr oldWinClip = NULL; /* old clip list for window */
|
|
|
|
RegionPtr borderVisible = NullRegion; /* visible area of the border */
|
|
|
|
Bool shrunk = FALSE; /* shrunk in an inner dimension */
|
|
|
|
Bool moved = FALSE; /* window position changed */
|
|
|
|
WindowPtr pLayerWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* if this is a root window, can't be resized */
|
|
|
|
if (!(pParent = pWin->parent))
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
newx = pParent->drawable.x + x + bw;
|
|
|
|
newy = pParent->drawable.y + y + bw;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (WasViewable) {
|
|
|
|
anyMarked = FALSE;
|
|
|
|
/*
|
|
|
|
* save the visible region of the window
|
|
|
|
*/
|
|
|
|
oldRegion = RegionCreate(NullBox, 1);
|
|
|
|
RegionCopy(oldRegion, &pWin->winSize);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* categorize child windows into regions to be moved
|
|
|
|
*/
|
|
|
|
for (g = 0; g <= StaticGravity; g++)
|
|
|
|
gravitate[g] = (RegionPtr) NULL;
|
|
|
|
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) {
|
|
|
|
g = pChild->winGravity;
|
|
|
|
if (g != UnmapGravity) {
|
|
|
|
if (!gravitate[g])
|
|
|
|
gravitate[g] = RegionCreate(NullBox, 1);
|
|
|
|
RegionUnion(gravitate[g], gravitate[g], &pChild->borderClip);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UnmapWindow(pChild, TRUE);
|
|
|
|
anyMarked = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin, pWin, &pLayerWin);
|
|
|
|
|
|
|
|
oldWinClip = NULL;
|
|
|
|
if (pWin->bitGravity != ForgetGravity) {
|
|
|
|
oldWinClip = RegionCreate(NullBox, 1);
|
|
|
|
RegionCopy(oldWinClip, &pWin->clipList);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* if the window is changing size, borderExposed
|
|
|
|
* can't be computed correctly without some help.
|
|
|
|
*/
|
|
|
|
if (pWin->drawable.height > h || pWin->drawable.width > w)
|
|
|
|
shrunk = TRUE;
|
|
|
|
|
|
|
|
if (newx != oldx || newy != oldy)
|
|
|
|
moved = TRUE;
|
|
|
|
|
|
|
|
if ((pWin->drawable.height != h || pWin->drawable.width != w) &&
|
|
|
|
HasBorder(pWin)) {
|
|
|
|
borderVisible = RegionCreate(NullBox, 1);
|
|
|
|
/* for tiled borders, we punt and draw the whole thing */
|
|
|
|
if (pWin->borderIsPixel || !moved) {
|
|
|
|
if (shrunk || moved)
|
|
|
|
RegionSubtract(borderVisible,
|
|
|
|
&pWin->borderClip, &pWin->winSize);
|
|
|
|
else
|
|
|
|
RegionCopy(borderVisible, &pWin->borderClip);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
pWin->origin.x = x + bw;
|
|
|
|
pWin->origin.y = y + bw;
|
|
|
|
pWin->drawable.height = h;
|
|
|
|
pWin->drawable.width = w;
|
|
|
|
|
|
|
|
x = pWin->drawable.x = newx;
|
|
|
|
y = pWin->drawable.y = newy;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
SetWinSize(pWin);
|
|
|
|
SetBorderSize(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
dw = (int) w - (int) width;
|
|
|
|
dh = (int) h - (int) height;
|
2006-11-26 11:13:41 -07:00
|
|
|
ResizeChildrenWinSize(pWin, x - oldx, y - oldy, dw, dh);
|
|
|
|
|
|
|
|
/* let the hardware adjust background and border pixmaps, if any */
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->PositionWindow) (pWin, x, y);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pFirstChange = MoveWindowInStack(pWin, pSib);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (WasViewable) {
|
|
|
|
pRegion = RegionCreate(NullBox, 1);
|
|
|
|
|
|
|
|
if (pLayerWin == pWin)
|
|
|
|
anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin, pFirstChange,
|
|
|
|
NULL);
|
|
|
|
else
|
|
|
|
anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin, pLayerWin,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (pWin->valdata) {
|
|
|
|
pWin->valdata->before.resized = TRUE;
|
|
|
|
pWin->valdata->before.borderVisible = borderVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (anyMarked)
|
|
|
|
(*pScreen->ValidateTree) (pLayerWin->parent, pFirstChange, VTOther);
|
|
|
|
/*
|
|
|
|
* the entire window is trashed unless bitGravity
|
|
|
|
* recovers portions of it
|
|
|
|
*/
|
|
|
|
RegionCopy(&pWin->valdata->after.exposed, &pWin->clipList);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
GravityTranslate(x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
|
|
|
|
|
|
|
|
if (WasViewable) {
|
|
|
|
/* avoid the border */
|
|
|
|
if (HasBorder(pWin)) {
|
|
|
|
int offx, offy, dx, dy;
|
|
|
|
|
|
|
|
/* kruft to avoid double translates for each gravity */
|
|
|
|
offx = 0;
|
|
|
|
offy = 0;
|
|
|
|
for (g = 0; g <= StaticGravity; g++) {
|
|
|
|
if (!gravitate[g])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* align winSize to gravitate[g].
|
|
|
|
* winSize is in new coordinates,
|
|
|
|
* gravitate[g] is still in old coordinates */
|
|
|
|
GravityTranslate(x, y, oldx, oldy, dw, dh, g, &nx, &ny);
|
|
|
|
|
|
|
|
dx = (oldx - nx) - offx;
|
|
|
|
dy = (oldy - ny) - offy;
|
|
|
|
if (dx || dy) {
|
|
|
|
RegionTranslate(&pWin->winSize, dx, dy);
|
|
|
|
offx += dx;
|
|
|
|
offy += dy;
|
|
|
|
}
|
|
|
|
RegionIntersect(gravitate[g], gravitate[g], &pWin->winSize);
|
|
|
|
}
|
|
|
|
/* get winSize back where it belongs */
|
|
|
|
if (offx || offy)
|
|
|
|
RegionTranslate(&pWin->winSize, -offx, -offy);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* add screen bits to the appropriate bucket
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (oldWinClip) {
|
|
|
|
/*
|
|
|
|
* clip to new clipList
|
|
|
|
*/
|
|
|
|
RegionCopy(pRegion, oldWinClip);
|
|
|
|
RegionTranslate(pRegion, nx - oldx, ny - oldy);
|
|
|
|
RegionIntersect(oldWinClip, pRegion, &pWin->clipList);
|
|
|
|
/*
|
|
|
|
* don't step on any gravity bits which will be copied after this
|
|
|
|
* region. Note -- this assumes that the regions will be copied
|
|
|
|
* in gravity order.
|
|
|
|
*/
|
|
|
|
for (g = pWin->bitGravity + 1; g <= StaticGravity; g++) {
|
|
|
|
if (gravitate[g])
|
|
|
|
RegionSubtract(oldWinClip, oldWinClip, gravitate[g]);
|
|
|
|
}
|
|
|
|
RegionTranslate(oldWinClip, oldx - nx, oldy - ny);
|
|
|
|
g = pWin->bitGravity;
|
|
|
|
if (!gravitate[g])
|
|
|
|
gravitate[g] = oldWinClip;
|
|
|
|
else {
|
|
|
|
RegionUnion(gravitate[g], gravitate[g], oldWinClip);
|
|
|
|
RegionDestroy(oldWinClip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* move the bits on the screen
|
|
|
|
*/
|
|
|
|
|
|
|
|
destClip = NULL;
|
|
|
|
|
|
|
|
for (g = 0; g <= StaticGravity; g++) {
|
|
|
|
if (!gravitate[g])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
GravityTranslate(x, y, oldx, oldy, dw, dh, g, &nx, &ny);
|
|
|
|
|
|
|
|
oldpt.x = oldx + (x - nx);
|
|
|
|
oldpt.y = oldy + (y - ny);
|
|
|
|
|
|
|
|
/* Note that gravitate[g] is *translated* by CopyWindow */
|
|
|
|
|
|
|
|
/* only copy the remaining useful bits */
|
|
|
|
|
|
|
|
RegionIntersect(gravitate[g], gravitate[g], oldRegion);
|
|
|
|
|
|
|
|
/* clip to not overwrite already copied areas */
|
|
|
|
|
|
|
|
if (destClip) {
|
|
|
|
RegionTranslate(destClip, oldpt.x - x, oldpt.y - y);
|
|
|
|
RegionSubtract(gravitate[g], gravitate[g], destClip);
|
|
|
|
RegionTranslate(destClip, x - oldpt.x, y - oldpt.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* and move those bits */
|
|
|
|
|
|
|
|
if (oldpt.x != x || oldpt.y != y
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef COMPOSITE
|
2012-06-10 07:21:05 -06:00
|
|
|
|| pWin->redirectDraw
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
) {
|
|
|
|
(*pWin->drawable.pScreen->CopyWindow) (pWin, oldpt,
|
|
|
|
gravitate[g]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove any overwritten bits from the remaining useful bits */
|
|
|
|
|
|
|
|
RegionSubtract(oldRegion, oldRegion, gravitate[g]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* recompute exposed regions of child windows
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) {
|
|
|
|
if (pChild->winGravity != g)
|
|
|
|
continue;
|
|
|
|
RegionIntersect(pRegion, &pChild->borderClip, gravitate[g]);
|
2014-09-27 11:52:59 -06:00
|
|
|
TraverseTree(pChild, miRecomputeExposures, (void *) pRegion);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* remove the successfully copied regions of the
|
|
|
|
* window from its exposed region
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (g == pWin->bitGravity)
|
|
|
|
RegionSubtract(&pWin->valdata->after.exposed,
|
|
|
|
&pWin->valdata->after.exposed, gravitate[g]);
|
|
|
|
if (!destClip)
|
|
|
|
destClip = gravitate[g];
|
|
|
|
else {
|
|
|
|
RegionUnion(destClip, destClip, gravitate[g]);
|
|
|
|
RegionDestroy(gravitate[g]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegionDestroy(oldRegion);
|
|
|
|
RegionDestroy(pRegion);
|
|
|
|
if (destClip)
|
|
|
|
RegionDestroy(destClip);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (anyMarked) {
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->HandleExposures) (pLayerWin->parent);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (pScreen->PostValidateTree)
|
|
|
|
(*pScreen->PostValidateTree) (pLayerWin->parent, pFirstChange,
|
|
|
|
VTOther);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
WindowPtr
|
2009-09-06 13:44:18 -06:00
|
|
|
miGetLayerWindow(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return pWin->firstChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******
|
|
|
|
*
|
|
|
|
* miSetShape
|
|
|
|
* The border/window shape has changed. Recompute winSize/borderSize
|
|
|
|
* and send appropriate exposure events
|
|
|
|
*/
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
void
|
2010-12-05 08:36:02 -07:00
|
|
|
miSetShape(WindowPtr pWin, int kind)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool WasViewable = (Bool) (pWin->viewable);
|
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
|
|
|
Bool anyMarked = FALSE;
|
|
|
|
WindowPtr pLayerWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (kind != ShapeInput) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (WasViewable) {
|
|
|
|
anyMarked = (*pScreen->MarkOverlappedWindows) (pWin, pWin,
|
|
|
|
&pLayerWin);
|
|
|
|
if (pWin->valdata) {
|
|
|
|
if (HasBorder(pWin)) {
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionPtr borderVisible;
|
|
|
|
|
|
|
|
borderVisible = RegionCreate(NullBox, 1);
|
|
|
|
RegionSubtract(borderVisible,
|
2012-06-10 07:21:05 -06:00
|
|
|
&pWin->borderClip, &pWin->winSize);
|
2010-12-05 08:36:02 -07:00
|
|
|
pWin->valdata->before.borderVisible = borderVisible;
|
|
|
|
}
|
|
|
|
pWin->valdata->before.resized = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
SetWinSize(pWin);
|
|
|
|
SetBorderSize(pWin);
|
2010-12-05 08:36:02 -07:00
|
|
|
|
|
|
|
ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (WasViewable) {
|
|
|
|
anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin, pWin, NULL);
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
if (anyMarked) {
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->ValidateTree) (pLayerWin->parent, NullWindow,
|
|
|
|
VTOther);
|
|
|
|
(*pScreen->HandleExposures) (pLayerWin->parent);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (pScreen->PostValidateTree)
|
|
|
|
(*pScreen->PostValidateTree) (pLayerWin->parent, NULL,
|
|
|
|
VTOther);
|
|
|
|
}
|
2010-12-05 08:36:02 -07: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
|
|
|
CheckCursorConfinement(pWin);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Keeps the same inside(!) origin */
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
void
|
|
|
|
miChangeBorderWidth(WindowPtr pWin, unsigned int width)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int oldwidth;
|
|
|
|
Bool anyMarked = FALSE;
|
2007-11-24 10:55:21 -07:00
|
|
|
ScreenPtr pScreen;
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool WasViewable = (Bool) (pWin->viewable);
|
2006-11-26 11:13:41 -07:00
|
|
|
Bool HadBorder;
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr pLayerWin;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
oldwidth = wBorderWidth(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (oldwidth == width)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
HadBorder = HasBorder(pWin);
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
if (WasViewable && width < oldwidth)
|
2012-06-10 07:21:05 -06:00
|
|
|
anyMarked = (*pScreen->MarkOverlappedWindows) (pWin, pWin, &pLayerWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pWin->borderWidth = width;
|
2012-06-10 07:21:05 -06:00
|
|
|
SetBorderSize(pWin);
|
|
|
|
|
|
|
|
if (WasViewable) {
|
|
|
|
if (width > oldwidth) {
|
|
|
|
anyMarked = (*pScreen->MarkOverlappedWindows) (pWin, pWin,
|
|
|
|
&pLayerWin);
|
|
|
|
/*
|
|
|
|
* save the old border visible region to correctly compute
|
|
|
|
* borderExposed.
|
|
|
|
*/
|
|
|
|
if (pWin->valdata && HadBorder) {
|
|
|
|
RegionPtr borderVisible;
|
|
|
|
|
|
|
|
borderVisible = RegionCreate(NULL, 1);
|
|
|
|
RegionSubtract(borderVisible,
|
|
|
|
&pWin->borderClip, &pWin->winSize);
|
|
|
|
pWin->valdata->before.borderVisible = borderVisible;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (anyMarked) {
|
|
|
|
(*pScreen->ValidateTree) (pLayerWin->parent, pLayerWin, VTOther);
|
|
|
|
(*pScreen->HandleExposures) (pLayerWin->parent);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (pScreen->PostValidateTree)
|
|
|
|
(*pScreen->PostValidateTree) (pLayerWin->parent, pLayerWin,
|
|
|
|
VTOther);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-09-06 13:44:18 -06:00
|
|
|
miMarkUnrealizedWindow(WindowPtr pChild, WindowPtr pWin, Bool fromConfigure)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((pChild != pWin) || fromConfigure) {
|
|
|
|
RegionEmpty(&pChild->clipList);
|
|
|
|
if (pChild->drawable.pScreen->ClipNotify)
|
|
|
|
(*pChild->drawable.pScreen->ClipNotify) (pChild, 0, 0);
|
|
|
|
RegionEmpty(&pChild->borderClip);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
WindowPtr
|
|
|
|
miSpriteTrace(SpritePtr pSprite, int x, int y)
|
|
|
|
{
|
|
|
|
WindowPtr pWin;
|
|
|
|
BoxRec box;
|
|
|
|
|
|
|
|
pWin = DeepestSpriteWin(pSprite)->firstChild;
|
|
|
|
while (pWin) {
|
|
|
|
if ((pWin->mapped) &&
|
|
|
|
(x >= pWin->drawable.x - wBorderWidth(pWin)) &&
|
|
|
|
(x < pWin->drawable.x + (int) pWin->drawable.width +
|
|
|
|
wBorderWidth(pWin)) &&
|
|
|
|
(y >= pWin->drawable.y - wBorderWidth(pWin)) &&
|
|
|
|
(y < pWin->drawable.y + (int) pWin->drawable.height +
|
|
|
|
wBorderWidth(pWin))
|
|
|
|
/* When a window is shaped, a further check
|
|
|
|
* is made to see if the point is inside
|
|
|
|
* borderSize
|
|
|
|
*/
|
|
|
|
&& (!wBoundingShape(pWin) || PointInBorderSize(pWin, x, y))
|
|
|
|
&& (!wInputShape(pWin) ||
|
|
|
|
RegionContainsPoint(wInputShape(pWin),
|
|
|
|
x - pWin->drawable.x,
|
|
|
|
y - pWin->drawable.y, &box))
|
|
|
|
/* In rootless mode windows may be offscreen, even when
|
|
|
|
* they're in X's stack. (E.g. if the native window system
|
|
|
|
* implements some form of virtual desktop system).
|
|
|
|
*/
|
2016-05-29 06:02:34 -06:00
|
|
|
&& !pWin->unhittable) {
|
2014-09-27 11:52:59 -06:00
|
|
|
if (pSprite->spriteTraceGood >= pSprite->spriteTraceSize) {
|
|
|
|
pSprite->spriteTraceSize += 10;
|
2016-05-29 06:02:34 -06:00
|
|
|
pSprite->spriteTrace = reallocarray(pSprite->spriteTrace,
|
|
|
|
pSprite->spriteTraceSize,
|
|
|
|
sizeof(WindowPtr));
|
2014-09-27 11:52:59 -06:00
|
|
|
}
|
|
|
|
pSprite->spriteTrace[pSprite->spriteTraceGood++] = pWin;
|
|
|
|
pWin = pWin->firstChild;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pWin = pWin->nextSib;
|
|
|
|
}
|
|
|
|
return DeepestSpriteWin(pSprite);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Traversed from the root window to the window at the position x/y. While
|
|
|
|
* traversing, it sets up the traversal history in the spriteTrace array.
|
|
|
|
* After completing, the spriteTrace history is set in the following way:
|
|
|
|
* spriteTrace[0] ... root window
|
|
|
|
* spriteTrace[1] ... top level window that encloses x/y
|
|
|
|
* ...
|
|
|
|
* spriteTrace[spriteTraceGood - 1] ... window at x/y
|
|
|
|
*
|
|
|
|
* @returns the window at the given coordinates.
|
|
|
|
*/
|
|
|
|
WindowPtr
|
|
|
|
miXYToWindow(ScreenPtr pScreen, SpritePtr pSprite, int x, int y)
|
|
|
|
{
|
|
|
|
pSprite->spriteTraceGood = 1; /* root window still there */
|
|
|
|
return miSpriteTrace(pSprite, x, y);
|
|
|
|
}
|