diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 5e9ad63fe..5008130ad 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -1172,14 +1172,8 @@ var BaseAppView = GObject.registerClass({ } _getDropTarget(x, y, source) { - const { currentPage } = this._grid; - - let [item, dragLocation] = this._grid.getDropTarget(x, y); - const [sourcePage, sourcePosition] = this._grid.getItemPosition(source); - const targetPage = currentPage; - let targetPosition = item - ? this._grid.getItemPosition(item)[1] : -1; + let [targetPage, targetPosition, dragLocation] = this._grid.getDropTarget(x, y); // In case we're hovering over the edge of an item but the // reflow will happen in the opposite direction (the drag @@ -1212,14 +1206,6 @@ var BaseAppView = GObject.registerClass({ } } - // Append to the page if dragging over empty area - if (dragLocation === IconGrid.DragLocation.EMPTY_SPACE) { - const pageItems = - this._grid.getItemsAtPage(currentPage).filter(c => c.visible); - - targetPosition = pageItems.length; - } - return [targetPage, targetPosition, dragLocation]; } diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js index 4e83b56ef..313621a5e 100644 --- a/js/ui/iconGrid.js +++ b/js/ui/iconGrid.js @@ -1008,19 +1008,21 @@ var IconGridLayout = GObject.registerClass({ // Out of bounds if (page >= this._pages.length) - return [null, DragLocation.INVALID]; + return [0, 0, DragLocation.INVALID]; if (isRtl && this._orientation === Clutter.Orientation.HORIZONTAL) page = swap(page, this._pages.length); - // Page-relative coordinates from now on + // Get page-relative coordinates + let adjX = x; + let adjY = y; if (this._orientation === Clutter.Orientation.HORIZONTAL) - x %= this._pageWidth; + adjX %= this._pageWidth; else - y %= this._pageHeight; + adjY %= this._pageHeight; - if (x < leftEmptySpace || y < topEmptySpace) - return [null, DragLocation.INVALID]; + if (adjX < leftEmptySpace || adjY < topEmptySpace) + return [0, 0, DragLocation.INVALID]; const gridWidth = childSize * this.columnsPerPage + @@ -1029,25 +1031,16 @@ var IconGridLayout = GObject.registerClass({ childSize * this.rowsPerPage + vSpacing * (this.rowsPerPage - 1); - if (x > leftEmptySpace + gridWidth || y > topEmptySpace + gridHeight) - return [null, DragLocation.INVALID]; + if (adjX > leftEmptySpace + gridWidth || adjY > topEmptySpace + gridHeight) + return [0, 0, DragLocation.INVALID]; const halfHSpacing = hSpacing / 2; const halfVSpacing = vSpacing / 2; const visibleItems = this._pages[page].visibleChildren; - for (const item of visibleItems) { - const childBox = item.allocation.copy(); - - // Page offset - switch (this._orientation) { - case Clutter.Orientation.HORIZONTAL: - childBox.set_origin(childBox.x1 % this._pageWidth, childBox.y1); - break; - case Clutter.Orientation.VERTICAL: - childBox.set_origin(childBox.x1, childBox.y1 % this._pageHeight); - break; - } + for (let i = 0; i < visibleItems.length; i++) { + const item = visibleItems[i]; + const childBox = item.allocation; // Outside the icon boundaries if (x < childBox.x1 - halfHSpacing || @@ -1072,10 +1065,10 @@ var IconGridLayout = GObject.registerClass({ dragLocation = DragLocation.START_EDGE; } - return [item, dragLocation]; + return [page, i, dragLocation]; } - return [null, DragLocation.EMPTY_SPACE]; + return [page, -1, DragLocation.EMPTY_SPACE]; } get iconSize() {