winrt: Use handleExtendedKeyEvent when handling back button.

QWindowSystemInterface::handleKeyEvent runs the shortcut override
unconditionally; use QWindowSystemInterface::handleExtendedKeyEvent
instead, because it allows bypassing the override (as the back button
press is not a valid shortcut). This also prevents an unnecessary mutex
lock.

Change-Id: I8d8bb957e1556ac47e031cfe6fca6481f7c3220d
Reviewed-by: Andrew Knight <andrew.knight@intopalo.com>
This commit is contained in:
Samuel Nevala 2015-11-16 15:47:46 +02:00
parent 97c8f6aa9c
commit dd3be4fbac

View File

@ -260,8 +260,10 @@ HRESULT QWinRTIntegration::onBackButtonPressed(IInspectable *, IBackPressedEvent
Q_D(QWinRTIntegration);
QWindow *window = d->mainScreen->topWindow();
QWindowSystemInterface::setSynchronousWindowSystemEvents(true);
const bool pressed = QWindowSystemInterface::handleKeyEvent(window, QEvent::KeyPress, Qt::Key_Back, Qt::NoModifier);
const bool released = QWindowSystemInterface::handleKeyEvent(window, QEvent::KeyRelease, Qt::Key_Back, Qt::NoModifier);
const bool pressed = QWindowSystemInterface::handleExtendedKeyEvent(window, QEvent::KeyPress, Qt::Key_Back, Qt::NoModifier,
0, 0, 0, QString(), false, 1, false);
const bool released = QWindowSystemInterface::handleExtendedKeyEvent(window, QEvent::KeyRelease, Qt::Key_Back, Qt::NoModifier,
0, 0, 0, QString(), false, 1, false);
QWindowSystemInterface::setSynchronousWindowSystemEvents(false);
args->put_Handled(pressed || released);
return S_OK;