From dbb1b0d504734b7f1588782f5af2b7fecb9fff78 Mon Sep 17 00:00:00 2001 From: Alexander Lopatin Date: Thu, 10 Jan 2019 09:43:08 +0300 Subject: [PATCH] Fix #684: touchpad vertical scroll causes horizontal scrolling of timeline --- pitivi/timeline/timeline.py | 29 +++++++++++++++-------------- pitivi/utils/ui.py | 2 ++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py index 1ef1fbfa4..04f2ca207 100644 --- a/pitivi/timeline/timeline.py +++ b/pitivi/timeline/timeline.py @@ -59,6 +59,7 @@ from pitivi.utils.ui import set_children_state_recurse from pitivi.utils.ui import SNAPBAR_COLOR from pitivi.utils.ui import SNAPBAR_WIDTH from pitivi.utils.ui import SPACING +from pitivi.utils.ui import TOUCH_INPUT_SOURCES from pitivi.utils.ui import unset_children_state_recurse from pitivi.utils.ui import URI_TARGET_ENTRY from pitivi.utils.widgets import ZoomBox @@ -591,14 +592,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable): return False event_widget = Gtk.get_event_widget(event) - if event.get_state() & Gdk.ModifierType.SHIFT_MASK: - if delta_y > 0: - # Scroll down. - self.__scroll_adjustment(self.vadj, 1) - elif delta_y < 0: - # Scroll up. - self.__scroll_adjustment(self.vadj, -1) - elif event.get_state() & (Gdk.ModifierType.CONTROL_MASK | + if event.get_state() & (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK): # Zoom. x, unused_y = event_widget.translate_coordinates(self.layout.layers_vbox, event.x, event.y) @@ -616,13 +610,20 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable): # Scroll so position remains in place. x, unused_y = event_widget.translate_coordinates(self.layout, event.x, event.y) self.hadj.set_value(self.nsToPixel(position) - x) + return False + + device = event.get_source_device() or event.device + if device and device.get_source() in TOUCH_INPUT_SOURCES: + scroll_x = delta_x + scroll_y = delta_y else: - if delta_y > 0: - # Scroll right. - self.__scroll_adjustment(self.hadj, 1) - else: - # Scroll left. - self.__scroll_adjustment(self.hadj, -1) + scroll_x = delta_y + scroll_y = 0 + if event.get_state() & Gdk.ModifierType.SHIFT_MASK: + scroll_x, scroll_y = scroll_y, scroll_x + + self.__scroll_adjustment(self.hadj, scroll_x) + self.__scroll_adjustment(self.vadj, scroll_y) return False diff --git a/pitivi/utils/ui.py b/pitivi/utils/ui.py index cbfa56da3..9d9dc0155 100644 --- a/pitivi/utils/ui.py +++ b/pitivi/utils/ui.py @@ -71,6 +71,8 @@ FILE_TARGET_ENTRY = Gtk.TargetEntry.new("text/plain", 0, 0) URI_TARGET_ENTRY = Gtk.TargetEntry.new("text/uri-list", 0, 0) EFFECT_TARGET_ENTRY = Gtk.TargetEntry.new("pitivi/effect", 0, 0) +TOUCH_INPUT_SOURCES = (Gdk.InputSource.TOUCHPAD, Gdk.InputSource.TRACKPOINT, Gdk.InputSource.TABLET_PAD) + def get_month_format_string(): """Returns the appropriate format string for month name in time.strftime() function.""" -- GitLab