winmultiwindowshape.c [plain text]
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
#ifdef SHAPE
#include "win.h"
void
winSetShapeMultiWindow (WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
winWindowPriv(pWin);
winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG
ErrorF ("winSetShapeMultiWindow - pWin: %08x\n", pWin);
#endif
WIN_UNWRAP(SetShape);
(*pScreen->SetShape)(pWin);
WIN_WRAP(SetShape, winSetShapeMultiWindow);
winReshapeMultiWindow (pWin);
winUpdateRgnMultiWindow (pWin);
return;
}
void
winUpdateRgnMultiWindow (WindowPtr pWin)
{
SetWindowRgn (winGetWindowPriv(pWin)->hWnd,
winGetWindowPriv(pWin)->hRgn, TRUE);
}
void
winReshapeMultiWindow (WindowPtr pWin)
{
int nRects;
RegionRec rrNewShape;
BoxPtr pShape, pRects, pEnd;
HRGN hRgn, hRgnRect;
winWindowPriv(pWin);
#if CYGDEBUG
winDebug ("winReshape ()\n");
#endif
if (pWin->parent == NULL)
return;
if (pWin->parent->parent != NULL)
return;
if (pWinPriv->hWnd == NULL)
return;
if (pWinPriv->hRgn != NULL)
{
DeleteObject (pWinPriv->hRgn);
pWinPriv->hRgn = NULL;
}
if (!wBoundingShape (pWin))
return;
REGION_NULL(pWin->drawable.pScreen, &rrNewShape);
REGION_COPY(pWin->drawable.pScreen, &rrNewShape, wBoundingShape(pWin));
REGION_TRANSLATE(pWin->drawable.pScreen,
&rrNewShape,
pWin->borderWidth,
pWin->borderWidth);
nRects = REGION_NUM_RECTS(&rrNewShape);
pShape = REGION_RECTS(&rrNewShape);
if (nRects > 0)
{
RECT rcClient;
RECT rcWindow;
int iOffsetX, iOffsetY;
if (!GetClientRect (pWinPriv->hWnd, &rcClient))
{
ErrorF ("winReshape - GetClientRect failed, bailing: %d\n",
(int) GetLastError ());
return;
}
ClientToScreen (pWinPriv->hWnd, (LPPOINT) &rcClient);
if (!GetWindowRect (pWinPriv->hWnd, &rcWindow))
{
ErrorF ("winReshape - GetWindowRect failed, bailing: %d\n",
(int) GetLastError ());
return;
}
iOffsetX = rcClient.left - rcWindow.left;
iOffsetY = rcClient.top - rcWindow.top;
hRgn = CreateRectRgn (0, 0, rcWindow.right, iOffsetY);
if (hRgn == NULL)
{
ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
"failed: %d\n",
0, 0, (int) rcWindow.right, iOffsetY, (int) GetLastError ());
}
for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++)
{
hRgnRect = CreateRectRgn (pRects->x1 + iOffsetX,
pRects->y1 + iOffsetY,
pRects->x2 + iOffsetX,
pRects->y2 + iOffsetY);
if (hRgnRect == NULL)
{
ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
"failed: %d\n"
"\tx1: %d x2: %d xOff: %d y1: %d y2: %d yOff: %d\n",
pRects->x1 + iOffsetX,
pRects->y1 + iOffsetY,
pRects->x2 + iOffsetX,
pRects->y2 + iOffsetY,
(int) GetLastError (),
pRects->x1, pRects->x2, iOffsetX,
pRects->y1, pRects->y2, iOffsetY);
}
if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
{
ErrorF ("winReshape - CombineRgn () failed: %d\n",
(int) GetLastError ());
}
DeleteObject (hRgnRect);
}
pWinPriv->hRgn = hRgn;
}
REGION_UNINIT(pWin->drawable.pScreen, &rrNewShape);
return;
}
#endif