diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2019-01-22 10:28:09 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2019-02-05 10:45:44 +0100 |
commit | 07333e1ca382ed570d781a99ee8c168cb8b252d0 (patch) | |
tree | 43ef04392035a82df938d6142feb7951bfdb7eee /ui/sdl2.c | |
parent | 85b03694e1843141eaf851fb15300ae12cc76468 (diff) |
kbd-state: use state tracker for sdl2
Use the new keyboard state tracked for sdl2. We can drop the modifier
state tracking from sdl2. Also keyup code is simpler, the state tracker
will take care to not send suspious keyup events to the guest.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20190122092814.14919-4-kraxel@redhat.com
Diffstat (limited to 'ui/sdl2.c')
-rw-r--r-- | ui/sdl2.c | 12 |
1 files changed, 3 insertions, 9 deletions
@@ -38,7 +38,6 @@ static int gui_grab; /* if true, all keyboard/mouse events are grabbed */ static int gui_saved_grab; static int gui_fullscreen; -static int gui_keysym; static int gui_grab_code = KMOD_LALT | KMOD_LCTRL; static SDL_Cursor *sdl_cursor_normal; static SDL_Cursor *sdl_cursor_hidden; @@ -330,6 +329,7 @@ static void handle_keydown(SDL_Event *ev) int win; struct sdl2_console *scon = get_scon_from_window(ev->key.windowID); int gui_key_modifier_pressed = get_mod_state(); + int gui_keysym = 0; if (!scon->ignore_hotkeys && gui_key_modifier_pressed && !ev->key.repeat) { switch (ev->key.keysym.scancode) { @@ -410,16 +410,9 @@ static void handle_keydown(SDL_Event *ev) static void handle_keyup(SDL_Event *ev) { struct sdl2_console *scon = get_scon_from_window(ev->key.windowID); - int gui_key_modifier_pressed = get_mod_state(); scon->ignore_hotkeys = false; - - if (!gui_key_modifier_pressed) { - gui_keysym = 0; - } - if (!gui_keysym) { - sdl2_process_key(scon, &ev->key); - } + sdl2_process_key(scon, &ev->key); } static void handle_textinput(SDL_Event *ev) @@ -823,6 +816,7 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o) sdl2_console[i].dcl.ops = &dcl_2d_ops; #endif sdl2_console[i].dcl.con = con; + sdl2_console[i].kbd = qkbd_state_init(con); register_displaychangelistener(&sdl2_console[i].dcl); #if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_X11) |