Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save craigcabrey/32bce9ee830f076cd1a32b2df2fee9b3 to your computer and use it in GitHub Desktop.
Save craigcabrey/32bce9ee830f076cd1a32b2df2fee9b3 to your computer and use it in GitHub Desktop.
Patch to re-enable kinetic scrolling on non-touchscreen input sources in GTK+ 3.20.
From c76461960d05b3d64185d1a67096461ce6854009 Mon Sep 17 00:00:00 2001
From: Craig Cabrey <craigcabrey@gmail.com>
Date: Fri, 8 Jul 2016 13:07:26 -0400
Subject: [PATCH] Don't restrict movement gestures to touchscreens
---
gtk/gtkscrolledwindow.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 1b52082..dc30ade 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -2042,7 +2042,7 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
priv->overlay_scrolling = TRUE;
priv->drag_gesture = gtk_gesture_drag_new (widget);
- gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->drag_gesture), TRUE);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->drag_gesture), TRUE);
g_signal_connect_swapped (priv->drag_gesture, "drag-begin",
G_CALLBACK (scrolled_window_drag_begin_cb),
scrolled_window);
@@ -2055,17 +2055,17 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
priv->pan_gesture = gtk_gesture_pan_new (widget, GTK_ORIENTATION_VERTICAL);
gtk_gesture_group (priv->pan_gesture, priv->drag_gesture);
- gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->pan_gesture), TRUE);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->pan_gesture), TRUE);
priv->swipe_gesture = gtk_gesture_swipe_new (widget);
gtk_gesture_group (priv->swipe_gesture, priv->drag_gesture);
- gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->swipe_gesture), TRUE);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->swipe_gesture), TRUE);
g_signal_connect_swapped (priv->swipe_gesture, "swipe",
G_CALLBACK (scrolled_window_swipe_cb),
scrolled_window);
priv->long_press_gesture = gtk_gesture_long_press_new (widget);
gtk_gesture_group (priv->long_press_gesture, priv->drag_gesture);
- gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->long_press_gesture), TRUE);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->long_press_gesture), TRUE);
g_signal_connect_swapped (priv->long_press_gesture, "pressed",
G_CALLBACK (scrolled_window_long_press_cb),
scrolled_window);
--
2.9.0

Kinetic Scrolling

e3a281be135337924f50c829bf418895f64e978f disabled kinetic scrolling if the input source wasn't from a touchscreen (GDK_SOURCE_TOUCHSCREEN).

This patch re-enables that functionality. libinput does not mimic kinetic scrolling (for good reason), so it is up to the toolkit to implement the feature.

Usage

  1. Download 0001-Don-t-restrict-movement-gestures-to-touchscreens.patch.
  2. Clone the GTK repository: git clone git://git.gnome.org/gtk+ && cd gtk+.
  3. Checkout the 3.20 branch: git checkout -b 3_20 origin/gtk-3-20.
  4. Apply the patch: git apply ../0001-Don-t-restrict-movement-gestures-to-touchscreens.patch.
  5. Build GTK and install.

I run Arch so I downloaded the PKGBUILD and modified it to include the patch.

@heftig
Copy link

heftig commented Jul 8, 2016

Technically, the argument to gtk_gesture_single_set_button should be 1, not TRUE.

@andrewlin0410
Copy link

Hello, I came across this and I wonder if this will enable 2 finger pinch to zoom for Ubuntu 19.10. I cannot try because I am not sure how to do step 5. If not, this is probably the closest solution because this can make the system think the input from the touchpad is from the screen. Anyways, please add more details on how to do step 5. Thank you

@bmorashad
Copy link

I can use this for gnome 3.34 as well right? and 5th step is to run make && sudo make install from inside build folder right? I badly need this feature since I depend on touchpad & it's a pain without kinetic scroll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment