server: Use a separate variable to determine the message on Alt release.

Based on a patch by Huw Davies.
This commit is contained in:
Rémi Bernon 2024-06-20 23:59:52 +02:00 committed by Alexandre Julliard
parent 5b013260d1
commit 534aff4a63
3 changed files with 7 additions and 6 deletions

View file

@ -2171,17 +2171,16 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
if (input->kbd.flags & KEYEVENTF_KEYUP)
{
/* send WM_SYSKEYUP if Alt still pressed and no other key in between */
/* we use 0x02 as a flag to track if some other SYSKEYUP was sent already */
if ((desktop->keystate[VK_MENU] & 0x82) != 0x82) break;
if (!(desktop->keystate[VK_MENU] & 0x80) || !desktop->alt_pressed) break;
message_code = WM_SYSKEYUP;
desktop->keystate[VK_MENU] &= ~0x02;
desktop->alt_pressed = 0;
}
else
{
/* send WM_SYSKEYDOWN for Alt except with Ctrl */
if (desktop->keystate[VK_CONTROL] & 0x80) break;
message_code = WM_SYSKEYDOWN;
desktop->keystate[VK_MENU] |= 0x02;
desktop->alt_pressed = 1;
}
break;
@ -2191,7 +2190,7 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
if (!(input->kbd.flags & KEYEVENTF_KEYUP)) break;
if (!(desktop->keystate[VK_MENU] & 0x80)) break;
message_code = WM_SYSKEYUP;
desktop->keystate[VK_MENU] &= ~0x02;
desktop->alt_pressed = 0;
break;
default:
@ -2201,7 +2200,7 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
/* fall through */
case VK_F10:
message_code = (input->kbd.flags & KEYEVENTF_KEYUP) ? WM_SYSKEYUP : WM_SYSKEYDOWN;
desktop->keystate[VK_MENU] &= ~0x02;
desktop->alt_pressed = 0;
break;
}

View file

@ -81,6 +81,7 @@ struct desktop
struct thread_input *foreground_input; /* thread input of foreground thread */
unsigned int users; /* processes and threads using this desktop */
unsigned char keystate[256]; /* asynchronous key state */
unsigned char alt_pressed; /* last key press was Alt (used to determine msg on release) */
struct key_repeat key_repeat; /* key auto-repeat */
unsigned int clip_flags; /* last cursor clip flags */
user_handle_t cursor_win; /* window that contains the cursor */

View file

@ -294,6 +294,7 @@ static struct desktop *create_desktop( const struct unicode_str *name, unsigned
list_init( &desktop->threads );
desktop->clip_flags = 0;
desktop->cursor_win = 0;
desktop->alt_pressed = 0;
memset( desktop->keystate, 0, sizeof(desktop->keystate) );
memset( &desktop->key_repeat, 0, sizeof(desktop->key_repeat) );
list_add_tail( &winstation->desktops, &desktop->entry );