Merge branch 'w32-transient-ordering-rollback' into 'gtk-3-24'

GDK W32: transient Z-order rollback

See merge request GNOME/gtk!1769
This commit is contained in:
LRN 2020-10-08 05:16:11 +00:00
commit 69b43edd55
2 changed files with 8 additions and 215 deletions

View File

@ -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 | SWP_NOOWNERZORDER);
}
}
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 | SWP_NOOWNERZORDER);
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 | SWP_NOOWNERZORDER);
break;
}
}
}
static gboolean
handle_wm_sysmenu (GdkWindow *window, MSG *msg, gint *ret_valp)
{
@ -3367,8 +3171,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)
@ -3458,13 +3260,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 */
@ -3946,8 +3741,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! */

View File

@ -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));
}
}
@ -5396,7 +5396,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);
@ -5422,7 +5422,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,
@ -5448,7 +5448,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,