[pitivi] timeline: Fix click to select for tablets
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] timeline: Fix click to select for tablets
- Date: Sat, 29 Jun 2019 22:48:42 +0000 (UTC)
commit ee2e1096c28e2d2d8c025d9313a94d964801f1dc
Author: Diego Garcia Gangl <dnicolas gmail com>
Date: Sat May 25 19:37:39 2019 -0300
timeline: Fix click to select for tablets
Left clicking in Digitizer tablets (Wacom, Huion, etc.) is done by
tapping the pad with the stylus. However since the stylus is entirely in
the user's hand it is in constant movement due to pulse, involuntary
movements, etc. This means that after press down the cursor will always
move, which will be registered as a drag.
To fix this we set a tolerance of 3 pixels, so we can tell if the
user really wants to start dragging.
Fixes #2319
pitivi/timeline/timeline.py | 19 +++++++++++++++++--
tests/test_timeline_timeline.py | 5 ++++-
2 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index d9f20a15..477ccd14 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -44,7 +44,6 @@ from pitivi.undo.timeline import CommitTimelineFinalizingAction
from pitivi.utils.loggable import Loggable
from pitivi.utils.timeline import EditingContext
from pitivi.utils.timeline import SELECT
-from pitivi.utils.timeline import SELECT_ADD
from pitivi.utils.timeline import Selection
from pitivi.utils.timeline import TimelineError
from pitivi.utils.timeline import UNSELECT
@@ -847,7 +846,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
self.dragEnd()
return False
- if self.got_dragged or self.__drag_start_x != event.x:
+ if self.got_dragged or self.__past_threshold(event):
event_widget = Gtk.get_event_widget(event)
x, y = event_widget.translate_coordinates(self.layout.layers_vbox, event.x, event.y)
self.__drag_update(x, y)
@@ -870,6 +869,22 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
return False
+ def __past_threshold(self, event):
+ threshold = 0
+ tool = event.get_device_tool()
+ if tool:
+ if tool.get_tool_type() in {Gdk.DeviceToolType.PEN,
+ Gdk.DeviceToolType.ERASER}:
+ # Wait for the user to drag at least 3 pixels in any direction
+ # before dragging when using a stylus. This avoids issues
+ # with digitizer tablets where there may be some movement in
+ # the stylus while clicking.
+ threshold = 3
+
+ delta_x = abs(self.__drag_start_x - event.x)
+
+ return delta_x > threshold
+
def _seek(self, event):
event_widget = Gtk.get_event_widget(event)
x, unused_y = event_widget.translate_coordinates(self.layout.layers_vbox, event.x, event.y)
diff --git a/tests/test_timeline_timeline.py b/tests/test_timeline_timeline.py
index aed19b40..20e53b1c 100644
--- a/tests/test_timeline_timeline.py
+++ b/tests/test_timeline_timeline.py
@@ -478,7 +478,7 @@ class TestGrouping(BaseTestTimeline):
# Click the first clip in the group.
with mock.patch.object(Gtk, 'get_event_widget') as get_event_widget:
event = mock.Mock()
- event.x = 0
+ event.x = 100
event.get_button.return_value = True, 1
get_event_widget.return_value = clip1.ui
timeline._button_press_event_cb(None, event)
@@ -486,6 +486,7 @@ class TestGrouping(BaseTestTimeline):
# Move it to the right, on the separator below.
event = mock.Mock()
+ event.x = 101
event.get_state.return_value = Gdk.ModifierType.BUTTON1_MASK
with mock.patch.object(clip1.ui, "translate_coordinates") as translate_coordinates:
translate_coordinates.return_value = (40, 0)
@@ -576,6 +577,7 @@ class TestEditing(BaseTestTimeline):
# Click the right trim handle of the clip.
with mock.patch.object(Gtk, 'get_event_widget') as get_event_widget:
event = mock.Mock()
+ event.x = 100
event.get_button.return_value = True, 1
get_event_widget.return_value = clip.ui.rightHandle
timeline._button_press_event_cb(None, event)
@@ -583,6 +585,7 @@ class TestEditing(BaseTestTimeline):
# Drag it to the left, on the separator below.
event = mock.Mock()
+ event.x = 99
event.get_state.return_value = Gdk.ModifierType.BUTTON1_MASK
with mock.patch.object(clip.ui.rightHandle, "translate_coordinates") as translate_coordinates:
translate_coordinates.return_value = (0, 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]