aboutsummaryrefslogtreecommitdiff
path: root/ui/sdl.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2012-01-31 13:45:27 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2012-02-01 14:45:01 -0600
commit6659635619721f319be80e114a65c3386d9bf8a0 (patch)
treef20593cfdca18249f77c33c635b5bd4d2f69c98b /ui/sdl.c
parent25de59350606772a4df479f0f49721281091ec56 (diff)
downloadqemu-6659635619721f319be80e114a65c3386d9bf8a0.zip
qemu-6659635619721f319be80e114a65c3386d9bf8a0.tar.gz
qemu-6659635619721f319be80e114a65c3386d9bf8a0.tar.bz2
sdl: Do not grab mouse on mode switch while in background
When the mouse mode changes to absolute while the SDL windows is not in focus, refrain from grabbing the input. It would steal from some other window. 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.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/ui/sdl.c b/ui/sdl.c
index 8cafc44..384276d 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -483,12 +483,27 @@ static void sdl_grab_end(void)
sdl_update_caption();
}
+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();
+ }
+ }
+}
+
static void sdl_mouse_mode_change(Notifier *notify, void *data)
{
if (kbd_mouse_is_absolute()) {
if (!absolute_enabled) {
- sdl_grab_start();
absolute_enabled = 1;
+ if (is_graphic_console()) {
+ absolute_mouse_grab();
+ }
}
} else if (absolute_enabled) {
if (!gui_fullscreen) {
@@ -571,19 +586,6 @@ static void toggle_full_screen(DisplayState *ds)
vga_hw_update();
}
-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();
- }
- }
-}
-
static void handle_keydown(DisplayState *ds, SDL_Event *ev)
{
int mod_state;