From 5fef9188c9c9638c684a26017e8c26e954d04537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Mon, 15 Nov 2010 21:58:27 +0100 Subject: [PATCH] workspaces: Change handling of window-drag signals Delegate the emission of the window-drag-begin/window-drag-end signals to overview functions, as done already for other items. This will enable objects to react to those signals without having access to the workspace objects / the workspaces view. https://bugzilla.gnome.org/show_bug.cgi?id=634948 --- js/ui/overview.js | 8 +++++ js/ui/workspace.js | 4 +-- js/ui/workspacesView.js | 65 ++++++++++++++++++----------------------- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/js/ui/overview.js b/js/ui/overview.js index 19a24ed51..61c29c940 100644 --- a/js/ui/overview.js +++ b/js/ui/overview.js @@ -247,6 +247,14 @@ Overview.prototype = { this.emit('item-drag-end'); }, + beginWindowDrag: function(source) { + this.emit('window-drag-begin'); + }, + + endWindowDrag: function(source) { + this.emit('window-drag-end'); + }, + // Returns the scale the Overview has when we just start zooming out // to overview mode. That is, when just the active workspace is showing. getZoomedInScale : function() { diff --git a/js/ui/workspace.js b/js/ui/workspace.js index 154f7e806..4194897ea 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -1309,12 +1309,12 @@ Workspace.prototype = { Lang.bind(this, this._onCloneSelected)); clone.connect('drag-begin', Lang.bind(this, function(clone) { - this.emit('window-drag-begin', clone.actor); + Main.overview.beginWindowDrag(); overlay.hide(); })); clone.connect('drag-end', Lang.bind(this, function(clone) { - this.emit('window-drag-end', clone.actor); + Main.overview.endWindowDrag(); overlay.show(); })); clone.connect('zoom-start', diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js index ec0dfd26d..2a4edc2c8 100644 --- a/js/ui/workspacesView.js +++ b/js/ui/workspacesView.js @@ -62,15 +62,8 @@ WorkspacesView.prototype = { this._workspaces = workspaces; // Add workspace actors - for (let w = 0; w < global.screen.n_workspaces; w++) { + for (let w = 0; w < global.screen.n_workspaces; w++) this._workspaces[w].actor.reparent(this.actor); - this._workspaces[w]._windowDragBeginId = - this._workspaces[w].connect('window-drag-begin', - Lang.bind(this, this._dragBegin)); - this._workspaces[w]._windowDragEndId = - this._workspaces[w].connect('window-drag-end', - Lang.bind(this, this._dragEnd)); - } this._workspaces[activeWorkspaceIndex].actor.raise_top(); // Position/scale the desktop windows and their children after the @@ -114,6 +107,10 @@ WorkspacesView.prototype = { Lang.bind(this, this._dragBegin)); this._itemDragEndId = Main.overview.connect('item-drag-end', Lang.bind(this, this._dragEnd)); + this._windowDragBeginId = Main.overview.connect('window-drag-begin', + Lang.bind(this, this._dragBegin)); + this._windowDragEndId = Main.overview.connect('window-drag-end', + Lang.bind(this, this._dragEnd)); }, _lookupWorkspaceForMetaWindow: function (metaWindow) { @@ -583,13 +580,8 @@ WorkspacesView.prototype = { }); if (newNumWorkspaces > oldNumWorkspaces) { - for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) { + for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) this.actor.add_actor(this._workspaces[w].actor); - this._workspaces[w]._windowDragBeginId = this._workspaces[w].connect('window-drag-begin', - Lang.bind(this, this._dragBegin)); - this._workspaces[w]._windowDragEndId = this._workspaces[w].connect('window-drag-end', - Lang.bind(this, this._dragEnd)); - } this._computeWorkspacePositions(); this._updateWorkspaceActors(false); @@ -625,15 +617,13 @@ WorkspacesView.prototype = { Main.overview.disconnect(this._itemDragEndId); this._itemDragEndId = 0; } - for (let w = 0; w < this._workspaces.length; w++) { - if (this._workspaces[w]._windowDragBeginId) { - this._workspaces[w].disconnect(this._workspaces[w]._windowDragBeginId); - this._workspaces[w]._windowDragBeginId = 0; - } - if (this._workspaces[w]._windowDragEndId) { - this._workspaces[w].disconnect(this._workspaces[w]._windowDragEndId); - this._workspaces[w]._windowDragEndId = 0; - } + if (this._windowDragBeginId > 0) { + Main.overview.disconnect(this._windowDragBeginId); + this._windowDragBeginId = 0; + } + if (this._windowDragEndId > 0) { + Main.overview.disconnect(this._windowDragEndId); + this._windowDragEndId = 0; } }, @@ -649,8 +639,6 @@ WorkspacesView.prototype = { dragMotion: Lang.bind(this, this._onDragMotion) }; DND.addDragMonitor(this._dragMonitor); - - this.emit('window-drag-begin'); }, _onDragMotion: function(dragEvent) { @@ -741,8 +729,6 @@ WorkspacesView.prototype = { for (let i = 0; i < this._workspaces.length; i++) this._workspaces[i].setReservedSlot(null); - - this.emit('window-drag-end'); }, // sync the workspaces' positions to the value of the scroll adjustment @@ -948,6 +934,8 @@ WorkspaceControlsContainer.prototype = { this._itemDragBeginId = 0; this._itemDragEndId = 0; + this._windowDragBeginId = 0; + this._windowDragEndId = 0; }, show: function() { @@ -957,6 +945,12 @@ WorkspaceControlsContainer.prototype = { if (this._itemDragEndId == 0) this._itemDragEndId = Main.overview.connect('item-drag-end', Lang.bind(this, this.popIn)); + if (this._windowDragBeginId == 0) + this._windowDragBeginId = Main.overview.connect('window-drag-begin', + Lang.bind(this, this.popOut)); + if (this._windowDragEndId == 0) + this._windowDragEndId = Main.overview.connect('window-drag-end', + Lang.bind(this, this.popIn)); this._controls.x = this._poppedInX(); }, @@ -969,6 +963,14 @@ WorkspaceControlsContainer.prototype = { Main.overview.disconnect(this._itemDragEndId); this._itemDragEndId = 0; } + if (this._windowDragBeginId > 0) { + Main.overview.disconnect(this._windowDragBeginId); + this._windowDragBeginId = 0; + } + if (this._windowDragEndId > 0) { + Main.overview.disconnect(this._windowDragEndId); + this._windowDragEndId = 0; + } }, _getPreferredWidth: function(actor, forHeight, alloc) { @@ -1120,15 +1122,6 @@ WorkspacesDisplay.prototype = { this.workspacesView.destroy(); this.workspacesView = newView; - this.workspacesView.connect('window-drag-begin', Lang.bind(this, - function() { - this._controlsContainer.popOut(); - })); - this.workspacesView.connect('window-drag-end', Lang.bind(this, - function() { - this._controlsContainer.popIn(); - })); - this._workspaceIndicatorPanel.updateWorkspaces(this._workspaces); this._nWorkspacesNotifyId =