[gnome-shell] Add Main.activateWindow() to remove some duplication



commit 24d42adc044b74b62522fc6c9826e6444adc1022
Author: Dan Winship <danw gnome org>
Date:   Mon Sep 21 16:29:37 2009 -0400

    Add Main.activateWindow() to remove some duplication

 js/ui/main.js       |   22 ++++++++++++++++++++++
 js/ui/workspaces.js |   21 +++++----------------
 2 files changed, 27 insertions(+), 16 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index 310a3ed..c6b09d9 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -329,3 +329,25 @@ function currentTime() {
 
     return Clutter.get_current_event_time();
 }
+
+/**
+ * activateWindow:
+ * @window: the Meta.Window to activate
+ * @time: (optional) current event time
+ *
+ * Activates @window, switching to its workspace first if necessary
+ */
+function activateWindow(window, time) {
+    let activeWorkspaceNum = global.screen.get_active_workspace_index();
+    let windowWorkspaceNum = window.get_workspace().index();
+
+    if (!time)
+        time = currentTime();
+
+    if (windowWorkspaceNum != activeWorkspaceNum) {
+        let workspace = global.screen.get_workspace_by_index(windowWorkspaceNum);
+        workspace.activate_with_focus(window, time);
+    } else {
+        window.activate(time);
+    }
+}
diff --git a/js/ui/workspaces.js b/js/ui/workspaces.js
index 7c6de26..41042d7 100644
--- a/js/ui/workspaces.js
+++ b/js/ui/workspaces.js
@@ -1409,21 +1409,6 @@ Workspaces.prototype = {
         }
     },
 
-    _activateWindowInternal: function (metaWindow, time) {
-        let activeWorkspaceNum = global.screen.get_active_workspace_index();
-        let windowWorkspaceNum = metaWindow.get_workspace().index();
-
-        let clone = this._lookupCloneForMetaWindow (metaWindow);
-        clone.actor.raise_top();
-
-        if (windowWorkspaceNum != activeWorkspaceNum) {
-            let workspace = global.screen.get_workspace_by_index(windowWorkspaceNum);
-            workspace.activate_with_focus(metaWindow, time);
-        } else {
-            metaWindow.activate(time);
-        }
-    },
-
     /**
      * activateWindowFromOverview:
      * @metaWindow: A #MetaWindow
@@ -1436,7 +1421,11 @@ Workspaces.prototype = {
         if (this._windowSelectionAppId != null) {
             this._clearApplicationWindowSelection(false);
         }
-        this._activateWindowInternal(metaWindow, time);
+
+        let clone = this._lookupCloneForMetaWindow (metaWindow);
+        clone.actor.raise_top();
+
+        Main.activateWindow(metaWindow, time);
         Main.overview.hide();
     },
 



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