[gnome-shell] swipeTracker: Optionally require modifiers for scrolling



commit ac8246050ddcba7ada494dd955c9028901794a13
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jan 29 21:28:52 2021 +0100

    swipeTracker: Optionally require modifiers for scrolling
    
    The design now calls for super-scroll for workspace switching
    in the session, however it is currently only possible for
    SwipeTracker to either handle scroll events or not.
    
    In order to support the new use case, add a new :scroll-modifiers
    property that allows specifying modifiers for which scroll events
    are handled.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1612>

 js/ui/swipeTracker.js | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/js/ui/swipeTracker.js b/js/ui/swipeTracker.js
index bed351f832..2ce054ab19 100644
--- a/js/ui/swipeTracker.js
+++ b/js/ui/swipeTracker.js
@@ -211,6 +211,10 @@ const ScrollGesture = GObject.registerClass({
             'orientation', 'orientation', 'orientation',
             GObject.ParamFlags.READWRITE,
             Clutter.Orientation, Clutter.Orientation.VERTICAL),
+        'scroll-modifiers': GObject.ParamSpec.flags(
+            'scroll-modifiers', 'scroll-modifiers', 'scroll-modifiers',
+            GObject.ParamFlags.READWRITE,
+            Clutter.ModifierType, 0),
     },
     Signals: {
         'begin':  { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] },
@@ -255,6 +259,10 @@ const ScrollGesture = GObject.registerClass({
         if ((this._allowedModes & Main.actionMode) === 0)
             return false;
 
+        if (this.scrollModifiers !== 0 &&
+            (event.get_state() & this.scrollModifiers) === 0)
+            return false;
+
         return true;
     }
 
@@ -336,6 +344,10 @@ var SwipeTracker = GObject.registerClass({
             'distance', 'distance', 'distance',
             GObject.ParamFlags.READWRITE,
             0, Infinity, 0),
+        'scroll-modifiers': GObject.ParamSpec.flags(
+            'scroll-modifiers', 'scroll-modifiers', 'scroll-modifiers',
+            GObject.ParamFlags.READWRITE,
+            Clutter.ModifierType, 0),
     },
     Signals: {
         'begin':  { param_types: [GObject.TYPE_UINT] },
@@ -394,6 +406,8 @@ var SwipeTracker = GObject.registerClass({
             this._scrollGesture.connect('end', this._endGesture.bind(this));
             this.bind_property('enabled', this._scrollGesture, 'enabled', 0);
             this.bind_property('orientation', this._scrollGesture, 'orientation', 0);
+            this.bind_property('scroll-modifiers',
+                this._scrollGesture, 'scroll-modifiers', 0);
         } else {
             this._scrollGesture = null;
         }


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