From 83ebdbdbf4c0f68513967bb7f65a08cb6a9c7bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Sun, 26 Apr 2020 19:11:45 +0000 Subject: [PATCH 1/2] Revert "GDK W32: Use SWP_NOOWNERZORDER everywhere it can be applied" This reverts commit fc2008f24073348f97751e2031761b6f388edabe. Turns out, we *don't* have code to maintain Z-order. Restacking code is not doint that, it just enforces a few weird Z-order-related behaviours. --- gdk/win32/gdkevents-win32.c | 6 +++--- gdk/win32/gdkwindow-win32.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index 7aef277c27..a695f5b0f7 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -1930,7 +1930,7 @@ ensure_stacking_on_unminimize (MSG *msg) g_print (" restacking %p above %p", msg->hwnd, lowest_transient)); SetWindowPos (msg->hwnd, lowest_transient, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER); + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } } @@ -2011,7 +2011,7 @@ ensure_stacking_on_activate_app (MSG *msg, impl->transient_owner != NULL) { SetWindowPos (msg->hwnd, HWND_TOP, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER); + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); return; } @@ -2053,7 +2053,7 @@ ensure_stacking_on_activate_app (MSG *msg, g_print (" restacking %p above %p", msg->hwnd, rover)); SetWindowPos (msg->hwnd, rover, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER); + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); break; } } diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index cf416d8e2a..f355cea409 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -1474,7 +1474,7 @@ show_window_internal (GdkWindow *window, 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 | SWP_NOOWNERZORDER)); + SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE)); } } @@ -1834,7 +1834,7 @@ gdk_win32_window_raise (GdkWindow *window) else API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_TOP, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER)); + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE)); } } @@ -1851,7 +1851,7 @@ gdk_win32_window_lower (GdkWindow *window) API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_BOTTOM, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER)); + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE)); } } @@ -2910,7 +2910,7 @@ _gdk_win32_window_update_style_bits (GdkWindow *window) rect.right += after.right - before.right; rect.bottom += after.bottom - before.bottom; - flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOREPOSITION | SWP_NOOWNERZORDER; + flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOREPOSITION; if (will_be_topmost && !was_topmost) { @@ -5372,7 +5372,7 @@ gdk_win32_window_fullscreen (GdkWindow *window) y - workaround_padding, width + (workaround_padding * 2), height + (workaround_padding * 2), - SWP_NOCOPYBITS | SWP_SHOWWINDOW | SWP_NOOWNERZORDER)); + SWP_NOCOPYBITS | SWP_SHOWWINDOW)); } } @@ -5395,7 +5395,7 @@ gdk_win32_window_unfullscreen (GdkWindow *window) API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_NOTOPMOST, fi->r.left, fi->r.top, fi->r.right - fi->r.left, fi->r.bottom - fi->r.top, - SWP_NOCOPYBITS | SWP_SHOWWINDOW | SWP_NOOWNERZORDER)); + SWP_NOCOPYBITS | SWP_SHOWWINDOW)); g_object_set_data (G_OBJECT (window), "fullscreen-info", NULL); g_free (fi); @@ -5421,7 +5421,7 @@ gdk_win32_window_set_keep_above (GdkWindow *window, API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), setting ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOOWNERZORDER)); + SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE)); } gdk_synthesize_window_state (window, @@ -5447,7 +5447,7 @@ gdk_win32_window_set_keep_below (GdkWindow *window, API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), setting ? HWND_BOTTOM : HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOOWNERZORDER)); + SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE)); } gdk_synthesize_window_state (window, From 00f06f2480e162edd4213cae5c7a28413ca4cabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Sun, 26 Apr 2020 19:16:02 +0000 Subject: [PATCH 2/2] GDK W32: Remove stacking functions Stacking functions enforce non-native stacking behaviour that is mostly unneeded, and doing so introduces bugs and complicates things. --- gdk/win32/gdkevents-win32.c | 207 ------------------------------------ 1 file changed, 207 deletions(-) diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index a695f5b0f7..3699083570 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -1863,202 +1863,6 @@ generate_button_event (GdkEventType type, _gdk_win32_append_event (event); } -/* - * Used by the stacking functions to see if a window - * should be always on top. - * Restacking is only done if both windows are either ontop - * or not ontop. - */ -static gboolean -should_window_be_always_on_top (GdkWindow *window) -{ - DWORD exstyle; - - if ((GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP) || - (window->state & GDK_WINDOW_STATE_ABOVE)) - return TRUE; - - exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE); - - if (exstyle & WS_EX_TOPMOST) - return TRUE; - - return FALSE; -} - -static void -ensure_stacking_on_unminimize (MSG *msg) -{ - HWND rover; - HWND lowest_transient = NULL; - GdkWindow *msg_window; - gboolean window_ontop = FALSE; - - msg_window = gdk_win32_handle_table_lookup (msg->hwnd); - - if (msg_window) - window_ontop = should_window_be_always_on_top (msg_window); - - for (rover = GetNextWindow (msg->hwnd, GW_HWNDNEXT); - rover; - rover = GetNextWindow (rover, GW_HWNDNEXT)) - { - GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover); - GdkWindowImplWin32 *rover_impl; - gboolean rover_ontop; - - /* Checking window group not implemented yet */ - if (rover_gdkw == NULL) - continue; - - rover_ontop = should_window_be_always_on_top (rover_gdkw); - rover_impl = GDK_WINDOW_IMPL_WIN32 (rover_gdkw->impl); - - if (GDK_WINDOW_IS_MAPPED (rover_gdkw) && - (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY || - rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG || - rover_impl->transient_owner != NULL) && - ((window_ontop && rover_ontop) || (!window_ontop && !rover_ontop))) - { - lowest_transient = rover; - } - } - - if (lowest_transient != NULL) - { - GDK_NOTE (EVENTS, - g_print (" restacking %p above %p", - msg->hwnd, lowest_transient)); - SetWindowPos (msg->hwnd, lowest_transient, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); - } -} - -static gboolean -ensure_stacking_on_window_pos_changing (MSG *msg, - GdkWindow *window) -{ - GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (window->impl); - WINDOWPOS *windowpos = (WINDOWPOS *) msg->lParam; - HWND rover; - gboolean restacking; - gboolean window_ontop; - - if (GetActiveWindow () != msg->hwnd || - impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY || - impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG || - impl->transient_owner != NULL) - return FALSE; - - /* Make sure the window stays behind any transient-type windows - * of the same window group. - * - * If the window is not active and being activated, we let - * Windows bring it to the top and rely on the WM_ACTIVATEAPP - * handling to bring any utility windows on top of it. - */ - - window_ontop = should_window_be_always_on_top (window); - - for (rover = windowpos->hwndInsertAfter, restacking = FALSE; - rover; - rover = GetNextWindow (rover, GW_HWNDNEXT)) - { - GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover); - GdkWindowImplWin32 *rover_impl; - gboolean rover_ontop; - - /* Checking window group not implemented yet */ - - if (rover_gdkw == NULL) - continue; - - rover_ontop = should_window_be_always_on_top (rover_gdkw); - rover_impl = GDK_WINDOW_IMPL_WIN32 (rover_gdkw->impl); - - if (GDK_WINDOW_IS_MAPPED (rover_gdkw) && - (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY || - rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG || - rover_impl->transient_owner != NULL) && - ((window_ontop && rover_ontop) || (!window_ontop && !rover_ontop))) - { - restacking = TRUE; - windowpos->hwndInsertAfter = rover; - } - } - - if (restacking) - { - GDK_NOTE (EVENTS, - g_print (" letting Windows restack %p above %p", - msg->hwnd, windowpos->hwndInsertAfter)); - return TRUE; - } - - return FALSE; -} - -static void -ensure_stacking_on_activate_app (MSG *msg, - GdkWindow *window) -{ - GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (window->impl); - HWND rover; - gboolean window_ontop; - - if (impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY || - impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG || - impl->transient_owner != NULL) - { - SetWindowPos (msg->hwnd, HWND_TOP, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); - return; - } - - if (!IsWindowVisible (msg->hwnd) || - msg->hwnd != GetActiveWindow ()) - return; - - - /* This window is not a transient-type window and it is the - * activated window. Make sure this window is as visible as - * possible, just below the lowest transient-type window of this - * app. - */ - - window_ontop = should_window_be_always_on_top (window); - - for (rover = GetNextWindow (msg->hwnd, GW_HWNDPREV); - rover; - rover = GetNextWindow (rover, GW_HWNDPREV)) - { - GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover); - GdkWindowImplWin32 *rover_impl; - gboolean rover_ontop; - - /* Checking window group not implemented yet */ - if (rover_gdkw == NULL) - continue; - - rover_ontop = should_window_be_always_on_top (rover_gdkw); - rover_impl = GDK_WINDOW_IMPL_WIN32 (rover_gdkw->impl); - - if (GDK_WINDOW_IS_MAPPED (rover_gdkw) && - (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY || - rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG || - rover_impl->transient_owner != NULL) && - ((window_ontop && rover_ontop) || (!window_ontop && !rover_ontop))) - { - GDK_NOTE (EVENTS, - g_print (" restacking %p above %p", - msg->hwnd, rover)); - SetWindowPos (msg->hwnd, rover, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); - break; - } - } -} - static gboolean handle_wm_sysmenu (GdkWindow *window, MSG *msg, gint *ret_valp) { @@ -3389,8 +3193,6 @@ gdk_event_translate (MSG *msg, if (GDK_WINDOW_IS_MAPPED (window)) { - return_val = ensure_stacking_on_window_pos_changing (msg, window); - impl = GDK_WINDOW_IMPL_WIN32 (window->impl); if (impl->maximizing) @@ -3480,13 +3282,6 @@ gdk_event_translate (MSG *msg, if ((old_state & GDK_WINDOW_STATE_ICONIFIED) != (new_state & GDK_WINDOW_STATE_ICONIFIED)) do_show_window (window, (new_state & GDK_WINDOW_STATE_ICONIFIED)); - - - /* When un-minimizing, make sure we're stacked under any - transient-type windows. */ - if (!(old_state & GDK_WINDOW_STATE_ICONIFIED) && - (new_state & GDK_WINDOW_STATE_ICONIFIED)) - ensure_stacking_on_unminimize (msg); } /* Show, New size or position => configure event */ @@ -3968,8 +3763,6 @@ gdk_event_translate (MSG *msg, GDK_NOTE (EVENTS, g_print (" %s thread: %" G_GINT64_FORMAT, msg->wParam ? "YES" : "NO", (gint64) msg->lParam)); - if (msg->wParam && GDK_WINDOW_IS_MAPPED (window)) - ensure_stacking_on_activate_app (msg, window); break; case WM_NCHITTEST: /* TODO: pass all messages to DwmDefWindowProc() first! */