From a85913d21a0cfdf129fdbece9308d8d4bf84d8d0 Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Mon, 6 Jun 2005 12:34:28 +0000 Subject: [PATCH] Lars's key input queue git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9999 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 8 ++----- src/ChangeLog | 5 +++++ src/frontends/qt2/ChangeLog | 7 +++++++ src/frontends/qt2/QContentPane.C | 36 +++++++++++++++++++++++++++++--- src/frontends/qt2/QContentPane.h | 8 +++++++ 5 files changed, 55 insertions(+), 9 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 0617392056..8753da7fbe 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -520,12 +520,8 @@ void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key, * of the cursor. Note we cannot do this inside * dispatch() itself, because that's called recursively. */ - if (available()) { - screen().prepareCursor(); - cursor_timeout.setTimeout(100); - cursor_timeout.restart(); - cursor_timeout.setTimeout(400); - } + if (available()) + screen().showCursor(*bv_); } diff --git a/src/ChangeLog b/src/ChangeLog index 0bc6d26e46..3907b72139 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-06-06 Martin Vermeer + + * BufferView_pimpl.C: revert to showCursor in connection with + Lars's front-end stack + 2005-06-06 Jürgen Spitzmüller * text.C (redoParagraph): move cursor right after a bibitem diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index dcc1a7df7b..b0d223dedf 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,10 @@ +2005-06-06 Lars Gullik Bjonnes + (Committed Martin Vermeer ) + + * QContentPane.[Ch]: implement keystroke event stack with + repeat key "regulation". Key are not sent to LyX core faster + than rendering can handle. + 2005-06-03 Jürgen Spitzmüller * QContentPane.[Ch]: Limit the QIM*Events to X11. They are not diff --git a/src/frontends/qt2/QContentPane.C b/src/frontends/qt2/QContentPane.C index 7fb3ca107d..1731af6c6d 100644 --- a/src/frontends/qt2/QContentPane.C +++ b/src/frontends/qt2/QContentPane.C @@ -19,7 +19,6 @@ #include #include -#include #include @@ -90,6 +89,8 @@ QContentPane::QContentPane(QWorkArea * parent) boost::bind(&QContentPane::generateSyntheticMouseEvent, this)); + connect(&step_timer_, SIGNAL(timeout()), SLOT(keyeventTimeout())); + setFocusPolicy(QWidget::WheelFocus); setFocus(); setCursor(ibeamCursor); @@ -101,6 +102,9 @@ QContentPane::QContentPane(QWorkArea * parent) // stupid moc strikes again connect(wa_->scrollbar_, SIGNAL(valueChanged(int)), this, SLOT(scrollBarChanged(int))); + + // Start the timer, one-shot. + step_timer_.start(25, true); } @@ -251,9 +255,35 @@ void QContentPane::wheelEvent(QWheelEvent * e) void QContentPane::keyPressEvent(QKeyEvent * e) { + keyeventQueue_.push(boost::shared_ptr(new QKeyEvent(*e))); +} + + +void QContentPane::keyeventTimeout() +{ + bool handle_autos = true; + + while (!keyeventQueue_.empty()) { + boost::shared_ptr 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 sym(new QLyXKeySym); - sym->set(e); - wa_->workAreaKeyPress(sym, q_key_state(e->state())); + sym->set(ev.get()); + + wa_->workAreaKeyPress(sym, q_key_state(ev->state())); + keyeventQueue_.pop(); + + handle_autos = false; + } + + // Restart the timer. + step_timer_.start(25, true); } diff --git a/src/frontends/qt2/QContentPane.h b/src/frontends/qt2/QContentPane.h index 7cde77b24d..65a02b7bbe 100644 --- a/src/frontends/qt2/QContentPane.h +++ b/src/frontends/qt2/QContentPane.h @@ -21,9 +21,12 @@ #include #include +#include #include +#include + #if (defined(Q_WS_X11) && QT_VERSION >= 0x030200) #define USE_INPUT_METHODS 1 #endif @@ -115,6 +118,8 @@ public slots: void doubleClickTimeout(); void scrollBarChanged(int); + void keyeventTimeout(); + private: /// The slot connected to SyntheticMouseEvent::timeout. void generateSyntheticMouseEvent(); @@ -125,6 +130,9 @@ private: /// owning widget QWorkArea * wa_; + QTimer step_timer_; + std::queue > keyeventQueue_; + /// the double buffered pixmap boost::scoped_ptr pixmap_;