server: Don't send raw input events for unicode inputs.

This commit is contained in:
Alexandros Frantzis 2024-05-29 18:42:36 +03:00 committed by Alexandre Julliard
parent d14a827b8c
commit 69aad4aeca
2 changed files with 38 additions and 2 deletions

View file

@ -1471,6 +1471,35 @@ static void test_SendInput_raw_key_messages( WORD vkey, WORD wch, HKL hkl )
{.vkey = VK_PACKET, .flags = KEYEVENTF_KEYUP, .expect = {RAW_KEY(2, RI_KEY_BREAK, VK_PACKET, WM_KEYUP), {0}}},
{0},
};
struct send_input_keyboard_test raw_unicode_legacy[] =
{
{.scan = 0x3c0, .flags = KEYEVENTF_UNICODE, .expect_state = {[VK_PACKET] = 0x80},
.expect = {KEY_MSG(WM_KEYDOWN, 0, VK_PACKET, .todo_value = TRUE), WIN_MSG(WM_CHAR, 0x3c0, 1), {0}}},
{.scan = 0x3c0, .flags = KEYEVENTF_KEYUP | KEYEVENTF_UNICODE,
.expect = {KEY_MSG(WM_KEYUP, 0, VK_PACKET, .todo_value = TRUE), {0}}},
{0},
};
struct send_input_keyboard_test raw_unicode_nolegacy[] =
{
{.scan = 0x3c0, .flags = KEYEVENTF_UNICODE},
{.scan = 0x3c0, .flags = KEYEVENTF_KEYUP | KEYEVENTF_UNICODE},
{0},
};
struct send_input_keyboard_test raw_unicode_vkey_ctrl_legacy[] =
{
{.scan = 0x3c0, .vkey = VK_CONTROL, .flags = KEYEVENTF_UNICODE,
.expect_state = {[VK_CONTROL] = 0x80, [VK_LCONTROL] = 0x80},
.expect = {KEY_MSG(WM_KEYDOWN, 0xc0, VK_CONTROL), {0}}},
{.scan = 0x3c0, .vkey = VK_CONTROL, .flags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP,
.expect = {KEY_MSG(WM_KEYUP, 0xc0, VK_CONTROL), {0}}},
{0},
};
struct send_input_keyboard_test raw_unicode_vkey_ctrl_nolegacy[] =
{
{.scan = 0x3c0, .vkey = VK_CONTROL, .flags = KEYEVENTF_UNICODE},
{.scan = 0x3c0, .vkey = VK_CONTROL, .flags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP},
{0},
};
#undef WIN_MSG
#undef RAW_KEY
#undef KEY_MSG
@ -1514,6 +1543,9 @@ static void test_SendInput_raw_key_messages( WORD vkey, WORD wch, HKL hkl )
/* get both WM_INPUT and legacy messages */
check_send_input_keyboard_test( raw_legacy, !receive );
check_send_input_keyboard_test( raw_vk_packet_legacy, !receive );
/* no WM_INPUT message for unicode */
check_send_input_keyboard_test( raw_unicode_legacy, !receive );
check_send_input_keyboard_test( raw_unicode_vkey_ctrl_legacy, !receive );
rid.dwFlags = RIDEV_REMOVE;
ok_ret( 1, RegisterRawInputDevices( &rid, 1, sizeof(rid) ) );
@ -1524,6 +1556,9 @@ static void test_SendInput_raw_key_messages( WORD vkey, WORD wch, HKL hkl )
/* get only WM_INPUT messages */
check_send_input_keyboard_test( raw_nolegacy, !receive );
check_send_input_keyboard_test( raw_vk_packet_nolegacy, !receive );
/* no WM_INPUT message for unicode */
check_send_input_keyboard_test( raw_unicode_nolegacy, !receive );
check_send_input_keyboard_test( raw_unicode_vkey_ctrl_nolegacy, !receive );
rid.dwFlags = RIDEV_REMOVE;
ok_ret( 1, RegisterRawInputDevices( &rid, 1, sizeof(rid) ) );

View file

@ -2099,6 +2099,7 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
unsigned int message_code, time;
lparam_t lparam = input->kbd.scan << 16;
unsigned int flags = 0;
BOOL unicode = input->kbd.flags & KEYEVENTF_UNICODE;
int wait;
if (!(time = input->kbd.time)) time = get_tick_count();
@ -2188,7 +2189,7 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
}
}
if ((foreground = get_foreground_thread( desktop, win )))
if (!unicode && (foreground = get_foreground_thread( desktop, win )))
{
struct rawinput_message raw_msg = {0};
raw_msg.foreground = foreground;
@ -2216,7 +2217,7 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
msg->msg = message_code;
if (origin == IMO_INJECTED) msg_data->flags = LLKHF_INJECTED;
if (input->kbd.flags & KEYEVENTF_UNICODE && !vkey)
if (unicode && !vkey)
{
vkey = hook_vkey = VK_PACKET;
}