window: make determination of attached dialog windows more consistent

Different bits of code were using slightly different checks to test
whether a window was an attached dialog. Add a new
meta_window_is_attached_dialog(), and use that everywhere.

Also, freeze the is-attached status when the window is first shown,
rather than recomputing it each time the caller asks, since this could
cause problems if a window changes its type after it has already been
attached, etc. However, if an attached window's parent is destroyed,
or an attached window changes its transient-for, then fix things up by
destroying the old MetaWindow and creating a new one (causing
compositor unmap and map events to be fired off, allowing the display
of the window to be fixed up).

Remove some code in display.c that tried to fix existing windows if
the gconf setting changed, but which didn't actually do anything (at
least under gnome-shell). However, if 654643 was fixed then the new
behavior with this patch would be that changing the gconf setting
would affect new dialogs, but not existing ones.

https://bugzilla.gnome.org/show_bug.cgi?id=646761
This commit is contained in:
Dan Winship
2011-04-05 10:14:52 -04:00
parent 3650e9b074
commit 7f8c59614e
6 changed files with 141 additions and 83 deletions

View File

@@ -1469,44 +1469,48 @@ reload_transient_for (MetaWindow *window,
gboolean initial)
{
MetaWindow *parent = NULL;
Window transient_for, old_transient_for;
if (meta_window_appears_focused (window) && window->xtransient_for != None)
meta_window_propagate_focus_appearance (window, FALSE);
window->xtransient_for = None;
if (value->type != META_PROP_VALUE_INVALID)
window->xtransient_for = value->v.xwindow;
/* Make sure transient_for is valid */
if (window->xtransient_for != None)
{
parent = meta_display_lookup_x_window (window->display,
window->xtransient_for);
transient_for = value->v.xwindow;
parent = meta_display_lookup_x_window (window->display, transient_for);
if (!parent)
{
meta_warning (_("Invalid WM_TRANSIENT_FOR window 0x%lx specified "
"for %s.\n"),
window->xtransient_for, window->desc);
window->xtransient_for = None;
transient_for, window->desc);
transient_for = None;
}
}
/* Make sure there is not a loop */
while (parent)
{
if (parent == window)
/* Make sure there is not a loop */
while (parent)
{
meta_warning (_("WM_TRANSIENT_FOR window 0x%lx for %s "
"would create loop.\n"),
window->xtransient_for, window->desc);
window->xtransient_for = None;
break;
}
if (parent == window)
{
meta_warning (_("WM_TRANSIENT_FOR window 0x%lx for %s "
"would create loop.\n"),
transient_for, window->desc);
transient_for = None;
break;
}
parent = meta_display_lookup_x_window (parent->display,
parent->xtransient_for);
parent = meta_display_lookup_x_window (parent->display,
parent->xtransient_for);
}
}
else
transient_for = None;
if (transient_for == window->xtransient_for)
return;
if (meta_window_appears_focused (window) && window->xtransient_for != None)
meta_window_propagate_focus_appearance (window, FALSE);
old_transient_for = window->xtransient_for;
window->xtransient_for = transient_for;
window->transient_parent_is_root_window =
window->xtransient_for == window->screen->xroot;
@@ -1520,6 +1524,25 @@ reload_transient_for (MetaWindow *window,
/* may now be a dialog */
meta_window_recalc_window_type (window);
if (!window->constructing)
{
/* If the window attaches, detaches, or changes attached
* parents, we need to destroy the MetaWindow and let a new one
* be created (which happens as a side effect of
* meta_window_unmanage()). The condition below is correct
* because we know window->xtransient_for has changed.
*/
if (window->attached || meta_window_should_attach_to_parent (window))
{
guint32 timestamp;
window->xtransient_for = old_transient_for;
timestamp = meta_display_get_current_time_roundtrip (window->display);
meta_window_unmanage (window, timestamp);
return;
}
}
/* update stacking constraints */
if (!window->override_redirect)
meta_stack_update_transient (window->screen->stack, window);