Angus Leeming <[EMAIL PROTECTED]> writes:

| Lars Gullik Bjønnes wrote:
>> Comments bitte please por favor.
>
| It's a very small patch...

That is the nice thing about it...

Index: QContentPane.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.C,v
retrieving revision 1.32
diff -u -p -B -b -w -r1.32 QContentPane.C
--- QContentPane.C	1 Aug 2004 21:24:03 -0000	1.32
+++ QContentPane.C	12 May 2005 18:52:48 -0000
@@ -23,6 +23,8 @@
 
 #include <boost/bind.hpp>
 
+#include <queue>
+
 namespace {
 
 /// return the LyX key state from Qt's
@@ -73,6 +75,9 @@ mouse_button::state q_motion_state(Qt::B
 	return b;
 }
 
+QTimer * step_timer;
+std::queue<QKeyEvent> keyeventQueue;
+
 } // namespace anon
 
 
@@ -90,6 +95,11 @@ QContentPane::QContentPane(QWorkArea * p
 		boost::bind(&QContentPane::generateSyntheticMouseEvent,
 			    this));
 
+        step_timer = new QTimer(this);
+        connect(step_timer, SIGNAL(timeout()), SLOT(keyeventTimeout()));
+        // Start the timer, one-shot.
+        step_timer->start(25, true);
+        
 	setFocusPolicy(QWidget::WheelFocus);
 	setFocus();
 	setCursor(ibeamCursor);
@@ -216,9 +226,35 @@ void QContentPane::wheelEvent(QWheelEven
 
 void QContentPane::keyPressEvent(QKeyEvent * e)
 {
+        keyeventQueue.push(QKeyEvent(*e));
+}
+
+
+void QContentPane::keyeventTimeout()
+{
+        bool handle_autos = true;
+        
+        while (!keyeventQueue.empty()) {
+                QKeyEvent & ev = keyeventQueue.front();
+
+                // We never handle more than one auto repeated
+                // char in a list of queued up events.
+                if (!handle_autos && ev.isAutoRepeat()) {
+                        keyeventQueue.pop();
+                        continue;
+                }
+                
 	boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
-	sym->set(e);
-	wa_->workAreaKeyPress(sym, q_key_state(e->state()));
+                sym->set(&ev);
+                
+                wa_->workAreaKeyPress(sym, q_key_state(ev.state()));
+                keyeventQueue.pop();
+
+                handle_autos = false;
+        }
+
+        // Restart the timer.
+        step_timer->start(25, true);
 }
 
 
Index: QContentPane.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.h,v
retrieving revision 1.14
diff -u -p -B -b -w -r1.14 QContentPane.h
--- QContentPane.h	19 Jan 2005 15:03:30 -0000	1.14
+++ QContentPane.h	12 May 2005 18:52:48 -0000
@@ -105,6 +105,8 @@ public slots:
 	void doubleClickTimeout();
 
 	void scrollBarChanged(int);
+        void keyeventTimeout();
+        
 private:
 	/// The slot connected to SyntheticMouseEvent::timeout.
 	void generateSyntheticMouseEvent();
Index: lyx_gui.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lyx_gui.C,v
retrieving revision 1.82
diff -u -p -B -b -w -r1.82 lyx_gui.C
--- lyx_gui.C	11 May 2005 20:09:20 -0000	1.82
+++ lyx_gui.C	12 May 2005 18:52:48 -0000
@@ -253,15 +253,21 @@ void start(string const & batch, vector<
 }
 
 
+void sync_non_user_events()
+{
+        qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput
+                                         | QEventLoop::ExcludeSocketNotifiers,
+                                         5);
+
+}
+
 void sync_events()
 {
 	// This is the ONLY place where processEvents may be called.
 	// During screen update/ redraw, this method is disabled to 
 	// prevent keyboard events being handed to the LyX core, where
 	// they could cause re-entrant calls to screen update.
-#if QT_VERSION >= 0x030100
-	qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
-#endif
+	qApp->eventLoop()->processEvents(QEventLoop::AllEvents, 5);
 }
 
 
-- 
        Lgb

Reply via email to