diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2012-01-31 13:45:28 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-02-01 14:45:02 -0600 |
commit | 85f94f868fcd868f0f605e9d3c1ad6351c557190 (patch) | |
tree | 88aed5321893f9ad23192c9e8cf5a0da9f7799b9 /ui/sdl.c | |
parent | 6659635619721f319be80e114a65c3386d9bf8a0 (diff) |
sdl: Fix block prevention of SDL_WM_GrabInput
Consistently check for SDL_APPINPUTFOCUS before trying to grab the input
focus. Just checking for SDL_APPACTIVE doesn't work. Moving the check to
sdl_grab_start allows for some consolidation.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'ui/sdl.c')
-rw-r--r-- | ui/sdl.c | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -461,6 +461,14 @@ static void sdl_show_cursor(void) static void sdl_grab_start(void) { + /* + * If the application is not active, do not try to enter grab state. This + * prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the + * application (SDL bug). + */ + if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) { + return; + } if (guest_cursor) { SDL_SetCursor(guest_sprite); if (!kbd_mouse_is_absolute() && !absolute_enabled) @@ -487,12 +495,10 @@ static void absolute_mouse_grab(void) { int mouse_x, mouse_y; - if (SDL_GetAppState() & SDL_APPINPUTFOCUS) { - SDL_GetMouseState(&mouse_x, &mouse_y); - if (mouse_x > 0 && mouse_x < real_screen->w - 1 && - mouse_y > 0 && mouse_y < real_screen->h - 1) { - sdl_grab_start(); - } + SDL_GetMouseState(&mouse_x, &mouse_y); + if (mouse_x > 0 && mouse_x < real_screen->w - 1 && + mouse_y > 0 && mouse_y < real_screen->h - 1) { + sdl_grab_start(); } } @@ -745,11 +751,7 @@ static void handle_keyup(DisplayState *ds, SDL_Event *ev) if (gui_keysym == 0) { /* exit/enter grab if pressing Ctrl-Alt */ if (!gui_grab) { - /* If the application is not active, do not try to enter grab - * state. It prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from - * blocking all the application (SDL bug). */ - if (is_graphic_console() && - SDL_GetAppState() & SDL_APPACTIVE) { + if (is_graphic_console()) { sdl_grab_start(); } } else if (!gui_fullscreen) { @@ -779,7 +781,7 @@ static void handle_mousemotion(DisplayState *ds, SDL_Event *ev) ev->motion.x == max_x || ev->motion.y == max_y)) { sdl_grab_end(); } - if (!gui_grab && SDL_GetAppState() & SDL_APPINPUTFOCUS && + if (!gui_grab && (ev->motion.x > 0 && ev->motion.x < max_x && ev->motion.y > 0 && ev->motion.y < max_y)) { sdl_grab_start(); |