[gnome-shell/wip/carlosg/grabs-pt2: 7/25] slider: Use Clutter.grab() for implicit grab




commit 1aadbbd72bdbb9a8105edc822ec4d8b5becbb595
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Nov 18 00:00:52 2021 +0100

    slider: Use Clutter.grab() for implicit grab

 js/ui/slider.js | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/slider.js b/js/ui/slider.js
index ba3a233f15..6ca76fec0b 100644
--- a/js/ui/slider.js
+++ b/js/ui/slider.js
@@ -73,10 +73,7 @@ var Slider = GObject.registerClass({
         let device = event.get_device();
         let sequence = event.get_event_sequence();
 
-        if (sequence != null)
-            device.sequence_grab(sequence, this);
-        else
-            device.grab(this);
+        this._grab = global.stage.grab(this);
 
         this._grabbedDevice = device;
         this._grabbedSequence = sequence;
@@ -98,10 +95,10 @@ var Slider = GObject.registerClass({
                 this._releaseId = 0;
             }
 
-            if (this._grabbedSequence != null)
-                this._grabbedDevice.sequence_ungrab(this._grabbedSequence);
-            else
-                this._grabbedDevice.ungrab();
+            if (this._grab) {
+                this._grab.dismiss();
+                this._grab = null;
+            }
 
             this._grabbedSequence = null;
             this._grabbedDevice = null;
@@ -121,14 +118,14 @@ var Slider = GObject.registerClass({
 
     vfunc_touch_event() {
         let event = Clutter.get_current_event();
-        let device = event.get_device();
         let sequence = event.get_event_sequence();
 
         if (!this._dragging &&
             event.type() == Clutter.EventType.TOUCH_BEGIN) {
             this.startDragging(event);
             return Clutter.EVENT_STOP;
-        } else if (device.sequence_get_grabbed_actor(sequence) == this) {
+        } else if (this._grabbedSequence &&
+                   sequence.get_slot() === this._grabbedSequence.get_slot()) {
             if (event.type() == Clutter.EventType.TOUCH_UPDATE)
                 return this._motionEvent(this, event);
             else if (event.type() == Clutter.EventType.TOUCH_END)


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