Richard Heck wrote: > Andre Poenitz wrote: >> On Wed, May 16, 2007 at 11:57:51PM +0200, Peter Kümmel wrote: >> >>> void GuiWorkArea::keyPressEvent(QKeyEvent * e) >>> { >>> + // do nothing if there are other events >>> + // (the auto repeated events come too fast) >>> + if(QCoreApplication::hasPendingEvents()) { >>> + LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION >>> + << endl << "key ignored" << endl; >>> + e->ignore(); >>> + return; >>> + } >>> >> Have you tried typing _really_ fast? >> >> Do all keys still come through? If so, the idea looks good, although >> I'd restrict it to PageUp/Down events. >> > As I said in a different message, the original bug report did not > concern PgUp/Down but the scrollbar, and you see identical behavior with > the up and down arrow keys as well as with other keys. > > Richard > >
Here the next idea. It also catches not stopping paste events: the idea is to only allow a fixed number of key repetitions, currently 2. -- Peter Kümmel
Index: src/frontends/qt4/GuiWorkArea.cpp =================================================================== --- src/frontends/qt4/GuiWorkArea.cpp (revision 18371) +++ src/frontends/qt4/GuiWorkArea.cpp (working copy) @@ -414,6 +414,31 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * e) { + // do nothing if there are other events + // (the auto repeated events come too fast) + static int lastKey = 0; + static int count = 0; + const int maxRepititions = 1; + int key = e->key(); + if (key == lastKey) { + ++count; + } + lastKey = key; + // don't allow pending events for page scrolling + // and not more than maxRepititions + 1 repetitions for other keys + if (key == Qt::Key_PageDown || key == Qt::Key_PageUp + || count > maxRepititions ) { + if(QCoreApplication::hasPendingEvents()) { + LYXERR(Debug::KEY) + << BOOST_CURRENT_FUNCTION + << endl << "key ignored" << endl; + e->ignore(); + return; + } + } + if (count > maxRepititions) + count = 0; + LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION << " count=" << e->count() << " text=" << fromqstr(e->text())