Commit 7b03cbda authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

win32u: Implement opt-in auto-repeat for WM_(SYS)KEYDOWN messages.

parent c36b4193
......@@ -2292,6 +2292,22 @@ static void send_parent_notify( HWND hwnd, WORD event, WORD idChild, POINT pt )
}
}
static void handle_keyboard_repeat_message( HWND hwnd )
{
struct user_thread_info *thread_info = get_user_thread_info();
MSG *msg = &thread_info->key_repeat_msg;
UINT speed;
msg->lParam = (msg->lParam & ~(LPARAM)0xffff) + ((msg->lParam + 1) & 0xffff);
if (NtUserSystemParametersInfo( SPI_GETKEYBOARDSPEED, 0, &speed, 0 ))
NtUserSetSystemTimer( hwnd, SYSTEM_TIMER_KEY_REPEAT, 400 / (speed + 1) );
NtUserPostMessage( hwnd, msg->message, msg->wParam, msg->lParam );
}
/***********************************************************************
* process_keyboard_message
*
......@@ -2371,6 +2387,33 @@ static BOOL process_keyboard_message( MSG *msg, UINT hw_id, HWND hwnd_filter,
if (ImmProcessKey( msg->hwnd, NtUserGetKeyboardLayout(0), msg->wParam, msg->lParam, 0 ))
msg->wParam = VK_PROCESSKEY;
/* set/kill timers for key auto-repeat */
if (remove && keyboard_auto_repeat_enabled)
{
struct user_thread_info *thread_info = get_user_thread_info();
switch (msg->message)
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
{
UINT delay;
if (msg->wParam == VK_PROCESSKEY) break;
thread_info->key_repeat_msg = *msg;
if (NtUserSystemParametersInfo( SPI_GETKEYBOARDDELAY, 0, &delay, 0 ))
NtUserSetSystemTimer( msg->hwnd, SYSTEM_TIMER_KEY_REPEAT, (delay + 1) * 250 );
break;
}
case WM_KEYUP:
case WM_SYSKEYUP:
kill_system_timer( thread_info->key_repeat_msg.hwnd, SYSTEM_TIMER_KEY_REPEAT );
break;
}
}
return TRUE;
}
......@@ -3565,6 +3608,10 @@ LRESULT WINAPI NtUserDispatchMessage( const MSG *msg )
case SYSTEM_TIMER_TRACK_MOUSE:
update_mouse_tracking_info( msg->hwnd );
return 0;
case SYSTEM_TIMER_KEY_REPEAT:
handle_keyboard_repeat_message( msg->hwnd );
return 0;
}
}
......
......@@ -32,6 +32,9 @@ enum system_timer_id
{
SYSTEM_TIMER_TRACK_MOUSE = 0xfffa,
SYSTEM_TIMER_CARET = 0xffff,
/* not compatible with native */
SYSTEM_TIMER_KEY_REPEAT = 0xfff0,
};
struct rawinput_thread_data
......@@ -126,6 +129,7 @@ struct user_thread_info
struct received_message_info *receive_info; /* Message being currently received */
struct user_key_state_info *key_state; /* Cache of global key state */
struct imm_thread_data *imm_thread_data; /* IMM thread data */
MSG key_repeat_msg; /* Last WM_KEYDOWN message to repeat */
HKL kbd_layout; /* Current keyboard layout */
UINT kbd_layout_id; /* Current keyboard layout ID */
struct rawinput_thread_data *rawinput; /* RawInput thread local data / buffer */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment