From 12fc394b92178377f936bb58e444e7ac1a7e34a3 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 11 Jun 2014 16:36:17 -0400 Subject: [PATCH] display: Fix the logic for moving attached dialogs If we have a tree of a window, a non-attached dialog, and then an attached dialog, we want to move the second window, not the attached dialog or the topmost. In other words, we want to move the first non-attached window, or the first "freefloating window". This happens in Firefox, whose Preferences dialog is freefloating, but suboptions of those are modal dialogs. --- src/core/display.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/core/display.c b/src/core/display.c index a7db76e74..c1857624f 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1696,15 +1696,15 @@ meta_display_update_cursor (MetaDisplay *display) } static MetaWindow * -get_toplevel_transient_for (MetaWindow *window) +get_first_freefloating_window (MetaWindow *window) { - while (TRUE) - { - MetaWindow *parent = meta_window_get_transient_for (window); - if (parent == NULL) - return window; - window = parent; - } + while (meta_window_is_attached_dialog (window)) + window = meta_window_get_transient_for (window); + + /* Attached dialogs should always have a non-NULL transient-for */ + g_assert (window != NULL); + + return window; } gboolean @@ -1752,11 +1752,11 @@ meta_display_begin_grab_op (MetaDisplay *display, grab_window = window; - /* If window is a modal dialog attached to its parent, - * grab the parent instead for moving. + /* If we're trying to move a window, move the first + * non-attached dialog instead. */ - if (meta_window_is_attached_dialog (window) && meta_grab_op_is_moving (op)) - grab_window = get_toplevel_transient_for (window); + if (meta_grab_op_is_moving (op)) + grab_window = get_first_freefloating_window (window); g_assert (grab_window != NULL); g_assert (op != META_GRAB_OP_NONE);