summaryrefslogtreecommitdiff
path: root/hw/xwin
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2015-07-01 23:17:31 +0100
committerJon Turney <jon.turney@dronecode.org.uk>2015-11-11 11:56:35 +0000
commited7849f422df03f9c16109156253f91eafa28ddd (patch)
tree10675ced3456f2b751dc225668043feec551fcdb /hw/xwin
parent4cd600b92d5e46d31b60c6f0228557eb0d025532 (diff)
Map window in WM_WINDOWPOSCHANGED not WM_SHOWWINDOW
Instead of using WM_SHOWWINDOW, use WM_WINDOWPOSCHANGED SWP_(SHOW|HIDE)WINDOW events to map and unmap the window. WM_WINDOWPOSCHANGED doesn't have the quirks that WM_SHOWWINDOW has, which can lead to it being emitted multiple times while the window is in the shown state, so it's a reliable way of reacting to the window being shown and hidden. See also http://blogs.msdn.com/b/oldnewthing/archive/2008/01/15/7113860.aspx
Diffstat (limited to 'hw/xwin')
-rw-r--r--hw/xwin/winmultiwindowwndproc.c128
1 files changed, 64 insertions, 64 deletions
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 05cfd5929..f9f829a46 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -905,65 +905,6 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* else: Wait for WM_EXITSIZEMOVE */
return 0;
- case WM_SHOWWINDOW:
- /* Bail out if the window is being hidden */
- if (!wParam)
- return 0;
-
- /* */
- if (!pWin->overrideRedirect) {
- HWND zstyle = HWND_NOTOPMOST;
-
- /* Flag that this window needs to be made active when clicked */
- SetProp(hwnd, WIN_NEEDMANAGE_PROP, (HANDLE) 1);
-
- winUpdateWindowPosition(hwnd, &zstyle);
-
- {
- WinXWMHints hints;
-
- if (winMultiWindowGetWMHints(pWin, &hints)) {
- /*
- Give the window focus, unless it has an InputHint
- which is FALSE (this is used by e.g. glean to
- avoid every test window grabbing the focus)
- */
- if (!((hints.flags & InputHint) && (!hints.input))) {
- SetForegroundWindow(hwnd);
- }
- }
- }
- wmMsg.msg = WM_WM_MAP_MANAGED;
- }
- else { /* It is an overridden window so make it top of Z stack */
-
- HWND forHwnd = GetForegroundWindow();
-
-#if CYGWINDOWING_DEBUG
- ErrorF("overridden window is shown\n");
-#endif
- if (forHwnd != NULL) {
- if (GetWindowLongPtr(forHwnd, GWLP_USERDATA) & (LONG_PTR)
- XMING_SIGNATURE) {
- if (GetWindowLongPtr(forHwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
- SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- else
- SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- }
- }
- wmMsg.msg = WM_WM_MAP_UNMANAGED;
- }
-
- /* Tell our Window Manager thread to map the window */
- if (fWMMsgInitialized)
- winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg);
-
- winStartMousePolling(s_pScreenPriv);
-
- return 0;
-
case WM_SIZING:
/* Need to legalize the size according to WM_NORMAL_HINTS */
/* for applications like xterm */
@@ -1016,12 +957,71 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
}
}
}
+
+ /* Window is being shown */
+ if (pWinPos->flags & SWP_SHOWWINDOW) {
+ if (!pWin->overrideRedirect) {
+ HWND zstyle = HWND_NOTOPMOST;
+
+ /* Flag that this window needs to be made active when clicked */
+ SetProp(hwnd, WIN_NEEDMANAGE_PROP, (HANDLE) 1);
+
+ winUpdateWindowPosition(hwnd, &zstyle);
+
+ {
+ WinXWMHints hints;
+
+ if (winMultiWindowGetWMHints(pWin, &hints)) {
+ /*
+ Give the window focus, unless it has an InputHint
+ which is FALSE (this is used by e.g. glean to
+ avoid every test window grabbing the focus)
+ */
+ if (!((hints.flags & InputHint) && (!hints.input))) {
+ SetForegroundWindow(hwnd);
+ }
+ }
+ }
+ wmMsg.msg = WM_WM_MAP_MANAGED;
+ }
+ else { /* It is an overridden window so make it top of Z stack */
+ HWND forHwnd = GetForegroundWindow();
+
+ if (forHwnd != NULL) {
+ if (GetWindowLongPtr(forHwnd, GWLP_USERDATA) & (LONG_PTR)
+ XMING_SIGNATURE) {
+ if (GetWindowLongPtr(forHwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
+ SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ else
+ SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ }
+ }
+ wmMsg.msg = WM_WM_MAP_UNMANAGED;
+ }
+
+ /* Tell our Window Manager thread to map the window */
+ if (fWMMsgInitialized)
+ winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg);
+
+ winStartMousePolling(s_pScreenPriv);
+ }
+
+ /* Window is being hidden */
+ if (pWinPos->flags & SWP_HIDEWINDOW) {
+ /* Tell our Window Manager thread to unmap the window */
+ wmMsg.msg = WM_WM_UNMAP;
+
+ if (fWMMsgInitialized)
+ winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg);
+ }
}
- /*
- * Pass the message to DefWindowProc to let the function
- * break down WM_WINDOWPOSCHANGED to WM_MOVE and WM_SIZE.
- */
- break;
+ /*
+ * Pass the message to DefWindowProc to let the function
+ * break down WM_WINDOWPOSCHANGED to WM_MOVE and WM_SIZE.
+ */
+ break;
case WM_ENTERSIZEMOVE:
hasEnteredSizeMove = TRUE;