New upstream version 3.5.99.27

This commit is contained in:
geos_one
2025-08-08 20:00:36 +02:00
commit bc8d10cc33
4267 changed files with 1757978 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#include <Server.tmpl>
SRCS = dbe.c midbe.c
OBJS = dbe.o midbe.o
INCLUDES = -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) $(EXTRAINCLUDES) `pkg-config --cflags-only-I pixman-1`
LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
#if defined(NXAgentServer) && NXAgentServer
NX_DEFINES = -DNXAGENT_SERVER
#endif
DEFINES = \
$(NX_DEFINES) \
$(NULL)
NormalLibraryObjectRule()
NormalLibraryTarget(dbe,$(OBJS))
LintLibraryTarget(dbe,$(SRCS))
NormalLintTarget($(SRCS))
DependTarget()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,229 @@
/******************************************************************************
*
* 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:
*
* 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 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.
*
* 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.
*
* Header file for DIX-related DBE
*
*****************************************************************************/
#ifndef DBE_STRUCT_H
#define DBE_STRUCT_H
/* INCLUDES */
#include <nx-X11/extensions/Xdbeproto.h>
#include "windowstr.h"
/* DEFINES */
#define DBE_SCREEN_PRIV(pScreen) \
((dbeScreenPrivIndex < 0) ? \
NULL : \
((DbeScreenPrivPtr)((pScreen)->devPrivates[dbeScreenPrivIndex].ptr)))
#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \
DBE_SCREEN_PRIV((pDrawable)->pScreen)
#define DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(pDbeWindowPriv) \
DBE_SCREEN_PRIV((pDbeWindowPriv)->pWindow->drawable.pScreen)
#define DBE_SCREEN_PRIV_FROM_WINDOW(pWindow) \
DBE_SCREEN_PRIV((pWindow)->drawable.pScreen)
#define DBE_SCREEN_PRIV_FROM_PIXMAP(pPixmap) \
DBE_SCREEN_PRIV((pPixmap)->drawable.pScreen)
#define DBE_SCREEN_PRIV_FROM_GC(pGC)\
DBE_SCREEN_PRIV((pGC)->pScreen)
#define DBE_WINDOW_PRIV(pWindow)\
((dbeWindowPrivIndex < 0) ? \
NULL : \
((DbeWindowPrivPtr)(pWindow->devPrivates[dbeWindowPrivIndex].ptr)))
/* Initial size of the buffer ID array in the window priv. */
#define DBE_INIT_MAX_IDS 2
/* Reallocation increment for the buffer ID array. */
#define DBE_INCR_MAX_IDS 4
/* Marker for free elements in the buffer ID array. */
#define DBE_FREE_ID_ELEMENT 0
/* TYPEDEFS */
/* Record used to pass swap information between DIX and DDX swapping
* procedures.
*/
typedef struct _DbeSwapInfoRec
{
WindowPtr pWindow;
unsigned char swapAction;
} DbeSwapInfoRec, *DbeSwapInfoPtr;
/*
******************************************************************************
** Per-window data
******************************************************************************
*/
typedef struct _DbeWindowPrivRec
{
/* A pointer to the window with which the DBE window private (buffer) is
* associated.
*/
WindowPtr pWindow;
/* Last known swap action for this buffer. Legal values for this field
* are XdbeUndefined, XdbeBackground, XdbeUntouched, and XdbeCopied.
*/
unsigned char swapAction;
/* Last known buffer size.
*/
unsigned short width, height;
/* Coordinates used for static gravity when the window is positioned.
*/
short x, y;
/* Number of XIDs associated with this buffer.
*/
int nBufferIDs;
/* Capacity of the current buffer ID array, IDs. */
int maxAvailableIDs;
/* Pointer to the array of buffer IDs. This initially points to initIDs.
* When the static limit of the initIDs array is reached, the array is
* reallocated and this pointer is set to the new array instead of initIDs.
*/
XID *IDs;
/* Initial array of buffer IDs. We are defining the XID array within the
* window priv to optimize for data locality. In most cases, only one
* buffer will be associated with a window. Having the array declared
* here can prevent us from accessing the data in another memory page,
* possibly resulting in a page swap and loss of performance. Initially we
* will use this array to store buffer IDs. For situations where we have
* more IDs than can fit in this static array, we will allocate a larger
* array to use, possibly suffering a performance loss.
*/
XID initIDs[DBE_INIT_MAX_IDS];
/* Device-specific private information.
*/
DevUnion *devPrivates;
} DbeWindowPrivRec, *DbeWindowPrivPtr;
/*
******************************************************************************
** Per-screen data
******************************************************************************
*/
typedef struct _DbeScreenPrivRec
{
/* Info for creating window privs */
int winPrivPrivLen; /* Length of privs in DbeWindowPrivRec */
unsigned int *winPrivPrivSizes; /* Array of private record sizes */
unsigned int totalWinPrivSize; /* PrivRec + size of all priv priv ptrs */
/* Resources created by DIX to be used by DDX */
RESTYPE dbeDrawableResType;
RESTYPE dbeWindowPrivResType;
/* Private indices created by DIX to be used by DDX */
int dbeScreenPrivIndex;
int dbeWindowPrivIndex;
/* Wrapped functions
* It is the responsibilty of the DDX layer to wrap PositionWindow().
* DbeExtensionInit wraps DestroyWindow().
*/
PositionWindowProcPtr PositionWindow;
DestroyWindowProcPtr DestroyWindow;
/* Per-screen DIX routines */
Bool (*SetupBackgroundPainter)(
WindowPtr /*pWin*/,
GCPtr /*pGC*/
);
DbeWindowPrivPtr (*AllocWinPriv)(
ScreenPtr /*pScreen*/
);
int (*AllocWinPrivPrivIndex)(
void
);
Bool (*AllocWinPrivPriv)(
ScreenPtr /*pScreen*/,
int /*index*/,
unsigned /*amount*/
);
/* Per-screen DDX routines */
Bool (*GetVisualInfo)(
ScreenPtr /*pScreen*/,
XdbeScreenVisualInfo * /*pVisInfo*/
);
int (*AllocBackBufferName)(
WindowPtr /*pWin*/,
XID /*bufId*/,
int /*swapAction*/
);
int (*SwapBuffers)(
ClientPtr /*client*/,
int * /*pNumWindows*/,
DbeSwapInfoPtr /*swapInfo*/
);
void (*BeginIdiom)(
ClientPtr /*client*/
);
void (*EndIdiom)(
ClientPtr /*client*/
);
void (*WinPrivDelete)(
DbeWindowPrivPtr /*pDbeWindowPriv*/,
XID /*bufId*/
);
void (*ResetProc)(
ScreenPtr /*pScreen*/
);
/* Device-specific private information.
*/
DevUnion *devPrivates;
} DbeScreenPrivRec, *DbeScreenPrivPtr;
#endif /* DBE_STRUCT_H */

View File

@@ -0,0 +1,819 @@
/******************************************************************************
*
* 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:
*
* 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 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.
*
* 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.
*
* Machine-independent DBE code
*
*****************************************************************************/
/* INCLUDES */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <nx-X11/X.h>
#include <nx-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 "midbestr.h"
#include "regionstr.h"
#include "gcstruct.h"
#include "inputstr.h"
#include "midbe.h"
#include <stdio.h>
static int miDbePrivPrivGeneration = 0;
static int miDbeWindowPrivPrivIndex = -1;
static RESTYPE dbeDrawableResType;
static RESTYPE dbeWindowPrivResType;
static int dbeScreenPrivIndex = -1;
static int dbeWindowPrivIndex = -1;
/******************************************************************************
*
* 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
miDbeGetVisualInfo(ScreenPtr pScreen, XdbeScreenVisualInfo *pScrVisInfo)
{
register int i, j, k;
register int count;
DepthPtr pDepth;
XdbeVisualInfo *visInfo;
/* Determine number of visuals for this screen. */
for (i = 0, count = 0; i < pScreen->numDepths; i++)
{
count += pScreen->allowedDepths[i].numVids;
}
/* Allocate an array of XdbeVisualInfo items. */
if (!(visInfo = (XdbeVisualInfo *)malloc(count * sizeof(XdbeVisualInfo))))
{
return(FALSE); /* memory alloc failure */
}
for (i = 0, k = 0; i < pScreen->numDepths; i++)
{
/* For each depth of this screen, get visual information. */
pDepth = &pScreen->allowedDepths[i];
for (j = 0; j < pDepth->numVids; j++)
{
/* 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.
*/
visInfo[k].visual = pDepth->vids[j];
visInfo[k].depth = pDepth->depth;
visInfo[k].perflevel = 0;
k++;
}
}
/* Record the number of visuals and point visual_depth to
* the array of visual info.
*/
pScrVisInfo->count = count;
pScrVisInfo->visinfo = visInfo;
return(TRUE); /* success */
} /* miDbeGetVisualInfo() */
/******************************************************************************
*
* DBE MI Procedure: miAllocBackBufferName
*
* Description:
*
* This is the MI function for the DbeAllocateBackBufferName request.
*
*****************************************************************************/
static int
miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
{
ScreenPtr pScreen;
DbeWindowPrivPtr pDbeWindowPriv;
MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
DbeScreenPrivPtr pDbeScreenPriv;
GCPtr pGC;
xRectangle clearRect;
pScreen = pWin->drawable.pScreen;
pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
if (pDbeWindowPriv->nBufferIDs == 0)
{
/* 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);
/* Setup the window priv priv. */
pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
pDbeWindowPrivPriv->pDbeWindowPriv = pDbeWindowPriv;
/* Get a front pixmap. */
if (!(pDbeWindowPrivPriv->pFrontBuffer =
(*pScreen->CreatePixmap)(pScreen, pDbeWindowPriv->width,
pDbeWindowPriv->height,
pWin->drawable.depth, 0)))
{
return(BadAlloc);
}
/* Get a back pixmap. */
if (!(pDbeWindowPrivPriv->pBackBuffer =
(*pScreen->CreatePixmap)(pScreen, pDbeWindowPriv->width,
pDbeWindowPriv->height,
pWin->drawable.depth, 0)))
{
(*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pFrontBuffer);
return(BadAlloc);
}
/* Make the back pixmap a DBE drawable resource. */
if (!AddResource(bufId, dbeDrawableResType,
(void *)pDbeWindowPrivPriv->pBackBuffer))
{
/* free the buffer and the drawable resource */
FreeResource(bufId, RT_NONE);
return(BadAlloc);
}
/* Attach the priv priv to the priv. */
pDbeWindowPriv->devPrivates[miDbeWindowPrivPrivIndex].ptr =
(void *)pDbeWindowPrivPriv;
/* Clear the back buffer. */
pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC))
{
ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, pGC);
clearRect.x = clearRect.y = 0;
clearRect.width = pDbeWindowPrivPriv->pBackBuffer->drawable.width;
clearRect.height = pDbeWindowPrivPriv->pBackBuffer->drawable.height;
(*pGC->ops->PolyFillRect)(
(DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, pGC, 1,
&clearRect);
}
FreeScratchGC(pGC);
} /* if no buffer associated with the window */
else
{
/* 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. */
pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
if (!AddResource(bufId, dbeDrawableResType,
(void *)pDbeWindowPrivPriv->pBackBuffer))
{
return(BadAlloc);
}
}
return(Success);
} /* miDbeAllocBackBufferName() */
/******************************************************************************
*
* 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)
{
int i;
MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv =
MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
for (i = 0; i < pDbeWindowPriv->nBufferIDs; i++)
{
ChangeResourceValue(pDbeWindowPriv->IDs[i], dbeDrawableResType,
(void *)pDbeWindowPrivPriv->pBackBuffer);
}
} /* miDbeAliasBuffers() */
/******************************************************************************
*
* DBE MI Procedure: miDbeSwapBuffers
*
* Description:
*
* This is the MI function for the DbeSwapBuffers request.
*
*****************************************************************************/
static int
miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
{
DbeScreenPrivPtr pDbeScreenPriv;
GCPtr pGC;
WindowPtr pWin;
MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
PixmapPtr pTmpBuffer;
xRectangle clearRect;
pWin = swapInfo[0].pWindow;
pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin);
pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
/*
**********************************************************************
** Setup before swap.
**********************************************************************
*/
switch(swapInfo[0].swapAction)
{
case XdbeUndefined:
break;
case XdbeBackground:
break;
case XdbeUntouched:
ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer, pGC);
(*pGC->ops->CopyArea)((DrawablePtr)pWin,
(DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer,
pGC, 0, 0, pWin->drawable.width,
pWin->drawable.height, 0, 0);
break;
case XdbeCopied:
break;
}
/*
**********************************************************************
** Swap.
**********************************************************************
*/
ValidateGC((DrawablePtr)pWin, pGC);
(*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
(DrawablePtr)pWin, pGC, 0, 0,
pWin->drawable.width, pWin->drawable.height,
0, 0);
/*
**********************************************************************
** Tasks after swap.
**********************************************************************
*/
switch(swapInfo[0].swapAction)
{
case XdbeUndefined:
break;
case XdbeBackground:
if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC))
{
ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, pGC);
clearRect.x = 0;
clearRect.y = 0;
clearRect.width =
pDbeWindowPrivPriv->pBackBuffer->drawable.width;
clearRect.height =
pDbeWindowPrivPriv->pBackBuffer->drawable.height;
(*pGC->ops->PolyFillRect)(
(DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
pGC, 1, &clearRect);
}
break;
case XdbeUntouched:
/* Swap pixmap pointers. */
pTmpBuffer = pDbeWindowPrivPriv->pBackBuffer;
pDbeWindowPrivPriv->pBackBuffer =
pDbeWindowPrivPriv->pFrontBuffer;
pDbeWindowPrivPriv->pFrontBuffer = pTmpBuffer;
miDbeAliasBuffers(pDbeWindowPrivPriv->pDbeWindowPriv);
break;
case XdbeCopied:
break;
}
/* Remove the swapped window from the swap information array and decrement
* pNumWindows to indicate to the DIX level how many windows were actually
* swapped.
*/
if (*pNumWindows > 1)
{
/* 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.
*/
swapInfo[0].pWindow = swapInfo[*pNumWindows - 1].pWindow;
swapInfo[0].swapAction = swapInfo[*pNumWindows - 1].swapAction;
/* Clear the last window information just to be safe. */
swapInfo[*pNumWindows - 1].pWindow = (WindowPtr)NULL;
swapInfo[*pNumWindows - 1].swapAction = 0;
}
else
{
/* Clear the window information just to be safe. */
swapInfo[0].pWindow = (WindowPtr)NULL;
swapInfo[0].swapAction = 0;
}
(*pNumWindows)--;
FreeScratchGC(pGC);
return(Success);
} /* miSwapBuffers() */
/******************************************************************************
*
* 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.
*
* 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)
{
MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
if (pDbeWindowPriv->nBufferIDs != 0)
{
/* 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.
*/
pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
/* Destroy the front and back pixmaps. */
if (pDbeWindowPrivPriv->pFrontBuffer)
{
(*pDbeWindowPriv->pWindow->drawable.pScreen->DestroyPixmap)(
pDbeWindowPrivPriv->pFrontBuffer);
}
if (pDbeWindowPrivPriv->pBackBuffer)
{
(*pDbeWindowPriv->pWindow->drawable.pScreen->DestroyPixmap)(
pDbeWindowPrivPriv->pBackBuffer);
}
} /* miDbeWinPrivDelete() */
/******************************************************************************
*
* DBE MI Procedure: miDbePositionWindow
*
* Description:
*
* This function was cloned from miMbxPositionWindow() in mimultibuf.c.
* This function resizes the buffer when the window is resized.
*
*****************************************************************************/
static Bool
miDbePositionWindow(WindowPtr pWin, int x, int y)
{
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;
/*
**************************************************************************
** 1. Unwrap the member routine.
**************************************************************************
*/
pScreen = pWin->drawable.pScreen;
pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
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.
**************************************************************************
*/
/*
**************************************************************************
** 3. Call the member routine, saving its result if necessary.
**************************************************************************
*/
ret = (*pScreen->PositionWindow)(pWin, x, y);
/*
**************************************************************************
** 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.
**************************************************************************
*/
if (!(pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)))
{
return(ret);
}
if (pDbeWindowPriv->width == pWin->drawable.width &&
pDbeWindowPriv->height == pWin->drawable.height)
{
return(ret);
}
width = pWin->drawable.width;
height = pWin->drawable.height;
dx = pWin->drawable.x - pDbeWindowPriv->x;
dy = pWin->drawable.y - pDbeWindowPriv->y;
dw = width - pDbeWindowPriv->width;
dh = height - pDbeWindowPriv->height;
GravityTranslate (0, 0, -dx, -dy, dw, dh, pWin->bitGravity, &destx, &desty);
clear = ((pDbeWindowPriv->width < (unsigned short)width ) ||
(pDbeWindowPriv->height < (unsigned short)height) ||
(pWin->bitGravity == ForgetGravity));
sourcex = 0;
sourcey = 0;
savewidth = pDbeWindowPriv->width;
saveheight = pDbeWindowPriv->height;
/* Clip rectangle to source and destination. */
if (destx < 0)
{
savewidth += destx;
sourcex -= destx;
destx = 0;
}
if (destx + savewidth > width)
{
savewidth = width - destx;
}
if (desty < 0)
{
saveheight += desty;
sourcey -= desty;
desty = 0;
}
if (desty + saveheight > height)
{
saveheight = height - desty;
}
pDbeWindowPriv->width = width;
pDbeWindowPriv->height = height;
pDbeWindowPriv->x = pWin->drawable.x;
pDbeWindowPriv->y = pWin->drawable.y;
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;
}
}
/* Create DBE buffer pixmaps equal to size of resized window. */
pFrontBuffer = (*pScreen->CreatePixmap)(pScreen, width, height,
pWin->drawable.depth, 0);
pBackBuffer = (*pScreen->CreatePixmap)(pScreen, width, height,
pWin->drawable.depth, 0);
if (!pFrontBuffer || !pBackBuffer)
{
/* We failed at creating 1 or 2 of the pixmaps. */
if (pFrontBuffer)
{
(*pScreen->DestroyPixmap)(pFrontBuffer);
}
if (pBackBuffer)
{
(*pScreen->DestroyPixmap)(pBackBuffer);
}
/* Destroy all buffers for this window. */
while (pDbeWindowPriv)
{
/* 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);
return(FALSE);
}
else
{
/* Clear out the new DBE buffer pixmaps. */
MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
ValidateGC((DrawablePtr)pFrontBuffer, pGC);
/* I suppose this could avoid quite a bit of work if
* it computed the minimal area required.
*/
if (clear)
{
(*pGC->ops->PolyFillRect)((DrawablePtr)pFrontBuffer, pGC, 1,
&clearRect);
(*pGC->ops->PolyFillRect)((DrawablePtr)pBackBuffer , pGC, 1,
&clearRect);
}
/* Copy the contents of the old DBE pixmaps to the new pixmaps. */
if (pWin->bitGravity != ForgetGravity)
{
(*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer,
(DrawablePtr)pFrontBuffer, pGC, sourcex,
sourcey, savewidth, saveheight, destx, desty);
(*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
(DrawablePtr)pBackBuffer, pGC, sourcex,
sourcey, savewidth, saveheight, destx, desty);
}
/* Destroy the old pixmaps, and point the DBE window priv to the new
* pixmaps.
*/
(*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pFrontBuffer);
(*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pBackBuffer);
pDbeWindowPrivPriv->pFrontBuffer = pFrontBuffer;
pDbeWindowPrivPriv->pBackBuffer = pBackBuffer;
/* Make sure all XID are associated with the new back pixmap. */
miDbeAliasBuffers(pDbeWindowPriv);
FreeScratchGC(pGC);
}
return(ret);
} /* miDbePositionWindow() */
/******************************************************************************
*
* DBE MI Procedure: miDbeResetProc
*
* Description:
*
* This function is called from DbeResetProc(), which is called at the end
* of every server generation. This function peforms any MI-specific
* shutdown tasks.
*
*****************************************************************************/
static void
miDbeResetProc(ScreenPtr pScreen)
{
DbeScreenPrivPtr pDbeScreenPriv;
pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
/* Unwrap wrappers */
pScreen->PositionWindow = pDbeScreenPriv->PositionWindow;
} /* miDbeResetProc() */
/******************************************************************************
*
* DBE MI Procedure: miDbeInit
*
* Description:
*
* This is the MI initialization function called by DbeExtensionInit().
*
*****************************************************************************/
Bool
miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
{
/* Copy resource types created by DIX */
dbeDrawableResType = pDbeScreenPriv->dbeDrawableResType;
dbeWindowPrivResType = pDbeScreenPriv->dbeWindowPrivResType;
/* Copy private indices created by DIX */
dbeScreenPrivIndex = pDbeScreenPriv->dbeScreenPrivIndex;
dbeWindowPrivIndex = pDbeScreenPriv->dbeWindowPrivIndex;
/* Reset the window priv privs if generations do not match. */
if (miDbePrivPrivGeneration != serverGeneration)
{
/*
**********************************************************************
** Allocate the window priv priv.
**********************************************************************
*/
miDbeWindowPrivPrivIndex = (*pDbeScreenPriv->AllocWinPrivPrivIndex)();
/* Make sure we only do this code once. */
miDbePrivPrivGeneration = serverGeneration;
} /* if -- Reset priv privs. */
if (!(*pDbeScreenPriv->AllocWinPrivPriv)(pScreen,
miDbeWindowPrivPrivIndex, sizeof(MiDbeWindowPrivPrivRec)))
{
return(FALSE);
}
/* Wrap functions. */
pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
pScreen->PositionWindow = miDbePositionWindow;
/* Initialize the per-screen DBE function pointers. */
pDbeScreenPriv->GetVisualInfo = miDbeGetVisualInfo;
pDbeScreenPriv->AllocBackBufferName = miDbeAllocBackBufferName;
pDbeScreenPriv->SwapBuffers = miDbeSwapBuffers;
pDbeScreenPriv->BeginIdiom = 0;
pDbeScreenPriv->EndIdiom = 0;
pDbeScreenPriv->ResetProc = miDbeResetProc;
pDbeScreenPriv->WinPrivDelete = miDbeWinPrivDelete;
return(TRUE);
} /* miDbeInit() */

View File

@@ -0,0 +1,47 @@
/******************************************************************************
* 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:
*
* 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 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.
*
* 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.
*
* Header file for users of machine-independent DBE code
*
*****************************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef MIDBE_H
#define MIDBE_H
/* EXTERNS */
extern Bool miDbeInit(
ScreenPtr pScreen,
DbeScreenPrivPtr pDbeScreenPriv
);
#endif /* MIDBE_H */

View File

@@ -0,0 +1,99 @@
/******************************************************************************
*
* 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:
*
* 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 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.
*
* 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.
*
* Header file for users of machine-independent DBE code
*
*****************************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef MIDBE_STRUCT_H
#define MIDBE_STRUCT_H
/* DEFINES */
#define MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv) \
(((miDbeWindowPrivPrivIndex < 0) || (!pDbeWindowPriv)) ? \
NULL : \
((MiDbeWindowPrivPrivPtr) \
((pDbeWindowPriv)->devPrivates[miDbeWindowPrivPrivIndex].ptr)))
#define MI_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin)\
MI_DBE_WINDOW_PRIV_PRIV(DBE_WINDOW_PRIV(pWin))
#define MI_DBE_SCREEN_PRIV_PRIV(pDbeScreenPriv) \
(((miDbeScreenPrivPrivIndex < 0) || (!pDbeScreenPriv)) ? \
NULL : \
((MiDbeScreenPrivPrivPtr) \
((pDbeScreenPriv)->devPrivates[miDbeScreenPrivPrivIndex].ptr)))
/* TYPEDEFS */
typedef struct _MiDbeWindowPrivPrivRec
{
/* Place machine-specific fields in here.
* Since this is mi code, we do not really have machine-specific fields.
*/
/* Pointer to a drawable that contains the contents of the back buffer.
*/
PixmapPtr pBackBuffer;
/* Pointer to a drawable that contains the contents of the front buffer.
* This pointer is only used for the XdbeUntouched swap action. For that
* swap action, we need to copy the front buffer (window) contents into
* this drawable, copy the contents of current back buffer drawable (the
* back buffer) into the window, swap the front and back drawable pointers,
* and then swap the drawable/resource associations in the resource
* database.
*/
PixmapPtr pFrontBuffer;
/* Pointer back to our window private with which we are associated. */
DbeWindowPrivPtr pDbeWindowPriv;
} MiDbeWindowPrivPrivRec, *MiDbeWindowPrivPrivPtr;
typedef struct _MiDbeScreenPrivPrivRec
{
/* Place machine-specific fields in here.
* Since this is mi code, we do not really have machine-specific fields.
*/
/* Pointer back to our screen private with which we are associated. */
DbeScreenPrivPtr pDbeScreenPriv;
} MiDbeScreenPrivPrivRec, *MiDbeScreenPrivPrivPtr;
#endif /* MIDBE_STRUCT_H */