This removes the fallback to desktop async keystate and uses instead the keystate synchronization logic in all cases.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=26269 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=27238 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=31899 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=35907 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45385 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/input.c | 50 +++++++++++++++++++-------------------- server/queue.c | 18 +++----------- 2 files changed, 28 insertions(+), 40 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 246569961be..561f932b18b 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -3761,8 +3761,8 @@ struct get_key_state_thread_params int index; };
-#define check_get_keyboard_state(i, j, c, x, todo_x) check_get_keyboard_state_(i, j, c, x, todo_x, __LINE__) -static void check_get_keyboard_state_(int i, int j, int c, int x, int todo_x, int line) +#define check_get_keyboard_state(i, j, c, x) check_get_keyboard_state_(i, j, c, x, __LINE__) +static void check_get_keyboard_state_(int i, int j, int c, int x, int line) { unsigned char keystate[256]; BOOL ret; @@ -3770,24 +3770,24 @@ static void check_get_keyboard_state_(int i, int j, int c, int x, int todo_x, in memset(keystate, 0, sizeof(keystate)); ret = GetKeyboardState(keystate); ok_(__FILE__, line)(ret, "GetKeyboardState failed, %u\n", GetLastError()); - todo_wine_if(todo_x) ok_(__FILE__, line)(!(keystate['X'] & 0x80) == !x, "%d:%d: expected that X keystate is %s\n", i, j, x ? "set" : "unset"); + ok_(__FILE__, line)(!(keystate['X'] & 0x80) == !x, "%d:%d: expected that X keystate is %s\n", i, j, x ? "set" : "unset"); ok_(__FILE__, line)(!(keystate['C'] & 0x80) == !c, "%d:%d: expected that C keystate is %s\n", i, j, c ? "set" : "unset");
/* calling it twice shouldn't change */ memset(keystate, 0, sizeof(keystate)); ret = GetKeyboardState(keystate); ok_(__FILE__, line)(ret, "GetKeyboardState failed, %u\n", GetLastError()); - todo_wine_if(todo_x) ok_(__FILE__, line)(!(keystate['X'] & 0x80) == !x, "%d:%d: expected that X keystate is %s\n", i, j, x ? "set" : "unset"); + ok_(__FILE__, line)(!(keystate['X'] & 0x80) == !x, "%d:%d: expected that X keystate is %s\n", i, j, x ? "set" : "unset"); ok_(__FILE__, line)(!(keystate['C'] & 0x80) == !c, "%d:%d: expected that C keystate is %s\n", i, j, c ? "set" : "unset"); }
-#define check_get_key_state(i, j, c, x, todo_x) check_get_key_state_(i, j, c, x, todo_x, __LINE__) -static void check_get_key_state_(int i, int j, int c, int x, int todo_x, int line) +#define check_get_key_state(i, j, c, x) check_get_key_state_(i, j, c, x, __LINE__) +static void check_get_key_state_(int i, int j, int c, int x, int line) { SHORT state;
state = GetKeyState('X'); - todo_wine_if(todo_x) ok_(__FILE__, line)(!(state & 0x8000) == !x, "%d:%d: expected that X highest bit is %s, got %#x\n", i, j, x ? "set" : "unset", state); + ok_(__FILE__, line)(!(state & 0x8000) == !x, "%d:%d: expected that X highest bit is %s, got %#x\n", i, j, x ? "set" : "unset", state); ok_(__FILE__, line)(!(state & 0x007e), "%d:%d: expected that X undefined bits are unset, got %#x\n", i, j, state);
state = GetKeyState('C'); @@ -3841,18 +3841,18 @@ static DWORD WINAPI get_key_state_thread(void *arg) if (test->set_keyboard_state) expect_c = TRUE; else expect_c = FALSE;
- check_get_keyboard_state(i, j, expect_c, FALSE, /* todo */ !has_queue); - check_get_key_state(i, j, expect_c, expect_x, /* todo */ !has_queue && j == 0); - check_get_keyboard_state(i, j, expect_c, expect_x, /* todo */ !has_queue && j == 0); + check_get_keyboard_state(i, j, expect_c, FALSE); + check_get_key_state(i, j, expect_c, expect_x); + check_get_keyboard_state(i, j, expect_c, expect_x);
/* key released */ ReleaseSemaphore(semaphores[0], 1, NULL); result = WaitForSingleObject(semaphores[1], 1000); ok(result == WAIT_OBJECT_0, "%d: WaitForSingleObject returned %u\n", i, result);
- check_get_keyboard_state(i, j, expect_c, expect_x, /* todo */ !has_queue && j > 0); - check_get_key_state(i, j, expect_c, FALSE, /* todo */ FALSE); - check_get_keyboard_state(i, j, expect_c, FALSE, /* todo */ FALSE); + check_get_keyboard_state(i, j, expect_c, expect_x); + check_get_key_state(i, j, expect_c, FALSE); + check_get_keyboard_state(i, j, expect_c, FALSE); }
return 0; @@ -3920,18 +3920,18 @@ static void test_GetKeyState(void) } else expect_c = FALSE;
- check_get_keyboard_state(i, j, expect_c, FALSE, /* todo */ FALSE); - check_get_key_state(i, j, expect_c, FALSE, /* todo */ FALSE); - check_get_keyboard_state(i, j, expect_c, FALSE, /* todo */ FALSE); + check_get_keyboard_state(i, j, expect_c, FALSE); + check_get_key_state(i, j, expect_c, FALSE); + check_get_keyboard_state(i, j, expect_c, FALSE);
if (test->peek_message_main) while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
if (test->peek_message_main) expect_x = TRUE; else expect_x = FALSE;
- check_get_keyboard_state(i, j, expect_c, expect_x, /* todo */ FALSE); - check_get_key_state(i, j, expect_c, expect_x, /* todo */ FALSE); - check_get_keyboard_state(i, j, expect_c, expect_x, /* todo */ FALSE); + check_get_keyboard_state(i, j, expect_c, expect_x); + check_get_key_state(i, j, expect_c, expect_x); + check_get_keyboard_state(i, j, expect_c, expect_x);
ReleaseSemaphore(params.semaphores[1], 1, NULL);
@@ -3947,15 +3947,15 @@ static void test_GetKeyState(void) SetKeyboardState(keystate); }
- check_get_keyboard_state(i, j, FALSE, expect_x, /* todo */ FALSE); - check_get_key_state(i, j, FALSE, expect_x, /* todo */ FALSE); - check_get_keyboard_state(i, j, FALSE, expect_x, /* todo */ FALSE); + check_get_keyboard_state(i, j, FALSE, expect_x); + check_get_key_state(i, j, FALSE, expect_x); + check_get_keyboard_state(i, j, FALSE, expect_x);
if (test->peek_message_main) while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
- check_get_keyboard_state(i, j, FALSE, FALSE, /* todo */ FALSE); - check_get_key_state(i, j, FALSE, FALSE, /* todo */ FALSE); - check_get_keyboard_state(i, j, FALSE, FALSE, /* todo */ FALSE); + check_get_keyboard_state(i, j, FALSE, FALSE); + check_get_key_state(i, j, FALSE, FALSE); + check_get_keyboard_state(i, j, FALSE, FALSE);
ReleaseSemaphore(params.semaphores[1], 1, NULL); } diff --git a/server/queue.c b/server/queue.c index 0782c526327..fce65e360d4 100644 --- a/server/queue.c +++ b/server/queue.c @@ -3025,25 +3025,13 @@ DECL_HANDLER(get_key_state) set_reply_data( desktop->keystate, size ); release_object( desktop ); } - else if (!current->queue) - { - unsigned char *keystate; - /* fallback to desktop keystate */ - if (!(desktop = get_thread_desktop( current, 0 ))) return; - if (req->key >= 0) reply->state = desktop->keystate[req->key & 0xff] & ~0x40; - if ((keystate = set_reply_data_size( size ))) - { - unsigned int i; - for (i = 0; i < size; i++) keystate[i] = desktop->keystate[i] & ~0x40; - } - release_object( desktop ); - } else { - unsigned char *keystate = current->queue->input->keystate; + struct msg_queue *queue = get_current_queue(); + unsigned char *keystate = queue->input->keystate; if (req->key >= 0) { - if (current->queue) sync_input_keystate( current->queue->input ); + sync_input_keystate( queue->input ); reply->state = keystate[req->key & 0xff]; } set_reply_data( keystate, size );