From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmkqC-0005gs-1d for qemu-devel@nongnu.org; Tue, 20 May 2014 10:16:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wmkq5-0004cC-Og for qemu-devel@nongnu.org; Tue, 20 May 2014 10:16:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wmkq5-0004bv-CB for qemu-devel@nongnu.org; Tue, 20 May 2014 10:16:21 -0400 From: Gerd Hoffmann Date: Tue, 20 May 2014 16:00:45 +0200 Message-Id: <1400594447-16637-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1400594447-16637-1-git-send-email-kraxel@redhat.com> References: <1400594447-16637-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 4/6] sdl: pass key event source to input layer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Anthony Liguori So the input layer knows where the input is coming from and input routing works correctly. Signed-off-by: Gerd Hoffmann --- ui/sdl2.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index 361de61..0e884f9 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -190,30 +190,33 @@ static void sdl_switch(DisplayChangeListener *dcl, } } -static void reset_keys(void) +static void reset_keys(struct sdl2_state *scon) { + QemuConsole *con = scon ? scon->dcl.con : NULL; int i; for (i = 0; i < 256; i++) { if (modifiers_state[i]) { int qcode = sdl2_scancode_to_qcode[i]; - qemu_input_event_send_key_qcode(NULL, qcode, false); + qemu_input_event_send_key_qcode(con, qcode, false); modifiers_state[i] = 0; } } } -static void sdl_process_key(SDL_KeyboardEvent *ev) +static void sdl_process_key(struct sdl2_state *scon, + SDL_KeyboardEvent *ev) { int qcode = sdl2_scancode_to_qcode[ev->keysym.scancode]; + QemuConsole *con = scon ? scon->dcl.con : NULL; switch (ev->keysym.scancode) { #if 0 case SDL_SCANCODE_NUMLOCKCLEAR: case SDL_SCANCODE_CAPSLOCK: /* SDL does not send the key up event, so we generate it */ - qemu_input_event_send_key_qcode(NULL, qcode, true); - qemu_input_event_send_key_qcode(NULL, qcode, false); + qemu_input_event_send_key_qcode(con, qcode, true); + qemu_input_event_send_key_qcode(con, qcode, false); return; #endif case SDL_SCANCODE_LCTRL: @@ -231,7 +234,7 @@ static void sdl_process_key(SDL_KeyboardEvent *ev) } /* fall though */ default: - qemu_input_event_send_key_qcode(NULL, qcode, + qemu_input_event_send_key_qcode(con, qcode, ev->type == SDL_KEYDOWN); } } @@ -506,7 +509,7 @@ static void handle_keydown(SDL_Event *ev) } } if (!gui_keysym) { - sdl_process_key(&ev->key); + sdl_process_key(scon, &ev->key); } } @@ -531,13 +534,13 @@ static void handle_keyup(SDL_Event *ev) } /* SDL does not send back all the modifiers key, so we must * correct it. */ - reset_keys(); + reset_keys(scon); return; } gui_keysym = 0; } if (!gui_keysym) { - sdl_process_key(&ev->key); + sdl_process_key(scon, &ev->key); } } -- 1.8.3.1