[vte] widget: Limit bell rate
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] widget: Limit bell rate
- Date: Sat, 3 Mar 2018 17:35:10 +0000 (UTC)
commit 5c94130ec7a8f9bb5eb38db7c7fe384c9699a199
Author: Christian Persch <chpe src gnome org>
Date: Sat Mar 3 18:32:44 2018 +0100
widget: Limit bell rate
Also move the gdk_display_beep() and the signal emission out
of the processing loop and just queue it.
https://bugzilla.gnome.org/show_bug.cgi?id=790815
src/vte.cc | 12 ++++++++++++
src/vtedefines.hh | 3 +++
src/vteinternal.hh | 4 ++++
src/vteseq.cc | 3 +--
4 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index cfa8a19..57aa197 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -10648,6 +10648,8 @@ VteTerminalPrivate::reset(bool clear_tabstops,
GObject *object = G_OBJECT(m_terminal);
g_object_freeze_notify(object);
+ m_bell_pending = false;
+
/* Clear the output buffer. */
_vte_byte_array_clear(m_outgoing);
/* Reset charset substitution state. */
@@ -11078,6 +11080,16 @@ VteTerminalPrivate::emit_pending_signals()
g_signal_emit(m_terminal, signals[SIGNAL_CONTENTS_CHANGED], 0);
m_contents_changed_pending = false;
}
+ if (m_bell_pending) {
+ auto const timestamp = g_get_monotonic_time();
+ if ((timestamp - m_bell_timestamp) >= VTE_BELL_MINIMUM_TIME_DIFFERENCE) {
+ beep();
+ emit_bell();
+ }
+
+ m_bell_timestamp = timestamp;
+ m_bell_pending = false;
+ }
g_object_thaw_notify(object);
}
diff --git a/src/vtedefines.hh b/src/vtedefines.hh
index 115081b..e8ffb62 100644
--- a/src/vtedefines.hh
+++ b/src/vtedefines.hh
@@ -109,6 +109,9 @@
#define VTE_CELL_SCALE_MIN (1.)
#define VTE_CELL_SCALE_MAX (2.)
+/* Minimum time between two beeps (µs) */
+#define VTE_BELL_MINIMUM_TIME_DIFFERENCE (100000)
+
/* Maximum length of a URI in the OSC 8 escape sequences. There's no de jure limit,
* 2000-ish the de facto standard, and Internet Explorer supports 2083.
* See also the comment of VTE_HYPERLINK_TOTAL_LENGTH_MAX. */
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index fe63e76..ba8bd10 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -648,6 +648,10 @@ public:
/* Background */
double m_background_alpha;
+ /* Bell */
+ int64_t m_bell_timestamp;
+ bool m_bell_pending{false};
+
/* Key modifiers. */
guint m_modifiers;
diff --git a/src/vteseq.cc b/src/vteseq.cc
index fd3227f..4da48c4 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -927,8 +927,7 @@ VteTerminalPrivate::seq_shift_out(vte::parser::Params const& params)
void
VteTerminalPrivate::seq_bell(vte::parser::Params const& params)
{
- beep();
- emit_bell();
+ m_bell_pending = true;
}
/* Backtab. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]