[gnome-shell] appDisplay: Bring back drag overshoot region



commit 4dcae8ddd2637384b82fcbaa5ebd26c3dc2b77cd
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Aug 9 19:39:41 2022 -0300

    appDisplay: Bring back drag overshoot region
    
    This is a region where, if hovered while dragging, immediately goes
    to the previous or next page. This behavior was lost during the
    transition to the new app grid layout manager.
    
    Bring back the drag overshoot region.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2335>

 js/ui/appDisplay.js | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 9ede9a6900..92ed05b72f 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -43,6 +43,7 @@ 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 = 300;
 
 const DELAYED_MOVE_TIMEOUT = 200;
@@ -843,6 +844,23 @@ var BaseAppView = GObject.registerClass({
         this._overshootTimeoutId = 0;
     }
 
+    _dragWithinOvershootRegion(dragEvent) {
+        const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
+        const {x, y, targetActor: indicator} = dragEvent;
+        const [indicatorX, indicatorY] = indicator.get_transformed_position();
+        const [indicatorWidth, indicatorHeight] = indicator.get_transformed_size();
+
+        let overshootX = indicatorX;
+        if (indicator === this._nextPageIndicator || rtl)
+            overshootX += indicatorWidth - OVERSHOOT_THRESHOLD;
+
+        const overshootBox = new Clutter.ActorBox();
+        overshootBox.set_origin(overshootX, indicatorY);
+        overshootBox.set_size(OVERSHOOT_THRESHOLD, indicatorHeight);
+
+        return overshootBox.contains(x, y);
+    }
+
     _handleDragOvershoot(dragEvent) {
         // Already animating
         if (this._adjustment.get_transition('value') !== null)
@@ -868,6 +886,13 @@ var BaseAppView = GObject.registerClass({
         if (targetPage < 0 || targetPage >= this._grid.nPages)
             return; // don't go beyond first/last page
 
+        // If dragging over the drag overshoot threshold region, immediately
+        // switch pages
+        if (this._dragWithinOvershootRegion(dragEvent)) {
+            this._resetOvershoot();
+            this.goToPage(targetPage);
+        }
+
         this._overshootTimeoutId =
             GLib.timeout_add(GLib.PRIORITY_DEFAULT, OVERSHOOT_TIMEOUT, () => {
                 this._resetOvershoot();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]