logo       

[gnome-shell] Bug 589937 - Raise clone on window activation: msg#08224

svn-commits-list

Subject: [gnome-shell] Bug 589937 - Raise clone on window activation

commit 026f014d32f70c425500e8b7b9071b6470c85b19
Author: Colin Walters <walters@xxxxxxxxxx>
Date: Fri Jul 31 17:20:26 2009 -0400

Bug 589937 - Raise clone on window activation

We had duplicate code in appDisplay and workspaces for handling activating
a window; unify that inside workspaces, add an API to Main.overlay to
access it from both contexts.

Also, explicitly raise the clone we're activating to the top
before starting the animation to leave the overlay.

js/ui/appDisplay.js | 14 +++--------
js/ui/overlay.js | 15 ++++++++++++
js/ui/workspaces.js | 62 +++++++++++++++++++++++++++++++++++++--------------
3 files changed, 64 insertions(+), 27 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 9ecfc11..7025e4e 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -14,6 +14,7 @@ const Mainloop = imports.mainloop;

const DND = imports.ui.dnd;
const GenericDisplay = imports.ui.genericDisplay;
+const Main = imports.ui.main;
const Workspaces = imports.ui.workspaces;

const ENTERED_MENU_COLOR = new Clutter.Color();
@@ -527,17 +528,10 @@ WellDisplayItem.prototype = {
if (this._windows.length == 0)
this.launch();
else {
- /* Pick the first window and activate it, switching to its
workspace
- * if necessary. In the future, we want to have a menu dropdown
here. */
+ /* Pick the first window and activate it;
+ * In the future, we want to have a menu dropdown here. */
let first = this._windows[0];
- let firstWorkspace = first.get_workspace();
- let currentWorkspaceIndex =
Shell.Global.get().screen.get_active_workspace_index();
- let currentWorkspace =
Shell.Global.get().screen.get_workspace_by_index(currentWorkspaceIndex);
- let ts = Clutter.get_current_event_time();
- if (currentWorkspace != firstWorkspace)
- firstWorkspace.activate_with_focus(first, ts);
- else
- first.activate(ts);
+ Main.overlay.activateWindow (first,
Clutter.get_current_event_time());
}
this.emit('activated');
},
diff --git a/js/ui/overlay.js b/js/ui/overlay.js
index f0ea2e7..235b0ee 100644
--- a/js/ui/overlay.js
+++ b/js/ui/overlay.js
@@ -934,6 +934,21 @@ Overlay.prototype = {
this.show();
},

+ /**
+ * activateWindow:
+ * @metaWindow: A #MetaWindow
+ * @time: Event timestamp integer
+ *
+ * Make the given MetaWindow be the focus window, switching
+ * to the workspace it's on if necessary. This function
+ * should only be used when the overlay is currently active;
+ * outside of that, use the relevant methods on MetaDisplay.
+ */
+ activateWindow: function (metaWindow, time) {
+ this._workspaces.activateWindowFromOverlay(metaWindow, time);
+ this.hide();
+ },
+
//// Private methods ////

// Raises the Dash to the top, so that we can tell if the pointer is above
one of its items.
diff --git a/js/ui/workspaces.js b/js/ui/workspaces.js
index e703294..7da0e40 100644
--- a/js/ui/workspaces.js
+++ b/js/ui/workspaces.js
@@ -364,6 +364,23 @@ Workspace.prototype = {
}
},

+ _lookupIndexAndClone: function (metaWindow) {
+ let index, clone;
+ for (let i = 0; i < this._windows.length; i++) {
+ if (this._windows[i].metaWindow == metaWindow) {
+ index = i;
+ clone = this._windows[index];
+ return [index, clone];
+ }
+ }
+ return [-1, null];
+ },
+
+ lookupCloneForMetaWindow: function (metaWindow) {
+ let [index, clone] = this._lookupIndexAndClone (metaWindow);
+ return clone;
+ },
+
_adjustRemoveButton : function() {
this._removeButton.set_scale(1.0 / this.actor.scale_x,
1.0 / this.actor.scale_y);
@@ -450,14 +467,7 @@ Workspace.prototype = {
let win = metaWin.get_compositor_private();

// find the position of the window in our list
- let index = - 1, clone;
- for (let i = 0; i < this._windows.length; i++) {
- if (this._windows[i].metaWindow == metaWin) {
- index = i;
- clone = this._windows[index];
- break;
- }
- }
+ let [index, clone] = this._lookupIndexAndClone (metaWin);

if (index == -1)
return;
@@ -712,15 +722,7 @@ Workspace.prototype = {
},

_onCloneSelected : function (clone, time) {
- let global = Shell.Global.get();
- let activeWorkspace = global.screen.get_active_workspace_index();
-
- if (this.workspaceNum != activeWorkspace) {
- let workspace =
global.screen.get_workspace_by_index(this.workspaceNum);
- workspace.activate_with_focus(clone.metaWindow, time);
- } else
- clone.metaWindow.activate(time);
- Main.overlay.hide();
+ Main.overlay.activateWindow(clone.metaWindow, time);
},

_removeSelf : function(actor, event) {
@@ -828,6 +830,32 @@ Workspaces.prototype = {
Lang.bind(this,
this._activeWorkspaceChanged));
},

+ _lookupCloneForMetaWindow: function (metaWindow) {
+ for (let i = 0; i < this._workspaces.length; i++) {
+ let clone =
this._workspaces[i].lookupCloneForMetaWindow(metaWindow);
+ if (clone)
+ return clone;
+ }
+ return null;
+ },
+
+ // Should only be called from active overlay context
+ activateWindowFromOverlay: function (metaWindow, time) {
+ let global = Shell.Global.get();
+ 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);
+ }
+ },
+
// Updates position of the workspaces display based on the new coordinates.
// Preserves the old value for the coordinate, if the passed value is null.
updatePosition : function(x, y) {
_______________________________________________
SVN-commits-list mailing list (read only)
http://mail.gnome.org/mailman/listinfo/svn-commits-list

Want to limit the commits to a few modules? Go to above URL, log in to edit
your options and select the modules ('topics') you want.

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise