diff options
author | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2015-09-04 17:56:20 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2015-10-07 13:24:45 +0000 |
commit | c7e5e1d9e01849347a9e59b8285477a20d82002b (patch) | |
tree | 3e53068d1b421f935905cb4b60b29ed94cd0457a /src/gui/kernel/qwindowsysteminterface.h | |
parent | 590c73bee2083c8dc8635123726e138a26dd3a97 (diff) |
Move shortcut handling back into QPA and simplify delivery
Commit 7f5b94b47 moved shortcut handling into QGuiApplication (for all
platforms except OS X), due to crashes on Android where the events are
delivered from another thread.
Now that we have synchronous event delivery (also across threads) from
QPA, this is no longer needed, and we can move the code back to QPA,
where the platform has more control over when and how shortcut events
are delivered in relation to normal key events.
Handling shortcuts is as before a two step process. We first send a
QKeyEvent::ShortcutOverride event to the active window, which allows
clients (widgets e.g.) to signal that they want to handle the shortcut
themselves. If the override event is accepted, we treat it as the
shortcut not being handled as a regular shortcut, and send the event
as a key press instead, allowing the widget to handle the shortcut.
If nothing accepted the shortcut override event we pass it along to
the global shortcut map, which will treat the event as handled if
an exact or partial match is found.
The QShortcutMap::tryShortcutEvent() and nextState() implementation
has been simplified to not use the events accepted state for its
internal operation, which removes the need for saving the state
of the incoming event.
The QKeyEvent::ShortcutOverride event was also always sent with
the accepted state set to false, by calling ignore() on it before
sending it. This is now explicit by having shortcut override
events being ignored by default in their constructor, and the
documentation has been updated accordingly.
Change-Id: I9afa29dbc00bef09fd22ee6bf09661b06340d715
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qwindowsysteminterface.h')
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.h | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 97bd087b53..387c1e00b9 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -78,22 +78,8 @@ public: Qt::KeyboardModifiers mods = Qt::NoModifier, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); - static bool tryHandleShortcutOverrideEvent(QWindow *w, QKeyEvent *ev); - - static bool tryHandleShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods, - const QString & text = QString(), bool autorep = false, ushort count = 1); - static bool tryHandleShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods, - const QString & text = QString(), bool autorep = false, ushort count = 1); - - static bool tryHandleShortcutEventToObject(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, - const QString & text = QString(), bool autorep = false, ushort count = 1); - - static bool tryHandleExtendedShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods, - quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, - const QString & text = QString(), bool autorep = false, ushort count = 1); - static bool tryHandleExtendedShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods, - quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, - const QString & text = QString(), bool autorep = false, ushort count = 1); + static bool handleShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods, quint32 nativeScanCode, + quint32 nativeVirtualKey, quint32 nativeModifiers, const QString & text = QString(), bool autorep = false, ushort count = 1); static bool handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1); static bool handleKeyEvent(QWindow *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1); |