#include "win.h"
static int
winAddRgn (WindowPtr pWindow, pointer data);
static
void
winUpdateRgnPRootless (WindowPtr pWindow);
#ifdef SHAPE
static
void
winReshapePRootless (WindowPtr pWin);
#endif
Bool
winCreateWindowNativeGDI (WindowPtr pWin)
{
ErrorF ("winCreateWindowNativeGDI ()\n");
return TRUE;
}
Bool
winDestroyWindowNativeGDI (WindowPtr pWin)
{
ErrorF ("winDestroyWindowNativeGDI ()\n");
return TRUE;
}
Bool
winPositionWindowNativeGDI (WindowPtr pWin, int x, int y)
{
ErrorF ("winPositionWindowNativeGDI ()\n");
return TRUE;
}
void
winCopyWindowNativeGDI (WindowPtr pWin,
DDXPointRec ptOldOrg,
RegionPtr prgnSrc)
{
DDXPointPtr pptSrc;
DDXPointPtr ppt;
RegionPtr prgnDst;
BoxPtr pBox;
int dx, dy;
int i, nbox;
WindowPtr pwinRoot;
BoxPtr pBoxDst;
ScreenPtr pScreen = pWin->drawable.pScreen;
winScreenPriv(pScreen);
#if 0
ErrorF ("winCopyWindow\n");
#endif
pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip,
prgnSrc);
pBox = REGION_RECTS(prgnDst);
nbox = REGION_NUM_RECTS(prgnDst);
if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
return;
ppt = pptSrc;
for (i = nbox; --i >= 0; ppt++, pBox++)
{
ppt->x = pBox->x1 + dx;
ppt->y = pBox->y1 + dy;
}
pBoxDst = REGION_RECTS(prgnDst);
ppt = pptSrc;
#if 0
ErrorF ("winCopyWindow - x1\tx2\ty1\ty2\tx\ty\n");
#endif
for (i = nbox; --i >= 0; pBoxDst++, ppt++)
{
#if 0
ErrorF ("winCopyWindow - %d\t%d\t%d\t%d\t%d\t%d\n",
pBoxDst->x1, pBoxDst->x2, pBoxDst->y1, pBoxDst->y2,
ppt->x, ppt->y);
#endif
BitBlt (pScreenPriv->hdcScreen,
pBoxDst->x1, pBoxDst->y1,
pBoxDst->x2 - pBoxDst->x1, pBoxDst->y2 - pBoxDst->y1,
pScreenPriv->hdcScreen,
ppt->x, ppt->y,
SRCCOPY);
}
DEALLOCATE_LOCAL(pptSrc);
REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
}
Bool
winChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask)
{
ErrorF ("winChangeWindowAttributesNativeGDI ()\n");
return TRUE;
}
Bool
winUnmapWindowNativeGDI (WindowPtr pWindow)
{
ErrorF ("winUnmapWindowNativeGDI ()\n");
return TRUE;
}
Bool
winMapWindowNativeGDI (WindowPtr pWindow)
{
ErrorF ("winMapWindowNativeGDI ()\n");
return TRUE;
}
Bool
winCreateWindowPRootless (WindowPtr pWin)
{
Bool fResult = FALSE;
winWindowPriv(pWin);
#if CYGDEBUG
ErrorF ("winCreateWindowPRootless ()\n");
#endif
fResult = winGetScreenPriv(pWin->drawable.pScreen)->CreateWindow(pWin);
pWinPriv->hRgn = NULL;
return fResult;
}
Bool
winDestroyWindowPRootless (WindowPtr pWin)
{
Bool fResult = FALSE;
winWindowPriv(pWin);
#if CYGDEBUG
ErrorF ("winDestroyWindowPRootless ()\n");
#endif
fResult = winGetScreenPriv(pWin->drawable.pScreen)->DestroyWindow(pWin);
if (pWinPriv->hRgn != NULL)
{
DeleteObject(pWinPriv->hRgn);
pWinPriv->hRgn = NULL;
}
winUpdateRgnPRootless (pWin);
return fResult;
}
Bool
winPositionWindowPRootless (WindowPtr pWin, int x, int y)
{
Bool fResult = FALSE;
#if CYGDEBUG
ErrorF ("winPositionWindowPRootless ()\n");
#endif
fResult = winGetScreenPriv(pWin->drawable.pScreen)->PositionWindow(pWin, x, y);
winUpdateRgnPRootless (pWin);
return fResult;
}
Bool
winChangeWindowAttributesPRootless (WindowPtr pWin, unsigned long mask)
{
Bool fResult = FALSE;
#if CYGDEBUG
ErrorF ("winChangeWindowAttributesPRootless ()\n");
#endif
fResult = winGetScreenPriv(pWin->drawable.pScreen)->ChangeWindowAttributes(pWin, mask);
winUpdateRgnPRootless (pWin);
return fResult;
}
Bool
winUnmapWindowPRootless (WindowPtr pWin)
{
Bool fResult = FALSE;
winWindowPriv(pWin);
#if CYGDEBUG
ErrorF ("winUnmapWindowPRootless ()\n");
#endif
fResult = winGetScreenPriv(pWin->drawable.pScreen)->UnrealizeWindow(pWin);
if (pWinPriv->hRgn != NULL)
{
DeleteObject(pWinPriv->hRgn);
pWinPriv->hRgn = NULL;
}
winUpdateRgnPRootless (pWin);
return fResult;
}
Bool
winMapWindowPRootless (WindowPtr pWin)
{
Bool fResult = FALSE;
#if CYGDEBUG
ErrorF ("winMapWindowPRootless ()\n");
#endif
fResult = winGetScreenPriv(pWin->drawable.pScreen)->RealizeWindow(pWin);
winReshapePRootless (pWin);
winUpdateRgnPRootless (pWin);
return fResult;
}
#ifdef SHAPE
void
winSetShapePRootless (WindowPtr pWin)
{
#if CYGDEBUG
ErrorF ("winSetShapePRootless ()\n");
#endif
winGetScreenPriv(pWin->drawable.pScreen)->SetShape(pWin);
winReshapePRootless (pWin);
winUpdateRgnPRootless (pWin);
return;
}
#endif
static
int
winAddRgn (WindowPtr pWin, pointer data)
{
int iX, iY, iWidth, iHeight, iBorder;
HRGN hRgn = *(HRGN*)data;
HRGN hRgnWin;
winWindowPriv(pWin);
if (pWin->parent != NULL)
{
#if CYGDEBUG
ErrorF ("winAddRgn ()\n");
#endif
if (pWin->mapped)
{
iBorder = wBorderWidth (pWin);
iX = pWin->drawable.x - iBorder;
iY = pWin->drawable.y - iBorder;
iWidth = pWin->drawable.width + iBorder * 2;
iHeight = pWin->drawable.height + iBorder * 2;
hRgnWin = CreateRectRgn (0, 0, iWidth, iHeight);
if (hRgnWin == NULL)
{
ErrorF ("winAddRgn - CreateRectRgn () failed\n");
ErrorF (" Rect %d %d %d %d\n",
iX, iY, iX + iWidth, iY + iHeight);
}
if (pWinPriv->hRgn)
{
if (CombineRgn (hRgnWin, hRgnWin, pWinPriv->hRgn, RGN_AND)
== ERROR)
{
ErrorF ("winAddRgn - CombineRgn () failed\n");
}
}
OffsetRgn (hRgnWin, iX, iY);
if (CombineRgn (hRgn, hRgn, hRgnWin, RGN_OR) == ERROR)
{
ErrorF ("winAddRgn - CombineRgn () failed\n");
}
DeleteObject (hRgnWin);
}
return WT_DONTWALKCHILDREN;
}
else
{
return WT_WALKCHILDREN;
}
}
static
void
winUpdateRgnPRootless (WindowPtr pWin)
{
HRGN hRgn = CreateRectRgn (0, 0, 0, 0);
if (hRgn != NULL)
{
WalkTree (pWin->drawable.pScreen, winAddRgn, &hRgn);
SetWindowRgn (winGetScreenPriv(pWin->drawable.pScreen)->hwndScreen,
hRgn, TRUE);
}
else
{
ErrorF ("winUpdateRgnPRootless - CreateRectRgn failed.\n");
}
}
#ifdef SHAPE
static
void
winReshapePRootless (WindowPtr pWin)
{
int nRects;
ScreenPtr pScreen = pWin->drawable.pScreen;
RegionRec rrNewShape;
BoxPtr pShape, pRects, pEnd;
HRGN hRgn, hRgnRect;
winWindowPriv(pWin);
#if CYGDEBUG
ErrorF ("winReshapePRootless ()\n");
#endif
if (pWin->parent == NULL)
return;
if (pWin->parent->parent != NULL)
return;
if (pWinPriv->hRgn != NULL)
{
DeleteObject (pWinPriv->hRgn);
pWinPriv->hRgn = NULL;
}
if (!wBoundingShape (pWin))
return;
REGION_NULL(pScreen, &rrNewShape);
REGION_COPY(pScreen, &rrNewShape, wBoundingShape(pWin));
REGION_TRANSLATE(pScreen, &rrNewShape, pWin->borderWidth,
pWin->borderWidth);
nRects = REGION_NUM_RECTS(&rrNewShape);
pShape = REGION_RECTS(&rrNewShape);
if (nRects > 0)
{
hRgn = CreateRectRgn (0, 0, 0, 0);
for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++)
{
hRgnRect = CreateRectRgn (pRects->x1, pRects->y1,
pRects->x2, pRects->y2);
if (hRgnRect == NULL)
{
ErrorF("winReshapePRootless - CreateRectRgn() failed\n");
}
if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
{
ErrorF("winReshapePRootless - CombineRgn() failed\n");
}
DeleteObject (hRgnRect);
}
pWinPriv->hRgn = hRgn;
}
REGION_UNINIT(pScreen, &rrNewShape);
return;
}
#endif