mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-11 08:07:16 +00:00
spice: on toggle_full_screen, generate on_key_down if shift is still pressed
This commit is contained in:
parent
ba04ac69c6
commit
18270e0235
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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) {}
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user