[Spice-commits] Branch '0.8' - client/application.cpp client/screen.cpp client/windows

Yonit Halperin yhalperi at kemper.freedesktop.org
Tue Jun 14 00:14:05 PDT 2011


 client/application.cpp      |    4 ++++
 client/screen.cpp           |    4 ++++
 client/windows/platform.cpp |   29 +++++++++++++++++++----------
 3 files changed, 27 insertions(+), 10 deletions(-)

New commits:
commit 4f0e0ac7122e5eecdb4094dd71db8f621e657d08
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Thu May 26 17:20:19 2011 +0300

    client: fix for redundant shift+f11 RHBZ #674532
    
    After shift+F11, both in Windows 7 and xp clients, WM_KEYUP events were missing for
    SHIFT and F11. For F11 it was less important since unpress_all was preformed for all keys.
    However, we perform sync for all the keyboard modifiers and the GetKeyboardState returns "down" for shift.
    In windows7 client, we sometimes received afterwards a F11 KEYDOWN event repetition, and this caused SHIFT+F11 to be called again.
    Not performing hiding of the windows while changing client resolutions, solved the problem of missing events, and I don't see any difference
    in how spice looks while toggling to full screen.
    Using GetAsyncKeyState, returns "UP" for shift in windows 7, and helps avoid performing shift+f11 again, if there is an F11 repetition
    before we receive the KEYUP event for shift.

diff --git a/client/application.cpp b/client/application.cpp
index e5cb4c4..f19bd58 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -1519,7 +1519,11 @@ void Application::enter_full_screen()
     _changing_screens = true;
     bool capture = release_capture();
     assign_monitors();
+#ifndef WIN32
+    /* performing hide during resolution changes resulted in
+       missing WM_KEYUP events */
     hide();
+#endif
     prepare_monitors();
     position_screens();
     show_full_screen();
diff --git a/client/screen.cpp b/client/screen.cpp
index 575ab5d..caa5d4f 100644
--- a/client/screen.cpp
+++ b/client/screen.cpp
@@ -827,7 +827,11 @@ void RedScreen::show_full_screen()
         return;
     }
     RecurciveLock lock(_update_lock);
+#ifndef WIN32
+    /* performing hide during resolution changes resulted in
+       missing WM_KEYUP events */
     hide();
+#endif
     save_position();
     _full_screen = true;
     __show_full_screen();
diff --git a/client/windows/platform.cpp b/client/windows/platform.cpp
index fc6fb2e..0f35a65 100644
--- a/client/windows/platform.cpp
+++ b/client/windows/platform.cpp
@@ -680,21 +680,30 @@ void Platform::set_keyboard_lock_modifiers(uint32_t modifiers)
     }
 }
 
-#define KEY_BIT(keymap, key, bit) (keymap[key] & 0x80 ? bit : 0)
+typedef struct KeyboardModifier {
+    int vkey;
+    int bit;
+} KeyboardModifier;
+
+static const KeyboardModifier KEYBOARD_MODIFIERS[] = {
+    {VK_LSHIFT, Platform::L_SHIFT_MODIFIER},
+    {VK_RSHIFT, Platform::R_SHIFT_MODIFIER},
+    {VK_LCONTROL, Platform::L_CTRL_MODIFIER},
+    {VK_RCONTROL, Platform::R_CTRL_MODIFIER},
+    {VK_LMENU, Platform::L_ALT_MODIFIER},
+    {VK_RMENU, Platform::R_ALT_MODIFIER}};
 
 uint32_t Platform::get_keyboard_modifiers()
 {
-    BYTE keymap[256];
+    uint32_t modifiers_state = 0;
+    int num_modifiers = sizeof(KEYBOARD_MODIFIERS)/sizeof(KEYBOARD_MODIFIERS[0]);
 
-    if (!GetKeyboardState(keymap)) {
-        return 0;
+    for (int i = 0; i < num_modifiers; i++) {
+        short key_state = GetAsyncKeyState(KEYBOARD_MODIFIERS[i].vkey);
+        modifiers_state |= (key_state & 0x8000) ? KEYBOARD_MODIFIERS[i].bit : 0;
     }
-    return KEY_BIT(keymap, VK_LSHIFT, L_SHIFT_MODIFIER) |
-           KEY_BIT(keymap, VK_RSHIFT, R_SHIFT_MODIFIER) |
-           KEY_BIT(keymap, VK_LCONTROL, L_CTRL_MODIFIER) |
-           KEY_BIT(keymap, VK_RCONTROL, R_CTRL_MODIFIER) |
-           KEY_BIT(keymap, VK_LMENU, L_ALT_MODIFIER) |
-           KEY_BIT(keymap, VK_RMENU, R_ALT_MODIFIER);
+
+    return modifiers_state;
 }
 
 void Platform::reset_cursor_pos()


More information about the Spice-commits mailing list