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>
This commit is contained in:
parent
09b975fabf
commit
8f247971eb
@ -79,13 +79,6 @@ const DEFAULT_FOLDERS = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
var SidePages = {
|
|
||||||
NONE: 0,
|
|
||||||
PREVIOUS: 1 << 0,
|
|
||||||
NEXT: 1 << 1,
|
|
||||||
DND: 1 << 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
function _getCategories(info) {
|
function _getCategories(info) {
|
||||||
let categoriesStr = info.get_categories();
|
let categoriesStr = info.get_categories();
|
||||||
if (!categoriesStr)
|
if (!categoriesStr)
|
||||||
@ -884,6 +877,7 @@ var BaseAppView = GObject.registerClass({
|
|||||||
_onDragBegin() {
|
_onDragBegin() {
|
||||||
this._dragMonitor = {
|
this._dragMonitor = {
|
||||||
dragMotion: this._onDragMotion.bind(this),
|
dragMotion: this._onDragMotion.bind(this),
|
||||||
|
dragDrop: this._onDragDrop.bind(this),
|
||||||
};
|
};
|
||||||
DND.addDragMonitor(this._dragMonitor);
|
DND.addDragMonitor(this._dragMonitor);
|
||||||
this._appGridLayout.showPageIndicators();
|
this._appGridLayout.showPageIndicators();
|
||||||
@ -908,6 +902,13 @@ var BaseAppView = GObject.registerClass({
|
|||||||
return DND.DragMotionResult.CONTINUE;
|
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() {
|
_onDragEnd() {
|
||||||
if (this._dragMonitor) {
|
if (this._dragMonitor) {
|
||||||
DND.removeDragMonitor(this._dragMonitor);
|
DND.removeDragMonitor(this._dragMonitor);
|
||||||
@ -939,11 +940,15 @@ var BaseAppView = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
acceptDrop(source) {
|
acceptDrop(source) {
|
||||||
|
const dropTarget = this._dropTarget;
|
||||||
|
delete this._dropTarget;
|
||||||
|
|
||||||
if (!this._canAccept(source))
|
if (!this._canAccept(source))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (this._dropPage) {
|
if (dropTarget === this._prevPageIndicator ||
|
||||||
const increment = this._dropPage === SidePages.NEXT ? 1 : -1;
|
dropTarget === this._nextPageIndicator) {
|
||||||
|
const increment = dropTarget === this._prevPageIndicator ? -1 : 1;
|
||||||
const { currentPage, nPages } = this._grid;
|
const { currentPage, nPages } = this._grid;
|
||||||
const page = Math.min(currentPage + increment, nPages);
|
const page = Math.min(currentPage + increment, nPages);
|
||||||
const position = page < nPages ? -1 : 0;
|
const position = page < nPages ? -1 : 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user