From aa86ce8b1e8a5039310e0622dcd2af062b5b2093 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Thu, 24 Jan 2019 22:20:58 -0500 Subject: [PATCH] Adjust appIcon drag positioning --- proximity.js | 5 ----- stylesheet.css | 2 +- taskbar.js | 55 ++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/proximity.js b/proximity.js index 87e47d9..6849bd1 100644 --- a/proximity.js +++ b/proximity.js @@ -117,11 +117,6 @@ var ProximityManager = new Lang.Class({ _bindSignals: function() { this._signalsHandler.add( - [ - Utils.DisplayWrapper.getScreen(), - 'restacked', - () => this._queueUpdate() - ], [ global.window_manager, 'switch-workspace', diff --git a/stylesheet.css b/stylesheet.css index 1425c97..1dddd0e 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -28,7 +28,7 @@ padding: 0; } -#dashtopanelScrollview .app-well-app .dtp-icon-container { +#dashtopanelScrollview .dtp-icon-container { padding: 0 4px; } diff --git a/taskbar.js b/taskbar.js index e81ad89..a10bc55 100644 --- a/taskbar.js +++ b/taskbar.js @@ -456,6 +456,12 @@ var taskbar = new Lang.Class({ }, _endDrag: function() { + if (this._dragInfo && this._dragInfo[1]._dashItemContainer instanceof DragPlaceholderItem) { + this._box.remove_child(this._dragInfo[1]._dashItemContainer); + this._dragInfo[1]._dashItemContainer.destroy(); + delete this._dragInfo[1]._dashItemContainer; + } + this._dragInfo = null; this._clearEmptyDropTarget(); this._showAppsIcon.setDragApp(null); @@ -662,7 +668,8 @@ var taskbar = new Lang.Class({ _updateAppIconsGeometry: function() { let appIcons = this._getAppIcons(); - appIcons.forEach(function(icon){ + + appIcons.filter(icon => icon.constructor === AppIcons.taskbarAppIcon).forEach(function(icon) { icon.updateIconGeometry(); }); }, @@ -960,7 +967,7 @@ var taskbar = new Lang.Class({ } }, - handleDragOver : function(source, actor, x, y, time) { + handleDragOver: function(source, actor, x, y, time) { if (source == Main.xdndHandler) return DND.DragMotionResult.CONTINUE; @@ -971,6 +978,14 @@ var taskbar = new Lang.Class({ if (!this._settings.is_writable('favorite-apps')) return DND.DragMotionResult.NO_DROP; + if (!this._box.contains(source.actor) && !source._dashItemContainer) { + //not an appIcon of the taskbar, probably from the applications view + source._dashItemContainer = new DragPlaceholderItem(source, this.iconSize); + this._box.insert_child_above(source._dashItemContainer, null); + } + + x -= this.showAppsButton.width; + let currentAppIcons = this._getAppIcons(); let sourceIndex = currentAppIcons.indexOf(source); let hoveredIndex = findIndex(currentAppIcons, @@ -986,12 +1001,12 @@ var taskbar = new Lang.Class({ // Don't allow positioning before or after self and between icons of same app if (!(hoveredIndex === sourceIndex || - (isLeft && hoveredIndex - 1 == sourceIndex) || - (isLeft && hoveredIndex - 1 >= 0 && source.app != currentAppIcons[hoveredIndex - 1].app && - currentAppIcons[hoveredIndex - 1].app == currentAppIcons[hoveredIndex].app) || - (!isLeft && hoveredIndex + 1 == sourceIndex) || - (!isLeft && hoveredIndex + 1 < currentAppIcons.length && source.app != currentAppIcons[hoveredIndex + 1].app && - currentAppIcons[hoveredIndex + 1].app == currentAppIcons[hoveredIndex].app))) { + (isLeft && hoveredIndex - 1 == sourceIndex) || + (isLeft && hoveredIndex - 1 >= 0 && source.app != currentAppIcons[hoveredIndex - 1].app && + currentAppIcons[hoveredIndex - 1].app == currentAppIcons[hoveredIndex].app) || + (!isLeft && hoveredIndex + 1 == sourceIndex) || + (!isLeft && hoveredIndex + 1 < currentAppIcons.length && source.app != currentAppIcons[hoveredIndex + 1].app && + currentAppIcons[hoveredIndex + 1].app == currentAppIcons[hoveredIndex].app))) { this._box.set_child_at_index(source._dashItemContainer, hoveredIndex); // Ensure the next and previous icon are visible when moving the icon @@ -1214,6 +1229,30 @@ var taskbar = new Lang.Class({ Signals.addSignalMethods(taskbar.prototype); +var DragPlaceholderItem = new Lang.Class({ + Name: 'DashToPanel-DragPlaceholderItem', + Extends: St.Widget, + + _init: function(appIcon, iconSize) { + this.parent({ style_class: 'dtp-icon-container', layout_manager: new Clutter.BinLayout() }); + + this.child = { _delegate: appIcon }; + + this._clone = new Clutter.Clone({ + source: appIcon.icon._iconBin, + width: iconSize, + height: iconSize + }); + + this.add_actor(this._clone); + }, + + destroy: function() { + this._clone.destroy(); + this.parent(); + }, +}); + function getAppStableSequence(app, settings, monitor) { let windows = AppIcons.getInterestingWindows(app, settings, monitor);