[vte/vte-0-50-ntfy-scroll: 4/5] Add a property to configure the scroll speed
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-0-50-ntfy-scroll: 4/5] Add a property to configure the scroll speed
- Date: Thu, 5 Oct 2017 12:43:01 +0000 (UTC)
commit 2b3284d6f7c24f5ef58eb31e96d2d6f8e208f5f8
Author: Debarshi Ray <debarshir gnome org>
Date: Fri May 13 17:53:54 2016 +0200
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
doc/reference/vte-sections.txt | 1 +
src/vte.cc | 19 ++++++++++++++++-
src/vte/vteterminal.h | 4 +++
src/vtegtk.cc | 45 ++++++++++++++++++++++++++++++++++++++++
src/vtegtk.hh | 1 +
src/vteinternal.hh | 2 +
6 files changed, 71 insertions(+), 1 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index 9b34536..b67f395 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -44,6 +44,7 @@ vte_terminal_set_cursor_shape
vte_terminal_get_cursor_shape
vte_terminal_get_cursor_blink_mode
vte_terminal_set_cursor_blink_mode
+vte_terminal_set_scroll_speed
vte_terminal_set_scrollback_lines
vte_terminal_set_font
vte_terminal_get_font
diff --git a/src/vte.cc b/src/vte.cc
index f3b8664..c1b1e50 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -9899,6 +9899,7 @@ void
VteTerminalPrivate::widget_scroll(GdkEventScroll *event)
{
gdouble delta_x, delta_y;
+ gdouble scroll_speed;
gdouble v;
gint cnt, i;
int button;
@@ -9952,7 +9953,13 @@ VteTerminalPrivate::widget_scroll(GdkEventScroll *event)
return;
}
- v = MAX (1., ceil (gtk_adjustment_get_page_increment (m_vadjustment) / 10.));
+ if (m_scroll_speed == 0) {
+ scroll_speed = ceil (gtk_adjustment_get_page_increment (m_vadjustment) / 10.);
+ } else {
+ scroll_speed = m_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);
@@ -10190,6 +10197,16 @@ VteTerminalPrivate::decscusr_cursor_shape()
}
bool
+VteTerminalPrivate::set_scroll_speed(unsigned int scroll_speed)
+{
+ if (scroll_speed == m_scroll_speed)
+ return false;
+
+ m_scroll_speed = scroll_speed;
+ return true;
+}
+
+bool
VteTerminalPrivate::set_scrollback_lines(long lines)
{
glong low, high, next;
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
index b3c6978..befde68 100644
--- a/src/vte/vteterminal.h
+++ b/src/vte/vteterminal.h
@@ -275,6 +275,10 @@ void vte_terminal_set_cursor_shape(VteTerminal *terminal,
_VTE_PUBLIC
VteCursorShape vte_terminal_get_cursor_shape(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
+_VTE_PUBLIC
+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. */
_VTE_PUBLIC
void vte_terminal_set_scrollback_lines(VteTerminal *terminal,
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 4ccc4ff..2b98eb8 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -481,6 +481,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, impl->m_scroll_speed);
+ break;
case PROP_SCROLLBACK_LINES:
g_value_set_uint (value, impl->m_scrollback_lines);
break;
@@ -570,6 +573,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;
@@ -1467,6 +1473,21 @@ vte_terminal_class_init(VteTerminalClass *klass)
(GParamFlags) (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.
+ */
+ pspecs[PROP_SCROLL_SPEED] =
+ g_param_spec_uint ("scroll-speed", NULL, NULL,
+ 0, G_MAXUINT,
+ 0,
+ (GParamFlags) (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
@@ -3810,6 +3831,30 @@ vte_terminal_get_row_count(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)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+ GObject *object = G_OBJECT(terminal);
+ g_object_freeze_notify(object);
+
+ if (IMPL(terminal)->set_scroll_speed(scroll_speed))
+ g_object_notify_by_pspec(object, pspecs[PROP_SCROLL_SPEED]);
+
+ g_object_thaw_notify(object);
+}
+
+/**
* vte_terminal_set_scrollback_lines:
* @terminal: a #VteTerminal
* @lines: the length of the history buffer
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
index 07c714e..5a6c938 100644
--- a/src/vtegtk.hh
+++ b/src/vtegtk.hh
@@ -83,6 +83,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,
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index f7faa7a..137987a 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -385,6 +385,7 @@ public:
gboolean m_scroll_on_output;
gboolean m_scroll_on_keystroke;
gboolean m_alternate_screen_scroll;
+ guint m_scroll_speed;
vte::grid::row_t m_scrollback_lines;
/* Restricted scrolling */
@@ -1112,6 +1113,7 @@ public:
bool set_mouse_autohide(bool autohide);
bool set_pty(VtePty *pty);
bool set_rewrap_on_resize(bool rewrap);
+ bool set_scroll_speed(unsigned int scroll_speed);
bool set_scrollback_lines(long lines);
bool set_scroll_on_keystroke(bool scroll);
bool set_scroll_on_output(bool scroll);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]