diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 3c7d2f3d4..7fbb83b32 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -1177,6 +1177,16 @@ var BaseAppView = GObject.registerClass({ const [sourcePage, sourcePosition] = this._grid.getItemPosition(source); let [targetPage, targetPosition, dragLocation] = this._grid.getDropTarget(x, y); + let reflowDirection = Clutter.ActorAlign.END; + + if (sourcePosition === targetPosition) + reflowDirection = -1; + + if (sourcePage === targetPage && sourcePosition < targetPosition) + reflowDirection = Clutter.ActorAlign.START; + if (!this._grid.layout_manager.allow_incomplete_pages && sourcePage < targetPage) + reflowDirection = Clutter.ActorAlign.START; + // In case we're hovering over the edge of an item but the // reflow will happen in the opposite direction (the drag // can't "naturally push the item away"), we instead set the @@ -1187,8 +1197,7 @@ var BaseAppView = GObject.registerClass({ // or last column though, in that case there is no adjacent // icon we could push away. if (dragLocation === IconGrid.DragLocation.START_EDGE && - targetPosition > sourcePosition && - targetPage === sourcePage) { + reflowDirection === Clutter.ActorAlign.START) { const nColumns = this._grid.layout_manager.columns_per_page; const targetColumn = targetPosition % nColumns; @@ -1197,8 +1206,7 @@ var BaseAppView = GObject.registerClass({ dragLocation = IconGrid.DragLocation.END_EDGE; } } else if (dragLocation === IconGrid.DragLocation.END_EDGE && - (targetPosition < sourcePosition || - targetPage !== sourcePage)) { + reflowDirection === Clutter.ActorAlign.END) { const nColumns = this._grid.layout_manager.columns_per_page; const targetColumn = targetPosition % nColumns;