[mutter] window: Allow activation on non-active workspaces with proper timestamps



commit 87bec99a0ad8e070b33a1632d59e9507ff651de3
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Apr 11 13:52:55 2014 +0200

    window: Allow activation on non-active workspaces with proper timestamps
    
    Our focus stealing prevention is still mostly inherited from metacity;
    in particular, a (non-transient) window that is not on the current
    workspace will not be given focus. This behavior made sense in the
    GNOME 2 days, where workspaces were separated much more strictly.
    However this is no longer the case in GNOME 3 - activating a launcher
    will switch workspaces if necessary, and so will the app switcher.
    There is no good reason to not do the same for other user actions
    like clicking a URL or activating a search result, so allow activation
    of windows on non-active workspaces if a proper timestamp is supplied,
    assuming that this is a strong enough indication that we are dealing
    with a legitimate user action.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728018

 src/core/window.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index ed09047..e610398 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -3703,11 +3703,13 @@ meta_window_activate_full (MetaWindow     *window,
                            MetaClientType  source_indication,
                            MetaWorkspace  *workspace)
 {
+  gboolean allow_workspace_switch;
   meta_topic (META_DEBUG_FOCUS,
               "_NET_ACTIVE_WINDOW message sent for %s at time %u "
               "by client type %u.\n",
               window->desc, timestamp, source_indication);
 
+  allow_workspace_switch = (timestamp != 0);
   if (timestamp != 0 &&
       XSERVER_TIME_IS_BEFORE (timestamp, window->display->last_user_time))
     {
@@ -3735,6 +3737,7 @@ meta_window_activate_full (MetaWindow     *window,
      rather than move windows or workspaces.
      See http://bugzilla.gnome.org/show_bug.cgi?id=482354 */
   if (window->transient_for == NULL &&
+      !allow_workspace_switch &&
       !meta_window_located_on_workspace (window, workspace))
     {
       meta_window_set_demands_attention (window);
@@ -3745,7 +3748,7 @@ meta_window_activate_full (MetaWindow     *window,
     {
       /* Move transients to current workspace - preference dialogs should appear over
          the source window.  */
-    meta_window_change_workspace (window, workspace);
+      meta_window_change_workspace (window, workspace);
     }
 
   if (window->shaded)
@@ -3760,7 +3763,10 @@ meta_window_activate_full (MetaWindow     *window,
   meta_topic (META_DEBUG_FOCUS,
               "Focusing window %s due to activation\n",
               window->desc);
-  meta_window_focus (window, timestamp);
+  if (meta_window_located_on_workspace (window, workspace))
+    meta_window_focus (window, timestamp);
+  else
+    meta_workspace_activate_with_focus (window->workspace, window, timestamp);
 
   meta_window_check_alive (window, timestamp);
 }


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