From 68557afff29ef8c5e8cd8fb7ad55e9e5f7f8b32d Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Mon, 31 Mar 2014 15:54:57 +0000 Subject: [PATCH] fixed: modifier keys are repeated on windows server. --- src/lib/platform/MSWindowsScreen.cpp | 33 ++++++++++++++++++++++++++++ src/lib/platform/MSWindowsScreen.h | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/src/lib/platform/MSWindowsScreen.cpp b/src/lib/platform/MSWindowsScreen.cpp index 714f743e..3422fd03 100644 --- a/src/lib/platform/MSWindowsScreen.cpp +++ b/src/lib/platform/MSWindowsScreen.cpp @@ -1136,6 +1136,11 @@ CMSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam) } } + // stop sending modifier keys over and over again + if (isModifierRepeat(oldState, state, wParam)) { + return true; + } + // ignore message if posted prior to last mark change if (!ignore()) { // check for ctrl+alt+del. we do not want to pass that to the @@ -1816,3 +1821,31 @@ CMSWindowsScreen::getDropTarget() const { return m_desktopPath; } + +bool +CMSWindowsScreen::isModifierRepeat(KeyModifierMask oldState, KeyModifierMask state, WPARAM wParam) const +{ + bool result = false; + + if (oldState == state && state != 0) { + UINT virtKey = (wParam & 0xffu); + if ((state & KeyModifierShift) != 0 + && (virtKey == VK_LSHIFT || virtKey == VK_RSHIFT)) { + result = true; + } + if ((state & KeyModifierControl) != 0 + && (virtKey == VK_LCONTROL || virtKey == VK_RCONTROL)) { + result = true; + } + if ((state & KeyModifierAlt) != 0 + && (virtKey == VK_LMENU || virtKey == VK_RMENU)) { + result = true; + } + if ((state & KeyModifierSuper) != 0 + && (virtKey == VK_LWIN || virtKey == VK_RWIN)) { + result = true; + } + } + + return result; +} diff --git a/src/lib/platform/MSWindowsScreen.h b/src/lib/platform/MSWindowsScreen.h index 2df94811..4350cd7f 100644 --- a/src/lib/platform/MSWindowsScreen.h +++ b/src/lib/platform/MSWindowsScreen.h @@ -211,6 +211,10 @@ private: // HACK // save last position of mouse to compute next delta movement void saveMousePosition(SInt32 x, SInt32 y); + + // check if it is a modifier key repeating message + bool isModifierRepeat(KeyModifierMask oldState, + KeyModifierMask state, WPARAM wParam) const; private: struct CHotKeyItem {