Konsole scrolling

Waldo Bastian kde-optimize@mail.kde.org
Fri, 21 Feb 2003 17:23:33 +0100


--Boundary-00=_FKlV+HXH4inUsuu
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Friday 21 February 2003 16:49, Karl Vogel wrote:
> On 21 Feb 2003, you wrote in kde.kde-optimize:
> > Hmm, isn't a scrollbar change signal emitted whenever the scrollbar
> > changes? Why not queue the changes, so that only after X
> > cycles/milliseconds/interval it repaints.  This way, you either move
> > the scrollbar slowly, or you move it to appr. where you want it, and
> > fine-tune when you're sure. This should ease CPU a little, as repaints
> > wouldn't be at every move.  Or is this what your patch does Waldo?
> > (Haven't looked at it, or much of the KDE source at all to tell you
> > the truth).
> >
> > -Justin
>
> Well I just tried the patch Waldo made, on this KDE 3.1 system with the
> LTSP Client and it does indeed also help here.
>
> Would this patch be something for 3.2 or is it safe enough for inclusion in
> 3.1.1?!

I would like to hear Stephan Binner's opinion about the patch first. If he 
thinks it's ok it can go in for both 3.2 and 3.1.1 IMO.

(Attached once more for Stephan's convenience :)

Cheers,
Waldo
-- 
bastian@kde.org -=|[ SuSE, The Linux Desktop Experts ]|=- bastian@suse.com

--Boundary-00=_FKlV+HXH4inUsuu
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="konsole_scroll.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="konsole_scroll.diff"

Index: TEmulation.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/TEmulation.cpp,v
retrieving revision 1.48
diff -u -r1.48 TEmulation.cpp
--- TEmulation.cpp	5 Jan 2003 20:01:06 -0000	1.48
+++ TEmulation.cpp	20 Feb 2003 14:37:01 -0000
@@ -49,15 +49,11 @@
    As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger
    refresh. This rule suits both bulk display operation as done by curses as
    well as individual characters typed.
-   (BULK_TIMEOUT < 1000 / max characters received from keyboard per second).
 
-   Additionally, we trigger refreshing by newlines comming in to make visual
-   snapshots of lists as produced by `cat', `ls' and likely programs, thereby
-   producing the illusion of a permanent and immediate display operation.
-
-   As a sort of catch-all needed for cases where none of the above
-   conditions catch, the screen refresh is also triggered by a count
-   of incoming bulks (`bulk_incnt').
+   We start also a second time which is never restarted. If repeatedly
+   restarting of the first timer could delay continous output indefinitly,
+   the second timer guarantees that the output is refreshed with at least
+   a fixed rate.
 */
 
 /* FIXME
@@ -101,8 +97,6 @@
   codec(0),
   decoder(0),
   keytrans(0),
-  bulk_nlcnt(0),
-  bulk_incnt(0),
   m_findPos(-1)
 {
 
@@ -110,7 +104,8 @@
   screen[1] = new TEScreen(gui->Lines(),gui->Columns());
   scr = screen[0];
 
-  QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) );
+  QObject::connect(&bulk_timer1, SIGNAL(timeout()), this, SLOT(showBulk()) );
+  QObject::connect(&bulk_timer2, SIGNAL(timeout()), this, SLOT(showBulk()) );
   connectGUI();
   setKeymap(0); // Default keymap
 }
@@ -179,7 +174,6 @@
   delete screen[0];
   delete screen[1];
   delete decoder;
-  bulk_timer.stop();
 }
 
 /*! change between primary and alternate screen
@@ -306,7 +300,6 @@
   emit notifySessionState(NOTIFYACTIVITY);
 
   bulkStart();
-  bulk_incnt += 1;
   for (int i = 0; i < len; i++)
   {
     QString result = decoder->toUnicode(&s[i],1);
@@ -423,7 +416,8 @@
 
 // Refreshing -------------------------------------------------------------- --
 
-#define BULK_TIMEOUT 10
+#define BULK_TIMEOUT1 10
+#define BULK_TIMEOUT2 50
 
 /*!
    called when \n comes in. Evtl. triggers showBulk at endBulk
@@ -431,8 +425,6 @@
 
 void TEmulation::bulkNewline()
 {
-  bulk_nlcnt += 1;
-  bulk_incnt = 0;  // reset bulk counter since `nl' rule applies
 }
 
 /*!
@@ -440,8 +432,9 @@
 
 void TEmulation::showBulk()
 {
-  bulk_nlcnt = 0;                       // reset bulk newline counter
-  bulk_incnt = 0;                       // reset bulk counter
+  bulk_timer1.stop();
+  bulk_timer2.stop();
+
   if (connected)
   {
     ca* image = scr->getCookedImage();    // get the image
@@ -460,15 +453,13 @@
 
 void TEmulation::bulkStart()
 {
-  if (bulk_timer.isActive()) bulk_timer.stop();
+   bulk_timer1.start(BULK_TIMEOUT1,true);
+   if (!bulk_timer2.isActive())
+      bulk_timer2.start(BULK_TIMEOUT2, true);
 }
 
 void TEmulation::bulkEnd()
 {
-  if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 )
-    showBulk();                         // resets bulk_??cnt to 0, too.
-  else
-    bulk_timer.start(BULK_TIMEOUT,true);
 }
 
 void TEmulation::setConnect(bool c)
@@ -512,7 +503,8 @@
 {
   if (!connected) return;
   scr->setHistCursor(cursor);
-  showBulk();
+
+  bulkStart();
 }
 
 void TEmulation::setColumns(int columns)
Index: TEmulation.h
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/TEmulation.h,v
retrieving revision 1.28
diff -u -r1.28 TEmulation.h
--- TEmulation.h	28 Nov 2002 15:35:28 -0000	1.28
+++ TEmulation.h	20 Feb 2003 14:37:01 -0000
@@ -122,9 +122,8 @@
 
 private:
 
-  QTimer bulk_timer;
-  int    bulk_nlcnt;   // bulk newline counter
-  int    bulk_incnt;   // bulk counter
+  QTimer bulk_timer1;
+  QTimer bulk_timer2;
   
   int    m_findPos;
 };

--Boundary-00=_FKlV+HXH4inUsuu--