[gnome-shell/gbsneto/custom-icon-positions: 59/72] 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: 59/72] appDisplay: Accept dropping any kind of icon over it
- Date: Thu, 4 Jun 2020 19:00:30 +0000 (UTC)
commit 65eec564726056d6e5ec08c01999bed9eae43823
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 730fa863d9..7a95267f8e 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -986,14 +986,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;
}
@@ -1024,18 +1017,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]