[gnome-shell/gbsneto/icon-grid-dnd: 43/43] appDisplay: Close popup when dragging
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/icon-grid-dnd: 43/43] appDisplay: Close popup when dragging
- Date: Fri, 2 Aug 2019 19:36:46 +0000 (UTC)
commit 87a76a5757519207ddf0aa334345a405a3ddeb45
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Jul 4 16:03:20 2019 -0300
appDisplay: Close popup when dragging
When a drag starts inside a folder, and the cursor moves to
outside it, close the currently opened folder popup.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/603
js/ui/appDisplay.js | 39 +++++++++++++++++++++++++++++++++++----
1 file changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 7e9b558e5..4bf87d004 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -431,6 +431,7 @@ var AllView = class AllView extends BaseAppView {
Main.overview.connect('item-drag-end', this._onDragEnd.bind(this));
this._nEventBlockerInhibits = 0;
+ this._popdownId = 0;
}
_refilterApps() {
@@ -864,6 +865,25 @@ var AllView = class AllView extends BaseAppView {
}
}
+ _schedulePopdown() {
+ if (this._popdownId > 0)
+ return;
+
+ this._popdownId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, () => {
+ if (this._currentPopup)
+ this._currentPopup.popdown();
+ this._popdownId = 0;
+ return GLib.SOURCE_REMOVE;
+ });
+ }
+
+ _unschedulePopdown() {
+ if (this._popdownId > 0) {
+ GLib.source_remove(this._popdownId);
+ this._popdownId = 0;
+ }
+ }
+
_onDragBegin() {
this._dragMonitor = {
dragMotion: this._onDragMotion.bind(this)
@@ -874,11 +894,22 @@ var AllView = class AllView extends BaseAppView {
_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.view == this)
+ // When dragging from a folder, don't nudge items; instead,
+ // prevent DND entirely by returning NO_DROP
+ if (this._currentPopup) {
+ if (dragEvent.targetActor == this._grid ||
+ this._grid.contains(dragEvent.targetActor)) {
+ this._schedulePopdown();
+ return DND.DragMotionResult.NO_DROP;
+ } else {
+ this._unschedulePopdown();
+ }
+ } else {
+ // Handle the drag overshoot. When dragging to above the
+ // icon grid, move to the page above; when dragging below,
+ // move to the page below.
this._handleDragOvershoot(dragEvent);
+ }
if (dragEvent.targetActor != this._grid)
this.removeNudges();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]