Release modifier keys (including Meta) on loss of focus
cover Release modifier keys (including Meta) on loss of focus
I got tired of my guests thinking that the logo key was being constantly held down whenever I used Meta-Tab to switch away from the qemu window.
It turns out that both the "clear modifiers on focus loss" feature in the SDL front-end was broken and Meta (i.e. the "logo" keys) wasn't being considered a modifier.
PATCH 1/2 Fix clearing modifiers on focus loss
It seems there is an intention to clear all modifier keys (in the SDL front-end) when the window loses focus, but it seems that it doesn't work right. Let's just explicitly do it when we lose input focus.
--- sdl.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
sdl.c +3 -0
@@ -728,6 +728,9 @@ static void sdl_refresh(DisplayState *ds) }break ;case SDL_ACTIVEEVENT : +if (ev->active.state ==SDL_APPINPUTFOCUS && !ev->active.gain) { +reset_keys (); + }if (gui_grab && ev->active.state ==SDL_APPINPUTFOCUS && !ev->active.gain && !gui_fullscreen_initial_grab) {sdl_grab_end ();
Signature · 1 line
1.7.1
PATCH 2/2 Count "logo" keys as modifier keys
In reply to Brad JorschThese are often mapped to Meta on Linux. And I for one use Meta-Tab as the equivalent of Windows's Alt-Tab, so not having it marked as a modifier leaves the guest thinking it's permanently pressed.
--- sdl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
sdl.c +2 -0
@@ -385,6 +385,8 @@ static void sdl_process_key(SDL_KeyboardEvent *ev)case 0x9d :/* Right CTRL */ case 0x38 :/* Left ALT */ case 0xb8 :/* Right ALT */ +case 0xdb :/* Left META */ +case 0xdc :/* Right META */ if (ev->type ==SDL_KEYUP ) modifiers_state[keycode] =0 ;else
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 2/2] Count "logo" keys as modifier keys
Quoted 6 lines · Brad Jorsch
These are often mapped to Meta on Linux. And I for one use Meta-Tab as the equivalent of Windows's Alt-Tab, so not having it marked as a modifier leaves the guest thinking it's permanently pressed.
Signed-off-by Brad Jorsch<[email protected]>
Seems reasonable.
Regards,
Anthony Liguori
Quoted 18 lines
--- sdl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)sdl.c +2
-0@@ -385,6 +385,8 @@ static void sdl_process_key(SDL_KeyboardEvent *ev)case 0x9d :/* Right CTRL */ case 0x38 :/* Left ALT */ case 0xb8 :/* Right ALT */ +case 0xdb :/* Left META */ +case 0xdc :/* Right META */ if (ev->type ==SDL_KEYUP ) modifiers_state[keycode] =0 ;else