[mutter/gnome-3-10] display: Don't leave focus on a window we are unmanaging when sending WM_TAKE_FOCUS



commit 7278f9bd6b965cf551a44d4dde85f18325b95338
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Dec 16 12:20:02 2013 -0500

    display: Don't leave focus on a window we are unmanaging when sending WM_TAKE_FOCUS
    
    When we move focus elsewhere when unmanaging a window, we *need* to move
    the focus, so if the target is globally active, move the focus to the
    no-focus-window in anticipation that the focus will normally get moved
    to the right window when the target window responds to WM_TAKE_FOCUS.
    
    If the window doesn't respond to WM_TAKE_FOCUS, then focus will be left
    on the no-focus-window, but there's no way to distinguish whether the
    app will respond or not.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711618

 src/core/window.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index ca92b6d..41a515e 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -5962,6 +5962,25 @@ meta_window_focus (MetaWindow  *window,
                       "Sending WM_TAKE_FOCUS to %s since take_focus = true\n",
                       window->desc);
 
+          if (!window->input)
+            {
+              /* The "Globally Active Input" window case, where the window
+               * doesn't want us to call XSetInputFocus on it, but does
+               * want us to send a WM_TAKE_FOCUS.
+               *
+               * Normally, we want to just leave the focus undisturbed until
+               * the window respnds to WM_TAKE_FOCUS, but if we're unmanaging
+               * the current focus window we *need* to move the focus away, so
+               * we focus the no_focus_window now (and set
+               * display->focus_window to that) before sending WM_TAKE_FOCUS.
+               */
+              if (window->display->focus_window != NULL &&
+                  window->display->focus_window->unmanaging)
+                meta_display_focus_the_no_focus_window (window->display,
+                                                        window->screen,
+                                                        timestamp);
+            }
+
           meta_display_request_take_focus (window->display,
                                            window,
                                            timestamp);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]