Blob Blame History Raw
From c69816b69f813c4678779e8a01f7a1b716170b1f Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Fri, 13 May 2016 17:53:54 +0200
Subject: [PATCH 1/2] widget: Add a property to configure the scroll speed

By default, it is set to zero which gives the current behaviour of
moving the buffer by a function of the number of visible rows.

https://bugzilla.redhat.com/show_bug.cgi?id=1103380
---
 src/vte-private.h |  1 +
 src/vte.c         | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 src/vteterminal.h |  3 +++
 3 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/src/vte-private.h b/src/vte-private.h
index 1f4ba76f62a4..212ff56f3627 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -284,6 +284,7 @@ struct _VteTerminalPrivate {
 	gboolean scroll_on_output;
 	gboolean scroll_on_keystroke;
 	gboolean alternate_screen_scroll;
+	guint scroll_speed;
 	long scrollback_lines;
 
 	/* Cursor shape */
diff --git a/src/vte.c b/src/vte.c
index da9addb8a904..14784ab9afb1 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -169,6 +169,7 @@ enum {
         PROP_MOUSE_POINTER_AUTOHIDE,
         PROP_PTY,
         PROP_REWRAP_ON_RESIZE,
+        PROP_SCROLL_SPEED,
         PROP_SCROLLBACK_LINES,
         PROP_SCROLL_ON_KEYSTROKE,
         PROP_SCROLL_ON_OUTPUT,
@@ -10384,9 +10385,9 @@ vte_cairo_get_clip_region (cairo_t *cr)
 static gboolean
 vte_terminal_scroll(GtkWidget *widget, GdkEventScroll *event)
 {
-	GtkAdjustment *adj;
 	VteTerminal *terminal;
 	gdouble delta_x, delta_y;
+        gdouble scroll_speed;
 	gdouble v;
 	gint cnt, i;
 	int button;
@@ -10442,8 +10443,16 @@ vte_terminal_scroll(GtkWidget *widget, GdkEventScroll *event)
 		return TRUE;
 	}
 
-	adj = terminal->pvt->vadjustment;
-	v = MAX (1., ceil (gtk_adjustment_get_page_increment (adj) / 10.));
+        if (terminal->pvt->scroll_speed == 0) {
+                GtkAdjustment *adj;
+
+                adj = terminal->pvt->vadjustment;
+                scroll_speed = ceil (gtk_adjustment_get_page_increment (adj) / 10.);
+        } else {
+                scroll_speed = terminal->pvt->scroll_speed;
+        }
+
+	v = MAX (1., scroll_speed);
 	_vte_debug_print(VTE_DEBUG_EVENTS,
 			"Scroll speed is %d lines per non-smooth scroll unit\n",
 			(int) v);
@@ -10560,6 +10569,9 @@ vte_terminal_get_property (GObject *object,
                 case PROP_REWRAP_ON_RESIZE:
                         g_value_set_boolean (value, vte_terminal_get_rewrap_on_resize (terminal));
                         break;
+                case PROP_SCROLL_SPEED:
+                        g_value_set_uint (value, pvt->scroll_speed);
+                        break;
                 case PROP_SCROLLBACK_LINES:
                         g_value_set_uint (value, pvt->scrollback_lines);
                         break;
@@ -10646,6 +10658,9 @@ vte_terminal_set_property (GObject *object,
                 case PROP_REWRAP_ON_RESIZE:
                         vte_terminal_set_rewrap_on_resize (terminal, g_value_get_boolean (value));
                         break;
+                case PROP_SCROLL_SPEED:
+                        vte_terminal_set_scroll_speed (terminal, g_value_get_uint (value));
+                        break;
                 case PROP_SCROLLBACK_LINES:
                         vte_terminal_set_scrollback_lines (terminal, g_value_get_uint (value));
                         break;
@@ -11472,6 +11487,23 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                        G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
 
         /**
+         * VteTerminal:scroll-speed:
+         *
+         * The number of lines by which the buffer is moved when
+         * scrolling with a mouse wheel on top of the
+         * terminal. Setting it to zero will cause the buffer to be
+         * moved by an amount depending on the number of visible rows
+         * the widget can display.
+         */
+        g_object_class_install_property
+                (gobject_class,
+                 PROP_SCROLL_SPEED,
+                 g_param_spec_uint ("scroll-speed", NULL, NULL,
+                                    0, G_MAXUINT,
+                                    0,
+                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
+
+        /**
          * VteTerminal:scrollback-lines:
          *
          * The length of the scrollback buffer used by the terminal.  The size of
@@ -11990,6 +12022,33 @@ vte_terminal_get_cursor_shape(VteTerminal *terminal)
 }
 
 /**
+ * vte_terminal_set_scroll_speed:
+ * @terminal: a #VteTerminal
+ * @scroll_speed: move the buffer by this number of lines while scrolling
+ *
+ * Sets the number of lines by which the buffer is moved when
+ * scrolling with a mouse wheel. Setting it to zero will cause the
+ * buffer to be moved by an amount depending on the number of visible
+ * rows the widget can display.
+ */
+void
+vte_terminal_set_scroll_speed(VteTerminal *terminal,
+                              guint scroll_speed)
+{
+        VteTerminalPrivate *pvt;
+
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+        pvt = terminal->pvt;
+
+        if (pvt->scroll_speed == scroll_speed)
+                return;
+
+        pvt->scroll_speed = scroll_speed;
+        g_object_notify(G_OBJECT(terminal), "scroll-speed");
+}
+
+/**
  * vte_terminal_set_scrollback_lines:
  * @terminal: a #VteTerminal
  * @lines: the length of the history buffer
diff --git a/src/vteterminal.h b/src/vteterminal.h
index 88e21b86704a..e6c23c7fe109 100644
--- a/src/vteterminal.h
+++ b/src/vteterminal.h
@@ -221,6 +221,9 @@ void vte_terminal_set_cursor_shape(VteTerminal *terminal,
 				   VteCursorShape shape) _VTE_GNUC_NONNULL(1);
 VteCursorShape vte_terminal_get_cursor_shape(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
 
+void vte_terminal_set_scroll_speed(VteTerminal *terminal,
+                                   guint scroll_speed) _VTE_GNUC_NONNULL(1);
+
 /* Set the number of scrollback lines, above or at an internal minimum. */
 void vte_terminal_set_scrollback_lines(VteTerminal *terminal,
                                        glong lines) _VTE_GNUC_NONNULL(1);
-- 
2.5.0


From 4f39f6592d1bc5c0c9aefd9176292015ce48ee38 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Fri, 13 May 2016 17:54:57 +0200
Subject: [PATCH 2/2] vteapp: Add a test for the scroll-speed property

https://bugzilla.redhat.com/show_bug.cgi?id=1103380
---
 src/app.vala | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/app.vala b/src/app.vala
index 67a58a24ce6c..396241f11a68 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -122,6 +122,7 @@ class Window : Gtk.ApplicationWindow
     terminal.set_rewrap_on_resize(!App.Options.no_rewrap);
     terminal.set_scroll_on_output(false);
     terminal.set_scroll_on_keystroke(true);
+    terminal.set_scroll_speed(App.Options.scroll_speed);
     terminal.set_scrollback_lines(App.Options.scrollback_lines);
 
     /* Style */
@@ -564,6 +565,7 @@ class App : Gtk.Application
     public static string? output_filename = null;
     private static string? pty_flags_string = null;
     public static bool reverse = false;
+    public static uint scroll_speed = 0;
     public static int scrollback_lines = 512;
     public static int transparency_percent = 0;
     public static bool version = false;
@@ -755,6 +757,8 @@ class App : Gtk.Application
         "PTY flags set from default|no-utmp|no-wtmp|no-lastlog|no-helper|no-fallback", null },
       { "reverse", 0, 0, OptionArg.NONE, ref reverse,
         "Reverse foreground/background colors", null },
+      { "scroll-speed", 'n', 0, OptionArg.INT, ref scroll_speed,
+        "Specify the scroll speed", null },
       { "scrollback-lines", 'n', 0, OptionArg.INT, ref scrollback_lines,
         "Specify the number of scrollback-lines", null },
       { "transparent", 'T', 0, OptionArg.INT, ref transparency_percent,
-- 
2.5.0