[gnome-shell] appDisplay: Reimplement drag motion using page indicators
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] appDisplay: Reimplement drag motion using page indicators
- Date: Wed, 10 Aug 2022 15:28:51 +0000 (UTC)
commit 09b975fabf8e05ca2c777a498364672701808dcc
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Jun 28 19:47:06 2022 -0300
appDisplay: Reimplement drag motion using page indicators
This simplified the _handleDragOvershoot() callback quite a lot.
Instead of transforming point positions and checking them against
grid coordinates, merely check if the drop target is one of the
page indicators.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2335>
js/ui/appDisplay.js | 47 ++++++++++++++---------------------------------
1 file changed, 14 insertions(+), 33 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 8689e62a26..cc7881c6e1 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -43,7 +43,6 @@ const PAGE_PREVIEW_ANIMATION_TIME = 150;
const PAGE_INDICATOR_FADE_TIME = 200;
const PAGE_PREVIEW_RATIO = 0.20;
-const OVERSHOOT_THRESHOLD = 20;
const OVERSHOOT_TIMEOUT = 1000;
const DELAYED_MOVE_TIMEOUT = 200;
@@ -548,7 +547,7 @@ var BaseAppView = GObject.registerClass({
style_class: 'page-navigation-hint next',
opacity: 0,
visible: false,
- reactive: false,
+ reactive: true,
x_expand: true,
y_expand: true,
x_align: Clutter.ActorAlign.FILL,
@@ -559,7 +558,7 @@ var BaseAppView = GObject.registerClass({
style_class: 'page-navigation-hint previous',
opacity: 0,
visible: false,
- reactive: false,
+ reactive: true,
x_expand: true,
y_expand: true,
x_align: Clutter.ActorAlign.FILL,
@@ -641,7 +640,6 @@ var BaseAppView = GObject.registerClass({
() => this._redisplay(), this);
// Drag n' Drop
- this._lastOvershoot = -1;
this._lastOvershootTimeoutId = 0;
this._delayedMoveData = null;
@@ -846,54 +844,37 @@ var BaseAppView = GObject.registerClass({
if (this._lastOvershootTimeoutId)
GLib.source_remove(this._lastOvershootTimeoutId);
this._lastOvershootTimeoutId = 0;
- this._lastOvershoot = -1;
}
_handleDragOvershoot(dragEvent) {
- const [gridX, gridY] = this.get_transformed_position();
- const [gridWidth, gridHeight] = this.get_transformed_size();
-
- const vertical = this._orientation === Clutter.Orientation.VERTICAL;
- const gridStart = vertical ? gridY : gridX;
- const gridEnd = vertical
- ? gridY + gridHeight - OVERSHOOT_THRESHOLD
- : gridX + gridWidth - OVERSHOOT_THRESHOLD;
-
// Already animating
if (this._adjustment.get_transition('value') !== null)
return;
- // Within the grid boundaries
- const dragPosition = vertical ? dragEvent.y : dragEvent.x;
- if (dragPosition > gridStart && dragPosition < gridEnd) {
- // Check whether we moved out the area of the last switch
- if (Math.abs(this._lastOvershoot - dragPosition) > OVERSHOOT_THRESHOLD)
- this._resetOvershoot();
+ const {targetActor} = dragEvent;
+ if (targetActor !== this._prevPageIndicator &&
+ targetActor !== this._nextPageIndicator) {
+ this._resetOvershoot();
return;
}
- // Still in the area of the previous page switch
- if (this._lastOvershoot >= 0)
+ if (this._lastOvershootTimeoutId > 0)
return;
- const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
- if (dragPosition <= gridStart)
- this.goToPage(this._grid.currentPage + (rtl ? 1 : -1));
- else if (dragPosition >= gridEnd)
- this.goToPage(this._grid.currentPage + (rtl ? -1 : 1));
+ let targetPage;
+ if (dragEvent.targetActor === this._prevPageIndicator)
+ targetPage = this._grid.currentPage - 1;
else
- return; // don't go beyond first/last page
-
- this._lastOvershoot = dragPosition;
+ targetPage = this._grid.currentPage + 1;
- if (this._lastOvershootTimeoutId > 0)
- GLib.source_remove(this._lastOvershootTimeoutId);
+ if (targetPage < 0 || targetPage >= this._grid.nPages)
+ return; // don't go beyond first/last page
this._lastOvershootTimeoutId =
GLib.timeout_add(GLib.PRIORITY_DEFAULT, OVERSHOOT_TIMEOUT, () => {
this._resetOvershoot();
- this._handleDragOvershoot(dragEvent);
+ this.goToPage(targetPage);
return GLib.SOURCE_REMOVE;
});
GLib.Source.set_name_by_id(this._lastOvershootTimeoutId,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]