[gnome-shell/gbsneto/icon-grid-dnd: 5/13] allView: Switch pages when dragging above or below the grid
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/icon-grid-dnd: 5/13] allView: Switch pages when dragging above or below the grid
- Date: Sat, 29 Jun 2019 04:52:32 +0000 (UTC)
commit 553de0ac90200d0a34e764e78b3b6d23ca5b06c5
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Jun 28 20:48:22 2019 -0300
allView: Switch pages when dragging above or below the grid
This is necessary for being able to drag application icons
to folders in different pages.
Add a drag motion handler to AllView and handle overshoots
when dragging. Only handle it when dragging from AllView.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/603
js/ui/appDisplay.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index b1aeafa93..c7029a739 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -334,6 +334,9 @@ var AllView = class AllView extends BaseAppView {
Main.queueDeferredWork(this._redisplayWorkId);
});
+ Main.overview.connect('item-drag-begin', this._onDragBegin.bind(this));
+ Main.overview.connect('item-drag-end', this._onDragEnd.bind(this));
+
this._nEventBlockerInhibits = 0;
}
@@ -649,6 +652,59 @@ var AllView = class AllView extends BaseAppView {
this.folderIcons[i].adaptToSize(availWidth, availHeight);
}
+ _handleDragOvershoot(dragEvent) {
+ let [gridX, gridY] = this.actor.get_transformed_position();
+ let [gridWidth, gridHeight] = this.actor.get_transformed_size();
+ let gridBottom = gridY + gridHeight;
+
+ // Within the grid boundaries - cancel any existing scrolling
+ if (dragEvent.y > gridY && dragEvent.y < gridBottom) {
+ if (Tweener.isTweening(this._adjustment))
+ Tweener.removeTweens(this._adjustment);
+ return;
+ }
+
+ // Moving above the grid
+ let currentY = this._adjustment.value;
+ if (dragEvent.y <= gridY && currentY > 0) {
+ this.goToPage(this._grid.currentPage - 1);
+ return;
+ }
+
+ // Moving below the grid
+ let maxY = this._adjustment.upper - this._adjustment.page_size;
+ if (dragEvent.y >= gridBottom && currentY < maxY) {
+ this.goToPage(this._grid.currentPage + 1);
+ return;
+ }
+ }
+
+ _onDragBegin() {
+ this._dragMonitor = {
+ dragMotion: this._onDragMotion.bind(this)
+ };
+ DND.addDragMonitor(this._dragMonitor);
+ }
+
+ _onDragMotion(dragEvent) {
+ let appIcon = dragEvent.source;
+
+ // Handle the drag overshoot. When dragging to above the
+ // icon grid, move to the page above; when dragging below,
+ // move to the page below.
+ if (appIcon.parentView == this)
+ this._handleDragOvershoot(dragEvent);
+
+ return DND.DragMotionResult.CONTINUE;
+ }
+
+ _onDragEnd() {
+ if (this._dragMonitor) {
+ DND.removeDragMonitor(this._dragMonitor);
+ this._dragMonitor = null;
+ }
+ }
+
inhibitEventBlocker() {
this._nEventBlockerInhibits++;
this._eventBlocker.visible = this._nEventBlockerInhibits == 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]