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/15 13:08:02 @@ -132,6 +132,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 +875,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/15 13:08:06 @@ -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,6 +475,23 @@ 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; } winPrivScreenRec, *winPrivScreenPtr; @@ -1265,6 +1284,24 @@ 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); /* 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/15 13:08:09 @@ -355,6 +355,35 @@ } #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); + + if (pScreenInfo->fPseudoRootless) + { + /* Window Procedures */ + pScreen->CreateWindow = winCreateWindowPRootless; + pScreen->DestroyWindow = winDestroyWindowPRootless; + pScreen->PositionWindow = winPositionWindowPRootless; + pScreen->ChangeWindowAttributes = winChangeWindowAttributesPRootless; + pScreen->RealizeWindow = winMapWindowPRootless; + pScreen->UnrealizeWindow = winUnmapWindowPRootless; + } +#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/15 13:08:10 @@ -31,6 +31,12 @@ #include "win.h" +static int +winAddRgn (WindowPtr pWin, pointer data); + +static void +winUpdateRgn(WindowPtr pWin); + /* See Porting Layer Definition - p. 37 */ /* See mfb/mfbwindow.c - mfbCreateWindow() */ Bool @@ -101,4 +107,175 @@ * we probably won't need to do anything */ return TRUE; +} + +/* See Porting Layer Definition - p. 37 */ +/* See mfb/mfbwindow.c - mfbCreateWindow() */ +Bool +winCreateWindowPRootless (WindowPtr pWin) +{ + Bool fResult = FALSE; + +#if CYGDEBUG + ErrorF ("winCreateWindowPRootless()\n"); +#endif + + fResult = winGetScreenPriv(pWin->drawable.pScreen)->CreateWindow(pWin); + + /*winUpdateRgn (pWin);*/ + + return fResult; +} + +/* See Porting Layer Definition - p. 37 */ +/* See mfb/mfbwindow.c - mfbDestroyWindow() */ +Bool +winDestroyWindowPRootless (WindowPtr pWin) +{ + Bool fResult = FALSE; + +#if CYGDEBUG + ErrorF ("winDestroyWindowPRootless()\n"); +#endif + + fResult = winGetScreenPriv(pWin->drawable.pScreen)->DestroyWindow(pWin); + + 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); + + 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; +} + +static +int +winAddRgn (WindowPtr pWin, pointer data) +{ + int iX, iY, iWidth, iHeight, iBorder; + HRGN hRgn = *(HRGN*)data; + HRGN hRgnWin; + + if (pWin->parent != NULL) /* If pWin is not Root */ + { + ErrorF("winAddRgn()\n"); + 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 (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"); + } } 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/15 13:08:11 @@ -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: