server: Create message queue and thread input in get_key_state.
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> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f076e5f854
commit
68b6e876f0
|
@ -3961,8 +3961,8 @@ struct get_key_state_thread_params
|
||||||
int index;
|
int index;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define check_get_keyboard_state(i, j, c, x, todo_x) check_get_keyboard_state_(i, j, c, x, todo_x, __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 todo_x, int line)
|
static void check_get_keyboard_state_(int i, int j, int c, int x, int line)
|
||||||
{
|
{
|
||||||
unsigned char keystate[256];
|
unsigned char keystate[256];
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
@ -3970,24 +3970,24 @@ static void check_get_keyboard_state_(int i, int j, int c, int x, int todo_x, in
|
||||||
memset(keystate, 0, sizeof(keystate));
|
memset(keystate, 0, sizeof(keystate));
|
||||||
ret = GetKeyboardState(keystate);
|
ret = GetKeyboardState(keystate);
|
||||||
ok_(__FILE__, line)(ret, "GetKeyboardState failed, %lu\n", GetLastError());
|
ok_(__FILE__, line)(ret, "GetKeyboardState failed, %lu\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");
|
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 */
|
/* calling it twice shouldn't change */
|
||||||
memset(keystate, 0, sizeof(keystate));
|
memset(keystate, 0, sizeof(keystate));
|
||||||
ret = GetKeyboardState(keystate);
|
ret = GetKeyboardState(keystate);
|
||||||
ok_(__FILE__, line)(ret, "GetKeyboardState failed, %lu\n", GetLastError());
|
ok_(__FILE__, line)(ret, "GetKeyboardState failed, %lu\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");
|
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__)
|
#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 todo_x, int line)
|
static void check_get_key_state_(int i, int j, int c, int x, int line)
|
||||||
{
|
{
|
||||||
SHORT state;
|
SHORT state;
|
||||||
|
|
||||||
state = GetKeyState('X');
|
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);
|
ok_(__FILE__, line)(!(state & 0x007e), "%d:%d: expected that X undefined bits are unset, got %#x\n", i, j, state);
|
||||||
|
|
||||||
state = GetKeyState('C');
|
state = GetKeyState('C');
|
||||||
|
@ -4041,18 +4041,18 @@ static DWORD WINAPI get_key_state_thread(void *arg)
|
||||||
if (test->set_keyboard_state) expect_c = TRUE;
|
if (test->set_keyboard_state) expect_c = TRUE;
|
||||||
else expect_c = FALSE;
|
else expect_c = FALSE;
|
||||||
|
|
||||||
check_get_keyboard_state(i, j, expect_c, FALSE, /* todo */ !has_queue);
|
check_get_keyboard_state(i, j, expect_c, FALSE);
|
||||||
check_get_key_state(i, j, expect_c, expect_x, /* todo */ !has_queue && j == 0);
|
check_get_key_state(i, j, expect_c, expect_x);
|
||||||
check_get_keyboard_state(i, j, expect_c, expect_x, /* todo */ !has_queue && j == 0);
|
check_get_keyboard_state(i, j, expect_c, expect_x);
|
||||||
|
|
||||||
/* key released */
|
/* key released */
|
||||||
ReleaseSemaphore(semaphores[0], 1, NULL);
|
ReleaseSemaphore(semaphores[0], 1, NULL);
|
||||||
result = WaitForSingleObject(semaphores[1], 1000);
|
result = WaitForSingleObject(semaphores[1], 1000);
|
||||||
ok(result == WAIT_OBJECT_0, "%d: WaitForSingleObject returned %lu\n", i, result);
|
ok(result == WAIT_OBJECT_0, "%d: WaitForSingleObject returned %lu\n", i, result);
|
||||||
|
|
||||||
check_get_keyboard_state(i, j, expect_c, expect_x, /* todo */ !has_queue && j > 0);
|
check_get_keyboard_state(i, j, expect_c, expect_x);
|
||||||
check_get_key_state(i, j, expect_c, FALSE, /* todo */ FALSE);
|
check_get_key_state(i, j, expect_c, FALSE);
|
||||||
check_get_keyboard_state(i, j, expect_c, FALSE, /* todo */ FALSE);
|
check_get_keyboard_state(i, j, expect_c, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4120,18 +4120,18 @@ static void test_GetKeyState(void)
|
||||||
}
|
}
|
||||||
else expect_c = FALSE;
|
else expect_c = 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, /* todo */ FALSE);
|
check_get_key_state(i, j, expect_c, FALSE);
|
||||||
check_get_keyboard_state(i, j, expect_c, FALSE, /* todo */ 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) while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
|
||||||
|
|
||||||
if (test->peek_message_main) expect_x = TRUE;
|
if (test->peek_message_main) expect_x = TRUE;
|
||||||
else expect_x = FALSE;
|
else expect_x = 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, /* todo */ FALSE);
|
check_get_key_state(i, j, expect_c, expect_x);
|
||||||
check_get_keyboard_state(i, j, expect_c, expect_x, /* todo */ FALSE);
|
check_get_keyboard_state(i, j, expect_c, expect_x);
|
||||||
|
|
||||||
ReleaseSemaphore(params.semaphores[1], 1, NULL);
|
ReleaseSemaphore(params.semaphores[1], 1, NULL);
|
||||||
|
|
||||||
|
@ -4147,15 +4147,15 @@ static void test_GetKeyState(void)
|
||||||
SetKeyboardState(keystate);
|
SetKeyboardState(keystate);
|
||||||
}
|
}
|
||||||
|
|
||||||
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, /* todo */ FALSE);
|
check_get_key_state(i, j, FALSE, expect_x);
|
||||||
check_get_keyboard_state(i, j, FALSE, expect_x, /* todo */ FALSE);
|
check_get_keyboard_state(i, j, FALSE, expect_x);
|
||||||
|
|
||||||
if (test->peek_message_main) while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
|
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_keyboard_state(i, j, FALSE, FALSE);
|
||||||
check_get_key_state(i, j, FALSE, FALSE, /* todo */ FALSE);
|
check_get_key_state(i, j, FALSE, FALSE);
|
||||||
check_get_keyboard_state(i, j, FALSE, FALSE, /* todo */ FALSE);
|
check_get_keyboard_state(i, j, FALSE, FALSE);
|
||||||
|
|
||||||
ReleaseSemaphore(params.semaphores[1], 1, NULL);
|
ReleaseSemaphore(params.semaphores[1], 1, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3098,25 +3098,13 @@ DECL_HANDLER(get_key_state)
|
||||||
set_reply_data( desktop->keystate, size );
|
set_reply_data( desktop->keystate, size );
|
||||||
release_object( desktop );
|
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
|
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 (req->key >= 0)
|
||||||
{
|
{
|
||||||
if (current->queue) sync_input_keystate( current->queue->input );
|
sync_input_keystate( queue->input );
|
||||||
reply->state = keystate[req->key & 0xff];
|
reply->state = keystate[req->key & 0xff];
|
||||||
}
|
}
|
||||||
set_reply_data( keystate, size );
|
set_reply_data( keystate, size );
|
||||||
|
|
Loading…
Reference in New Issue