[gnome-shell] appDisplay: Special-case dropping over page indicators
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] appDisplay: Special-case dropping over page indicators
- Date: Wed, 10 Aug 2022 15:28:51 +0000 (UTC)
commit 8f247971eb47e153df896ee173fa148c8b48d411
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Jun 29 14:25:47 2022 -0300
appDisplay: Special-case dropping over page indicators
This brings back the ability to drop an icon beyong the last page.
Because the acceptDrop() method does not have access to the target
drop actor, to avoid an extra pick or manually calculating it from
allocations, simply store it during DragMonitor.dragDrop(), and
use the target actor in acceptDrop().
This commit also removes the last usage of SidePages, so drop the
enum too.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2335>
js/ui/appDisplay.js | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index cc7881c6e1..1b21f14dc8 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -79,13 +79,6 @@ const DEFAULT_FOLDERS = {
},
};
-var SidePages = {
- NONE: 0,
- PREVIOUS: 1 << 0,
- NEXT: 1 << 1,
- DND: 1 << 2,
-};
-
function _getCategories(info) {
let categoriesStr = info.get_categories();
if (!categoriesStr)
@@ -884,6 +877,7 @@ var BaseAppView = GObject.registerClass({
_onDragBegin() {
this._dragMonitor = {
dragMotion: this._onDragMotion.bind(this),
+ dragDrop: this._onDragDrop.bind(this),
};
DND.addDragMonitor(this._dragMonitor);
this._appGridLayout.showPageIndicators();
@@ -908,6 +902,13 @@ var BaseAppView = GObject.registerClass({
return DND.DragMotionResult.CONTINUE;
}
+ _onDragDrop(dropEvent) {
+ // Because acceptDrop() does not receive the target actor, store it
+ // here and use this value in the acceptDrop() implementation below.
+ this._dropTarget = dropEvent.targetActor;
+ return DND.DragMotionResult.CONTINUE;
+ }
+
_onDragEnd() {
if (this._dragMonitor) {
DND.removeDragMonitor(this._dragMonitor);
@@ -939,11 +940,15 @@ var BaseAppView = GObject.registerClass({
}
acceptDrop(source) {
+ const dropTarget = this._dropTarget;
+ delete this._dropTarget;
+
if (!this._canAccept(source))
return false;
- if (this._dropPage) {
- const increment = this._dropPage === SidePages.NEXT ? 1 : -1;
+ if (dropTarget === this._prevPageIndicator ||
+ dropTarget === this._nextPageIndicator) {
+ const increment = dropTarget === this._prevPageIndicator ? -1 : 1;
const { currentPage, nPages } = this._grid;
const page = Math.min(currentPage + increment, nPages);
const position = page < nPages ? -1 : 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]