diff --git a/hw/xwin/win.h b/hw/xwin/win.h index 9f0de66d8..994e12b99 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -508,7 +508,7 @@ typedef struct _winPrivScreenRec /* Privates used by both multi-window and rootless */ Bool fRootWindowShown; Bool fRestacking; - Bool fWindowOrderChanged; /* Only for rootless */ + Bool fWindowOrderChanged; #if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) /* Privates used for any module running in a seperate thread */ diff --git a/hw/xwin/winblock.c b/hw/xwin/winblock.c index 589aae493..941c2b53c 100644 --- a/hw/xwin/winblock.c +++ b/hw/xwin/winblock.c @@ -88,6 +88,11 @@ winBlockHandler_ProcessMessages: } } +#ifdef XWIN_MULTIWINDOW + if (pScreenPriv->pScreenInfo->fMultiWindow) + winReorderWindowsMultiWindow ((ScreenPtr)pBlockData); +#endif + #ifdef XWIN_MULTIWINDOWEXTWM if (pScreenPriv->pScreenInfo->fMWExtWM) winMWExtWMReorderWindows ((ScreenPtr)pBlockData); diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 3c23248c9..30870e70e 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -737,9 +737,7 @@ winFindWindow (pointer value, XID id, pointer cdata) /* - * winReorderWindowsMultiWindow - - * - * Change X windows' Z orders with respect to their Windows counterparts. + * winReorderWindowsMultiWindow - */ void @@ -756,41 +754,48 @@ winReorderWindowsMultiWindow (ScreenPtr pScreen) #if CYGMULTIWINDOW_DEBUG ErrorF ("winReorderWindowsMultiWindow\n"); #endif - + pScreenPriv->fRestacking = TRUE; - hwnd = GetTopWindow (NULL); - - while (hwnd) + if (pScreenPriv->fWindowOrderChanged) { - GetWindowThreadProcessId (hwnd, &dwWindowProcessID); +#if CYGMULTIWINDOW_DEBUG + ErrorF ("winReorderWindowsMultiWindow - Need to restack\n"); +#endif + hwnd = GetTopWindow (NULL); - if ( (dwWindowProcessID == dwCurrentProcessID) - && GetProp (hwnd, WIN_WINDOW_PROP) - && !IsIconic (hwnd) ) /* ignore minimized windows */ + while (hwnd) { - 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; + GetWindowThreadProcessId (hwnd, &dwWindowProcessID); - ConfigureWindow (pWin, CWSibling | CWStackMode, - vlist, wClient(pWin)); + if ( (dwWindowProcessID == dwCurrentProcessID) + && 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)); + } } + hwnd = GetNextWindow (hwnd, GW_HWNDNEXT); } - hwnd = GetNextWindow (hwnd, GW_HWNDNEXT); } pScreenPriv->fRestacking = FALSE; + pScreenPriv->fWindowOrderChanged = FALSE; } diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index 1cc9f493f..fc295fbae 100755 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -620,7 +620,6 @@ winTopLevelWindowProc (HWND hwnd, UINT message, break; winRestoreModeKeyStates (); - winReorderWindowsMultiWindow (s_pScreen); return 0; case WM_KILLFOCUS: @@ -727,6 +726,9 @@ winTopLevelWindowProc (HWND hwnd, UINT message, /* Pass the message to the root window */ SendMessage (hwndScreen, message, wParam, lParam); + if (s_pScreenPriv != NULL) + s_pScreenPriv->fWindowOrderChanged = TRUE; + if (LOWORD(wParam) != WA_INACTIVE) { /* Tell our Window Manager thread to activate the window */ @@ -888,6 +890,8 @@ winTopLevelWindowProc (HWND hwnd, UINT message, if (fWMMsgInitialized) winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg); + if (s_pScreenPriv != NULL) + s_pScreenPriv->fWindowOrderChanged = TRUE; return 0; case WM_SIZING: @@ -896,6 +900,16 @@ winTopLevelWindowProc (HWND hwnd, UINT message, return ValidateSizing (hwnd, pWin, wParam, lParam); case WM_WINDOWPOSCHANGED: + if (!( ((LPWINDOWPOS)lParam)->flags + & SWP_NOZORDER )) + { +#if CYGWINDOWING_DEBUG + ErrorF ("winTopLevelWindowProc - WM_WINDOWPOSCHANGED: " + "Z order is changed\n"); +#endif + if (s_pScreenPriv != NULL) + s_pScreenPriv->fWindowOrderChanged = TRUE; + } /* * Pass the message to DefWindowProc to let the function * break down WM_WINDOWPOSCHANGED to WM_MOVE and WM_SIZE.