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>
This commit is contained in:
parent
69839e55c1
commit
ac5c2aaf35
@ -86,10 +86,15 @@ QT_BEGIN_NAMESPACE
|
|||||||
The code originates from \c qkeymapper_win.cpp.
|
The code originates from \c qkeymapper_win.cpp.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static void clearKeyRecorderOnApplicationInActive(Qt::ApplicationState state);
|
||||||
|
|
||||||
QWindowsKeyMapper::QWindowsKeyMapper()
|
QWindowsKeyMapper::QWindowsKeyMapper()
|
||||||
: m_useRTLExtensions(false), m_keyGrabber(0)
|
: m_useRTLExtensions(false), m_keyGrabber(0)
|
||||||
{
|
{
|
||||||
memset(keyLayout, 0, sizeof(keyLayout));
|
memset(keyLayout, 0, sizeof(keyLayout));
|
||||||
|
QGuiApplication *app = static_cast<QGuiApplication *>(QGuiApplication::instance());
|
||||||
|
QObject::connect(app, &QGuiApplication::applicationStateChanged,
|
||||||
|
app, clearKeyRecorderOnApplicationInActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWindowsKeyMapper::~QWindowsKeyMapper()
|
QWindowsKeyMapper::~QWindowsKeyMapper()
|
||||||
@ -144,6 +149,12 @@ struct KeyRecorder
|
|||||||
};
|
};
|
||||||
static KeyRecorder key_recorder;
|
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 *KeyRecorder::findKey(int code, bool remove)
|
||||||
{
|
{
|
||||||
KeyRecord *result = 0;
|
KeyRecord *result = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user