From 60d4b5aec1491046af82dcb78e55ea084a157a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Mon, 4 Oct 2021 10:11:46 +0200 Subject: [PATCH] widget: Do gestures in capture phase Capture phase runs from the toplevel down to the event widget and is meant to be used in containers that might possibly handle events before their children, like our OSD layer. This avoids an issue where pressing an OSD button does not emit cancelled signal, accidentally triggering long press gesture signal handler. Fixes #170 --- src/widget.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/widget.js b/src/widget.js index 4f6f15e2..c709573b 100644 --- a/src/widget.js +++ b/src/widget.js @@ -738,6 +738,7 @@ class ClapperWidget extends Gtk.Grid { const clickGesture = new Gtk.GestureClick({ button: 0, + propagation_phase: Gtk.PropagationPhase.CAPTURE, }); clickGesture.connect('pressed', this._onPressed.bind(this)); clickGesture.connect('released', this._onReleased.bind(this)); @@ -750,6 +751,7 @@ class ClapperWidget extends Gtk.Grid const longPressGesture = new Gtk.GestureLongPress({ touch_only: true, delay_factor: 0.9, + propagation_phase: Gtk.PropagationPhase.CAPTURE, }); longPressGesture.connect('pressed', this._onLongPressed.bind(this)); @@ -758,7 +760,9 @@ class ClapperWidget extends Gtk.Grid _getDragGesture() { - const dragGesture = new Gtk.GestureDrag(); + const dragGesture = new Gtk.GestureDrag({ + propagation_phase: Gtk.PropagationPhase.CAPTURE, + }); dragGesture.connect('drag-update', this._onDragUpdate.bind(this)); return dragGesture; @@ -768,6 +772,7 @@ class ClapperWidget extends Gtk.Grid { const swipeGesture = new Gtk.GestureSwipe({ touch_only: true, + propagation_phase: Gtk.PropagationPhase.CAPTURE, }); swipeGesture.connect('swipe', this._onSwipe.bind(this)); swipeGesture.connect('update', this._onSwipeUpdate.bind(this));