? xshapeext.path Index: InitOutput.c =================================================================== RCS file: /cvs/xc/programs/Xserver/hw/xwin/InitOutput.c,v retrieving revision 1.29 diff -u -r1.29 InitOutput.c --- InitOutput.c 2002/07/05 09:19:25 1.29 +++ InitOutput.c 2002/10/17 15:23:22 @@ -42,6 +42,7 @@ int g_iCmapPrivateIndex = -1; int g_iGCPrivateIndex = -1; int g_iPixmapPrivateIndex = -1; +int g_iWindowPrivateIndex = -1; unsigned long g_ulServerGeneration = 0; Bool g_fInitializedDefaultScreens = FALSE; FILE *g_pfLog = NULL; @@ -132,6 +133,7 @@ g_ScreenInfo[i].fFullScreen = FALSE; g_ScreenInfo[i].fDecoration = TRUE; g_ScreenInfo[i].fLessPointer = FALSE; + g_ScreenInfo[i].fPseudoRootless = FALSE; g_ScreenInfo[i].iE3BTimeout = WIN_E3B_OFF; g_ScreenInfo[i].dwWidth_mm = (dwWidth / WIN_DEFAULT_DPI) * 25.4; @@ -874,6 +876,34 @@ { /* Parameter is for a single screen */ g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = TRUE; + } + + /* Indicate that we have processed this argument */ + return 1; + } + + /* + * Look for the '-pseudorootless' argument + */ + if (strcmp (argv[i], "-pseudorootless") == 0) + { + /* Is this parameter attached to a screen or is it global? */ + if (-1 == g_iLastScreen) + { + int j; + + /* Parameter is for all screens */ + for (j = 0; j < MAXSCREENS; j++) + { + g_ScreenInfo[j].fPseudoRootless = TRUE; + g_ScreenInfo[j].fDecoration = FALSE; + } + } + else + { + /* Parameter is for a single screen */ + g_ScreenInfo[g_iLastScreen].fPseudoRootless = TRUE; + g_ScreenInfo[g_iLastScreen].fDecoration = FALSE; } /* Indicate that we have processed this argument */ Index: win.h =================================================================== RCS file: /cvs/xc/programs/Xserver/hw/xwin/win.h,v retrieving revision 1.30 diff -u -r1.30 win.h --- win.h 2002/07/05 09:19:25 1.30 +++ win.h 2002/10/17 15:23:25 @@ -188,6 +188,7 @@ */ #include "winms.h" +#undef CreateWindow /* Cygwin's winuser.h does not define VK_KANA as of 28Mar2001 */ /* NOTE: Cygwin's winuser.h was fixed shortly after 28Mar2001. */ @@ -376,6 +377,7 @@ Bool fFullScreen; Bool fDecoration; Bool fLessPointer; + Bool fPseudoRootless; int iE3BTimeout; /* Windows (Alt+F4) and Unix (Ctrl+Alt+Backspace) Killkey */ Bool fUseWinKillKey; @@ -473,10 +475,40 @@ winCreateColormapProcPtr pwinCreateColormap; winDestroyColormapProcPtr pwinDestroyColormap; winHotKeyAltTabPtr pwinHotKeyAltTab; + + /* Window Procedures for Rootless mode */ + CreateWindowProcPtr CreateWindow; + DestroyWindowProcPtr DestroyWindow; + PositionWindowProcPtr PositionWindow; + ChangeWindowAttributesProcPtr ChangeWindowAttributes; + RealizeWindowProcPtr RealizeWindow; + UnrealizeWindowProcPtr UnrealizeWindow; + ValidateTreeProcPtr ValidateTree; + PostValidateTreeProcPtr PostValidateTree; + WindowExposuresProcPtr WindowExposures; + PaintWindowBackgroundProcPtr PaintWindowBackground; + PaintWindowBorderProcPtr PaintWindowBorder; + CopyWindowProcPtr CopyWindow; + ClearToBackgroundProcPtr ClearToBackground; + ClipNotifyProcPtr ClipNotify; + RestackWindowProcPtr RestackWindow; +#ifdef SHAPE + SetShapeProcPtr SetShape; +#endif } winPrivScreenRec, *winPrivScreenPtr; /* + * Window privates + */ + +typedef struct +{ + HRGN hRgn; +} winPrivWindowRec, *winPrivWindowPtr; + + +/* * Extern declares for general global variables */ @@ -488,6 +520,7 @@ extern int g_iCmapPrivateIndex; extern int g_iGCPrivateIndex; extern int g_iPixmapPrivateIndex; +extern int g_iWindowPrivateIndex; extern unsigned long g_ulServerGeneration; extern CARD32 g_c32LastInputEventTime; extern DWORD g_dwEnginesSupported; @@ -564,10 +597,16 @@ * Window privates macros */ -#define winGetWindowPrivate(_pWin) ((winPrivWin *)\ - (_pWin)->devPrivates[winWindowPrivateIndex].ptr) +#define winGetWindowPriv(pWin) \ + ((winPrivWindowPtr) (pWin)->devPrivates[g_iWindowPrivateIndex].ptr) +#define winSetWindowPriv(pWin,v) \ + ((pWin)->devPrivates[g_iWindowPrivateIndex].ptr = (pointer) v) +#define winWindowPriv(pWin) \ + winPrivWindowPtr pWindowPriv = winGetWindowPriv(pWin) + + /* * FIXME: Windows mouse wheel macro; should be in Cygwin w32api headers. * Has been fixed after May 05, 2001. Remove this section after the @@ -1266,6 +1305,28 @@ Bool winMapWindowNativeGDI (WindowPtr pWindow); +Bool +winCreateWindowPRootless (WindowPtr pWin); + +Bool +winDestroyWindowPRootless (WindowPtr pWin); + +Bool +winPositionWindowPRootless (WindowPtr pWin, int x, int y); + +Bool +winChangeWindowAttributesPRootless (WindowPtr pWin, unsigned long mask); + +Bool +winUnmapWindowPRootless (WindowPtr pWindow); + +Bool +winMapWindowPRootless (WindowPtr pWindow); + +#ifdef SHAPE +void +winSetShapePRootless (WindowPtr pWindow); +#endif /* * winwndproc.c Index: winallpriv.c =================================================================== RCS file: /cvs/xc/programs/Xserver/hw/xwin/winallpriv.c,v retrieving revision 1.10 diff -u -r1.10 winallpriv.c --- winallpriv.c 2002/07/05 09:19:26 1.10 +++ winallpriv.c 2002/10/17 15:23:26 @@ -60,6 +60,7 @@ g_iScreenPrivateIndex = AllocateScreenPrivateIndex (); g_iGCPrivateIndex = AllocateGCPrivateIndex (); g_iPixmapPrivateIndex = AllocatePixmapPrivateIndex (); + g_iWindowPrivateIndex = AllocateWindowPrivateIndex (); g_ulServerGeneration = serverGeneration; } @@ -94,6 +95,14 @@ sizeof (winPrivPixmapRec))) { ErrorF ("winAllocatePrivates () - AllocatePixmapPrivates () failed\n"); + return FALSE; + } + + /* Reserve Window memory for our privates */ + if (!AllocateWindowPrivate (pScreen, g_iWindowPrivateIndex, + sizeof (winPrivWindowRec))) + { + ErrorF ("winAllocatePrivates () - AllocateWindowPrivates () failed\n"); return FALSE; } Index: winscrinit.c =================================================================== RCS file: /cvs/xc/programs/Xserver/hw/xwin/winscrinit.c,v retrieving revision 1.23 diff -u -r1.23 winscrinit.c --- winscrinit.c 2002/07/05 09:19:26 1.23 +++ winscrinit.c 2002/10/17 15:23:29 @@ -355,6 +355,42 @@ } #endif +#if 1 +#define WRAP(a) \ + if (pScreen->a) { \ + pScreenPriv->a = pScreen->a; \ + } else { \ + ErrorF("null screen fn " #a "\n"); \ + pScreenPriv->a = NULL; \ + } + + WRAP(CreateWindow); + WRAP(DestroyWindow); + WRAP(RealizeWindow); + WRAP(UnrealizeWindow); + WRAP(PositionWindow); + WRAP(ChangeWindowAttributes); +#ifdef SHAPE + WRAP(SetShape); +#endif + + + if (pScreenInfo->fPseudoRootless) + { + /* Window Procedures */ + pScreen->CreateWindow = winCreateWindowPRootless; + pScreen->DestroyWindow = winDestroyWindowPRootless; + pScreen->PositionWindow = winPositionWindowPRootless; + pScreen->ChangeWindowAttributes = winChangeWindowAttributesPRootless; + pScreen->RealizeWindow = winMapWindowPRootless; + pScreen->UnrealizeWindow = winUnmapWindowPRootless; +#ifdef SHAPE + pScreen->SetShape = winSetShapePRootless; +#endif + } +#undef WRAP +#endif + /* Wrap either fb's or shadow's CloseScreen with our CloseScreen */ pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = pScreenPriv->pwinCloseScreen; Index: winwindow.c =================================================================== RCS file: /cvs/xc/programs/Xserver/hw/xwin/winwindow.c,v retrieving revision 1.2 diff -u -r1.2 winwindow.c --- winwindow.c 2001/06/04 13:04:41 1.2 +++ winwindow.c 2002/10/17 15:23:30 @@ -31,6 +31,17 @@ #include "win.h" +static int +winAddRgn (WindowPtr pWin, pointer data); + +static void +winUpdateRgn(WindowPtr pWin); + +#ifdef SHAPE +static void +winReshape (WindowPtr pWin); +#endif + /* See Porting Layer Definition - p. 37 */ /* See mfb/mfbwindow.c - mfbCreateWindow() */ Bool @@ -102,3 +113,310 @@ */ return TRUE; } + +/* See Porting Layer Definition - p. 37 */ +/* See mfb/mfbwindow.c - mfbCreateWindow() */ +Bool +winCreateWindowPRootless (WindowPtr pWin) +{ + Bool fResult = FALSE; + winWindowPriv(pWin); + +#if CYGDEBUG + ErrorF ("winCreateWindowPRootless()\n"); +#endif + + fResult = winGetScreenPriv(pWin->drawable.pScreen)->CreateWindow(pWin); + + pWindowPriv->hRgn = NULL; + /*winUpdateRgn (pWin);*/ + + return fResult; +} + +/* See Porting Layer Definition - p. 37 */ +/* See mfb/mfbwindow.c - mfbDestroyWindow() */ +Bool +winDestroyWindowPRootless (WindowPtr pWin) +{ + Bool fResult = FALSE; + winWindowPriv(pWin); + +#if CYGDEBUG + ErrorF ("winDestroyWindowPRootless()\n"); +#endif + + fResult = winGetScreenPriv(pWin->drawable.pScreen)->DestroyWindow(pWin); + + if (pWindowPriv->hRgn != NULL) + { + DeleteObject(pWindowPriv->hRgn); + pWindowPriv->hRgn = NULL; + } + + winUpdateRgn (pWin); + + return fResult; +} + +/* See Porting Layer Definition - p. 37 */ +/* See mfb/mfbwindow.c - mfbPositionWindow() */ +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); + if (wBoundingShape(pWin)) + { + winReshape (pWin); + } + + winUpdateRgn (pWin); + + return fResult; +} + +/* See Porting Layer Definition - p. 37 */ +/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */ +Bool +winChangeWindowAttributesPRootless (WindowPtr pWin, unsigned long mask) +{ + Bool fResult = FALSE; + +#if CYGDEBUG + ErrorF ("winChangeWindowAttributesPRootless()\n"); +#endif + + fResult = winGetScreenPriv(pWin->drawable.pScreen)->ChangeWindowAttributes(pWin, mask); + + winUpdateRgn (pWin); + + return fResult; +} + +/* See Porting Layer Definition - p. 37 + * Also referred to as UnrealizeWindow + */ +Bool +winUnmapWindowPRootless (WindowPtr pWin) +{ + Bool fResult = FALSE; + +#if CYGDEBUG + ErrorF ("winUnmapWindowPRootless()\n"); +#endif + + fResult = winGetScreenPriv(pWin->drawable.pScreen)->UnrealizeWindow(pWin); + + winUpdateRgn (pWin); + + return fResult; +} + +/* See Porting Layer Definition - p. 37 + * Also referred to as RealizeWindow + */ +Bool +winMapWindowPRootless (WindowPtr pWin) +{ + Bool fResult = FALSE; + +#if CYGDEBUG + ErrorF ("winMapWindowPRootless()\n"); +#endif + + fResult = winGetScreenPriv(pWin->drawable.pScreen)->RealizeWindow(pWin); + + winUpdateRgn (pWin); + + return fResult; +} + +#ifdef SHAPE +void +winSetShapePRootless (WindowPtr pWin) +{ +#if CYGDEBUG + ErrorF ("winSetShapePRootless()\n"); +#endif + + winGetScreenPriv(pWin->drawable.pScreen)->SetShape(pWin); + + winReshape (pWin); + winUpdateRgn (pWin); + + return; +} +#endif + +static +int +winAddRgn (WindowPtr pWin, pointer data) +{ + int iX, iY, iWidth, iHeight, iBorder; + HRGN hRgn = *(HRGN*)data; + HRGN hRgnWin = NULL; + winWindowPriv(pWin); + + if (pWin->parent != NULL) /* If pWin is not Root */ + { + 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; + + if (pWindowPriv->hRgn) + { + 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 (CombineRgn(hRgnWin, hRgnWin, pWindowPriv->hRgn, RGN_AND) == ERROR) + { + ErrorF("winSetShapePRootless - CombineRgn() failed\n"); + } + OffsetRgn (hRgnWin, iX, iY); + } + else + { + hRgnWin = CreateRectRgn (iX, iY, iX + iWidth, iY + iHeight); + if (hRgnWin == NULL) + { + ErrorF("winAddRgn - CreateRectRgn() failed\n"); + ErrorF(" Rect %d %d %d %d\n", iX, iY, iX + iWidth, iY + iHeight); + } + } + + if (CombineRgn(hRgn, hRgn, hRgnWin, RGN_OR) == ERROR) + { + ErrorF("winAddRgn - CombineRgn() failed\n"); + } + + DeleteObject(hRgnWin); + } + return WT_DONTWALKCHILDREN; + } + else + { + return WT_WALKCHILDREN; + } +} + +static +void +winUpdateRgn(WindowPtr pWin) +{ + HRGN hRgn = CreateRectRgn (0, 0, 4, 4); + + if (hRgn != NULL) + { + WalkTree (pWin->drawable.pScreen, winAddRgn, &hRgn); + SetWindowRgn (winGetScreenPriv(pWin->drawable.pScreen)->hwndScreen, + hRgn, TRUE); + } + else + { + ErrorF("winUpdateRgn fail to CreateRectRgn\n"); + } +} + +#ifdef SHAPE +static +void +winReshape (WindowPtr pWin) +{ + int nRects; + ScreenPtr pScreen = pWin->drawable.pScreen; + RegionRec newShape; + BoxPtr pXRShape, pXRRects, pXREnd; + HRGN hRgn, hRgnRect; + winWindowPriv(pWin); + +#if CYGDEBUG + ErrorF ("winReshape()\n"); +#endif + + if (pWin->parent == NULL) + { /* If pWin is Root */ + return; + } + else if (pWin->parent->parent != NULL) + { /* If pWin is not top level */ + return; + } + + if (wBoundingShape(pWin)) + { + REGION_INIT(pScreen, &newShape, NullBox, 0); + REGION_COPY(pScreen, &newShape, wBoundingShape(pWin)); + REGION_TRANSLATE(pScreen, &newShape, pWin->borderWidth, + pWin->borderWidth); + } + else + { + if (pWindowPriv->hRgn != NULL) + { + DeleteObject(pWindowPriv->hRgn); + pWindowPriv->hRgn = NULL; + return; + } + } + + nRects = REGION_NUM_RECTS(&newShape); + pXRShape = REGION_RECTS(&newShape); + + if (nRects > 0) + { + hRgn = CreateRectRgn (0, 0, 0, 0); + for (pXRRects = pXRShape, pXREnd = pXRShape+nRects; pXRRects < pXREnd; pXRRects++) + { + hRgnRect = CreateRectRgn(pXRRects->x1, pXRRects->y1, + pXRRects->x2, pXRRects->y2); + if (hRgnRect == NULL) + { + ErrorF("winReshape - CreateRectRgn() failed\n"); + } + + if (CombineRgn(hRgn, hRgn, hRgnRect, RGN_OR) == ERROR) + { + ErrorF("winReshape - CombineRgn() failed\n"); + } + + DeleteObject(hRgnRect); + } + + if (pWindowPriv->hRgn != NULL) + { + DeleteObject(pWindowPriv->hRgn); + } + pWindowPriv->hRgn = hRgn; + } + else + { + if (pWindowPriv->hRgn != NULL) + { + DeleteObject(pWindowPriv->hRgn); + pWindowPriv->hRgn = NULL; + } + + } + + REGION_UNINIT(pScreen, &newShape); + winUpdateRgn (pWin); + + return; +} +#endif Index: winwndproc.c =================================================================== RCS file: /cvs/xc/programs/Xserver/hw/xwin/winwndproc.c,v retrieving revision 1.22 diff -u -r1.22 winwndproc.c --- winwndproc.c 2002/07/05 09:19:27 1.22 +++ winwndproc.c 2002/10/17 15:23:32 @@ -245,33 +245,39 @@ case WM_LBUTTONDOWN: if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) break; + SetCapture(hwnd); return winMouseButtonsHandle (s_pScreen, ButtonPress, Button1, wParam); case WM_LBUTTONUP: if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) break; + ReleaseCapture(); return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button1, wParam); case WM_MBUTTONDBLCLK: case WM_MBUTTONDOWN: if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) break; + SetCapture(hwnd); return winMouseButtonsHandle (s_pScreen, ButtonPress, Button2, wParam); case WM_MBUTTONUP: if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) break; + ReleaseCapture(); return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button2, wParam); case WM_RBUTTONDBLCLK: case WM_RBUTTONDOWN: if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) break; + SetCapture(hwnd); return winMouseButtonsHandle (s_pScreen, ButtonPress, Button3, wParam); case WM_RBUTTONUP: if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) break; + ReleaseCapture(); return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button3, wParam); case WM_TIMER: