window: fix a case of appears-focused getting stuck

Since appears-focus only propagates up from modal dialogs, if an
application removed the modal hint from a dialog before destroying it,
then its parent would be left with a stray reference to it in
attached_focus_window, causing it to be permanently appears-focused.

The obvious fix, calling meta_window_propagate_focus_appearance() when
the modal hint is removed, tends to cause noticeable flashing, because
the window will get drawn unfocused and then focused again.

So instead we just change meta_window_propagate_focus_appearance() to
check the window type only when focusing in, not when focusing out.

This would also cause flashing, but in this case we can avoid it by
not notifying the change in appears-focus on the parent window if it
is the expected_focus_window (which it will be by this point). (This
does mean though that if something weird happens and the window
doesn't end up becoming the focus window, it won't get redrawn
unfocused until something else forces it to.)

https://bugzilla.gnome.org/show_bug.cgi?id=647613
This commit is contained in:
Dan Winship 2011-04-13 14:19:40 -04:00
parent 4d069650ae
commit eb0e658c99

View File

@ -6390,7 +6390,7 @@ meta_window_propagate_focus_appearance (MetaWindow *window,
child = window;
parent = meta_window_get_transient_for (child);
while (child->type == META_WINDOW_MODAL_DIALOG && parent)
while (parent && (!focused || child->type == META_WINDOW_MODAL_DIALOG))
{
gboolean child_focus_state_changed;
@ -6409,7 +6409,8 @@ meta_window_propagate_focus_appearance (MetaWindow *window,
parent->attached_focus_window = NULL;
}
if (child_focus_state_changed && !parent->has_focus)
if (child_focus_state_changed && !parent->has_focus &&
parent != window->display->expected_focus_window)
{
g_object_notify (G_OBJECT (parent), "appears-focused");
if (parent->frame)