[gnome-shell/wip/new-notifications: 3/17] panel: Look at the app for the default window when no window has focus



commit 8238d4016097a908337dbe094f6c323c97d40eb5
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Dec 3 20:49:02 2013 -0500

    panel: Look at the app for the default window when no window has focus
    
    Previously, we played tricks by trying our hardest not to sync when
    the panel didn't have key focus, but that's not really an approachable
    situation anymore.
    
    Use new mutter APIs to look up the default window and look at the app
    for that when we're key-nav'd to the panel.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719468

 js/ui/panel.js             |   15 +--------------
 src/shell-window-tracker.c |   22 +++++++++++++++++++++-
 2 files changed, 22 insertions(+), 15 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index fea689d..2f3eafa 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -231,7 +231,7 @@ const AppMenuButton = new Lang.Class({
         let tracker = Shell.WindowTracker.get_default();
         let appSys = Shell.AppSystem.get_default();
         this._focusAppNotifyId =
-            tracker.connect('notify::focus-app', Lang.bind(this, this._focusAppChanged));
+            tracker.connect('notify::focus-app', Lang.bind(this, this._sync));
         this._appStateChangedSignalId =
             appSys.connect('app-state-changed', Lang.bind(this, this._onAppStateChanged));
         this._switchWorkspaceNotifyId =
@@ -419,19 +419,6 @@ const AppMenuButton = new Lang.Class({
         this._sync();
     },
 
-    _focusAppChanged: function() {
-        let tracker = Shell.WindowTracker.get_default();
-        let focusedApp = tracker.focus_app;
-        if (!focusedApp) {
-            // If the app has just lost focus to the panel, pretend
-            // nothing happened; otherwise you can't keynav to the
-            // app menu.
-            if (global.stage.key_focus != null)
-                return;
-        }
-        this._sync();
-    },
-
     _findTargetApp: function() {
         let workspace = global.screen.get_active_workspace();
         let tracker = Shell.WindowTracker.get_default();
diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c
index e1d563f..0ca8ba3 100644
--- a/src/shell-window-tracker.c
+++ b/src/shell-window-tracker.c
@@ -450,13 +450,33 @@ _shell_window_tracker_get_app_context (ShellWindowTracker *tracker, ShellApp *ap
   return "";
 }
 
+static MetaWindow *
+get_focus_app_window (void)
+{
+  ShellGlobal *global = shell_global_get ();
+  MetaDisplay *display = shell_global_get_display (global);
+  MetaScreen *screen;
+  MetaWindow *window;
+
+  window = meta_display_get_focus_window (display);
+  if (window)
+    return window;
+
+  screen = shell_global_get_screen (global);
+  window = meta_screen_get_default_window (screen);
+  if (window)
+    return window;
+
+  return NULL;
+}
+
 static void
 update_focus_app (ShellWindowTracker *self)
 {
   MetaWindow *new_focus_win;
   ShellApp *new_focus_app;
 
-  new_focus_win = meta_display_get_focus_window (shell_global_get_display (shell_global_get ()));
+  new_focus_win = get_focus_app_window ();
   new_focus_app = new_focus_win ? shell_window_tracker_get_window_app (self, new_focus_win) : NULL;
 
   if (new_focus_app)


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