slider: Use Clutter.grab() for implicit grab

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2045>
This commit is contained in:
Carlos Garnacho 2021-11-18 00:00:52 +01:00
parent a8a9d4f806
commit 88a8ba0869

View File

@ -73,10 +73,7 @@ var Slider = GObject.registerClass({
let device = event.get_device(); let device = event.get_device();
let sequence = event.get_event_sequence(); let sequence = event.get_event_sequence();
if (sequence != null) this._grab = global.stage.grab(this);
device.sequence_grab(sequence, this);
else
device.grab(this);
this._grabbedDevice = device; this._grabbedDevice = device;
this._grabbedSequence = sequence; this._grabbedSequence = sequence;
@ -98,10 +95,10 @@ var Slider = GObject.registerClass({
this._releaseId = 0; this._releaseId = 0;
} }
if (this._grabbedSequence != null) if (this._grab) {
this._grabbedDevice.sequence_ungrab(this._grabbedSequence); this._grab.dismiss();
else this._grab = null;
this._grabbedDevice.ungrab(); }
this._grabbedSequence = null; this._grabbedSequence = null;
this._grabbedDevice = null; this._grabbedDevice = null;
@ -121,14 +118,14 @@ var Slider = GObject.registerClass({
vfunc_touch_event() { vfunc_touch_event() {
let event = Clutter.get_current_event(); let event = Clutter.get_current_event();
let device = event.get_device();
let sequence = event.get_event_sequence(); let sequence = event.get_event_sequence();
if (!this._dragging && if (!this._dragging &&
event.type() == Clutter.EventType.TOUCH_BEGIN) { event.type() == Clutter.EventType.TOUCH_BEGIN) {
this.startDragging(event); this.startDragging(event);
return Clutter.EVENT_STOP; 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) if (event.type() == Clutter.EventType.TOUCH_UPDATE)
return this._motionEvent(this, event); return this._motionEvent(this, event);
else if (event.type() == Clutter.EventType.TOUCH_END) else if (event.type() == Clutter.EventType.TOUCH_END)