[gnome-shell/gbsneto/custom-icon-positions: 25/35] appDisplay: Accept dropping any kind of icon over it
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/custom-icon-positions: 25/35] appDisplay: Accept dropping any kind of icon over it
- Date: Wed, 27 May 2020 01:45:39 +0000 (UTC)
commit 1df3a27c6c1df93d801580ed62afdc7a68bddc35
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue May 26 11:19:39 2020 -0300
appDisplay: Accept dropping any kind of icon over it
The grid can handle it now!
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1284
js/ui/appDisplay.js | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 7bef3f0944..9397f408e9 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -990,14 +990,7 @@ class AppDisplay extends BaseAppView {
this.removeNudges();
}
- _canAccept(source) {
- if (!(source instanceof AppIcon))
- return false;
-
- let view = _getViewFromIcon(source);
- if (!(view instanceof FolderView))
- return false;
-
+ _canAccept(_source) {
return true;
}
@@ -1028,18 +1021,37 @@ class AppDisplay extends BaseAppView {
else
this.removeNudges();
+ if (dropTarget === IconGrid.DragLocation.INVALID)
+ return DND.DragMotionResult.NO_DROP;
+
if (!this._canAccept(source))
return DND.DragMotionResult.NO_DROP;
return DND.DragMotionResult.MOVE_DROP;
}
- acceptDrop(source) {
+ acceptDrop(source, _actor, x, y) {
if (!this._canAccept(source))
return false;
+ const [item, dropTarget] = this.getDropTarget(x, y);
+ if (!item || !this._dropTargetIsValid(source, item, dropTarget))
+ return false;
+
+ const [sourcePage, sourcePosition] = this._grid.getItemPosition(source);
+ let [targetPage, targetPosition] = this._grid.getItemPosition(item);
+
+ if (sourcePage === targetPage && targetPosition > sourcePosition)
+ targetPosition--;
+
+ if (source !== item && dropTarget === IconGrid.DragLocation.END_EDGE)
+ targetPosition++;
+
let view = _getViewFromIcon(source);
- view.removeApp(source.app);
+ if (view === this)
+ this.moveItem(source, targetPage, targetPosition);
+ else
+ view.removeApp(source.app);
if (this._currentDialog)
this._currentDialog.popdown();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]