mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-16 15:57:49 +00:00
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>
This commit is contained in:
parent
6659635619
commit
85f94f868f
26
ui/sdl.c
26
ui/sdl.c
@ -461,6 +461,14 @@ static void sdl_show_cursor(void)
|
|||||||
|
|
||||||
static void sdl_grab_start(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) {
|
if (guest_cursor) {
|
||||||
SDL_SetCursor(guest_sprite);
|
SDL_SetCursor(guest_sprite);
|
||||||
if (!kbd_mouse_is_absolute() && !absolute_enabled)
|
if (!kbd_mouse_is_absolute() && !absolute_enabled)
|
||||||
@ -487,12 +495,10 @@ static void absolute_mouse_grab(void)
|
|||||||
{
|
{
|
||||||
int mouse_x, mouse_y;
|
int mouse_x, mouse_y;
|
||||||
|
|
||||||
if (SDL_GetAppState() & SDL_APPINPUTFOCUS) {
|
SDL_GetMouseState(&mouse_x, &mouse_y);
|
||||||
SDL_GetMouseState(&mouse_x, &mouse_y);
|
if (mouse_x > 0 && mouse_x < real_screen->w - 1 &&
|
||||||
if (mouse_x > 0 && mouse_x < real_screen->w - 1 &&
|
mouse_y > 0 && mouse_y < real_screen->h - 1) {
|
||||||
mouse_y > 0 && mouse_y < real_screen->h - 1) {
|
sdl_grab_start();
|
||||||
sdl_grab_start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -745,11 +751,7 @@ static void handle_keyup(DisplayState *ds, SDL_Event *ev)
|
|||||||
if (gui_keysym == 0) {
|
if (gui_keysym == 0) {
|
||||||
/* exit/enter grab if pressing Ctrl-Alt */
|
/* exit/enter grab if pressing Ctrl-Alt */
|
||||||
if (!gui_grab) {
|
if (!gui_grab) {
|
||||||
/* If the application is not active, do not try to enter grab
|
if (is_graphic_console()) {
|
||||||
* state. It prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from
|
|
||||||
* blocking all the application (SDL bug). */
|
|
||||||
if (is_graphic_console() &&
|
|
||||||
SDL_GetAppState() & SDL_APPACTIVE) {
|
|
||||||
sdl_grab_start();
|
sdl_grab_start();
|
||||||
}
|
}
|
||||||
} else if (!gui_fullscreen) {
|
} 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)) {
|
ev->motion.x == max_x || ev->motion.y == max_y)) {
|
||||||
sdl_grab_end();
|
sdl_grab_end();
|
||||||
}
|
}
|
||||||
if (!gui_grab && SDL_GetAppState() & SDL_APPINPUTFOCUS &&
|
if (!gui_grab &&
|
||||||
(ev->motion.x > 0 && ev->motion.x < max_x &&
|
(ev->motion.x > 0 && ev->motion.x < max_x &&
|
||||||
ev->motion.y > 0 && ev->motion.y < max_y)) {
|
ev->motion.y > 0 && ev->motion.y < max_y)) {
|
||||||
sdl_grab_start();
|
sdl_grab_start();
|
||||||
|
Loading…
Reference in New Issue
Block a user