From a57a34c54037171f7411615c8d670c3e541ff16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 8 May 2010 16:06:28 +0200 Subject: [PATCH] [linearView] Zoom out when dragging an item from the dash When dragging windows in linear view, the workspace zooms out to allow moving the window to other workspaces. Enable the same behaviour for items dragged from the dash. https://bugzilla.gnome.org/show_bug.cgi?id=618055 --- js/ui/appDisplay.js | 15 ++++++++++----- js/ui/dash.js | 8 ++++++++ js/ui/docDisplay.js | 8 ++++++++ js/ui/genericDisplay.js | 8 ++++++++ js/ui/overview.js | 21 +++++++++------------ js/ui/placeDisplay.js | 8 ++++++++ js/ui/workspacesView.js | 24 ++++++++++++++++++------ 7 files changed, 69 insertions(+), 23 deletions(-) diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 3cd2eb3d5..deeeb6ff5 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -42,17 +42,17 @@ AllAppView.prototype = { }, _addApp: function(app) { - let App = new AppWellIcon(this._appSystem.get_app(app.get_id())); - App.connect('launching', Lang.bind(this, function() { + let appIcon = new AppWellIcon(this._appSystem.get_app(app.get_id())); + appIcon.connect('launching', Lang.bind(this, function() { this.emit('launching'); })); - App._draggable.connect('drag-begin', Lang.bind(this, function() { + appIcon._draggable.connect('drag-begin', Lang.bind(this, function() { this.emit('drag-begin'); })); - this._grid.addItem(App.actor); + this._grid.addItem(appIcon.actor); - this._apps.push(App); + this._apps.push(appIcon); }, refresh: function(apps) { @@ -402,6 +402,11 @@ AppWellIcon.prototype = { this._draggable.connect('drag-begin', Lang.bind(this, function () { this._removeMenuTimeout(); + Main.overview.beginItemDrag(this); + })); + this._draggable.connect('drag-end', Lang.bind(this, + function () { + Main.overview.endItemDrag(this); })); this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress)); diff --git a/js/ui/dash.js b/js/ui/dash.js index 9d9cddf15..4290fd378 100644 --- a/js/ui/dash.js +++ b/js/ui/dash.js @@ -351,6 +351,14 @@ SearchResult.prototype = { this.actor.connect('clicked', Lang.bind(this, this._onResultClicked)); let draggable = DND.makeDraggable(this.actor); + draggable.connect('drag-begin', + Lang.bind(this, function() { + Main.overview.beginItemDrag(this); + })); + draggable.connect('drag-end', + Lang.bind(this, function() { + Main.overview.endItemDrag(this); + })); }, setSelected: function(selected) { diff --git a/js/ui/docDisplay.js b/js/ui/docDisplay.js index 7e9de073f..3925c27fd 100644 --- a/js/ui/docDisplay.js +++ b/js/ui/docDisplay.js @@ -287,6 +287,14 @@ DashDocDisplayItem.prototype = { this.actor._delegate = this; let draggable = DND.makeDraggable(this.actor); + draggable.connect('drag-begin', + Lang.bind(this, function() { + Main.overview.beginItemDrag(this); + })); + draggable.connect('drag-end', + Lang.bind(this, function() { + Main.overview.endItemDrag(this); + })); }, getUri: function() { diff --git a/js/ui/genericDisplay.js b/js/ui/genericDisplay.js index 3ab8d0d78..46f1c9661 100644 --- a/js/ui/genericDisplay.js +++ b/js/ui/genericDisplay.js @@ -47,6 +47,14 @@ GenericDisplayItem.prototype = { })); let draggable = DND.makeDraggable(this.actor); + draggable.connect('drag-begin', + Lang.bind(this, function() { + Main.overview.beginItemDrag(this); + })); + draggable.connect('drag-end', + Lang.bind(this, function() { + Main.overview.endItemDrag(this); + })); this._iconBin = new St.Bin(); this.actor.add(this._iconBin); diff --git a/js/ui/overview.js b/js/ui/overview.js index b2a241dc5..377659f8b 100644 --- a/js/ui/overview.js +++ b/js/ui/overview.js @@ -376,23 +376,20 @@ Overview.prototype = { })); }, - //// Draggable target interface //// + //// Public methods //// - // Closes any active panes if a GenericDisplayItem is being - // dragged over the Overview, i.e. as soon as it starts being dragged. - // This allows the user to place the item on any workspace. - handleDragOver : function(source, actor, x, y, time) { - if (source instanceof GenericDisplay.GenericDisplayItem - || source instanceof AppDisplay.AppIcon) { + beginItemDrag: function(source) { + // Close any active panes if @source is a GenericDisplayItem. + // This allows the user to place the item on any workspace. + if (source instanceof GenericDisplay.GenericDisplayItem) if (this._activeDisplayPane != null) this._activeDisplayPane.close(); - return true; - } - - return false; + this.emit('item-drag-begin'); }, - //// Public methods //// + endItemDrag: function(source) { + this.emit('item-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. diff --git a/js/ui/placeDisplay.js b/js/ui/placeDisplay.js index 6c54a3cc6..452c8e19d 100644 --- a/js/ui/placeDisplay.js +++ b/js/ui/placeDisplay.js @@ -443,6 +443,14 @@ DashPlaceDisplayItem.prototype = { this.actor._delegate = this; this._draggable = DND.makeDraggable(this.actor); + this._draggable.connect('drag-begin', + Lang.bind(this, function() { + Main.overview.beginItemDrag(this); + })); + this._draggable.connect('drag-end', + Lang.bind(this, function() { + Main.overview.endItemDrag(this); + })); }, _onClicked: function(b) { diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js index b4b20586e..8eb74d43b 100644 --- a/js/ui/workspacesView.js +++ b/js/ui/workspacesView.js @@ -639,11 +639,15 @@ SingleView.prototype = { GenericWorkspacesView.prototype._init.call(this, width, height, x, y, workspaces); + this._itemDragBeginId = Main.overview.connect('item-drag-begin', + Lang.bind(this, this._dragBegin)); + this._itemDragEndId = Main.overview.connect('item-drag-end', + Lang.bind(this, this._dragEnd)); for (let i = 0; i < this._workspaces.length; i++) { this._workspaces[i]._windowDragBeginId = this._workspaces[i].connect('window-drag-begin', - Lang.bind(this, this._onWindowDragBegin)); + Lang.bind(this, this._dragBegin)); this._workspaces[i]._windowDragEndId = this._workspaces[i].connect('window-drag-end', - Lang.bind(this, this._onWindowDragEnd)); + Lang.bind(this, this._dragEnd)); } this.actor.add_actor(this._newWorkspaceArea.actor); @@ -1085,9 +1089,9 @@ SingleView.prototype = { 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._onWindowDragBegin)); + Lang.bind(this, this._dragBegin)); this._workspaces[w]._windowDragEndId = this._workspaces[w].connect('window-drag-end', - Lang.bind(this, this._onWindowDragEnd)); + Lang.bind(this, this._dragEnd)); } this._computeWorkspacePositions(); @@ -1117,6 +1121,14 @@ SingleView.prototype = { Mainloop.source_remove(this._timeoutId); this._timeoutId = 0; } + if (this._itemDragBeginId > 0) { + Main.overview.disconnect(this._itemDragBeginId); + this._itemDragBeginId = 0; + } + if (this._itemDragEndId > 0) { + 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); @@ -1170,7 +1182,7 @@ SingleView.prototype = { return false; }, - _onWindowDragBegin: function(w, actor) { + _dragBegin: function() { if (!this._scroll || this._scrolling) return; @@ -1242,7 +1254,7 @@ SingleView.prototype = { } }, - _onWindowDragEnd: function(w, actor) { + _dragEnd: function() { if (this._timeoutId) { Mainloop.source_remove(this._timeoutId); this._timeoutId = 0;