summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-08-25 15:39:47 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-08-27 19:49:55 +0200
commit2945c6223bf067f240a020b2454d6bcac8fa961a (patch)
tree117d3922b7d9530d597c4666080ed72c2b24ae8f /src/plugins/platforms/cocoa
parentb33ccd99e130c02d582ae42158663e13f093b7c3 (diff)
macOS: Return early from key handler if shortcut was handled
The code paths after accepting a shortcut event can never be hit. Pick-to: 6.2 Change-Id: Ida77417adb8fcfd25a4b20c4eb86056b3769f014 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qnsview_keys.mm10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview_keys.mm b/src/plugins/platforms/cocoa/qnsview_keys.mm
index 9ff3a8a762..db2b4f4139 100644
--- a/src/plugins/platforms/cocoa/qnsview_keys.mm
+++ b/src/plugins/platforms/cocoa/qnsview_keys.mm
@@ -93,8 +93,9 @@
qCDebug(lcQpaKeys) << "Handling" << nsevent << "as" << qtKey
<< "with" << modifiers << "and resulting text" << text;
+ QBoolBlocker resendKeyEventGuard(m_resendKeyEvent, false);
// We will send a key event unless the input method sets m_sendKeyEvent to false
- m_sendKeyEvent = true;
+ QBoolBlocker sendKeyEventGuard(m_sendKeyEvent, true);
if (eventType == QEvent::KeyPress) {
@@ -103,10 +104,7 @@
if (QWindowSystemInterface::handleShortcutEvent(window, timestamp, qtKey, modifiers,
nativeScanCode, nativeVirtualKey, nativeModifiers, text, [nsevent isARepeat], 1)) {
qCDebug(lcQpaKeys) << "Found matching shortcut; will not send as key event";
- m_sendKeyEvent = false;
- // Handling a shortcut may result in closing the window
- if (!m_platformWindow)
- return true;
+ return true;
} else {
qCDebug(lcQpaKeys) << "No matching shortcuts; continuing with key event delivery";
}
@@ -157,8 +155,6 @@
nativeScanCode, nativeVirtualKey, nativeModifiers, text, [nsevent isARepeat], 1, false);
accepted = QWindowSystemInterface::flushWindowSystemEvents();
}
- m_sendKeyEvent = false;
- m_resendKeyEvent = false;
return accepted;
}