[pitivi/1.0] timeline: Fix touchpad scrolling
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/1.0] timeline: Fix touchpad scrolling
- Date: Thu, 10 Jan 2019 08:13:00 +0000 (UTC)
commit 8f9bd4ecc6a15605d331d4f52458fe85071792a6
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 2890d7a3..d70949b4 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
@@ -569,14 +570,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)
@@ -594,13 +588,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 1461b489..0267e3f3 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_settings(schema):
if schema not in Gio.Settings.list_schemas():
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]