[pitivi] timeline: Fix touchpad scrolling
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] timeline: Fix touchpad scrolling
- Date: Thu, 10 Jan 2019 08:10:22 +0000 (UTC)
commit 7f5a6085fc7c6b7b4cce6aaa02f1f2be00a5f2d6
Author: Alexander Lopatin <alopatindev gmail com>
Date: Thu Jan 10 09:43:08 2019 +0300
timeline: Fix touchpad scrolling
Now touchpad users can scroll the timeline with horizontal movements.
Fixes #684
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 1ef1fbfa..04f2ca20 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 cbfa56da..9d9dc015 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."""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]