⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 miwindow.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 3 页
字号:
/***********************************************************Copyright (c) 1987  X ConsortiumPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THEX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER INAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.Except as contained in this notice, the name of the X Consortium shall not beused in advertising or otherwise to promote the sale, use or other dealingsin this Software without prior written authorization from the X Consortium.Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.                        All Rights ReservedPermission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and thatboth that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not beused in advertising or publicity pertaining to distribution of thesoftware without specific, written prior permission.  DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORANY 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 THISSOFTWARE.******************************************************************//* $XConsortium: miwindow.c,v 5.16 94/04/17 20:28:03 dpw Exp $ */#include "X.h"#include "miscstruct.h"#include "region.h"#include "mi.h"#include "windowstr.h"#include "scrnintstr.h"#include "pixmapstr.h"#include "mivalidate.h"void miClearToBackground(pWin, x, y, w, h, generateExposures)    WindowPtr pWin;    int x,y;    int w,h;    Bool generateExposures;{    BoxRec box;    RegionRec	reg;    RegionPtr pBSReg = NullRegion;    ScreenPtr	pScreen;    BoxPtr  extents;    int	    x1, y1, x2, y2;    /* 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)        y2 = y1 + h;	    else        y2 = y1 + (int) pWin->drawable.height - (int) y;    extents = &pWin->clipList.extents;        /* 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)	x1 = extents->x1;    if (x2 > extents->x2)	x2 = extents->x2;    if (y1 < extents->y1)	y1 = extents->y1;    if (y2 > extents->y2)	y2 = extents->y2;    if (x2 <= x1 || y2 <= y1)    {	x2 = x1 = 0;	y2 = y1 = 0;    }    box.x1 = x1;    box.x2 = x2;    box.y1 = y1;    box.y2 = y2;    pScreen = pWin->drawable.pScreen;    REGION_INIT(pScreen, &reg, &box, 1);    if (pWin->backStorage)    {	/*	 * If the window has backing-store on, call through the	 * ClearToBackground vector to handle the special semantics	 * (i.e. things backing store is to be cleared out and	 * an Expose event is to be generated for those areas in backing	 * store if generateExposures is TRUE).	 */	pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h,						 generateExposures);    }    REGION_INTERSECT(pScreen, &reg, &reg, &pWin->clipList);    if (generateExposures)	(*pScreen->WindowExposures)(pWin, &reg, pBSReg);    else if (pWin->backgroundState != None)        (*pScreen->PaintWindowBackground)(pWin, &reg, PW_BACKGROUND);    REGION_UNINIT(pScreen, &reg);    if (pBSReg)	REGION_DESTROY(pScreen, pBSReg);}/* * For SaveUnders using backing-store. The idea is that when a window is mapped * with saveUnder set TRUE, any windows it obscures will have its backing * store turned on setting the DIXsaveUnder bit, * The backing-store code must be written to allow for this *//*- *----------------------------------------------------------------------- * miCheckSubSaveUnder -- *	Check all the inferiors of a window for coverage by saveUnder *	windows. Called from ChangeSaveUnder and CheckSaveUnder. *	This code is very inefficient. * * Results: *	TRUE if any windows need to have backing-store removed. * * Side Effects: *	Windows may have backing-store turned on or off. * *----------------------------------------------------------------------- */static BoolmiCheckSubSaveUnder(pParent, pFirst, pRegion)    register WindowPtr	pParent;	/* Parent to check */    WindowPtr		pFirst;		/* first reconfigured window */    RegionPtr		pRegion;	/* Initial area obscured by saveUnder */{    register WindowPtr	pChild;		/* Current child */    register ScreenPtr	pScreen;	/* Screen to use */    RegionRec		SubRegion;	/* Area of children obscured */    Bool		res = FALSE;	/* result */    Bool		subInited=FALSE;/* SubRegion initialized */    pScreen = pParent->drawable.pScreen;    if ( (pChild = pParent->firstChild) )    {	/*	 * build region above first changed window	 */	for (; pChild != pFirst; pChild = pChild->nextSib)	    if (pChild->viewable && pChild->saveUnder)		REGION_UNION(pScreen, pRegion, pRegion, &pChild->borderSize);		/*	 * check region below and including first changed window	 */	for (; pChild; pChild = pChild->nextSib)	{	    if (pChild->viewable)	    {		/*		 * don't save under nephew/niece windows;		 * use a separate region		 */		if (pChild->firstChild)		{		    if (!subInited)		    {			REGION_INIT(pScreen, &SubRegion, NullBox, 0);			subInited = TRUE;		    }		    REGION_COPY(pScreen, &SubRegion, pRegion);		    res |= miCheckSubSaveUnder(pChild, pChild->firstChild,					     &SubRegion);		}		else		{		    res |= miCheckSubSaveUnder(pChild, pChild->firstChild,					     pRegion);		}		if (pChild->saveUnder)		    REGION_UNION(pScreen, pRegion, pRegion, &pChild->borderSize);	    }	}	if (subInited)	    REGION_UNINIT(pScreen, &SubRegion);    }    /*     * Check the state of this window.	DIX save unders are     * enabled for viewable windows with some client expressing     * exposure interest and which intersect the save under region     */    if (pParent->viewable && 	((pParent->eventMask | wOtherEventMasks(pParent)) & ExposureMask) &&	REGION_NOTEMPTY(pScreen, &pParent->borderSize) &&	RECT_IN_REGION(pScreen, pRegion, REGION_EXTENTS(pScreen, 					&pParent->borderSize)) != rgnOUT)    {	if (!pParent->DIXsaveUnder)	{	    pParent->DIXsaveUnder = TRUE;	    (*pScreen->ChangeWindowAttributes) (pParent, CWBackingStore);	}    }    else    {	if (pParent->DIXsaveUnder)	{	    res = TRUE;	    pParent->DIXsaveUnder = FALSE;	}    }    return res;}/*- *----------------------------------------------------------------------- * miChangeSaveUnder -- *	Change the save-under state of a tree of windows. Called when *	a window with saveUnder TRUE is mapped/unmapped/reconfigured. *	 * Results: *	TRUE if any windows need to have backing-store removed (which *	means that PostChangeSaveUnder needs to be called later to  *	finish the job). * * Side Effects: *	Windows may have backing-store turned on or off. * *----------------------------------------------------------------------- */BoolmiChangeSaveUnder(pWin, first)    register WindowPtr	pWin;    WindowPtr		first;		/* First window to check.					 * Used when pWin was restacked */{    RegionRec	rgn;	/* Area obscured by saveUnder windows */    register ScreenPtr pScreen;    Bool	res;    if (!deltaSaveUndersViewable && !numSaveUndersViewable)	return FALSE;    numSaveUndersViewable += deltaSaveUndersViewable;    deltaSaveUndersViewable = 0;    pScreen = pWin->drawable.pScreen;    REGION_INIT(pScreen, &rgn, NullBox, 1);    res = miCheckSubSaveUnder (pWin->parent,			       pWin->saveUnder ? first : pWin->nextSib,			       &rgn);    REGION_UNINIT(pScreen, &rgn);    return res;}/*- *----------------------------------------------------------------------- * miPostChangeSaveUnder -- *	Actually turn backing-store off for those windows that no longer *	need to have it on. * * Results: *	None. * * Side Effects: *	Backing-store and SAVE_UNDER_CHANGE_BIT are turned off for those *	windows affected. * *----------------------------------------------------------------------- */voidmiPostChangeSaveUnder(pWin, pFirst)    WindowPtr		pWin;    WindowPtr		pFirst;{    register WindowPtr pParent, pChild;    ChangeWindowAttributesProcPtr ChangeWindowAttributes;    if (!(pParent = pWin->parent))	return;    ChangeWindowAttributes = pParent->drawable.pScreen->ChangeWindowAttributes;    if (!pParent->DIXsaveUnder &&	(pParent->backingStore == NotUseful) && pParent->backStorage)	(*ChangeWindowAttributes)(pParent, CWBackingStore);    if (!(pChild = pFirst))	return;    while (1)    {	if (!pChild->DIXsaveUnder &&	    (pChild->backingStore == NotUseful) && pChild->backStorage)	    (*ChangeWindowAttributes)(pChild, CWBackingStore);	if (pChild->firstChild)	{	    pChild = pChild->firstChild;	    continue;	}	while (!pChild->nextSib)	{	    pChild = pChild->parent;	    if (pChild == pParent)		return;	}	pChild = pChild->nextSib;    }}voidmiMarkWindow(pWin)    register WindowPtr pWin;{    register ValidatePtr val;    if (pWin->valdata)	return;    val = (ValidatePtr)xnfalloc(sizeof(ValidateRec));    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;}BoolmiMarkOverlappedWindows(pWin, pFirst, ppLayerWin)    WindowPtr pWin;    WindowPtr pFirst;    WindowPtr *ppLayerWin;{    register BoxPtr box;    register WindowPtr pChild, pLast;    Bool anyMarked = FALSE;    void (* MarkWindow)() = pWin->drawable.pScreen->MarkWindow;    ScreenPtr pScreen = pWin->drawable.pScreen;    /* single layered systems are easy */    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)	    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -