diff options
author | Takuma Murakami <takuma@dgp.ne.jp> | 2004-03-25 12:43:39 +0000 |
---|---|---|
committer | Takuma Murakami <takuma@dgp.ne.jp> | 2004-03-25 12:43:39 +0000 |
commit | 40bb4441ac7c87cfa0c62e8553c7e53b9fe4d765 (patch) | |
tree | 209c43162b38abb0114c2b6c3b46d7271079f6fe /hw | |
parent | bc966c4f198bf975a7a187b3bffffd993cc39c45 (diff) |
Remove fAlwaysOnTop and PreserveWin32Stack() instead of reinstating
winReorderWindowsMultiWindow(), which now inhibits reentries to avoid
infinite restacking. Call winReorderWindowsMultiWindow() in appropriate
places to keep consistent window Z order even if always-on-top windows
are mixed. (Earle F. Philhower III and Takuma Murakami)
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xwin/win.h | 3 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwindow.c | 73 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwm.c | 57 | ||||
-rwxr-xr-x | hw/xwin/winmultiwindowwndproc.c | 34 | ||||
-rw-r--r-- | hw/xwin/winprefs.c | 4 | ||||
-rw-r--r-- | hw/xwin/winwindow.h | 1 |
6 files changed, 124 insertions, 48 deletions
diff --git a/hw/xwin/win.h b/hw/xwin/win.h index 1216af090..4e9d89b28 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -1524,6 +1524,9 @@ void winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib); void +winReorderWindowsMultiWindow (void); + +void winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w, unsigned int h, WindowPtr pSib); void diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 87544802e..b974efa40 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -103,7 +103,6 @@ winCreateWindowMultiWindow (WindowPtr pWin) pWinPriv->hWnd = NULL; pWinPriv->pScreenPriv = winGetScreenPriv(pWin->drawable.pScreen); pWinPriv->fXKilled = FALSE; - pWinPriv->fAlwaysOnTop = FALSE; return fResult; } @@ -389,8 +388,14 @@ winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib) if (winGetScreenPriv(pWin->drawable.pScreen)->RestackWindow) winGetScreenPriv(pWin->drawable.pScreen)->RestackWindow (pWin, pOldNextSib); - -#if 0 + +#if 1 + /* + * Calling winReorderWindowsMultiWindow here means our window manager + * (i.e. Windows Explorer) has initiative to determine Z order. + */ + winReorderWindowsMultiWindow (); +#else /* Bail out if no window privates or window handle is invalid */ if (!pWinPriv || !pWinPriv->hWnd) return; @@ -574,7 +579,7 @@ winCreateWindowsWindow (WindowPtr pWin) /* Change style back to popup, already placed... */ SetWindowLong (hWnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); SetWindowPos (hWnd, 0, 0, 0, 0, 0, - SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE); + SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE); pWinPriv->hWnd = hWnd; @@ -749,6 +754,66 @@ winFindWindow (pointer value, XID id, pointer cdata) /* + * winReorderWindowsMultiWindow - + */ + +void +winReorderWindowsMultiWindow (void) +{ + HWND hwnd = NULL; + WindowPtr pWin = NULL; + WindowPtr pWinSib = NULL; + XID vlist[2]; + static Bool fRestacking = FALSE; /* Avoid recusive calls to this function */ + +#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG + ErrorF ("winReorderWindowsMultiWindow\n"); +#endif + + if (fRestacking) + { + /* It is a recusive call so immediately exit */ +#if CYGWINDOWING_DEBUG + ErrorF ("winReorderWindowsMultiWindow - " + "exit because fRestacking == TRUE\n"); +#endif + return; + } + fRestacking = TRUE; + + /* Loop through top level Window windows, descending in Z order */ + for ( hwnd = GetTopWindow (NULL); + hwnd; + hwnd = GetNextWindow (hwnd, GW_HWNDNEXT) ) + { + if ( GetProp (hwnd, WIN_WINDOW_PROP) + && !IsIconic (hwnd) ) /* ignore minimized windows */ + { + pWinSib = pWin; + pWin = GetProp (hwnd, WIN_WINDOW_PROP); + + if (!pWinSib) + { /* 1st window - raise to the top */ + vlist[0] = Above; + + ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin)); + } + else + { /* 2nd or deeper windows - just below the previous one */ + vlist[0] = winGetWindowID (pWinSib); + vlist[1] = Below; + + ConfigureWindow (pWin, CWSibling | CWStackMode, + vlist, wClient(pWin)); + } + } + } + + fRestacking = FALSE; +} + + +/* * winMinimizeWindow - Minimize in response to WM_CHANGE_STATE */ diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 0ba4ff4e6..c5eaaee03 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -164,8 +164,11 @@ winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr); static void winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg); +#if 0 static void PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction); +#endif + /* * Local globals @@ -514,6 +517,8 @@ UpdateName (WMInfoPtr pWMInfo, Window iWindow) } } + +#if 0 /* * Fix up any differences between the X11 and Win32 window stacks * starting at the window passed in @@ -528,7 +533,7 @@ PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction) DWORD myWinProcID, winProcID; Window xWindow; WINDOWPLACEMENT wndPlace; - + hWnd = NULL; /* See if we can get the cached HWND for this window... */ if (XGetWindowProperty (pWMInfo->pDisplay, @@ -545,39 +550,41 @@ PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction) (unsigned char **) &retHwnd) == Success) { if (retHwnd) - { - hWnd = *retHwnd; - XFree (retHwnd); - } + { + hWnd = *retHwnd; + XFree (retHwnd); + } } if (!hWnd) return; - + GetWindowThreadProcessId (hWnd, &myWinProcID); hWnd = GetNextWindow (hWnd, direction); - + while (hWnd) { GetWindowThreadProcessId (hWnd, &winProcID); - if (winProcID == myWinProcID) + if (winProcID == myWinProcID) { - wndPlace.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement (hWnd, &wndPlace); - if ( !(wndPlace.showCmd==SW_HIDE || - wndPlace.showCmd==SW_MINIMIZE) ) - { - xWindow = (Window)GetProp (hWnd, WIN_WID_PROP); - if (xWindow) - { - if (direction==GW_HWNDPREV) - XRaiseWindow (pWMInfo->pDisplay, xWindow); - else - XLowerWindow (pWMInfo->pDisplay, xWindow); - } - } + wndPlace.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement (hWnd, &wndPlace); + if ( !(wndPlace.showCmd==SW_HIDE || + wndPlace.showCmd==SW_MINIMIZE) ) + { + xWindow = (Window)GetProp (hWnd, WIN_WID_PROP); + if (xWindow) + { + if (direction==GW_HWNDPREV) + XRaiseWindow (pWMInfo->pDisplay, xWindow); + else + XLowerWindow (pWMInfo->pDisplay, xWindow); + } + } } hWnd = GetNextWindow(hWnd, direction); } } +#endif /* PreserveWin32Stack */ + /* * winMultiWindowWMProc @@ -635,7 +642,9 @@ winMultiWindowWMProc (void *pArg) #endif /* Raise the window */ XRaiseWindow (pWMInfo->pDisplay, pNode->msg.iWindow); +#if 0 PreserveWin32Stack (pWMInfo, pNode->msg.iWindow, GW_HWNDPREV); +#endif break; case WM_WM_LOWER: @@ -662,8 +671,10 @@ winMultiWindowWMProc (void *pArg) 1); UpdateName (pWMInfo, pNode->msg.iWindow); winUpdateIcon (pNode->msg.iWindow); - /* Handles the case where there are AOT windows above it in W32 */ +#if 0 + /* Handles the case where there are AOT windows above it in W32 */ PreserveWin32Stack (pWMInfo, pNode->msg.iWindow, GW_HWNDPREV); +#endif break; case WM_WM_UNMAP: diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index d3fe40884..5c8fa754a 100755 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -364,6 +364,12 @@ winTopLevelWindowProc (HWND hwnd, UINT message, WIN_WID_PROP, (HANDLE)winGetWindowID (((LPCREATESTRUCT) lParam)->lpCreateParams)); + /* + * Make X windows' Z orders sync with Windows windows because + * there can be AlwaysOnTop windows overlapped on the window + * currently being created. + */ + winReorderWindowsMultiWindow (); return 0; case WM_INIT_SYS_MENU: @@ -883,9 +889,14 @@ winTopLevelWindowProc (HWND hwnd, UINT message, SetForegroundWindow (hwnd); } } - else /* It is an overridden window so make it top of Z stack */ - SetWindowPos (hwnd, HWND_TOPMOST, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); + else /* It is an overridden window so make it top of Z stack */ + { +#if CYGWINDOWING_DEBUG + ErrorF ("overridden window is shown\n"); +#endif + SetWindowPos (hwnd, HWND_TOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE); + } /* Setup the Window Manager message */ wmMsg.msg = WM_WM_MAP; @@ -934,23 +945,6 @@ winTopLevelWindowProc (HWND hwnd, UINT message, (int)(GetTickCount ())); } #endif - if (wParam==SIZE_MINIMIZED) - { - if (GetWindowLong (hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) - pWinPriv->fAlwaysOnTop = TRUE; - else - pWinPriv->fAlwaysOnTop = FALSE; - - SetWindowPos (hwnd, HWND_BOTTOM, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE ); - } - else if (wParam==SIZE_RESTORED) - { - if (pWinPriv->fAlwaysOnTop) - SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, - SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE ); - - } /* Adjust the X Window to the moved Windows window */ winAdjustXWindow (pWin, hwnd); return 0; /* end of WM_SIZE handler */ diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c index 92216632a..4ce312912 100644 --- a/hw/xwin/winprefs.c +++ b/hw/xwin/winprefs.c @@ -366,6 +366,10 @@ HandleCustomWM_COMMAND (unsigned long hwndIn, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); +#if XWIN_MULTIWINDOW + /* Reflect the changed Z order */ + winReorderWindowsMultiWindow (); +#endif return TRUE; case CMD_RELOAD: diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h index d5e80ac2d..53cf9d813 100644 --- a/hw/xwin/winwindow.h +++ b/hw/xwin/winwindow.h @@ -67,7 +67,6 @@ typedef struct HWND hWnd; winPrivScreenPtr pScreenPriv; Bool fXKilled; - Bool fAlwaysOnTop; /* Privates used by primary fb DirectDraw server */ LPDDSURFACEDESC pddsdPrimary; |