diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2015-05-21 16:02:51 +0100 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2015-06-02 14:39:03 +0100 |
commit | 15a26da2516cc15e2f9d23379714e66d22844024 (patch) | |
tree | c2dfd2da7dec4fae2918642f642ea112a6fa7277 | |
parent | bf3c9ca09a1035cfe650958d2117e00165909170 (diff) |
Track the window state in multiwindow mode.
Track the window state (hidden, mimimized, shown, maximized) when changed by
WM_CHANGE_STATE or via the native frame.
-rw-r--r-- | hw/xwin/winmultiwindowwindow.c | 50 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwm.c | 52 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwndproc.c | 30 | ||||
-rw-r--r-- | hw/xwin/winwindow.h | 4 |
4 files changed, 81 insertions, 55 deletions
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 499ba9f08..477853dce 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -1012,56 +1012,6 @@ winReorderWindowsMultiWindow(void) } /* - * winMinimizeWindow - Minimize in response to WM_CHANGE_STATE - */ - -void -winMinimizeWindow(Window id) -{ - WindowPtr pWin; - winPrivWinPtr pWinPriv; - -#ifdef XWIN_MULTIWINDOWEXTWM - win32RootlessWindowPtr pRLWinPriv; -#endif - HWND hWnd; - ScreenPtr pScreen = NULL; - winPrivScreenPtr pScreenPriv = NULL; - -#if CYGWINDOWING_DEBUG - ErrorF("winMinimizeWindow\n"); -#endif - - dixLookupResourceByType((void *) &pWin, id, RT_WINDOW, NullClient, - DixUnknownAccess); - if (!pWin) { - ErrorF("%s: NULL pWin. Leaving\n", __FUNCTION__); - return; - } - - pScreen = pWin->drawable.pScreen; - if (pScreen) - pScreenPriv = winGetScreenPriv(pScreen); - -#ifdef XWIN_MULTIWINDOWEXTWM - if (pScreenPriv && pScreenPriv->pScreenInfo->fInternalWM) { - pRLWinPriv = - (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE); - hWnd = pRLWinPriv->hWnd; - } - else -#else - if (pScreenPriv) -#endif - { - pWinPriv = winGetWindowPriv(pWin); - hWnd = pWinPriv->hWnd; - } - - ShowWindow(hWnd, SW_MINIMIZE); -} - -/* * CopyWindow - See Porting Layer Definition - p. 39 */ void diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index e2bd7e127..050969991 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -755,6 +755,54 @@ UpdateStyle(WMInfoPtr pWMInfo, Window iWindow) winApplyUrgency(pWMInfo->pDisplay, iWindow, hWnd); } +/* + * Updates the state of a HWND + */ + +static void +UpdateState(WMInfoPtr pWMInfo, Window iWindow, int state) +{ + HWND hWnd; + int current_state; + + winDebug("UpdateState: iWindow 0x%08x %d\n", (int)iWindow, state); + + hWnd = getHwnd(pWMInfo, iWindow); + if (!hWnd) + return; + + // Keep track of the Window state, do nothing if it's not changing + current_state = (intptr_t)GetProp(hWnd, WIN_STATE_PROP); + + if (current_state == state) + return; + + SetProp(hWnd, WIN_STATE_PROP, (HANDLE)(intptr_t)state); + + switch (state) + { + case IconicState: + ShowWindow(hWnd, SW_SHOWMINNOACTIVE); + break; + + case ZoomState: + // ZoomState should only come internally, not from a client + // There doesn't seem to be a SW_SHOWMAXNOACTIVE, but Window should + // already displayed correctly. + break; + + case NormalState: + ShowWindow(hWnd, SW_SHOWNA); + break; + + case WithdrawnState: + ShowWindow(hWnd, SW_HIDE); + break; + } + + // XXX: should also set WM_STATE, _NET_WM_STATE property +} + #if 0 /* * Fix up any differences between the X11 and Win32 window stacks @@ -1006,8 +1054,7 @@ winMultiWindowWMProc(void *pArg) break; case WM_WM_CHANGE_STATE: - /* Minimize the window in Windows */ - winMinimizeWindow(pNode->msg.iWindow); + UpdateState(pWMInfo, pNode->msg.iWindow, pNode->msg.dwID); break; default: @@ -1359,6 +1406,7 @@ winMultiWindowXMsgProc(void *pArg) msg.msg = WM_WM_CHANGE_STATE; msg.iWindow = event.xclient.window; + msg.dwID = event.xclient.data.l[0]; winSendMessageToWM(pProcArg->pWMInfo, &msg); } diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index 117b8a31d..65f1484ad 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -295,6 +295,31 @@ winStartMousePolling(winPrivScreenPtr s_pScreenPriv) MOUSE_POLLING_INTERVAL, NULL); } +static +void +winAdjustXWindowState(winPrivScreenPtr s_pScreenPriv, winWMMessageRec *wmMsg) +{ + wmMsg->msg = WM_WM_CHANGE_STATE; + if (IsIconic(wmMsg->hwndWindow)) { + wmMsg->dwID = 3; // IconicState + winSendMessageToWM(s_pScreenPriv->pWMInfo, wmMsg); + } + else if (IsZoomed(wmMsg->hwndWindow)) { + wmMsg->dwID = 2; // ZoomState + winSendMessageToWM(s_pScreenPriv->pWMInfo, wmMsg); + } + else if (IsWindowVisible(wmMsg->hwndWindow)) { + wmMsg->dwID = 1; // NormalState + winSendMessageToWM(s_pScreenPriv->pWMInfo, wmMsg); + } + else { + /* Only the client, not the user can Withdraw windows, so it doesn't make + much sense to handle that state here, and anything else is an + unanticapted state. */ + ErrorF("winAdjustXWindowState - Unknown state for %p\n", wmMsg->hwndWindow); + } +} + /* * winTopLevelWindowProc - Window procedure for all top-level Windows windows. */ @@ -869,6 +894,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) RemoveProp(hwnd, WIN_WINDOW_PROP); RemoveProp(hwnd, WIN_WID_PROP); RemoveProp(hwnd, WIN_NEEDMANAGE_PROP); + RemoveProp(hwnd, WIN_STATE_PROP); break; @@ -1017,6 +1043,8 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* Adjust the X Window to the moved Windows window */ hasEnteredSizeMove = FALSE; winAdjustXWindow(pWin, hwnd); + if (fWMMsgInitialized) + winAdjustXWindowState(s_pScreenPriv, &wmMsg); return 0; case WM_SIZE: @@ -1046,6 +1074,8 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (!hasEnteredSizeMove) { /* Adjust the X Window to the moved Windows window */ winAdjustXWindow(pWin, hwnd); + if (fWMMsgInitialized) + winAdjustXWindowState(s_pScreenPriv, &wmMsg); if (wParam == SIZE_MINIMIZED) winReorderWindowsMultiWindow(); } diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h index a5b9a386c..d21274f4f 100644 --- a/hw/xwin/winwindow.h +++ b/hw/xwin/winwindow.h @@ -58,6 +58,7 @@ #endif #define WIN_WID_PROP "cyg_wid_prop_rl" #define WIN_NEEDMANAGE_PROP "cyg_override_redirect_prop_rl" +#define WIN_STATE_PROP "cyg_state_prop_rl" #ifndef CYGMULTIWINDOW_DEBUG #define CYGMULTIWINDOW_DEBUG NO #endif @@ -149,9 +150,6 @@ void winDeinitMultiWindowWM(void); void - winMinimizeWindow(Window id); - -void winPropertyStoreInit(void); void |