Andre Poenitz wrote:
>> +    ///
>> +    QTimer& delayed_scrollbar_sync;
> 
> A _reference_? Why?
> 
> Andre'
> 

Here a updated patch.


-- 
Peter Kümmel
Index: src/frontends/qt4/GuiWorkArea.cpp
===================================================================
--- src/frontends/qt4/GuiWorkArea.cpp   (revision 18398)
+++ src/frontends/qt4/GuiWorkArea.cpp   (working copy)
@@ -190,8 +190,23 @@
 
        // Initialize the vertical Scroll Bar
        QObject::connect(verticalScrollBar(), SIGNAL(actionTriggered(int)),
-               this, SLOT(adjustViewWithScrollBar(int)));
+               this, SLOT(verticalScrollBarActionTriggered(int)));
+       QObject::connect(verticalScrollBar(), SIGNAL(sliderReleased()),
+               this, SLOT(verticalScrollBarSliderReleased()));
 
+       // We circumvent the event queue for scrolling events.
+       // This avoids scrolling after the user has stopped 
+       // scrolling, but scrolling proceeds because the 
+       // event queue is full of scroll events.
+       // We trigger the scrolling by a timer which we 
+       // could stop at any time (we can't clean the 
+       // event queue from scrolling events)
+       delayed_scrollbar_sync.setInterval(100);
+       delayed_scrollbar_sync.setSingleShot(true);
+       QObject::connect(&delayed_scrollbar_sync, SIGNAL(timeout()),
+               this, SLOT(adjustViewWithScrollBar()));
+
+
        // disable context menu for the scrollbar
        verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
 
@@ -237,6 +252,28 @@
 }
 
 
+void GuiWorkArea::verticalScrollBarActionTriggered(int)
+{
+       if (!QCoreApplication::hasPendingEvents()) {
+               // scroll immediately
+               delayed_scrollbar_sync.stop();
+               adjustViewWithScrollBar();
+       } else {
+               // multiple scroll events are merged into one
+               if (!delayed_scrollbar_sync.isActive()) {
+                       delayed_scrollbar_sync.start();
+               }
+       }
+}
+
+void GuiWorkArea::verticalScrollBarSliderReleased()
+{
+       delayed_scrollbar_sync.stop();
+       // finally adjust the scrollbar
+       adjustViewWithScrollBar();
+}
+
+
 void GuiWorkArea::dragEnterEvent(QDragEnterEvent * event)
 {
        if (event->mimeData()->hasUrls())
Index: src/frontends/qt4/GuiWorkArea.h
===================================================================
--- src/frontends/qt4/GuiWorkArea.h     (revision 18398)
+++ src/frontends/qt4/GuiWorkArea.h     (working copy)
@@ -156,6 +156,12 @@
        /// timer to limit triple clicks
        void doubleClickTimeout();
 
+private Q_SLOTS:
+       /// process vertical scroll bar event
+       void verticalScrollBarActionTriggered(int action);
+       ///
+       void verticalScrollBarSliderReleased();
+
 private:
        /// The slot connected to SyntheticMouseEvent::timeout.
        void generateSyntheticMouseEvent();
@@ -177,6 +183,8 @@
        bool schedule_redraw_;
        ///
        int preedit_lines_;
+       ///
+       QTimer delayed_scrollbar_sync;
 };
 
 } // namespace frontend

Reply via email to