From 36c76dcc24c1f66ccbfeb55495da4794c74dc868 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 2 Feb 2012 17:19:34 +0100 Subject: [PATCH] winex11: Update only the key state on KeymapNotify without sending fake key events. --- dlls/winex11.drv/keyboard.c | 54 ++++++++++++++++++++++++---------- include/wine/server_protocol.h | 4 ++- server/protocol.def | 1 + server/queue.c | 5 ++++ server/request.h | 3 +- server/trace.c | 1 + 6 files changed, 50 insertions(+), 18 deletions(-) diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 160b98689c2..57deb59b2cf 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1175,6 +1175,31 @@ static BOOL get_async_key_state( BYTE state[256] ) return ret; } +/*********************************************************************** + * set_async_key_state + */ +static void set_async_key_state( const BYTE state[256] ) +{ + SERVER_START_REQ( set_key_state ) + { + req->tid = GetCurrentThreadId(); + req->async = 1; + wine_server_add_data( req, state, 256 ); + wine_server_call( req ); + } + SERVER_END_REQ; +} + +static void update_key_state( BYTE *keystate, BYTE key, int down ) +{ + if (down) + { + if (!(keystate[key] & 0x80)) keystate[key] ^= 0x01; + keystate[key] |= 0x80; + } + else keystate[key] &= ~0x80; +} + /*********************************************************************** * X11DRV_KeymapNotify * @@ -1187,12 +1212,11 @@ static BOOL get_async_key_state( BYTE state[256] ) void X11DRV_KeymapNotify( HWND hwnd, XEvent *event ) { int i, j; - DWORD time = GetCurrentTime(); BYTE keystate[256]; WORD vkey; + BOOL changed = FALSE; struct { WORD vkey; - WORD scan; BOOL pressed; } modifiers[6]; /* VK_LSHIFT through VK_RMENU are contiguous */ @@ -1220,15 +1244,9 @@ void X11DRV_KeymapNotify( HWND hwnd, XEvent *event ) case VK_LSHIFT: case VK_RSHIFT: m = (vkey & 0xff) - VK_LSHIFT; - /* Take the vkey and scan from the first keycode we encounter - for this modifier. */ - if (!modifiers[m].vkey) - { - modifiers[m].vkey = vkey; - modifiers[m].scan = keyc2scan[(i * 8) + j]; - } - if (event->xkeymap.key_vector[i] & (1<xkeymap.key_vector[i] & (1<tid ))) return; if (thread->queue) memcpy( thread->queue->input->keystate, get_req_data(), size ); + if (req->async && (desktop = get_thread_desktop( thread, 0 ))) + { + memcpy( desktop->keystate, get_req_data(), size ); + release_object( desktop ); + } release_object( thread ); } } diff --git a/server/request.h b/server/request.h index c1cca4c2318..5b45cf97adb 100644 --- a/server/request.h +++ b/server/request.h @@ -1756,7 +1756,8 @@ C_ASSERT( sizeof(struct get_key_state_request) == 24 ); C_ASSERT( FIELD_OFFSET(struct get_key_state_reply, state) == 8 ); C_ASSERT( sizeof(struct get_key_state_reply) == 16 ); C_ASSERT( FIELD_OFFSET(struct set_key_state_request, tid) == 12 ); -C_ASSERT( sizeof(struct set_key_state_request) == 16 ); +C_ASSERT( FIELD_OFFSET(struct set_key_state_request, async) == 16 ); +C_ASSERT( sizeof(struct set_key_state_request) == 24 ); C_ASSERT( FIELD_OFFSET(struct set_foreground_window_request, handle) == 12 ); C_ASSERT( sizeof(struct set_foreground_window_request) == 16 ); C_ASSERT( FIELD_OFFSET(struct set_foreground_window_reply, previous) == 8 ); diff --git a/server/trace.c b/server/trace.c index b8dc316b479..cfef963ae9e 100644 --- a/server/trace.c +++ b/server/trace.c @@ -3162,6 +3162,7 @@ static void dump_get_key_state_reply( const struct get_key_state_reply *req ) static void dump_set_key_state_request( const struct set_key_state_request *req ) { fprintf( stderr, " tid=%04x", req->tid ); + fprintf( stderr, ", async=%d", req->async ); dump_varargs_bytes( ", keystate=", cur_size ); }