summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qguiapplication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r--src/gui/kernel/qguiapplication.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 1763624b83..7155127f75 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1507,10 +1507,20 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
{
QWindow *window = e->window.data();
modifier_buttons = e->modifiers;
- if (e->nullWindow)
+ if (e->nullWindow
+#ifdef Q_OS_ANDROID
+ || (e->keyType == QEvent::KeyRelease && e->key == Qt::Key_Back) || e->key == Qt::Key_Menu
+#endif
+ ) {
window = QGuiApplication::focusWindow();
- if (!window)
+ }
+ if (!window
+#ifdef Q_OS_ANDROID
+ && e->keyType != QEvent::KeyRelease && e->key != Qt::Key_Back
+#endif
+ ) {
return;
+ }
if (window->d_func()->blockedByModalWindow) {
// a modal window is blocking this window, don't allow key events through
return;
@@ -1520,7 +1530,19 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers,
e->unicode, e->repeat, e->repeatCount);
ev.setTimestamp(e->timestamp);
- QGuiApplication::sendSpontaneousEvent(window, &ev);
+
+#ifdef Q_OS_ANDROID
+ if (e->keyType == QEvent::KeyRelease && e->key == Qt::Key_Back) {
+ if (!window) {
+ qApp->quit();
+ } else {
+ QGuiApplication::sendEvent(window, &ev);
+ if (!ev.isAccepted() && e->key == Qt::Key_Back)
+ QWindowSystemInterface::handleCloseEvent(window);
+ }
+ } else
+#endif
+ QGuiApplication::sendSpontaneousEvent(window, &ev);
}
void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)