Blame SOURCES/vte291-command-notify-scroll-speed.patch

98e95b
From 9fc40e9bef26f6419c12f6a0f198c5f89bcc5c85 Mon Sep 17 00:00:00 2001
f5073b
From: Debarshi Ray <debarshir@gnome.org>
f5073b
Date: Wed, 7 Jan 2015 16:01:00 +0100
f5073b
Subject: [PATCH 1/5] Add sequences and signals for desktop notification
f5073b
f5073b
Add sequences
f5073b
  OSC 777 ; notify ; SUMMARY ; BODY BEL
f5073b
  OSC 777 ; notify ; SUMMARY BEL
f5073b
  OSC 777 ; notify ; SUMMARY ; BODY ST
f5073b
  OSC 777 ; notify ; SUMMARY ST
f5073b
f5073b
that let terminal applications send a notification to the desktop
f5073b
environment.
f5073b
f5073b
Based on Enlightenment's Terminology:
f5073b
https://phab.enlightenment.org/T1765
f5073b
f5073b
https://bugzilla.gnome.org/show_bug.cgi?id=711059
f5073b
---
98e95b
 src/caps-list.hh      |  4 +++
f5073b
 src/marshal.list      |  1 +
f5073b
 src/vte.cc            | 12 +++++++
f5073b
 src/vte/vteterminal.h |  4 ++-
f5073b
 src/vtegtk.cc         | 21 ++++++++++++
f5073b
 src/vtegtk.hh         |  1 +
f5073b
 src/vteinternal.hh    |  5 +++
98e95b
 src/vteseq-list.hh    |  1 +
98e95b
 src/vteseq.cc         | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++
98e95b
 9 files changed, 140 insertions(+), 1 deletion(-)
f5073b
98e95b
diff --git a/src/caps-list.hh b/src/caps-list.hh
98e95b
index cc7075c8e7fb..8a3704987a6c 100644
98e95b
--- a/src/caps-list.hh
98e95b
+++ b/src/caps-list.hh
98e95b
@@ -251,6 +251,8 @@ static const vte_matcher_entry_t entries[] = {
98e95b
         ENTRY(OSC "119" BEL, reset_highlight_foreground_color),
98e95b
         ENTRY(OSC "133;%s" BEL, iterm2_133),
98e95b
         ENTRY(OSC "777;%s" BEL, urxvt_777),
98e95b
+        ENTRY(OSC "777;%s;%s;%s" BEL, send_notification),
98e95b
+        ENTRY(OSC "777;%s;%s" BEL, send_notification),
98e95b
         ENTRY(OSC "1337;%s" BEL, iterm2_1337),
f5073b
 
98e95b
         /* Set text parameters, ST_terminated versions. */
98e95b
@@ -293,6 +295,8 @@ static const vte_matcher_entry_t entries[] = {
98e95b
         ENTRY(OSC "119" ST, reset_highlight_foreground_color),
98e95b
         ENTRY(OSC "133;%s" ST, iterm2_133),
98e95b
         ENTRY(OSC "777;%s" ST, urxvt_777),
98e95b
+        ENTRY(OSC "777;%s;%s;%s" ST, send_notification),
98e95b
+        ENTRY(OSC "777;%s;%s" ST, send_notification),
98e95b
         ENTRY(OSC "1337;%s" ST, iterm2_1337),
f5073b
 
98e95b
         /* These may be bogus, I can't find docs for them anywhere (#104154). */
f5073b
diff --git a/src/marshal.list b/src/marshal.list
98e95b
index 1e4d0c1b6476..3385b4759713 100644
f5073b
--- a/src/marshal.list
f5073b
+++ b/src/marshal.list
98e95b
@@ -1,5 +1,6 @@
f5073b
 VOID:INT,INT
f5073b
 VOID:OBJECT,OBJECT
98e95b
 VOID:STRING,BOXED
f5073b
+VOID:STRING,STRING
f5073b
 VOID:STRING,UINT
f5073b
 VOID:UINT,UINT
f5073b
diff --git a/src/vte.cc b/src/vte.cc
98e95b
index 2d26fe6227e3..fd461935490a 100644
f5073b
--- a/src/vte.cc
f5073b
+++ b/src/vte.cc
98e95b
@@ -8623,6 +8623,9 @@ VteTerminalPrivate::~VteTerminalPrivate()
f5073b
 
f5073b
 	remove_update_timeout(this);
f5073b
 
f5073b
+	g_free (m_notification_summary);
f5073b
+	g_free (m_notification_body);
f5073b
+
f5073b
 	/* discard title updates */
f5073b
         g_free(m_window_title);
f5073b
         g_free(m_window_title_changed);
98e95b
@@ -10883,6 +10886,15 @@ VteTerminalPrivate::emit_pending_signals()
f5073b
 
f5073b
 	emit_adjustment_changed();
f5073b
 
f5073b
+	if (m_notification_received) {
f5073b
+                _vte_debug_print (VTE_DEBUG_SIGNALS,
f5073b
+                                  "Emitting `notification-received'.\n");
f5073b
+                g_signal_emit(object, signals[SIGNAL_NOTIFICATION_RECEIVED], 0,
f5073b
+                              m_notification_summary,
f5073b
+                              m_notification_body);
f5073b
+                m_notification_received = FALSE;
f5073b
+	}
f5073b
+
f5073b
 	if (m_window_title_changed) {
98e95b
                 really_changed = (g_strcmp0(m_window_title, m_window_title_changed) != 0);
f5073b
 		g_free (m_window_title);
f5073b
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
98e95b
index 4e2896cf1aaf..f288f9e0f49a 100644
f5073b
--- a/src/vte/vteterminal.h
f5073b
+++ b/src/vte/vteterminal.h
f5073b
@@ -104,8 +104,10 @@ struct _VteTerminalClass {
f5073b
 
f5073b
 	void (*bell)(VteTerminal* terminal);
f5073b
 
f5073b
+	void (*notification_received)(VteTerminal* terminal, const gchar *summary, const gchar *body);
f5073b
+
f5073b
         /* Padding for future expansion. */
f5073b
-        gpointer padding[16];
f5073b
+        gpointer padding[15];
f5073b
 
f5073b
         VteTerminalClassPrivate *priv;
f5073b
 };
f5073b
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
98e95b
index 9adeccf37b8f..7b517372fb19 100644
f5073b
--- a/src/vtegtk.cc
f5073b
+++ b/src/vtegtk.cc
98e95b
@@ -700,6 +700,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
f5073b
 	klass->child_exited = NULL;
f5073b
 	klass->encoding_changed = NULL;
f5073b
 	klass->char_size_changed = NULL;
f5073b
+	klass->notification_received = NULL;
f5073b
 	klass->window_title_changed = NULL;
f5073b
 	klass->icon_title_changed = NULL;
f5073b
 	klass->selection_changed = NULL;
98e95b
@@ -775,6 +776,26 @@ vte_terminal_class_init(VteTerminalClass *klass)
98e95b
                              G_TYPE_NONE,
f5073b
                              1, G_TYPE_INT);
f5073b
 
98e95b
+        /**
f5073b
+         * VteTerminal::notification-received:
f5073b
+         * @vteterminal: the object which received the signal
f5073b
+         * @summary: The summary
f5073b
+         * @body: (allow-none): Extra optional text
f5073b
+         *
f5073b
+         * Emitted when a process running in the terminal wants to
f5073b
+         * send a notification to the desktop environment.
f5073b
+         */
f5073b
+        signals[SIGNAL_NOTIFICATION_RECEIVED] =
f5073b
+                g_signal_new(I_("notification-received"),
f5073b
+                             G_OBJECT_CLASS_TYPE(klass),
f5073b
+                             G_SIGNAL_RUN_LAST,
f5073b
+                             G_STRUCT_OFFSET(VteTerminalClass, notification_received),
f5073b
+                             NULL,
f5073b
+                             NULL,
f5073b
+                             _vte_marshal_VOID__STRING_STRING,
f5073b
+                             G_TYPE_NONE,
f5073b
+                             2, G_TYPE_STRING, G_TYPE_STRING);
f5073b
+
98e95b
         /**
f5073b
          * VteTerminal::window-title-changed:
f5073b
          * @vteterminal: the object which received the signal
f5073b
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
98e95b
index c49754ef38ee..126d29326f11 100644
f5073b
--- a/src/vtegtk.hh
f5073b
+++ b/src/vtegtk.hh
98e95b
@@ -56,6 +56,7 @@ enum {
f5073b
         SIGNAL_TEXT_INSERTED,
f5073b
         SIGNAL_TEXT_MODIFIED,
f5073b
         SIGNAL_TEXT_SCROLLED,
f5073b
+        SIGNAL_NOTIFICATION_RECEIVED,
f5073b
         SIGNAL_WINDOW_TITLE_CHANGED,
f5073b
         LAST_SIGNAL
f5073b
 };
f5073b
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
98e95b
index 1521cd1632fb..3248bd5fcce0 100644
f5073b
--- a/src/vteinternal.hh
f5073b
+++ b/src/vteinternal.hh
98e95b
@@ -630,6 +630,11 @@ public:
f5073b
         gboolean m_cursor_moved_pending;
f5073b
         gboolean m_contents_changed_pending;
f5073b
 
f5073b
+	/* desktop notification */
f5073b
+	gboolean m_notification_received;
f5073b
+	gchar *m_notification_summary;
f5073b
+	gchar *m_notification_body;
f5073b
+
f5073b
 	/* window name changes */
f5073b
         char* m_window_title;
f5073b
         char* m_window_title_changed;
98e95b
diff --git a/src/vteseq-list.hh b/src/vteseq-list.hh
98e95b
index daba388b664e..a9ec61ed30aa 100644
98e95b
--- a/src/vteseq-list.hh
98e95b
+++ b/src/vteseq-list.hh
98e95b
@@ -124,6 +124,7 @@ SEQUENCE_HANDLER(select_character_protection)
98e95b
 SEQUENCE_HANDLER(select_locator_events)
98e95b
 SEQUENCE_HANDLER(selective_erase_in_display)
98e95b
 SEQUENCE_HANDLER(selective_erase_in_line)
98e95b
+SEQUENCE_HANDLER(send_notification)
98e95b
 SEQUENCE_HANDLER(send_primary_device_attributes)
98e95b
 SEQUENCE_HANDLER(send_secondary_device_attributes)
98e95b
 SEQUENCE_HANDLER(send_tertiary_device_attributes)
f5073b
diff --git a/src/vteseq.cc b/src/vteseq.cc
98e95b
index 99b8bb37e770..c7e22d0ff711 100644
f5073b
--- a/src/vteseq.cc
f5073b
+++ b/src/vteseq.cc
98e95b
@@ -2202,6 +2202,98 @@ VteTerminalPrivate::seq_return_terminal_id(vte::parser::Params const& params)
98e95b
 	seq_send_primary_device_attributes(params);
f5073b
 }
f5073b
 
98e95b
+void
98e95b
+VteTerminalPrivate::seq_send_notification (vte::parser::Params const& params)
f5073b
+{
f5073b
+	GValue *value;
f5073b
+	const char *end;
f5073b
+	char *option = NULL;
f5073b
+	char *str = NULL;
f5073b
+	char *p, *validated;
f5073b
+
98e95b
+	g_clear_pointer (&m_notification_summary, g_free);
98e95b
+	g_clear_pointer (&m_notification_body, g_free);
f5073b
+
98e95b
+	value = params.value_at_unchecked (0);
f5073b
+	if (value == NULL) {
f5073b
+		goto out;
f5073b
+	}
f5073b
+
f5073b
+	if (G_VALUE_HOLDS_STRING (value)) {
f5073b
+		option = g_value_dup_string (value);
f5073b
+	} else if (G_VALUE_HOLDS_POINTER (value)) {
98e95b
+		option = params.ucs4_to_utf8 ((gunichar const*)g_value_get_pointer (value));
f5073b
+	} else {
f5073b
+		goto out;
f5073b
+	}
f5073b
+
f5073b
+	if (g_strcmp0 (option, "notify") != 0) {
f5073b
+		goto out;
f5073b
+	}
f5073b
+
98e95b
+	value = params.value_at_unchecked (1);
f5073b
+	if (value == NULL) {
f5073b
+		goto out;
f5073b
+	}
f5073b
+
f5073b
+	if (G_VALUE_HOLDS_STRING (value)) {
f5073b
+		str = g_value_dup_string (value);
f5073b
+	} else if (G_VALUE_HOLDS_POINTER (value)) {
98e95b
+		str = params.ucs4_to_utf8 ((gunichar const*)g_value_get_pointer (value));
f5073b
+	} else {
f5073b
+		goto out;
f5073b
+	}
f5073b
+
f5073b
+	g_utf8_validate (str, strlen (str), &end;;
f5073b
+	validated = g_strndup (str, end - str);
f5073b
+
f5073b
+	/* No control characters allowed. */
f5073b
+	for (p = validated; *p != '\0'; p++) {
f5073b
+		if ((*p & 0x1f) == *p) {
f5073b
+			*p = ' ';
f5073b
+		}
f5073b
+	}
f5073b
+
98e95b
+	m_notification_summary = validated;
98e95b
+	validated = NULL;
f5073b
+	g_free (str);
f5073b
+
98e95b
+	m_notification_received = TRUE;
98e95b
+	if (params.size () == 2) {
f5073b
+		goto out;
f5073b
+	}
f5073b
+
98e95b
+	value = params.value_at_unchecked (2);
f5073b
+	if (value == NULL) {
f5073b
+		goto out;
f5073b
+	}
f5073b
+
f5073b
+	if (G_VALUE_HOLDS_STRING (value)) {
f5073b
+		str = g_value_dup_string (value);
f5073b
+	} else if (G_VALUE_HOLDS_POINTER (value)) {
98e95b
+		str = params.ucs4_to_utf8 ((gunichar const*)g_value_get_pointer (value));
f5073b
+	} else {
f5073b
+		goto out;
f5073b
+	}
f5073b
+
f5073b
+	g_utf8_validate (str, strlen (str), &end;;
f5073b
+	validated = g_strndup (str, end - str);
f5073b
+
f5073b
+	/* No control characters allowed. */
f5073b
+	for (p = validated; *p != '\0'; p++) {
f5073b
+		if ((*p & 0x1f) == *p) {
f5073b
+			*p = ' ';
f5073b
+		}
f5073b
+	}
f5073b
+
98e95b
+	m_notification_body = validated;
98e95b
+	validated = NULL;
f5073b
+	g_free (str);
f5073b
+
f5073b
+ out:
f5073b
+	g_free (option);
f5073b
+}
f5073b
+
f5073b
 /* Send secondary device attributes. */
98e95b
 void
98e95b
 VteTerminalPrivate::seq_send_secondary_device_attributes(vte::parser::Params const& params)
f5073b
-- 
98e95b
2.14.4
f5073b
f5073b
98e95b
From 48fe151b1fb5079c6183795416192507568dfa55 Mon Sep 17 00:00:00 2001
f5073b
From: Debarshi Ray <debarshir@gnome.org>
f5073b
Date: Thu, 29 Jan 2015 13:09:17 +0100
f5073b
Subject: [PATCH 2/5] vte.sh: Emit OSC 777 from PROMPT_COMMAND
f5073b
f5073b
https://bugzilla.gnome.org/show_bug.cgi?id=711059
f5073b
---
f5073b
 src/vte.sh | 4 +++-
f5073b
 1 file changed, 3 insertions(+), 1 deletion(-)
f5073b
f5073b
diff --git a/src/vte.sh b/src/vte.sh
f5073b
index 2d211caa2f17..1c0543bd9d26 100644
f5073b
--- a/src/vte.sh
f5073b
+++ b/src/vte.sh
f5073b
@@ -50,9 +50,11 @@ __vte_osc7 () {
f5073b
 }
f5073b
 
f5073b
 __vte_prompt_command() {
f5073b
+  local command=$(HISTTIMEFORMAT= history 1 | sed 's/^ *[0-9]\+ *//')
f5073b
+  command="${command//;/ }"
f5073b
   local pwd='~'
f5073b
   [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
f5073b
-  printf "\033]0;%s@%s:%s\007%s" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)"
f5073b
+  printf "\033]777;notify;Command completed;%s\007\033]0;%s@%s:%s\007%s" "${command}" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)"
f5073b
 }
f5073b
 
f5073b
 case "$TERM" in
f5073b
-- 
98e95b
2.14.4
f5073b
f5073b
98e95b
From 2f8fda45ab2e0df516585e9c688f9e43a155d649 Mon Sep 17 00:00:00 2001
f5073b
From: Debarshi Ray <debarshir@gnome.org>
f5073b
Date: Thu, 22 Jan 2015 16:37:10 +0100
98e95b
Subject: [PATCH 3/5] Test the notification-received signal
f5073b
f5073b
---
98e95b
 bindings/vala/app.vala |  7 +++++++
98e95b
 src/app/app.cc         | 10 ++++++++++
98e95b
 2 files changed, 17 insertions(+)
f5073b
98e95b
diff --git a/bindings/vala/app.vala b/bindings/vala/app.vala
98e95b
index 8663d63c5445..4c5d9a2b3bad 100644
98e95b
--- a/bindings/vala/app.vala
98e95b
+++ b/bindings/vala/app.vala
f5073b
@@ -309,6 +309,8 @@ class Window : Gtk.ApplicationWindow
f5073b
     if (App.Options.object_notifications)
f5073b
       terminal.notify.connect(notify_cb);
f5073b
 
f5073b
+    terminal.notification_received.connect(notification_received_cb);
f5073b
+
f5073b
     /* Settings */
f5073b
     if (App.Options.no_double_buffer)
f5073b
       terminal.set_double_buffered(false);
98e95b
@@ -780,6 +782,11 @@ class Window : Gtk.ApplicationWindow
f5073b
     set_title(terminal.get_window_title());
f5073b
   }
f5073b
 
f5073b
+  private void notification_received_cb(Vte.Terminal terminal, string summary, string? body)
f5073b
+  {
f5073b
+    print ("[%s]: %s\n", summary, body);
f5073b
+  }
f5073b
+
f5073b
 } /* class Window */
f5073b
 
f5073b
 class App : Gtk.Application
98e95b
diff --git a/src/app/app.cc b/src/app/app.cc
98e95b
index d4240640fc82..a581c60a839e 100644
98e95b
--- a/src/app/app.cc
98e95b
+++ b/src/app/app.cc
98e95b
@@ -1588,6 +1588,14 @@ window_window_title_changed_cb(VteTerminal* terminal,
98e95b
                              vte_terminal_get_window_title(window->terminal));
98e95b
 }
98e95b
 
98e95b
+static void
98e95b
+notification_received_cb(VteTerminal *terminal,
98e95b
+                         const gchar *summary,
98e95b
+                         const gchar *body)
98e95b
+{
98e95b
+        g_print("[%s]: %s\n", summary, body);
98e95b
+}
98e95b
+
98e95b
 static void
98e95b
 window_lower_window_cb(VteTerminal* terminal,
98e95b
                        VteappWindow* window)
98e95b
@@ -1815,6 +1823,8 @@ vteapp_window_constructed(GObject *object)
98e95b
         if (options.object_notifications)
98e95b
                 g_signal_connect(window->terminal, "notify", G_CALLBACK(window_notify_cb), window);
98e95b
 
98e95b
+        g_signal_connect(window->terminal, "notification-received", G_CALLBACK(notification_received_cb), NULL);
98e95b
+
98e95b
         /* Settings */
98e95b
         if (options.no_double_buffer)
98e95b
                 gtk_widget_set_double_buffered(GTK_WIDGET(window->terminal), false);
f5073b
-- 
98e95b
2.14.4
f5073b
f5073b
98e95b
From 0b3c8a36b209086de49bc57a58648bea64b3c532 Mon Sep 17 00:00:00 2001
f5073b
From: Debarshi Ray <debarshir@gnome.org>
f5073b
Date: Fri, 13 May 2016 17:53:54 +0200
f5073b
Subject: [PATCH 4/5] Add a property to configure the scroll speed
f5073b
f5073b
By default, it is set to zero which gives the current behaviour of
f5073b
moving the buffer by a function of the number of visible rows.
f5073b
f5073b
https://bugzilla.redhat.com/show_bug.cgi?id=1103380
f5073b
---
f5073b
 doc/reference/vte-sections.txt |  1 +
f5073b
 src/vte.cc                     | 19 +++++++++++++++++-
f5073b
 src/vte/vteterminal.h          |  4 ++++
f5073b
 src/vtegtk.cc                  | 45 ++++++++++++++++++++++++++++++++++++++++++
f5073b
 src/vtegtk.hh                  |  1 +
f5073b
 src/vteinternal.hh             |  2 ++
f5073b
 6 files changed, 71 insertions(+), 1 deletion(-)
f5073b
f5073b
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
98e95b
index 6e37f0bad223..025986ee2146 100644
f5073b
--- a/doc/reference/vte-sections.txt
f5073b
+++ b/doc/reference/vte-sections.txt
98e95b
@@ -55,6 +55,7 @@ vte_terminal_get_cursor_blink_mode
f5073b
 vte_terminal_set_cursor_blink_mode
98e95b
 vte_terminal_get_text_blink_mode
98e95b
 vte_terminal_set_text_blink_mode
f5073b
+vte_terminal_set_scroll_speed
f5073b
 vte_terminal_set_scrollback_lines
98e95b
 vte_terminal_get_scrollback_lines
f5073b
 vte_terminal_set_font
f5073b
diff --git a/src/vte.cc b/src/vte.cc
98e95b
index fd461935490a..abb0abec9d23 100644
f5073b
--- a/src/vte.cc
f5073b
+++ b/src/vte.cc
98e95b
@@ -10132,6 +10132,7 @@ void
f5073b
 VteTerminalPrivate::widget_scroll(GdkEventScroll *event)
f5073b
 {
f5073b
 	gdouble delta_x, delta_y;
f5073b
+	gdouble scroll_speed;
f5073b
 	gdouble v;
f5073b
 	gint cnt, i;
f5073b
 	int button;
98e95b
@@ -10185,7 +10186,13 @@ VteTerminalPrivate::widget_scroll(GdkEventScroll *event)
f5073b
 		return;
f5073b
 	}
f5073b
 
f5073b
-	v = MAX (1., ceil (gtk_adjustment_get_page_increment (m_vadjustment) / 10.));
f5073b
+	if (m_scroll_speed == 0) {
f5073b
+		scroll_speed = ceil (gtk_adjustment_get_page_increment (m_vadjustment) / 10.);
f5073b
+	} else {
f5073b
+		scroll_speed = m_scroll_speed;
f5073b
+	}
f5073b
+
f5073b
+	v = MAX (1., scroll_speed);
f5073b
 	_vte_debug_print(VTE_DEBUG_EVENTS,
f5073b
 			"Scroll speed is %d lines per non-smooth scroll unit\n",
f5073b
 			(int) v);
98e95b
@@ -10446,6 +10453,16 @@ VteTerminalPrivate::decscusr_cursor_shape()
98e95b
         }
f5073b
 }
f5073b
 
98e95b
+bool
f5073b
+VteTerminalPrivate::set_scroll_speed(unsigned int scroll_speed)
f5073b
+{
f5073b
+        if (scroll_speed == m_scroll_speed)
f5073b
+                return false;
f5073b
+
f5073b
+        m_scroll_speed = scroll_speed;
f5073b
+        return true;
f5073b
+}
f5073b
+
98e95b
 bool
f5073b
 VteTerminalPrivate::set_scrollback_lines(long lines)
f5073b
 {
f5073b
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
98e95b
index f288f9e0f49a..7d09c761aded 100644
f5073b
--- a/src/vte/vteterminal.h
f5073b
+++ b/src/vte/vteterminal.h
98e95b
@@ -296,6 +296,10 @@ void vte_terminal_set_cursor_shape(VteTerminal *terminal,
f5073b
 _VTE_PUBLIC
f5073b
 VteCursorShape vte_terminal_get_cursor_shape(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
f5073b
 
f5073b
+_VTE_PUBLIC
f5073b
+void vte_terminal_set_scroll_speed(VteTerminal *terminal,
f5073b
+                                   guint scroll_speed) _VTE_GNUC_NONNULL(1);
f5073b
+
f5073b
 /* Set the number of scrollback lines, above or at an internal minimum. */
f5073b
 _VTE_PUBLIC
f5073b
 void vte_terminal_set_scrollback_lines(VteTerminal *terminal,
f5073b
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
98e95b
index 7b517372fb19..838d54a152ae 100644
f5073b
--- a/src/vtegtk.cc
f5073b
+++ b/src/vtegtk.cc
98e95b
@@ -483,6 +483,9 @@ vte_terminal_get_property (GObject *object,
f5073b
                 case PROP_REWRAP_ON_RESIZE:
f5073b
                         g_value_set_boolean (value, vte_terminal_get_rewrap_on_resize (terminal));
f5073b
                         break;
f5073b
+                case PROP_SCROLL_SPEED:
f5073b
+                        g_value_set_uint (value, impl->m_scroll_speed);
f5073b
+                        break;
f5073b
                 case PROP_SCROLLBACK_LINES:
98e95b
                         g_value_set_uint (value, vte_terminal_get_scrollback_lines(terminal));
f5073b
                         break;
98e95b
@@ -584,6 +587,9 @@ vte_terminal_set_property (GObject *object,
f5073b
                 case PROP_REWRAP_ON_RESIZE:
f5073b
                         vte_terminal_set_rewrap_on_resize (terminal, g_value_get_boolean (value));
f5073b
                         break;
f5073b
+                case PROP_SCROLL_SPEED:
f5073b
+                        vte_terminal_set_scroll_speed (terminal, g_value_get_uint (value));
f5073b
+                        break;
f5073b
                 case PROP_SCROLLBACK_LINES:
f5073b
                         vte_terminal_set_scrollback_lines (terminal, g_value_get_uint (value));
f5073b
                         break;
98e95b
@@ -1531,6 +1537,21 @@ vte_terminal_class_init(VteTerminalClass *klass)
98e95b
                                       TRUE,
f5073b
                                       (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
f5073b
 
98e95b
+        /**
f5073b
+         * VteTerminal:scroll-speed:
f5073b
+         *
f5073b
+         * The number of lines by which the buffer is moved when
f5073b
+         * scrolling with a mouse wheel on top of the terminal
f5073b
+         * Setting it to zero will cause the buffer to be moved by an
f5073b
+         * amount depending on the number of visible rows the widget
f5073b
+         * can display.
f5073b
+         */
f5073b
+        pspecs[PROP_SCROLL_SPEED] =
f5073b
+                g_param_spec_uint ("scroll-speed", NULL, NULL,
f5073b
+                                   0, G_MAXUINT,
f5073b
+                                   0,
f5073b
+                                   (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
f5073b
+
98e95b
         /**
f5073b
          * VteTerminal:scrollback-lines:
f5073b
          *
98e95b
@@ -4058,6 +4079,30 @@ vte_terminal_get_row_count(VteTerminal *terminal)
98e95b
 	return IMPL(terminal)->m_row_count;
f5073b
 }
f5073b
 
98e95b
+/**
f5073b
+ * vte_terminal_set_scroll_speed:
f5073b
+ * @terminal: a #VteTerminal
f5073b
+ * @scroll_speed: move the buffer by this number of lines while scrolling
f5073b
+ *
f5073b
+ * Sets the number of lines by which the buffer is moved when
f5073b
+ * scrolling with a mouse wheel. Setting it to zero will cause the
f5073b
+ * buffer to be moved by an amount depending on the number of visible
f5073b
+ * rows the widget can display.
f5073b
+ */
f5073b
+void
f5073b
+vte_terminal_set_scroll_speed(VteTerminal *terminal, guint scroll_speed)
f5073b
+{
f5073b
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
f5073b
+
f5073b
+        GObject *object = G_OBJECT(terminal);
f5073b
+        g_object_freeze_notify(object);
f5073b
+
f5073b
+        if (IMPL(terminal)->set_scroll_speed(scroll_speed))
f5073b
+                g_object_notify_by_pspec(object, pspecs[PROP_SCROLL_SPEED]);
f5073b
+
f5073b
+        g_object_thaw_notify(object);
f5073b
+}
f5073b
+
98e95b
 /**
f5073b
  * vte_terminal_set_scrollback_lines:
f5073b
  * @terminal: a #VteTerminal
f5073b
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
98e95b
index 126d29326f11..b2c9edfa8246 100644
f5073b
--- a/src/vtegtk.hh
f5073b
+++ b/src/vtegtk.hh
98e95b
@@ -86,6 +86,7 @@ enum {
f5073b
         PROP_MOUSE_POINTER_AUTOHIDE,
f5073b
         PROP_PTY,
f5073b
         PROP_REWRAP_ON_RESIZE,
f5073b
+        PROP_SCROLL_SPEED,
f5073b
         PROP_SCROLLBACK_LINES,
f5073b
         PROP_SCROLL_ON_KEYSTROKE,
f5073b
         PROP_SCROLL_ON_OUTPUT,
f5073b
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
98e95b
index 3248bd5fcce0..0cb6eb673f75 100644
f5073b
--- a/src/vteinternal.hh
f5073b
+++ b/src/vteinternal.hh
98e95b
@@ -498,6 +498,7 @@ public:
f5073b
         gboolean m_scroll_on_output;
f5073b
         gboolean m_scroll_on_keystroke;
f5073b
         gboolean m_alternate_screen_scroll;
f5073b
+        guint m_scroll_speed;
f5073b
         vte::grid::row_t m_scrollback_lines;
f5073b
 
f5073b
         /* Restricted scrolling */
98e95b
@@ -1260,6 +1261,7 @@ public:
f5073b
         bool set_mouse_autohide(bool autohide);
f5073b
         bool set_pty(VtePty *pty);
f5073b
         bool set_rewrap_on_resize(bool rewrap);
f5073b
+        bool set_scroll_speed(unsigned int scroll_speed);
f5073b
         bool set_scrollback_lines(long lines);
f5073b
         bool set_scroll_on_keystroke(bool scroll);
f5073b
         bool set_scroll_on_output(bool scroll);
f5073b
-- 
98e95b
2.14.4
f5073b
f5073b
98e95b
From ecc4e3c732f8683202afeb0369e8526193766560 Mon Sep 17 00:00:00 2001
f5073b
From: Debarshi Ray <debarshir@gnome.org>
f5073b
Date: Fri, 13 May 2016 17:54:57 +0200
98e95b
Subject: [PATCH 5/5] Test the scroll-speed property
f5073b
f5073b
https://bugzilla.redhat.com/show_bug.cgi?id=1103380
f5073b
---
98e95b
 bindings/vala/app.vala | 4 ++++
98e95b
 src/app/app.cc         | 4 ++++
98e95b
 2 files changed, 8 insertions(+)
f5073b
98e95b
diff --git a/bindings/vala/app.vala b/bindings/vala/app.vala
98e95b
index 4c5d9a2b3bad..3b7310679239 100644
98e95b
--- a/bindings/vala/app.vala
98e95b
+++ b/bindings/vala/app.vala
98e95b
@@ -335,6 +335,7 @@ class Window : Gtk.ApplicationWindow
f5073b
     terminal.set_rewrap_on_resize(!App.Options.no_rewrap);
f5073b
     terminal.set_scroll_on_output(false);
f5073b
     terminal.set_scroll_on_keystroke(true);
f5073b
+    terminal.set_scroll_speed(App.Options.scroll_speed);
f5073b
     terminal.set_scrollback_lines(App.Options.scrollback_lines);
f5073b
 
f5073b
     /* Style */
98e95b
@@ -856,6 +857,7 @@ class App : Gtk.Application
f5073b
     public static bool object_notifications = false;
f5073b
     public static string? output_filename = null;
f5073b
     public static bool reverse = false;
f5073b
+    public static uint scroll_speed = 0;
f5073b
     public static int scrollback_lines = 512;
f5073b
     public static int transparency_percent = 0;
f5073b
     public static bool version = false;
98e95b
@@ -1049,6 +1051,8 @@ class App : Gtk.Application
f5073b
         "Save terminal contents to file at exit", null },
f5073b
       { "reverse", 0, 0, OptionArg.NONE, ref reverse,
f5073b
         "Reverse foreground/background colors", null },
f5073b
+      { "scroll-speed", 0, 0, OptionArg.INT, ref scroll_speed,
f5073b
+        "Specify the scroll speed", null },
f5073b
       { "scrollback-lines", 'n', 0, OptionArg.INT, ref scrollback_lines,
f5073b
         "Specify the number of scrollback-lines", null },
f5073b
       { "transparent", 'T', 0, OptionArg.INT, ref transparency_percent,
98e95b
diff --git a/src/app/app.cc b/src/app/app.cc
98e95b
index a581c60a839e..3faa2d76dd10 100644
98e95b
--- a/src/app/app.cc
98e95b
+++ b/src/app/app.cc
98e95b
@@ -91,6 +91,7 @@ public:
98e95b
         int verbosity{0};
98e95b
         double cell_height_scale{1.0};
98e95b
         double cell_width_scale{1.0};
98e95b
+        unsigned int scroll_speed{0};
98e95b
         VteCursorBlinkMode cursor_blink_mode{VTE_CURSOR_BLINK_SYSTEM};
98e95b
         VteCursorShape cursor_shape{VTE_CURSOR_SHAPE_BLOCK};
98e95b
         VteTextBlinkMode text_blink_mode{VTE_TEXT_BLINK_ALWAYS};
98e95b
@@ -401,6 +402,8 @@ public:
98e95b
                           "Save terminal contents to file at exit", nullptr },
98e95b
                         { "reverse", 0, 0, G_OPTION_ARG_NONE, &reverse,
98e95b
                           "Reverse foreground/background colors", nullptr },
98e95b
+                        { "scroll-speed", 0, 0, G_OPTION_ARG_INT, &scroll_speed,
98e95b
+                          "Specify the scroll speed", nullptr },
98e95b
                         { "scrollback-lines", 'n', 0, G_OPTION_ARG_INT, &scrollback_lines,
98e95b
                           "Specify the number of scrollback-lines (-1 for infinite)", nullptr },
98e95b
                         { "transparent", 'T', 0, G_OPTION_ARG_INT, &transparency_percent,
98e95b
@@ -1853,6 +1856,7 @@ vteapp_window_constructed(GObject *object)
98e95b
         vte_terminal_set_rewrap_on_resize(window->terminal, !options.no_rewrap);
98e95b
         vte_terminal_set_scroll_on_output(window->terminal, false);
98e95b
         vte_terminal_set_scroll_on_keystroke(window->terminal, true);
98e95b
+        vte_terminal_set_scroll_speed(window->terminal, options.scroll_speed);
98e95b
         vte_terminal_set_scrollback_lines(window->terminal, options.scrollback_lines);
98e95b
         vte_terminal_set_text_blink_mode(window->terminal, options.text_blink_mode);
98e95b
 
f5073b
-- 
98e95b
2.14.4
f5073b