summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-12-14 12:02:29 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-12-17 14:58:21 +0000
commitac5c2aaf35bba3048aeff5c26cf0aa704fe63df6 (patch)
tree9e5a1533d780f573236b3b245e769e49d63cb187
parent69839e55c13000ee9bf8d8e9d74b70096a92ae51 (diff)
Windows: Clear key recorder when application becomes inactive.
When keys are pressed and the application becomes inactive before they are released, the stored state becomes inconsistent. Task-number: QTBUG-49930 Change-Id: Ide86b1d9052df060f30f7c02b81a4f2ae15d28e7 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index 4c0b94e6e7..c5dff60114 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -86,10 +86,15 @@ QT_BEGIN_NAMESPACE
The code originates from \c qkeymapper_win.cpp.
*/
+static void clearKeyRecorderOnApplicationInActive(Qt::ApplicationState state);
+
QWindowsKeyMapper::QWindowsKeyMapper()
: m_useRTLExtensions(false), m_keyGrabber(0)
{
memset(keyLayout, 0, sizeof(keyLayout));
+ QGuiApplication *app = static_cast<QGuiApplication *>(QGuiApplication::instance());
+ QObject::connect(app, &QGuiApplication::applicationStateChanged,
+ app, clearKeyRecorderOnApplicationInActive);
}
QWindowsKeyMapper::~QWindowsKeyMapper()
@@ -144,6 +149,12 @@ struct KeyRecorder
};
static KeyRecorder key_recorder;
+static void clearKeyRecorderOnApplicationInActive(Qt::ApplicationState state)
+{
+ if (state == Qt::ApplicationInactive)
+ key_recorder.clearKeys();
+}
+
KeyRecord *KeyRecorder::findKey(int code, bool remove)
{
KeyRecord *result = 0;