From 66f7e5d163b1f48eb2f83e4052838872fcee6ecc Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 25 Oct 2011 14:26:22 +0200 Subject: [PATCH] win32: Fix up window_show We don't pass in raise anymore, but already_mapped. Also, already_mapped must be used rather than MAPPED, as we already synthesize the MAPPED in the generic code (and thus we don't have to synthesize it again). --- gdk/win32/gdkwindow-win32.c | 70 ++++++++----------------------------- 1 file changed, 15 insertions(+), 55 deletions(-) diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index db2b04eb60..449a286d64 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -889,31 +889,30 @@ adjust_for_gravity_hints (GdkWindow *window, static void show_window_internal (GdkWindow *window, - gboolean raise, + gboolean already_mapped, gboolean deiconify) { HWND old_active_window; - gboolean focus_on_map = TRUE; + gboolean focus_on_map = FALSE; DWORD exstyle; HWND top; if (window->destroyed) return; - GDK_NOTE (MISC, g_print ("show_window_internal: %p: %s%s%s\n", + GDK_NOTE (MISC, g_print ("show_window_internal: %p: %s%s\n", GDK_WINDOW_HWND (window), _gdk_win32_window_state_to_string (window->state), - (raise ? " raise" : ""), (deiconify ? " deiconify" : ""))); /* If asked to show (not deiconify) an withdrawn and iconified * window, do that. */ if (!deiconify && - !GDK_WINDOW_IS_MAPPED (window) && + !already_mapped && (window->state & GDK_WINDOW_STATE_ICONIFIED)) { - ShowWindow (GDK_WINDOW_HWND (window), SW_MINIMIZE); + ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWMINNOACTIVE); return; } @@ -931,18 +930,13 @@ show_window_internal (GdkWindow *window, /* If asked to show (but not raise) a window that is already * visible, do nothing. */ - if (!deiconify && !raise && IsWindowVisible (GDK_WINDOW_HWND (window))) + if (!deiconify && !already_mapped && IsWindowVisible (GDK_WINDOW_HWND (window))) return; /* Other cases */ - if (!GDK_WINDOW_IS_MAPPED (window)) - { - gdk_synthesize_window_state (window, - GDK_WINDOW_STATE_WITHDRAWN, - 0); - focus_on_map = window->focus_on_map; - } + if (!already_mapped) + focus_on_map = window->focus_on_map; exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE); @@ -962,11 +956,9 @@ show_window_internal (GdkWindow *window, */ if (exstyle & WS_EX_TRANSPARENT) { - UINT flags = SWP_SHOWWINDOW | SWP_NOREDRAW | SWP_NOMOVE | SWP_NOSIZE; + UINT flags = SWP_SHOWWINDOW | SWP_NOREDRAW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER; - if (!raise) - flags |= SWP_NOZORDER; - if (!raise || GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP || !focus_on_map) + if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP || !focus_on_map) flags |= SWP_NOACTIVATE; SetWindowPos (GDK_WINDOW_HWND (window), top, 0, 0, 0, 0, flags); @@ -974,8 +966,6 @@ show_window_internal (GdkWindow *window, return; } - old_active_window = GetActiveWindow (); - if (window->state & GDK_WINDOW_STATE_FULLSCREEN) { gdk_window_fullscreen (window); @@ -986,7 +976,10 @@ show_window_internal (GdkWindow *window, } else if (window->state & GDK_WINDOW_STATE_ICONIFIED) { - ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE); + if (focus_on_map) + ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE); + else + ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNOACTIVATE); } else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP || !focus_on_map) { @@ -996,39 +989,6 @@ show_window_internal (GdkWindow *window, { ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNORMAL); } - - if (raise) - { - if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP) - SetWindowPos (GDK_WINDOW_HWND (window), HWND_TOPMOST, - 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); - else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL) - { - if (focus_on_map && window->accept_focus) - { - SetForegroundWindow (GDK_WINDOW_HWND (window)); - if (top == HWND_TOPMOST) - SetWindowPos (GDK_WINDOW_HWND (window), top, - 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); - } - else - { - SetWindowPos (GDK_WINDOW_HWND (window), top, - 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); - } - } - else - { - BringWindowToTop (GDK_WINDOW_HWND (window)); - } - } - else if (old_active_window != GDK_WINDOW_HWND (window)) - { - SetActiveWindow (old_active_window); - } } static void @@ -2634,7 +2594,7 @@ gdk_win32_window_deiconify (GdkWindow *window) if (GDK_WINDOW_IS_MAPPED (window)) { - show_window_internal (window, FALSE, TRUE); + show_window_internal (window, GDK_WINDOW_IS_MAPPED (window), TRUE); } else {