summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGal Hammer <ghammer@redhat.com>2011-11-14 12:51:33 +0200
committerUri Lublin <uril@redhat.com>2011-11-24 18:31:04 +0200
commit66f611bccf865701a26967c6c9ceef4cd130b04d (patch)
tree2acdf8d5afcbe2f3287b19bc46408ccf7c45ab85
parent39ea97ce6082aaefb73f401c7d65a7d9b75323d7 (diff)
downloadspice-66f611bccf865701a26967c6c9ceef4cd130b04d.tar.gz
spice-66f611bccf865701a26967c6c9ceef4cd130b04d.tar.xz
spice-66f611bccf865701a26967c6c9ceef4cd130b04d.zip
client: handle the redundant right ctrl windows' message send when a alt-gr is pressed bz#709074
Hello, I first updated the translate_key function. It now requires the windows message as parameter (will be used later). It also use the raw wparam and lparam parameters in order to remove the code duplication when calling the function. Gal. (cherry picked from commit 33be8633f5712062752efe75adc745130a72c4c2)
-rw-r--r--client/windows/red_window.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/client/windows/red_window.cpp b/client/windows/red_window.cpp
index 6d8a70d8..94bab52e 100644
--- a/client/windows/red_window.cpp
+++ b/client/windows/red_window.cpp
@@ -49,12 +49,13 @@ static inline int to_red_mouse_state(WPARAM wParam)
((wParam & MK_RBUTTON) ? SPICE_MOUSE_BUTTON_MASK_RIGHT : 0);
}
-static inline RedKey translate_key(int virtual_key, uint32_t scan, bool escape)
+static inline RedKey translate_key(UINT message, WPARAM wParam, LPARAM lParam)
{
+ uint32_t scan = HIWORD(lParam) & 0xff;
if (scan == 0) {
return REDKEY_INVALID;
}
- switch (virtual_key) {
+ switch (wParam) {
case VK_PAUSE:
return REDKEY_PAUSE;
case VK_SNAPSHOT:
@@ -71,13 +72,16 @@ static inline RedKey translate_key(int virtual_key, uint32_t scan, bool escape)
} else if (scan == 0xf2) {
return REDKEY_KOREAN_HANGUL;
}
+ break;
default:
- //todo: always use vitrtual key
- if (escape) {
- scan += REDKEY_ESCAPE_BASE;
- }
- return (RedKey)scan;
+ break;
+ }
+ // TODO: always use virtual key
+ bool extended = ((HIWORD (lParam) & KF_EXTENDED) != 0);
+ if (extended) {
+ scan += REDKEY_ESCAPE_BASE;
}
+ return (RedKey)scan;
}
static int menu_cmd_to_app(WPARAM wparam)
@@ -216,7 +220,7 @@ LRESULT CALLBACK RedWindow_p::WindowProc(HWND hWnd, UINT message, WPARAM wParam,
break;
case WM_SYSKEYDOWN:
case WM_KEYDOWN: {
- RedKey key = translate_key(wParam, HIWORD(lParam) & 0xff, (lParam & (1 << 24)) != 0);
+ RedKey key = translate_key(message, wParam, lParam);
window->get_listener().on_key_press(key);
BYTE key_state[256];
@@ -239,7 +243,7 @@ LRESULT CALLBACK RedWindow_p::WindowProc(HWND hWnd, UINT message, WPARAM wParam,
}
case WM_SYSKEYUP:
case WM_KEYUP: {
- RedKey key = translate_key(wParam, HIWORD(lParam) & 0xff, (lParam & (1 << 24)) != 0);
+ RedKey key = translate_key(message, wParam, lParam);
window->get_listener().on_key_release(key);
break;
}
@@ -1051,8 +1055,7 @@ static LRESULT CALLBACK MessageFilterProc(int nCode, WPARAM wParam, LPARAM lPara
switch (msg->message) {
case WM_SYSKEYUP:
case WM_KEYUP: {
- RedKey key = translate_key(msg->wParam, HIWORD(msg->lParam) & 0xff,
- (msg->lParam & (1 << 24)) != 0);
+ RedKey key = translate_key(msg->message, wParam, lParam);
filtered_up_keys.push_back(key);
break;
}