#ifdef HAVE_DMX_CONFIG_H
#include <dmx-config.h>
#endif
#include "dmx.h"
#include "dmxsync.h"
#include "dmxwindow.h"
#include "dmxpixmap.h"
#include "dmxcmap.h"
#include "dmxvisual.h"
#include "dmxinput.h"
#include "dmxextension.h"
#ifdef RENDER
#include "dmxpict.h"
#endif
#include "windowstr.h"
static void dmxDoRestackWindow(WindowPtr pWindow);
static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
unsigned long *mask,
XSetWindowAttributes *attribs);
static void dmxDoSetShape(WindowPtr pWindow);
Bool dmxInitWindow(ScreenPtr pScreen)
{
if (!dixRequestPrivate(dmxWinPrivateKey, sizeof(dmxWinPrivRec)))
return FALSE;
return TRUE;
}
Window dmxCreateRootWindow(WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
Window parent;
Visual *visual;
unsigned long mask;
XSetWindowAttributes attribs;
ColormapPtr pCmap;
dmxColormapPrivPtr pCmapPriv;
parent = dmxScreen->scrnWin;
visual = dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual;
pCmap = (ColormapPtr)LookupIDByType(wColormap(pWindow), RT_COLORMAP);
pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
mask = CWEventMask | CWBackingStore | CWColormap | CWBorderPixel;
attribs.event_mask = ExposureMask;
attribs.backing_store = NotUseful;
attribs.colormap = pCmapPriv->cmap;
attribs.border_pixel = 0;
if (pWinPriv->attribMask) {
dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
mask |= pWinPriv->attribMask;
}
return XCreateWindow(dmxScreen->beDisplay,
parent,
pWindow->origin.x - wBorderWidth(pWindow),
pWindow->origin.y - wBorderWidth(pWindow),
pWindow->drawable.width,
pWindow->drawable.height,
pWindow->borderWidth,
pWindow->drawable.depth,
pWindow->drawable.class,
visual,
mask,
&attribs);
}
void dmxResizeScreenWindow(ScreenPtr pScreen,
int x, int y, int w, int h)
{
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
unsigned int m;
XWindowChanges c;
if (!dmxScreen->beDisplay)
return;
m = CWX | CWY | CWWidth | CWHeight;
c.x = x;
c.y = y;
c.width = w;
c.height = h;
XConfigureWindow(dmxScreen->beDisplay, dmxScreen->scrnWin, m, &c);
dmxSync(dmxScreen, False);
}
void dmxResizeRootWindow(WindowPtr pRoot,
int x, int y, int w, int h)
{
DMXScreenInfo *dmxScreen = &dmxScreens[pRoot->drawable.pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
unsigned int m;
XWindowChanges c;
if (dmxScreen->beDisplay) {
m = CWX | CWY | CWWidth | CWHeight;
c.x = x;
c.y = y;
c.width = (w > 0) ? w : 1;
c.height = (h > 0) ? h : 1;
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
}
if (w == 0 || h == 0) {
if (pWinPriv->mapped) {
if (dmxScreen->beDisplay)
XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
pWinPriv->mapped = FALSE;
}
} else if (!pWinPriv->mapped) {
if (dmxScreen->beDisplay)
XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
pWinPriv->mapped = TRUE;
}
if (dmxScreen->beDisplay)
dmxSync(dmxScreen, False);
}
void dmxGetDefaultWindowAttributes(WindowPtr pWindow,
Colormap *cmap,
Visual **visual)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
if (pWindow->drawable.class != InputOnly &&
pWindow->optional &&
pWindow->optional->visual != wVisual(pWindow->parent)) {
*visual = dmxLookupVisualFromID(pScreen, wVisual(pWindow));
if (pWindow->optional->colormap) {
ColormapPtr pCmap;
dmxColormapPrivPtr pCmapPriv;
pCmap = (ColormapPtr)LookupIDByType(wColormap(pWindow),
RT_COLORMAP);
pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
*cmap = pCmapPriv->cmap;
} else {
*cmap = dmxColormapFromDefaultVisual(pScreen, *visual);
}
} else {
*visual = CopyFromParent;
*cmap = (Colormap)0;
}
}
static Window dmxCreateNonRootWindow(WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
Window parent;
unsigned long mask = 0L;
XSetWindowAttributes attribs;
dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
parent = pParentPriv->window;
if (!parent) {
dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
parent = pParentPriv->window;
}
if (pWinPriv->attribMask) {
dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
mask |= pWinPriv->attribMask;
}
if (pWindow->drawable.class != InputOnly) {
mask |= CWBackingStore;
attribs.backing_store = NotUseful;
if (!(mask & CWColormap) && pWinPriv->cmap) {
mask |= CWColormap;
attribs.colormap = pWinPriv->cmap;
if (!(mask & CWBorderPixel)) {
mask |= CWBorderPixel;
attribs.border_pixel = 0;
}
}
}
pWinPriv->restacked = (pWindow->prevSib != NullWindow);
return XCreateWindow(dmxScreen->beDisplay,
parent,
pWindow->origin.x - wBorderWidth(pWindow),
pWindow->origin.y - wBorderWidth(pWindow),
pWindow->drawable.width,
pWindow->drawable.height,
pWindow->borderWidth,
pWindow->drawable.depth,
pWindow->drawable.class,
pWinPriv->visual,
mask,
&attribs);
}
void dmxCreateAndRealizeWindow(WindowPtr pWindow, Bool doSync)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
if (!dmxScreen->beDisplay) return;
pWinPriv->window = dmxCreateNonRootWindow(pWindow);
if (pWinPriv->restacked) dmxDoRestackWindow(pWindow);
if (pWinPriv->isShaped) dmxDoSetShape(pWindow);
#ifdef RENDER
if (pWinPriv->hasPict) dmxCreatePictureList(pWindow);
#endif
if (pWinPriv->mapped) XMapWindow(dmxScreen->beDisplay,
pWinPriv->window);
if (doSync) dmxSync(dmxScreen, False);
}
Bool dmxCreateWindow(WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
Bool ret = TRUE;
DMX_UNWRAP(CreateWindow, dmxScreen, pScreen);
#if 0
if (pScreen->CreateWindow)
ret = pScreen->CreateWindow(pWindow);
#endif
pWinPriv->window = (Window)0;
pWinPriv->offscreen = TRUE;
pWinPriv->mapped = FALSE;
pWinPriv->restacked = FALSE;
pWinPriv->attribMask = 0;
pWinPriv->isShaped = FALSE;
#ifdef RENDER
pWinPriv->hasPict = FALSE;
#endif
#ifdef GLXEXT
pWinPriv->swapGroup = NULL;
pWinPriv->barrier = 0;
#endif
if (dmxScreen->beDisplay) {
if (!pWindow->parent) {
dmxScreen->rootWin = pWinPriv->window
= dmxCreateRootWindow(pWindow);
if (dmxScreen->scrnX != dmxScreen->rootX
|| dmxScreen->scrnY != dmxScreen->rootY
|| dmxScreen->scrnWidth != dmxScreen->rootWidth
|| dmxScreen->scrnHeight != dmxScreen->rootHeight) {
dmxResizeRootWindow(pWindow,
dmxScreen->rootX,
dmxScreen->rootY,
dmxScreen->rootWidth,
dmxScreen->rootHeight);
dmxUpdateScreenResources(screenInfo.screens[dmxScreen->index],
dmxScreen->rootX,
dmxScreen->rootY,
dmxScreen->rootWidth,
dmxScreen->rootHeight);
pWindow->origin.x = dmxScreen->rootX;
pWindow->origin.y = dmxScreen->rootY;
}
} else {
dmxGetDefaultWindowAttributes(pWindow,
&pWinPriv->cmap,
&pWinPriv->visual);
if (dmxLazyWindowCreation) {
if (pWinPriv->visual == CopyFromParent)
pWinPriv->visual =
dmxLookupVisualFromID(pScreen,
wVisual(pWindow->parent));
} else {
pWinPriv->window = dmxCreateNonRootWindow(pWindow);
}
}
dmxSync(dmxScreen, False);
}
DMX_WRAP(CreateWindow, dmxCreateWindow, dmxScreen, pScreen);
return ret;
}
Bool dmxBEDestroyWindow(WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
if (pWinPriv->window) {
XDestroyWindow(dmxScreen->beDisplay, pWinPriv->window);
pWinPriv->window = (Window)0;
return TRUE;
}
return FALSE;
}
Bool dmxDestroyWindow(WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
Bool ret = TRUE;
Bool needSync = FALSE;
#ifdef GLXEXT
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
#endif
DMX_UNWRAP(DestroyWindow, dmxScreen, pScreen);
#ifdef RENDER
needSync |= dmxDestroyPictureList(pWindow);
#endif
needSync |= dmxBEDestroyWindow(pWindow);
if (needSync) dmxSync(dmxScreen, FALSE);
#ifdef GLXEXT
if (pWinPriv->swapGroup && pWinPriv->windowDestroyed)
pWinPriv->windowDestroyed(pWindow);
#endif
#if 0
if (pScreen->DestroyWindow)
ret = pScreen->DestroyWindow(pWindow);
#endif
DMX_WRAP(DestroyWindow, dmxDestroyWindow, dmxScreen, pScreen);
return ret;
}
Bool dmxPositionWindow(WindowPtr pWindow, int x, int y)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
Bool ret = TRUE;
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
unsigned int m;
XWindowChanges c;
DMX_UNWRAP(PositionWindow, dmxScreen, pScreen);
#if 0
if (pScreen->PositionWindow)
ret = pScreen->PositionWindow(pWindow, x, y);
#endif
pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
dmxCreateAndRealizeWindow(pWindow, TRUE);
} else if (pWinPriv->window) {
m = CWX | CWY | CWWidth | CWHeight;
c.x = pWindow->origin.x - wBorderWidth(pWindow);
c.y = pWindow->origin.y - wBorderWidth(pWindow);
c.width = pWindow->drawable.width;
c.height = pWindow->drawable.height;
if (pWindow->drawable.class != InputOnly) {
m |= CWBorderWidth;
c.border_width = pWindow->borderWidth;
}
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
dmxSync(dmxScreen, False);
}
DMX_WRAP(PositionWindow, dmxPositionWindow, dmxScreen, pScreen);
return ret;
}
static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
unsigned long *mask,
XSetWindowAttributes *attribs)
{
dmxPixPrivPtr pPixPriv;
if (*mask & CWBackPixmap) {
switch (pWindow->backgroundState) {
case None:
attribs->background_pixmap = None;
break;
case ParentRelative:
attribs->background_pixmap = ParentRelative;
break;
case BackgroundPixmap:
pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->background.pixmap);
attribs->background_pixmap = pPixPriv->pixmap;
break;
case BackgroundPixel:
*mask &= ~CWBackPixmap;
break;
}
}
if (*mask & CWBackPixel) {
if (pWindow->backgroundState == BackgroundPixel)
attribs->background_pixel = pWindow->background.pixel;
else
*mask &= ~CWBackPixel;
}
if (*mask & CWBorderPixmap) {
if (pWindow->borderIsPixel)
*mask &= ~CWBorderPixmap;
else {
pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->border.pixmap);
attribs->border_pixmap = pPixPriv->pixmap;
}
}
if (*mask & CWBorderPixel) {
if (pWindow->borderIsPixel)
attribs->border_pixel = pWindow->border.pixel;
else
*mask &= ~CWBorderPixel;
}
if (*mask & CWBitGravity)
attribs->bit_gravity = pWindow->bitGravity;
if (*mask & CWWinGravity)
*mask &= ~CWWinGravity;
if (*mask & CWBackingStore)
*mask &= ~CWBackingStore;
if (*mask & CWBackingPlanes)
*mask &= ~CWBackingPlanes;
if (*mask & CWBackingPixel)
*mask &= ~CWBackingPixel;
if (*mask & CWOverrideRedirect)
attribs->override_redirect = pWindow->overrideRedirect;
if (*mask & CWSaveUnder)
*mask &= ~CWSaveUnder;
if (*mask & CWEventMask)
*mask &= ~CWEventMask;
if (*mask & CWDontPropagate)
*mask &= ~CWDontPropagate;
if (*mask & CWColormap) {
ColormapPtr pCmap;
dmxColormapPrivPtr pCmapPriv;
pCmap = (ColormapPtr)LookupIDByType(wColormap(pWindow), RT_COLORMAP);
pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
attribs->colormap = pCmapPriv->cmap;
}
if (*mask & CWCursor)
*mask &= ~CWCursor;
}
Bool dmxChangeWindowAttributes(WindowPtr pWindow, unsigned long mask)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
Bool ret = TRUE;
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
XSetWindowAttributes attribs;
DMX_UNWRAP(ChangeWindowAttributes, dmxScreen, pScreen);
#if 0
if (pScreen->ChangeWindowAttributes)
ret = pScreen->ChangeWindowAttributes(pWindow, mask);
#endif
dmxDoChangeWindowAttributes(pWindow, &mask, &attribs);
pWinPriv->attribMask |= mask;
if (mask && pWinPriv->window) {
XChangeWindowAttributes(dmxScreen->beDisplay, pWinPriv->window,
mask, &attribs);
dmxSync(dmxScreen, False);
}
DMX_WRAP(ChangeWindowAttributes, dmxChangeWindowAttributes, dmxScreen,
pScreen);
return ret;
}
Bool dmxRealizeWindow(WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
Bool ret = TRUE;
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
DMX_UNWRAP(RealizeWindow, dmxScreen, pScreen);
#if 0
if (pScreen->RealizeWindow)
ret = pScreen->RealizeWindow(pWindow);
#endif
pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
if (!pWinPriv->window && !pWinPriv->offscreen) {
dmxCreateAndRealizeWindow(pWindow, FALSE);
}
if (pWinPriv->window) {
XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
dmxSync(dmxScreen, False);
}
pWinPriv->mapped = TRUE;
DMX_WRAP(RealizeWindow, dmxRealizeWindow, dmxScreen, pScreen);
dmxUpdateWindowInfo(DMX_UPDATE_REALIZE, pWindow);
return ret;
}
Bool dmxUnrealizeWindow(WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
Bool ret = TRUE;
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
DMX_UNWRAP(UnrealizeWindow, dmxScreen, pScreen);
#if 0
if (pScreen->UnrealizeWindow)
ret = pScreen->UnrealizeWindow(pWindow);
#endif
if (pWinPriv->window) {
XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
dmxSync(dmxScreen, False);
}
pWinPriv->offscreen = TRUE;
pWinPriv->mapped = FALSE;
#ifdef GLXEXT
if (pWinPriv->swapGroup && pWinPriv->windowUnmapped)
pWinPriv->windowUnmapped(pWindow);
#endif
DMX_WRAP(UnrealizeWindow, dmxUnrealizeWindow, dmxScreen, pScreen);
dmxUpdateWindowInfo(DMX_UPDATE_UNREALIZE, pWindow);
return ret;
}
static void dmxDoRestackWindow(WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
WindowPtr pNextSib = pWindow->nextSib;
unsigned int m;
XWindowChanges c;
if (pNextSib == NullWindow) {
m = CWStackMode;
c.sibling = (Window)0;
c.stack_mode = Below;
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
} else {
dmxWinPrivPtr pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
while (!pNextSibPriv->window) {
pNextSib = pNextSib->nextSib;
if (pNextSib == NullWindow) {
m = CWStackMode;
c.sibling = (Window)0;
c.stack_mode = Below;
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
return;
}
pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
}
m = CWStackMode | CWSibling;
c.sibling = pNextSibPriv->window;
c.stack_mode = Above;
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
}
}
void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
DMX_UNWRAP(RestackWindow, dmxScreen, pScreen);
#if 0
if (pScreen->RestackWindow)
pScreen->RestackWindow(pWindow, pOldNextSib);
#endif
if (pOldNextSib != pWindow->nextSib) {
pWinPriv->restacked = TRUE;
if (pWinPriv->window) {
dmxDoRestackWindow(pWindow);
dmxSync(dmxScreen, False);
}
}
DMX_WRAP(RestackWindow, dmxRestackWindow, dmxScreen, pScreen);
dmxUpdateWindowInfo(DMX_UPDATE_RESTACK, pWindow);
}
static Bool dmxWindowExposurePredicate(Display *dpy, XEvent *ev, XPointer ptr)
{
return (ev->type == Expose && ev->xexpose.window == *(Window *)ptr);
}
void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn,
RegionPtr other_exposed)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
XEvent ev;
DMX_UNWRAP(WindowExposures, dmxScreen, pScreen);
dmxSync(dmxScreen, False);
if (pWinPriv->window) {
while (XCheckIfEvent(dmxScreen->beDisplay, &ev,
dmxWindowExposurePredicate,
(XPointer)&pWinPriv->window)) {
}
}
#if 1
if (pScreen->WindowExposures)
pScreen->WindowExposures(pWindow, prgn, other_exposed);
#endif
DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
}
void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
unsigned int m;
XWindowChanges c;
DMX_UNWRAP(CopyWindow, dmxScreen, pScreen);
#if 0
if (pScreen->CopyWindow)
pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc);
#endif
pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
dmxCreateAndRealizeWindow(pWindow, TRUE);
} else if (pWinPriv->window) {
m = CWX | CWY | CWWidth | CWHeight;
c.x = pWindow->origin.x - wBorderWidth(pWindow);
c.y = pWindow->origin.y - wBorderWidth(pWindow);
c.width = pWindow->drawable.width;
c.height = pWindow->drawable.height;
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
dmxSync(dmxScreen, False);
}
DMX_WRAP(CopyWindow, dmxCopyWindow, dmxScreen, pScreen);
dmxUpdateWindowInfo(DMX_UPDATE_COPY, pWindow);
}
void dmxResizeWindow(WindowPtr pWindow, int x, int y,
unsigned int w, unsigned int h, WindowPtr pSib)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
dmxWinPrivPtr pSibPriv;
unsigned int m;
XWindowChanges c;
if (pSib)
pSibPriv = DMX_GET_WINDOW_PRIV(pSib);
DMX_UNWRAP(ResizeWindow, dmxScreen, pScreen);
#if 1
if (pScreen->ResizeWindow)
pScreen->ResizeWindow(pWindow, x, y, w, h, pSib);
#endif
pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
dmxCreateAndRealizeWindow(pWindow, TRUE);
} else if (pWinPriv->window) {
m = CWX | CWY | CWWidth | CWHeight;
c.x = pWindow->origin.x - wBorderWidth(pWindow);
c.y = pWindow->origin.y - wBorderWidth(pWindow);
c.width = pWindow->drawable.width;
c.height = pWindow->drawable.height;
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
dmxSync(dmxScreen, False);
}
DMX_WRAP(ResizeWindow, dmxResizeWindow, dmxScreen, pScreen);
dmxUpdateWindowInfo(DMX_UPDATE_RESIZE, pWindow);
}
void dmxReparentWindow(WindowPtr pWindow, WindowPtr pPriorParent)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
DMX_UNWRAP(ReparentWindow, dmxScreen, pScreen);
#if 0
if (pScreen->ReparentWindow)
pScreen->ReparentWindow(pWindow, pPriorParent);
#endif
if (pWinPriv->window) {
if (!pParentPriv->window) {
dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
}
XReparentWindow(dmxScreen->beDisplay, pWinPriv->window,
pParentPriv->window,
pWindow->origin.x - wBorderWidth(pWindow),
pWindow->origin.x - wBorderWidth(pWindow));
dmxSync(dmxScreen, False);
}
DMX_WRAP(ReparentWindow, dmxReparentWindow, dmxScreen, pScreen);
dmxUpdateWindowInfo(DMX_UPDATE_REPARENT, pWindow);
}
void dmxChangeBorderWidth(WindowPtr pWindow, unsigned int width)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
unsigned int m;
XWindowChanges c;
DMX_UNWRAP(ChangeBorderWidth, dmxScreen, pScreen);
#if 1
if (pScreen->ChangeBorderWidth)
pScreen->ChangeBorderWidth(pWindow, width);
#endif
if (pWinPriv->window) {
m = CWBorderWidth;
c.border_width = width;
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
dmxSync(dmxScreen, False);
}
DMX_WRAP(ChangeBorderWidth, dmxChangeBorderWidth, dmxScreen, pScreen);
}
static void dmxDoSetShape(WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
int nBox;
BoxPtr pBox;
int nRect;
XRectangle *pRect;
XRectangle *pRectFirst;
if (wBoundingShape(pWindow)) {
pBox = REGION_RECTS(wBoundingShape(pWindow));
nRect = nBox = REGION_NUM_RECTS(wBoundingShape(pWindow));
pRectFirst = pRect = xalloc(nRect * sizeof(*pRect));
while (nBox--) {
pRect->x = pBox->x1;
pRect->y = pBox->y1;
pRect->width = pBox->x2 - pBox->x1;
pRect->height = pBox->y2 - pBox->y1;
pBox++;
pRect++;
}
XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
ShapeBounding, 0, 0,
pRectFirst, nRect,
ShapeSet, YXBanded);
xfree(pRectFirst);
} else {
XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
ShapeBounding, 0, 0, None, ShapeSet);
}
if (wClipShape(pWindow)) {
pBox = REGION_RECTS(wClipShape(pWindow));
nRect = nBox = REGION_NUM_RECTS(wClipShape(pWindow));
pRectFirst = pRect = xalloc(nRect * sizeof(*pRect));
while (nBox--) {
pRect->x = pBox->x1;
pRect->y = pBox->y1;
pRect->width = pBox->x2 - pBox->x1;
pRect->height = pBox->y2 - pBox->y1;
pBox++;
pRect++;
}
XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
ShapeClip, 0, 0,
pRectFirst, nRect,
ShapeSet, YXBanded);
xfree(pRectFirst);
} else {
XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
ShapeClip, 0, 0, None, ShapeSet);
}
if (XShapeInputSelected(dmxScreen->beDisplay, pWinPriv->window)) {
ErrorF("Input selected for window %x on Screen %d\n",
(unsigned int)pWinPriv->window, pScreen->myNum);
}
}
void dmxSetShape(WindowPtr pWindow)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
DMX_UNWRAP(SetShape, dmxScreen, pScreen);
#if 1
if (pScreen->SetShape)
pScreen->SetShape(pWindow);
#endif
if (pWinPriv->window) {
dmxDoSetShape(pWindow);
dmxSync(dmxScreen, False);
} else {
pWinPriv->isShaped = TRUE;
}
DMX_WRAP(SetShape, dmxSetShape, dmxScreen, pScreen);
}