From 725379192d76bf9885c93ca2e06c656121bbcdda Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 26 Oct 2011 11:08:33 +0200 Subject: [PATCH] win32: Make set_keep_above work also for non-mapped windows This fixes bug #171456 --- gdk/win32/gdkwindow-win32.c | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index d1b2c8f1c7..50f6c5c46a 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -895,7 +895,6 @@ show_window_internal (GdkWindow *window, HWND old_active_window; gboolean focus_on_map = FALSE; DWORD exstyle; - HWND top; if (window->destroyed) return; @@ -940,17 +939,6 @@ show_window_internal (GdkWindow *window, exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE); - if (window->state & GDK_WINDOW_STATE_BELOW) - exstyle &= (~WS_EX_TOPMOST); - - if (window->state & GDK_WINDOW_STATE_ABOVE) - exstyle |= WS_EX_TOPMOST; - - if (exstyle & WS_EX_TOPMOST) - top = HWND_TOPMOST; - else - top = HWND_TOP; - /* Use SetWindowPos to show transparent windows so automatic redraws * in other windows can be suppressed. */ @@ -961,7 +949,7 @@ show_window_internal (GdkWindow *window, 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); + SetWindowPos (GDK_WINDOW_HWND (window), HWND_TOP, 0, 0, 0, 0, flags); return; } @@ -989,6 +977,18 @@ show_window_internal (GdkWindow *window, { ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNORMAL); } + + /* Sync STATE_ABOVE to TOPMOST */ + if (((window->state & GDK_WINDOW_STATE_ABOVE) && + !(exstyle & WS_EX_TOPMOST)) || + (!(window->state & GDK_WINDOW_STATE_ABOVE) && + (exstyle & WS_EX_TOPMOST))) + { + API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), + (window->state & GDK_WINDOW_STATE_ABOVE)?HWND_TOPMOST:HWND_NOTOPMOST, + 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE)); + } } static void @@ -2779,10 +2779,10 @@ gdk_win32_window_set_keep_above (GdkWindow *window, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE)); } - else - gdk_synthesize_window_state (window, - setting ? GDK_WINDOW_STATE_BELOW : GDK_WINDOW_STATE_ABOVE, - setting ? GDK_WINDOW_STATE_ABOVE : 0); + + gdk_synthesize_window_state (window, + setting ? GDK_WINDOW_STATE_BELOW : GDK_WINDOW_STATE_ABOVE, + setting ? GDK_WINDOW_STATE_ABOVE : 0); } static void @@ -2805,10 +2805,10 @@ gdk_win32_window_set_keep_below (GdkWindow *window, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE)); } - else - gdk_synthesize_window_state (window, - setting ? GDK_WINDOW_STATE_ABOVE : GDK_WINDOW_STATE_BELOW, - setting ? GDK_WINDOW_STATE_BELOW : 0); + + gdk_synthesize_window_state (window, + setting ? GDK_WINDOW_STATE_ABOVE : GDK_WINDOW_STATE_BELOW, + setting ? GDK_WINDOW_STATE_BELOW : 0); } static void