Commit ee2e1096 authored by Diego Gangl's avatar Diego Gangl Committed by Alexandru Băluț

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
parent dd262c24
Pipeline #92220 failed with stages
in 72 minutes and 17 seconds
......@@ -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):
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,
# 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)
......@@ -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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment