Bug 90278 - Bell can be over used
Summary: Bell can be over used
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-26 18:41 UTC by Andre Masella
Modified: 2006-08-08 05:22 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Masella 2004-09-26 18:41:45 UTC
Version:            (using KDE KDE 3.3.0)
Installed from:    Compiled From Sources

If you are in a Konsole window and do something which will ring the bell a lot (like holding down backspace in sh or cat'ing a binary file), Konsole will ring the bell for every single \a received. When using aRts, since it's non-blocking, the sounds begin to overlap and become really loud. aRts uses a fair chunk of CPU mixing them and will continue to ring after the problem is over.

In puTTY, there is an option where you can ignore the bell for a customisable number of seconds. It would be nice to have a similar feature to not ring the bell when it is being over-used.

I was able to get the bell to not ring, but I don't know how to add the configuration, so I hard coded the value at 2 second. I also don't know if it's okay to include sys/types.h and time.h.

Index: TEWidget.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/TEWidget.cpp,v
retrieving revision 1.216
diff -u -3 -p -r1.216 TEWidget.cpp
--- TEWidget.cpp        1 Jun 2004 12:31:20 -0000       1.216
+++ TEWidget.cpp        26 Sep 2004 16:38:50 -0000
@@ -410,6 +410,10 @@ TEWidget::TEWidget(QWidget *parent, cons
     // Looks better at startup with KRootPixmap based pseudo-transparancy
     setBackgroundMode(NoBackground);
   }
+
+  // Bell over use
+  (void) time(&lastBell);
+
 }

 //FIXME: make proper destructor
@@ -1832,6 +1836,12 @@ void TEWidget::setBellMode(int mode)

 void TEWidget::Bell(bool visibleSession, QString message)
 {
+  time_t currentTime;
+  (void) time(&currentTime);
+  if ((int) currentTime-lastBell < 2) { return; }
+
+  lastBell = currentTime;
+
   if (m_bellMode==BELLSYSTEM) {
     KNotifyClient::beep();
   } else if (m_bellMode==BELLNOTIFY) {
Index: TEWidget.h
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/TEWidget.h,v
retrieving revision 1.83
diff -u -3 -p -r1.83 TEWidget.h
--- TEWidget.h  9 Apr 2004 18:34:37 -0000       1.83
+++ TEWidget.h  26 Sep 2004 16:38:50 -0000
@@ -21,6 +21,9 @@

 #include <kpopupmenu.h>

+#include <sys/types.h>
+#include <time.h>
+
 #include "TECommon.h"


@@ -282,6 +285,7 @@ private:

     QPoint configureRequestPoint;  // remember right mouse button click position
     bool colorsSwapped; // true during visual bell
+    time_t lastBell; // time the bell was last rung

     // the rim should normally be 1, 0 only when running in full screen mode.
     int rimX;      // left/right rim width
Comment 1 Robert Knight 2006-08-08 05:22:55 UTC
All 'bell' events are rate limited in Konsole for KDE 4 - this should solve the problem.