2006-11-26 11:13:41 -07:00
|
|
|
|
/******************************************************************************
|
2015-09-16 13:10:19 -06:00
|
|
|
|
*
|
2006-11-26 11:13:41 -07:00
|
|
|
|
* Copyright (c) 1994, 1995 Hewlett-Packard Company
|
|
|
|
|
*
|
|
|
|
|
* 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:
|
2015-09-16 13:10:19 -06:00
|
|
|
|
*
|
2006-11-26 11:13:41 -07:00
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
|
* in all copies or substantial portions of the Software.
|
2015-09-16 13:10:19 -06:00
|
|
|
|
*
|
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, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
|
* IN NO EVENT SHALL HEWLETT-PACKARD COMPANY 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.
|
2015-09-16 13:10:19 -06:00
|
|
|
|
*
|
2006-11-26 11:13:41 -07:00
|
|
|
|
* Except as contained in this notice, the name of the Hewlett-Packard
|
|
|
|
|
* Company 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 Hewlett-Packard Company.
|
2015-09-16 13:10:19 -06:00
|
|
|
|
*
|
2006-11-26 11:13:41 -07:00
|
|
|
|
* Machine-independent DBE code
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/* INCLUDES */
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
|
#include <dix-config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
|
#include "misc.h"
|
|
|
|
|
#include "os.h"
|
|
|
|
|
#include "windowstr.h"
|
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
|
#include "pixmapstr.h"
|
|
|
|
|
#include "extnsionst.h"
|
|
|
|
|
#include "dixstruct.h"
|
|
|
|
|
#include "resource.h"
|
|
|
|
|
#include "opaque.h"
|
|
|
|
|
#include "dbestruct.h"
|
|
|
|
|
#include "regionstr.h"
|
|
|
|
|
#include "gcstruct.h"
|
|
|
|
|
#include "inputstr.h"
|
|
|
|
|
#include "midbe.h"
|
2008-11-02 08:26:08 -07:00
|
|
|
|
#include "xace.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* DBE MI Procedure: miDbeGetVisualInfo
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
*
|
|
|
|
|
* This is the MI function for the DbeGetVisualInfo request. This function
|
|
|
|
|
* is called through pDbeScreenPriv->GetVisualInfo. This function is also
|
|
|
|
|
* called for the DbeAllocateBackBufferName request at the extension level;
|
|
|
|
|
* it is called by ProcDbeAllocateBackBufferName() in dbe.c.
|
|
|
|
|
*
|
|
|
|
|
* If memory allocation fails or we can not get the visual info, this
|
|
|
|
|
* function returns FALSE. Otherwise, it returns TRUE for success.
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
|
miDbeGetVisualInfo(ScreenPtr pScreen, XdbeScreenVisualInfo * pScrVisInfo)
|
2006-11-26 11:13:41 -07:00
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
|
register int i, j, k;
|
|
|
|
|
register int count;
|
|
|
|
|
DepthPtr pDepth;
|
|
|
|
|
XdbeVisualInfo *visInfo;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/* Determine number of visuals for this screen. */
|
2012-06-10 07:21:05 -06:00
|
|
|
|
for (i = 0, count = 0; i < pScreen->numDepths; i++) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
count += pScreen->allowedDepths[i].numVids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Allocate an array of XdbeVisualInfo items. */
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (!(visInfo = (XdbeVisualInfo *) malloc(count * sizeof(XdbeVisualInfo)))) {
|
|
|
|
|
return FALSE; /* memory alloc failure */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
for (i = 0, k = 0; i < pScreen->numDepths; i++) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/* For each depth of this screen, get visual information. */
|
|
|
|
|
|
|
|
|
|
pDepth = &pScreen->allowedDepths[i];
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
for (j = 0; j < pDepth->numVids; j++) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/* For each visual for this depth of this screen, get visual ID
|
|
|
|
|
* and visual depth. Since this is MI code, we will always return
|
|
|
|
|
* the same performance level for all visuals (0). A higher
|
|
|
|
|
* performance level value indicates higher performance.
|
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
|
visInfo[k].visual = pDepth->vids[j];
|
|
|
|
|
visInfo[k].depth = pDepth->depth;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
visInfo[k].perflevel = 0;
|
|
|
|
|
k++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Record the number of visuals and point visual_depth to
|
|
|
|
|
* the array of visual info.
|
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
|
pScrVisInfo->count = count;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
pScrVisInfo->visinfo = visInfo;
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
return TRUE; /* success */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
} /* miDbeGetVisualInfo() */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* DBE MI Procedure: miAllocBackBufferName
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
*
|
|
|
|
|
* This is the MI function for the DbeAllocateBackBufferName request.
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
|
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
|
DbeWindowPrivPtr pDbeWindowPriv;
|
|
|
|
|
DbeScreenPrivPtr pDbeScreenPriv;
|
|
|
|
|
GCPtr pGC;
|
|
|
|
|
xRectangle clearRect;
|
|
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
|
pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (pDbeWindowPriv->nBufferIDs == 0) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/* There is no buffer associated with the window.
|
|
|
|
|
* We have to create the window priv priv. Remember, the window
|
|
|
|
|
* priv was created at the DIX level, so all we need to do is
|
|
|
|
|
* create the priv priv and attach it to the priv.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
|
|
|
|
|
|
|
|
|
|
/* Get a front pixmap. */
|
2014-05-02 13:27:46 -06:00
|
|
|
|
if (!(pDbeWindowPriv->pFrontBuffer =
|
2012-06-10 07:21:05 -06:00
|
|
|
|
(*pScreen->CreatePixmap) (pScreen, pDbeWindowPriv->width,
|
|
|
|
|
pDbeWindowPriv->height,
|
|
|
|
|
pWin->drawable.depth, 0))) {
|
2010-12-05 08:36:02 -07:00
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get a back pixmap. */
|
2014-05-02 13:27:46 -06:00
|
|
|
|
if (!(pDbeWindowPriv->pBackBuffer =
|
2012-06-10 07:21:05 -06:00
|
|
|
|
(*pScreen->CreatePixmap) (pScreen, pDbeWindowPriv->width,
|
|
|
|
|
pDbeWindowPriv->height,
|
|
|
|
|
pWin->drawable.depth, 0))) {
|
2014-05-02 13:27:46 -06:00
|
|
|
|
(*pScreen->DestroyPixmap) (pDbeWindowPriv->pFrontBuffer);
|
2010-12-05 08:36:02 -07:00
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
/* Security creation/labeling check. */
|
|
|
|
|
rc = XaceHook(XACE_RESOURCE_ACCESS, serverClient, bufId,
|
2014-05-02 13:27:46 -06:00
|
|
|
|
dbeDrawableResType, pDbeWindowPriv->pBackBuffer,
|
2012-06-10 07:21:05 -06:00
|
|
|
|
RT_WINDOW, pWin, DixCreateAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/* Make the back pixmap a DBE drawable resource. */
|
2008-11-02 08:26:08 -07:00
|
|
|
|
if (rc != Success || !AddResource(bufId, dbeDrawableResType,
|
2014-05-02 13:27:46 -06:00
|
|
|
|
pDbeWindowPriv->pBackBuffer)) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/* free the buffer and the drawable resource */
|
|
|
|
|
FreeResource(bufId, RT_NONE);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
return (rc == Success) ? BadAlloc : rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Clear the back buffer. */
|
|
|
|
|
pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if ((*pDbeScreenPriv->SetupBackgroundPainter) (pWin, pGC)) {
|
2014-05-02 13:27:46 -06:00
|
|
|
|
ValidateGC((DrawablePtr) pDbeWindowPriv->pBackBuffer, pGC);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
clearRect.x = clearRect.y = 0;
|
2014-05-02 13:27:46 -06:00
|
|
|
|
clearRect.width = pDbeWindowPriv->pBackBuffer->drawable.width;
|
|
|
|
|
clearRect.height = pDbeWindowPriv->pBackBuffer->drawable.height;
|
|
|
|
|
(*pGC->ops->PolyFillRect) ((DrawablePtr) pDbeWindowPriv->
|
2012-06-10 07:21:05 -06:00
|
|
|
|
pBackBuffer, pGC, 1, &clearRect);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
FreeScratchGC(pGC);
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
} /* if no buffer associated with the window */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/* A buffer is already associated with the window.
|
|
|
|
|
* Place the new buffer ID information at the head of the ID list.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Associate the new ID with an existing pixmap. */
|
|
|
|
|
if (!AddResource(bufId, dbeDrawableResType,
|
2014-09-27 11:52:59 -06:00
|
|
|
|
(void *) pDbeWindowPriv->pBackBuffer)) {
|
2010-12-05 08:36:02 -07:00
|
|
|
|
return BadAlloc;
|
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
|
|
|
|
} /* miDbeAllocBackBufferName() */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* DBE MI Procedure: miDbeAliasBuffers
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
*
|
|
|
|
|
* This function associates all XIDs of a buffer with the back pixmap
|
|
|
|
|
* stored in the window priv.
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
miDbeAliasBuffers(DbeWindowPrivPtr pDbeWindowPriv)
|
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
for (i = 0; i < pDbeWindowPriv->nBufferIDs; i++) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
ChangeResourceValue(pDbeWindowPriv->IDs[i], dbeDrawableResType,
|
2014-09-27 11:52:59 -06:00
|
|
|
|
(void *) pDbeWindowPriv->pBackBuffer);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
} /* miDbeAliasBuffers() */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* DBE MI Procedure: miDbeSwapBuffers
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
*
|
|
|
|
|
* This is the MI function for the DbeSwapBuffers request.
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
|
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
|
DbeScreenPrivPtr pDbeScreenPriv;
|
2014-05-02 13:27:46 -06:00
|
|
|
|
DbeWindowPrivPtr pDbeWindowPriv;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
GCPtr pGC;
|
|
|
|
|
WindowPtr pWin;
|
|
|
|
|
PixmapPtr pTmpBuffer;
|
|
|
|
|
xRectangle clearRect;
|
|
|
|
|
|
|
|
|
|
pWin = swapInfo[0].pWindow;
|
|
|
|
|
pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
|
2014-05-02 13:27:46 -06:00
|
|
|
|
pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
**********************************************************************
|
|
|
|
|
** Setup before swap.
|
|
|
|
|
**********************************************************************
|
|
|
|
|
*/
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
switch (swapInfo[0].swapAction) {
|
|
|
|
|
case XdbeUndefined:
|
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
case XdbeBackground:
|
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
case XdbeUntouched:
|
2014-05-02 13:27:46 -06:00
|
|
|
|
ValidateGC((DrawablePtr) pDbeWindowPriv->pFrontBuffer, pGC);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
(*pGC->ops->CopyArea) ((DrawablePtr) pWin,
|
2014-05-02 13:27:46 -06:00
|
|
|
|
(DrawablePtr) pDbeWindowPriv->pFrontBuffer,
|
2012-06-10 07:21:05 -06:00
|
|
|
|
pGC, 0, 0, pWin->drawable.width,
|
|
|
|
|
pWin->drawable.height, 0, 0);
|
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
case XdbeCopied:
|
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
**********************************************************************
|
|
|
|
|
** Swap.
|
|
|
|
|
**********************************************************************
|
|
|
|
|
*/
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
ValidateGC((DrawablePtr) pWin, pGC);
|
2014-05-02 13:27:46 -06:00
|
|
|
|
(*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pBackBuffer,
|
2012-06-10 07:21:05 -06:00
|
|
|
|
(DrawablePtr) pWin, pGC, 0, 0,
|
|
|
|
|
pWin->drawable.width, pWin->drawable.height, 0, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
**********************************************************************
|
|
|
|
|
** Tasks after swap.
|
|
|
|
|
**********************************************************************
|
|
|
|
|
*/
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
switch (swapInfo[0].swapAction) {
|
|
|
|
|
case XdbeUndefined:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case XdbeBackground:
|
|
|
|
|
if ((*pDbeScreenPriv->SetupBackgroundPainter) (pWin, pGC)) {
|
2014-05-02 13:27:46 -06:00
|
|
|
|
ValidateGC((DrawablePtr) pDbeWindowPriv->pBackBuffer, pGC);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
clearRect.x = 0;
|
|
|
|
|
clearRect.y = 0;
|
2014-05-02 13:27:46 -06:00
|
|
|
|
clearRect.width = pDbeWindowPriv->pBackBuffer->drawable.width;
|
|
|
|
|
clearRect.height = pDbeWindowPriv->pBackBuffer->drawable.height;
|
|
|
|
|
(*pGC->ops->PolyFillRect) ((DrawablePtr) pDbeWindowPriv->
|
2012-06-10 07:21:05 -06:00
|
|
|
|
pBackBuffer, pGC, 1, &clearRect);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case XdbeUntouched:
|
|
|
|
|
/* Swap pixmap pointers. */
|
2014-05-02 13:27:46 -06:00
|
|
|
|
pTmpBuffer = pDbeWindowPriv->pBackBuffer;
|
|
|
|
|
pDbeWindowPriv->pBackBuffer = pDbeWindowPriv->pFrontBuffer;
|
|
|
|
|
pDbeWindowPriv->pFrontBuffer = pTmpBuffer;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
|
miDbeAliasBuffers(pDbeWindowPriv);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case XdbeCopied:
|
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Remove the swapped window from the swap information array and decrement
|
|
|
|
|
* pNumWindows to indicate to the DIX level how many windows were actually
|
|
|
|
|
* swapped.
|
|
|
|
|
*/
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (*pNumWindows > 1) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/* We were told to swap more than one window, but we only swapped the
|
|
|
|
|
* first one. Remove the first window in the list by moving the last
|
|
|
|
|
* window to the beginning.
|
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
|
swapInfo[0].pWindow = swapInfo[*pNumWindows - 1].pWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
swapInfo[0].swapAction = swapInfo[*pNumWindows - 1].swapAction;
|
|
|
|
|
|
|
|
|
|
/* Clear the last window information just to be safe. */
|
2012-06-10 07:21:05 -06:00
|
|
|
|
swapInfo[*pNumWindows - 1].pWindow = (WindowPtr) NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
swapInfo[*pNumWindows - 1].swapAction = 0;
|
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/* Clear the window information just to be safe. */
|
2012-06-10 07:21:05 -06:00
|
|
|
|
swapInfo[0].pWindow = (WindowPtr) NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
swapInfo[0].swapAction = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(*pNumWindows)--;
|
|
|
|
|
|
|
|
|
|
FreeScratchGC(pGC);
|
|
|
|
|
|
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
|
|
|
|
} /* miSwapBuffers() */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* DBE MI Procedure: miDbeWinPrivDelete
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
*
|
|
|
|
|
* This is the MI function for deleting the dbeWindowPrivResType resource.
|
|
|
|
|
* This function is invoked indirectly by calling FreeResource() to free
|
|
|
|
|
* the resources associated with a DBE buffer ID. There are 5 ways that
|
|
|
|
|
* miDbeWinPrivDelete() can be called by FreeResource(). They are:
|
|
|
|
|
*
|
|
|
|
|
* - A DBE window is destroyed, in which case the DbeDestroyWindow()
|
|
|
|
|
* wrapper is invoked. The wrapper calls FreeResource() for all DBE
|
|
|
|
|
* buffer IDs.
|
|
|
|
|
*
|
|
|
|
|
* - miDbeAllocBackBufferName() calls FreeResource() to clean up resources
|
|
|
|
|
* after a buffer allocation failure.
|
|
|
|
|
*
|
|
|
|
|
* - The PositionWindow wrapper, miDbePositionWindow(), calls
|
|
|
|
|
* FreeResource() when it fails to create buffers of the new size.
|
|
|
|
|
* FreeResource() is called for all DBE buffer IDs.
|
|
|
|
|
*
|
|
|
|
|
* - FreeClientResources() calls FreeResource() when a client dies or the
|
|
|
|
|
* the server resets.
|
|
|
|
|
*
|
|
|
|
|
* When FreeResource() is called for a DBE buffer ID, the delete function
|
|
|
|
|
* for the only other type of DBE resource, dbeDrawableResType, is also
|
|
|
|
|
* invoked. This delete function (DbeDrawableDelete) is a NOOP to make
|
|
|
|
|
* resource deletion easier. It is not guaranteed which delete function is
|
|
|
|
|
* called first. Hence, we will let miDbeWinPrivDelete() free all DBE
|
|
|
|
|
* resources.
|
2015-09-16 13:10:19 -06:00
|
|
|
|
*
|
2006-11-26 11:13:41 -07:00
|
|
|
|
* This function deletes/frees the following stuff associated with
|
|
|
|
|
* the window private:
|
|
|
|
|
*
|
|
|
|
|
* - the ID node in the ID list representing the passed in ID.
|
|
|
|
|
*
|
|
|
|
|
* In addition, pDbeWindowPriv->nBufferIDs is decremented.
|
|
|
|
|
*
|
|
|
|
|
* If this function is called for the last/only buffer ID for a window,
|
|
|
|
|
* these are additionally deleted/freed:
|
|
|
|
|
*
|
|
|
|
|
* - the front and back pixmaps
|
|
|
|
|
* - the window priv itself
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
miDbeWinPrivDelete(DbeWindowPrivPtr pDbeWindowPriv, XID bufId)
|
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (pDbeWindowPriv->nBufferIDs != 0) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/* We still have at least one more buffer ID associated with this
|
|
|
|
|
* window.
|
|
|
|
|
*/
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We have no more buffer IDs associated with this window. We need to
|
|
|
|
|
* free some stuff.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Destroy the front and back pixmaps. */
|
2014-05-02 13:27:46 -06:00
|
|
|
|
if (pDbeWindowPriv->pFrontBuffer) {
|
2012-06-10 07:21:05 -06:00
|
|
|
|
(*pDbeWindowPriv->pWindow->drawable.pScreen->
|
2014-05-02 13:27:46 -06:00
|
|
|
|
DestroyPixmap) (pDbeWindowPriv->pFrontBuffer);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
2014-05-02 13:27:46 -06:00
|
|
|
|
if (pDbeWindowPriv->pBackBuffer) {
|
2012-06-10 07:21:05 -06:00
|
|
|
|
(*pDbeWindowPriv->pWindow->drawable.pScreen->
|
2014-05-02 13:27:46 -06:00
|
|
|
|
DestroyPixmap) (pDbeWindowPriv->pBackBuffer);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
} /* miDbeWinPrivDelete() */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* DBE MI Procedure: miDbePositionWindow
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
*
|
2015-09-16 13:10:19 -06:00
|
|
|
|
* This function was cloned from miMbxPositionWindow() in mimultibuf.c.
|
2006-11-26 11:13:41 -07:00
|
|
|
|
* This function resizes the buffer when the window is resized.
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
miDbePositionWindow(WindowPtr pWin, int x, int y)
|
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
|
DbeScreenPrivPtr pDbeScreenPriv;
|
|
|
|
|
DbeWindowPrivPtr pDbeWindowPriv;
|
|
|
|
|
int width, height;
|
|
|
|
|
int dx, dy, dw, dh;
|
|
|
|
|
int sourcex, sourcey;
|
|
|
|
|
int destx, desty;
|
|
|
|
|
int savewidth, saveheight;
|
|
|
|
|
PixmapPtr pFrontBuffer;
|
|
|
|
|
PixmapPtr pBackBuffer;
|
|
|
|
|
Bool clear;
|
|
|
|
|
GCPtr pGC;
|
|
|
|
|
xRectangle clearRect;
|
|
|
|
|
Bool ret;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
**************************************************************************
|
|
|
|
|
** 1. Unwrap the member routine.
|
|
|
|
|
**************************************************************************
|
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
|
pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
pScreen->PositionWindow = pDbeScreenPriv->PositionWindow;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
**************************************************************************
|
|
|
|
|
** 2. Do any work necessary before the member routine is called.
|
|
|
|
|
**
|
|
|
|
|
** In this case we do not need to do anything.
|
|
|
|
|
**************************************************************************
|
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/*
|
|
|
|
|
**************************************************************************
|
|
|
|
|
** 3. Call the member routine, saving its result if necessary.
|
|
|
|
|
**************************************************************************
|
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
|
|
ret = (*pScreen->PositionWindow) (pWin, x, y);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
**************************************************************************
|
|
|
|
|
** 4. Rewrap the member routine, restoring the wrapper value first in case
|
|
|
|
|
** the wrapper (or something that it wrapped) change this value.
|
|
|
|
|
**************************************************************************
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
|
|
|
|
|
pScreen->PositionWindow = miDbePositionWindow;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
**************************************************************************
|
|
|
|
|
** 5. Do any work necessary after the member routine has been called.
|
|
|
|
|
**************************************************************************
|
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
|
|
if (!(pDbeWindowPriv = DBE_WINDOW_PRIV(pWin))) {
|
|
|
|
|
return ret;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (pDbeWindowPriv->width == pWin->drawable.width &&
|
|
|
|
|
pDbeWindowPriv->height == pWin->drawable.height) {
|
|
|
|
|
return ret;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
width = pWin->drawable.width;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
height = pWin->drawable.height;
|
|
|
|
|
|
|
|
|
|
dx = pWin->drawable.x - pDbeWindowPriv->x;
|
|
|
|
|
dy = pWin->drawable.y - pDbeWindowPriv->y;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
dw = width - pDbeWindowPriv->width;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
dh = height - pDbeWindowPriv->height;
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
GravityTranslate(0, 0, -dx, -dy, dw, dh, pWin->bitGravity, &destx, &desty);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
clear = ((pDbeWindowPriv->width < (unsigned short) width) ||
|
|
|
|
|
(pDbeWindowPriv->height < (unsigned short) height) ||
|
2006-11-26 11:13:41 -07:00
|
|
|
|
(pWin->bitGravity == ForgetGravity));
|
|
|
|
|
|
|
|
|
|
sourcex = 0;
|
|
|
|
|
sourcey = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
savewidth = pDbeWindowPriv->width;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
saveheight = pDbeWindowPriv->height;
|
|
|
|
|
|
|
|
|
|
/* Clip rectangle to source and destination. */
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (destx < 0) {
|
|
|
|
|
savewidth += destx;
|
|
|
|
|
sourcex -= destx;
|
|
|
|
|
destx = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (destx + savewidth > width) {
|
|
|
|
|
savewidth = width - destx;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (desty < 0) {
|
|
|
|
|
saveheight += desty;
|
|
|
|
|
sourcey -= desty;
|
|
|
|
|
desty = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (desty + saveheight > height) {
|
|
|
|
|
saveheight = height - desty;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
pDbeWindowPriv->width = width;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
pDbeWindowPriv->height = height;
|
|
|
|
|
pDbeWindowPriv->x = pWin->drawable.x;
|
|
|
|
|
pDbeWindowPriv->y = pWin->drawable.y;
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
pGC = GetScratchGC(pWin->drawable.depth, pScreen);
|
|
|
|
|
|
|
|
|
|
if (clear) {
|
|
|
|
|
if ((*pDbeScreenPriv->SetupBackgroundPainter) (pWin, pGC)) {
|
|
|
|
|
clearRect.x = 0;
|
|
|
|
|
clearRect.y = 0;
|
|
|
|
|
clearRect.width = width;
|
|
|
|
|
clearRect.height = height;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
clear = FALSE;
|
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create DBE buffer pixmaps equal to size of resized window. */
|
2012-06-10 07:21:05 -06:00
|
|
|
|
pFrontBuffer = (*pScreen->CreatePixmap) (pScreen, width, height,
|
|
|
|
|
pWin->drawable.depth, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
pBackBuffer = (*pScreen->CreatePixmap) (pScreen, width, height,
|
|
|
|
|
pWin->drawable.depth, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (!pFrontBuffer || !pBackBuffer) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/* We failed at creating 1 or 2 of the pixmaps. */
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (pFrontBuffer) {
|
|
|
|
|
(*pScreen->DestroyPixmap) (pFrontBuffer);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
if (pBackBuffer) {
|
|
|
|
|
(*pScreen->DestroyPixmap) (pBackBuffer);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Destroy all buffers for this window. */
|
2012-06-10 07:21:05 -06:00
|
|
|
|
while (pDbeWindowPriv) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/* DbeWindowPrivDelete() will free the window private if there no
|
|
|
|
|
* more buffer IDs associated with this window.
|
|
|
|
|
*/
|
|
|
|
|
FreeResource(pDbeWindowPriv->IDs[0], RT_NONE);
|
|
|
|
|
pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FreeScratchGC(pGC);
|
2010-12-05 08:36:02 -07:00
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
/* Clear out the new DBE buffer pixmaps. */
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
/* I suppose this could avoid quite a bit of work if
|
|
|
|
|
* it computed the minimal area required.
|
|
|
|
|
*/
|
|
|
|
|
ValidateGC(&pFrontBuffer->drawable, pGC);
|
|
|
|
|
if (clear) {
|
|
|
|
|
(*pGC->ops->PolyFillRect) ((DrawablePtr) pFrontBuffer, pGC, 1,
|
|
|
|
|
&clearRect);
|
|
|
|
|
}
|
|
|
|
|
/* Copy the contents of the old front pixmap to the new one. */
|
|
|
|
|
if (pWin->bitGravity != ForgetGravity) {
|
2014-05-02 13:27:46 -06:00
|
|
|
|
(*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pFrontBuffer,
|
|
|
|
|
(DrawablePtr) pFrontBuffer, pGC,
|
|
|
|
|
sourcex, sourcey, savewidth, saveheight,
|
2012-06-10 07:21:05 -06:00
|
|
|
|
destx, desty);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
ValidateGC(&pBackBuffer->drawable, pGC);
|
|
|
|
|
if (clear) {
|
|
|
|
|
(*pGC->ops->PolyFillRect) ((DrawablePtr) pBackBuffer, pGC, 1,
|
|
|
|
|
&clearRect);
|
|
|
|
|
}
|
|
|
|
|
/* Copy the contents of the old back pixmap to the new one. */
|
|
|
|
|
if (pWin->bitGravity != ForgetGravity) {
|
2014-05-02 13:27:46 -06:00
|
|
|
|
(*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pBackBuffer,
|
|
|
|
|
(DrawablePtr) pBackBuffer, pGC,
|
2012-06-10 07:21:05 -06:00
|
|
|
|
sourcex, sourcey, savewidth, saveheight,
|
|
|
|
|
destx, desty);
|
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/* Destroy the old pixmaps, and point the DBE window priv to the new
|
|
|
|
|
* pixmaps.
|
|
|
|
|
*/
|
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
|
(*pScreen->DestroyPixmap) (pDbeWindowPriv->pFrontBuffer);
|
|
|
|
|
(*pScreen->DestroyPixmap) (pDbeWindowPriv->pBackBuffer);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
|
pDbeWindowPriv->pFrontBuffer = pFrontBuffer;
|
|
|
|
|
pDbeWindowPriv->pBackBuffer = pBackBuffer;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
/* Make sure all XID are associated with the new back pixmap. */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
miDbeAliasBuffers(pDbeWindowPriv);
|
|
|
|
|
|
|
|
|
|
FreeScratchGC(pGC);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
|
return ret;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
} /* miDbePositionWindow() */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* DBE MI Procedure: miDbeInit
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
*
|
|
|
|
|
* This is the MI initialization function called by DbeExtensionInit().
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
|
|
|
|
|
{
|
|
|
|
|
/* Wrap functions. */
|
|
|
|
|
pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
pScreen->PositionWindow = miDbePositionWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
|
|
/* Initialize the per-screen DBE function pointers. */
|
2012-06-10 07:21:05 -06:00
|
|
|
|
pDbeScreenPriv->GetVisualInfo = miDbeGetVisualInfo;
|
|
|
|
|
pDbeScreenPriv->AllocBackBufferName = miDbeAllocBackBufferName;
|
|
|
|
|
pDbeScreenPriv->SwapBuffers = miDbeSwapBuffers;
|
|
|
|
|
pDbeScreenPriv->WinPrivDelete = miDbeWinPrivDelete;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
} /* miDbeInit() */
|