summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-01-27 16:58:53 +0100
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2015-01-29 09:29:56 +0000
commit03a40d3a46b078f6cf516e5a42ef2e11a5366a20 (patch)
tree817b96384158b32c3e33acd82aa744edbf5d47ca
parent6430d6e3ec31afabe0e674397088dd6d9e056195 (diff)
Revert "Windows: Fix call of ToUnicode"
This reverts commit dfe853bff90444edf92a993e391df853780c9e8d. When using cyrillic or other keyboard layouts, standard shortcuts like CTRL-C are still supposed to work as if the US keyboard layout were in effect. Task-number: QTBUG-44021 Task-number: QTBUG-35734 Change-Id: If6cd96a1e03e62900b293f8e304e523460e85810 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index d781cdbe9c..4b1d1112d5 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -537,16 +537,15 @@ static inline int toKeyOrUnicode(int vk, int scancode, unsigned char *kbdBuffer,
Q_ASSERT(vk > 0 && vk < 256);
int code = 0;
QChar unicodeBuffer[5];
- // While key combinations containing alt and ctrl might trigger the third assignment of a key
- // (for example "alt+ctrl+q" causes '@' on a German layout), ToUnicode often does not return the
- // wanted character if only the ctrl modifier is used. Thus we unset this modifier temporarily
- // if it is not used together with alt.
- const unsigned char controlState = kbdBuffer[VK_MENU] ? 0 : kbdBuffer[VK_CONTROL];
- if (controlState)
- kbdBuffer[VK_CONTROL] = 0;
int res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast<LPWSTR>(unicodeBuffer), 5, 0);
- if (controlState)
+ // When Ctrl modifier is used ToUnicode does not return correct values. In order to assign the
+ // right key the control modifier is removed for just that function if the previous call failed.
+ if (res == 0 && kbdBuffer[VK_CONTROL]) {
+ const unsigned char controlState = kbdBuffer[VK_CONTROL];
+ kbdBuffer[VK_CONTROL] = 0;
+ res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast<LPWSTR>(unicodeBuffer), 5, 0);
kbdBuffer[VK_CONTROL] = controlState;
+ }
if (res)
code = unicodeBuffer[0].toUpper().unicode();