diff options
author | Anders Bakken <anders.bakken@nokia.com> | 2009-07-28 20:49:03 (GMT) |
---|---|---|
committer | Anders Bakken <anders.bakken@nokia.com> | 2009-07-28 21:11:42 (GMT) |
commit | c0f85469a76a25fff6951b634b67cfbcd0507b93 (patch) | |
tree | dfe60f394feb0895c5b17bccd27b66c64cff1015 /src | |
parent | 4caf5c1568163aa8efbfabb69ef0d83c3c6efd0a (diff) | |
download | Qt-c0f85469a76a25fff6951b634b67cfbcd0507b93.zip Qt-c0f85469a76a25fff6951b634b67cfbcd0507b93.tar.gz Qt-c0f85469a76a25fff6951b634b67cfbcd0507b93.tar.bz2 |
Make autorepeat work for DirectFB
When holding down a key DirectFB gives us only keypresses.
Qt wants these kind of events:
press not autorepeat
release autorepeat
press autorepeat
release autorepeat
press autorepeat
release not autorepeat
Reviewed-by: Donald <qt-info@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp index b5376b1..13c4053 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp @@ -77,13 +77,15 @@ private: QSocketNotifier *keyboardNotifier; DFBEvent event; int bytesRead; - + int lastUnicode, lastKeycode; + Qt::KeyboardModifiers lastModifiers; private Q_SLOTS: void readKeyboardData(); }; QDirectFBKeyboardHandlerPrivate::QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboardHandler *h) - : handler(h), eventBuffer(0) + : handler(h), eventBuffer(0), keyboardNotifier(0), bytesRead(0), + lastUnicode(0), lastKeycode(0), lastModifiers(0) { Q_ASSERT(qt_screen); @@ -114,8 +116,6 @@ QDirectFBKeyboardHandlerPrivate::QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboa ::fcntl(fd, F_SETFL, flags | O_NONBLOCK); memset(&event, 0, sizeof(event)); - bytesRead = 0; - keyboardNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); connect(keyboardNotifier, SIGNAL(activated(int)), @@ -213,8 +213,27 @@ void QDirectFBKeyboardHandlerPrivate::readKeyboardData() unicode = symbol; if (unicode != -1 || keycode != 0) { + bool autoRepeat = false; + if (press) { + if (unicode == lastUnicode && keycode == lastKeycode && modifiers == lastModifiers) { + autoRepeat = true; + } else { + lastUnicode = unicode; + lastKeycode = keycode; + lastModifiers = modifiers; + } + } else { + lastUnicode = lastKeycode = -1; + lastModifiers = 0; + } + if (autoRepeat) { + handler->processKeyEvent(unicode, keycode, + modifiers, false, autoRepeat); + + } + handler->processKeyEvent(unicode, keycode, - modifiers, press, false); + modifiers, press, autoRepeat); } } } |