summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorArnon Gilboa <agilboa@redhat.com>2009-11-17 16:44:50 +0200
committerYaniv Kamay <ykamay@redhat.com>2010-01-03 17:37:05 +0200
commit18270e02353786a64e01a303ac4db5fa05e05eeb (patch)
tree96b8c03442b5dc18c70e08525dbc9f8eef2dad09 /client
parentba04ac69c680389b8aa225c2ecac0d9fe9b7f0ff (diff)
downloadspice-18270e02353786a64e01a303ac4db5fa05e05eeb.tar.gz
spice-18270e02353786a64e01a303ac4db5fa05e05eeb.tar.xz
spice-18270e02353786a64e01a303ac4db5fa05e05eeb.zip
spice: on toggle_full_screen, generate on_key_down if shift is still pressed
Diffstat (limited to 'client')
-rw-r--r--client/application.cpp12
-rw-r--r--client/inputs_channel.cpp4
-rw-r--r--client/platform.h20
-rw-r--r--client/windows/platform.cpp21
-rw-r--r--client/x11/platform.cpp25
5 files changed, 74 insertions, 8 deletions
diff --git a/client/application.cpp b/client/application.cpp
index 061dc37c..fb14fff6 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -1230,11 +1230,23 @@ void Application::exit_full_screen()
bool Application::toggle_full_screen()
{
+ RedKey shift_pressed = REDKEY_INVALID;
+
+ if (_key_table[REDKEY_L_SHIFT].press) {
+ shift_pressed = REDKEY_L_SHIFT;
+ } else if (_key_table[REDKEY_R_SHIFT].press) {
+ shift_pressed = REDKEY_R_SHIFT;
+ }
if (_full_screen) {
exit_full_screen();
} else {
enter_full_screen();
}
+ uint32_t modifiers = Platform::get_keyboard_modifiers();
+ if ((shift_pressed == REDKEY_L_SHIFT && (modifiers & Platform::L_SHIFT_MODIFIER)) ||
+ (shift_pressed == REDKEY_R_SHIFT && (modifiers & Platform::R_SHIFT_MODIFIER))) {
+ on_key_down(shift_pressed);
+ }
return _full_screen;
}
diff --git a/client/inputs_channel.cpp b/client/inputs_channel.cpp
index d686be22..df434937 100644
--- a/client/inputs_channel.cpp
+++ b/client/inputs_channel.cpp
@@ -327,7 +327,7 @@ void InputsChannel::set_local_modifiers()
modifiers |= Platform::CAPS_LOCK_MODIFIER;
}
- Platform::set_keyboard_modifiers(_modifiers);
+ Platform::set_keyboard_lock_modifiers(_modifiers);
}
void InputsChannel::on_focus_in()
@@ -335,7 +335,7 @@ void InputsChannel::on_focus_in()
#ifdef SYNC_REMOTH_MODIFIRES
Message* message = new Message(REDC_INPUTS_KEY_MODIFAIERS, sizeof(RedcKeyDown));
RedcKeyModifiers* modifiers = (RedcKeyModifiers*)message->data();
- modifiers->modifiers = Platform::get_keyboard_modifiers();
+ modifiers->modifiers = Platform::get_keyboard_lock_modifiers();
post_message(message);
#else
set_local_modifiers();
diff --git a/client/platform.h b/client/platform.h
index 5dca7177..ece61c9d 100644
--- a/client/platform.h
+++ b/client/platform.h
@@ -77,8 +77,26 @@ public:
CAPS_LOCK_MODIFIER = (1 << CAPS_LOCK_MODIFIER_SHIFT),
};
+ static uint32_t get_keyboard_lock_modifiers();
+ static void set_keyboard_lock_modifiers(uint32_t modifiers);
+
+ enum {
+ L_SHIFT_MODIFIER_SHIFT,
+ R_SHIFT_MODIFIER_SHIFT,
+ L_CTRL_MODIFIER_SHIFT,
+ R_CTRL_MODIFIER_SHIFT,
+ L_ALT_MODIFIER_SHIFT,
+ R_ALT_MODIFIER_SHIFT,
+
+ L_SHIFT_MODIFIER = (1 << L_SHIFT_MODIFIER_SHIFT),
+ R_SHIFT_MODIFIER = (1 << R_SHIFT_MODIFIER_SHIFT),
+ L_CTRL_MODIFIER = (1 << L_CTRL_MODIFIER_SHIFT),
+ R_CTRL_MODIFIER = (1 << R_CTRL_MODIFIER_SHIFT),
+ L_ALT_MODIFIER = (1 << L_ALT_MODIFIER_SHIFT),
+ R_ALT_MODIFIER = (1 << R_ALT_MODIFIER_SHIFT),
+ };
+
static uint32_t get_keyboard_modifiers();
- static void set_keyboard_modifiers(uint32_t modifiers);
static LocalCursor* create_local_cursor(CursorData* cursor_data);
static LocalCursor* create_inactive_cursor();
diff --git a/client/windows/platform.cpp b/client/windows/platform.cpp
index 24c9ca93..6b218404 100644
--- a/client/windows/platform.cpp
+++ b/client/windows/platform.cpp
@@ -444,7 +444,7 @@ static void toggle_modifier(int key)
SendInput(2, inputs, sizeof(INPUT));
}
-uint32_t Platform::get_keyboard_modifiers()
+uint32_t Platform::get_keyboard_lock_modifiers()
{
uint32_t modifiers = 0;
if ((GetKeyState(VK_SCROLL) & 1)) {
@@ -459,7 +459,7 @@ uint32_t Platform::get_keyboard_modifiers()
return modifiers;
}
-void Platform::set_keyboard_modifiers(uint32_t modifiers)
+void Platform::set_keyboard_lock_modifiers(uint32_t modifiers)
{
if (((modifiers >> SCROLL_LOCK_MODIFIER_SHIFT) & 1) != (GetKeyState(VK_SCROLL) & 1)) {
toggle_modifier(VK_SCROLL);
@@ -474,6 +474,23 @@ void Platform::set_keyboard_modifiers(uint32_t modifiers)
}
}
+#define KEY_BIT(keymap, key, bit) (keymap[key] & 0x80 ? bit : 0)
+
+uint32_t Platform::get_keyboard_modifiers()
+{
+ BYTE keymap[256];
+
+ if (!GetKeyboardState(keymap)) {
+ return 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);
+}
+
class WinBaseLocalCursor: public LocalCursor {
public:
WinBaseLocalCursor() : _handle (0) {}
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index 8288f555..10d621ba 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -2148,7 +2148,7 @@ void Platform::set_process_loop(ProcessLoop& main_process_loop)
main_loop->add_file(*x_event_handler);
}
-uint32_t Platform::get_keyboard_modifiers()
+uint32_t Platform::get_keyboard_lock_modifiers()
{
XKeyboardState keyboard_state;
uint32_t modifiers = 0;
@@ -2195,9 +2195,9 @@ static void set_keyboard_led(XLed led, int set)
}
}
-void Platform::set_keyboard_modifiers(uint32_t modifiers)
+void Platform::set_keyboard_lock_modifiers(uint32_t modifiers)
{
- uint32_t now = get_keyboard_modifiers();
+ uint32_t now = get_keyboard_lock_modifiers();
if ((now & CAPS_LOCK_MODIFIER) != (modifiers & CAPS_LOCK_MODIFIER)) {
set_keyboard_led(X11_CAPS_LOCK_LED, !!(modifiers & CAPS_LOCK_MODIFIER));
@@ -2210,6 +2210,25 @@ void Platform::set_keyboard_modifiers(uint32_t modifiers)
}
}
+uint32_t key_bit(char* keymap, int key, uint32_t bit)
+{
+ KeyCode key_code = XKeysymToKeycode(x_display, key);
+ return (((keymap[key_code >> 3] >> (key_code & 7)) & 1) ? bit : 0);
+}
+
+uint32_t Platform::get_keyboard_modifiers()
+{
+ char keymap[32];
+
+ XQueryKeymap(x_display, keymap);
+ return key_bit(keymap, XK_Shift_L, L_SHIFT_MODIFIER) |
+ key_bit(keymap, XK_Shift_R, R_SHIFT_MODIFIER) |
+ key_bit(keymap, XK_Control_L, L_CTRL_MODIFIER) |
+ key_bit(keymap, XK_Control_R, R_CTRL_MODIFIER) |
+ key_bit(keymap, XK_Alt_L, L_ALT_MODIFIER) |
+ key_bit(keymap, XK_Alt_R, R_ALT_MODIFIER);
+}
+
WaveRecordAbstract* Platform::create_recorder(RecordClient& client,
uint32_t sampels_per_sec,
uint32_t bits_per_sample,