[EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:

| | Then we just need a timer that kicks in some 10-20 times a second to
| | check the queue and do the real work.
>
| and with the queue doing the right thing we can actually put
| processEvents allover as much as we want to to make the interactive
| feeling better. Because we know that all events that is sendt to lyx
| core is queued up until we allow them to be handed.

this is kindo a proof-of-concept.

Would be nice if people could try this a bit and see if the problems
seen earlier can be reproduced with this patch applied.

- most likely a check for update in progress is needed in the
  keyeventTimeout
- event coalescing would be nice... (may be 1.5 stuff if we go this route)

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 16:43:58 -0000
@@ -23,6 +23,8 @@
 
 #include <boost/bind.hpp>
 
+#include <queue>
+
 namespace {
 
 /// return the LyX key state from Qt's
@@ -73,6 +75,10 @@ mouse_button::state q_motion_state(Qt::B
 	return b;
 }
 
+QTimer * step_timer;
+typedef boost::shared_ptr<QLyXKeySym> SharedSym;
+std::queue<std::pair<SharedSym, key_modifier::state> > keyeventQueue;
+
 } // namespace anon
 
 
@@ -90,6 +96,10 @@ QContentPane::QContentPane(QWorkArea * p
 		boost::bind(&QContentPane::generateSyntheticMouseEvent,
 			    this));
 
+        step_timer = new QTimer(this);
+        connect(step_timer, SIGNAL(timeout()), SLOT(keyeventTimeout()));
+        step_timer->start(50); // signal every .05 seconds
+        
 	setFocusPolicy(QWidget::WheelFocus);
 	setFocus();
 	setCursor(ibeamCursor);
@@ -218,7 +228,17 @@ void QContentPane::keyPressEvent(QKeyEve
 {
 	boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
 	sym->set(e);
-	wa_->workAreaKeyPress(sym, q_key_state(e->state()));
+        keyeventQueue.push(std::make_pair(sym, q_key_state(e->state())));
+}
+
+
+void QContentPane::keyeventTimeout()
+{
+        while (!keyeventQueue.empty()) {
+                std::pair<boost::shared_ptr<QLyXKeySym>, key_modifier::state> sym = keyeventQueue.front();
+                keyeventQueue.pop();
+                wa_->workAreaKeyPress(sym.first, sym.second);
+        }
 }
 
 
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 16:43:58 -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 16:43:58 -0000
@@ -259,9 +259,7 @@ void sync_events()
 	// 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->processEvents();
 }
 
 
-- 
        Lgb

Reply via email to