blob: b8a9206fee6cf03b9f43c70f4c48cceabb40ce1c [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From 18fb45c34a473c4ba247bb82bcea94b7c3ba493a Mon Sep 17 00:00:00 2001
Brad Bishopd5ae7d92018-06-14 09:52:03 -07002From: Ross Burton <ross.burton@intel.com>
3Date: Wed, 18 Sep 2013 14:04:54 +0100
4Subject: [PATCH] sdl.c: allow user to disable pointer grabs
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009When the pointer enters the Qemu window it calls SDL_WM_GrabInput, which calls
10XGrabPointer in a busyloop until it returns GrabSuccess. However if there's already
11a pointer grab (screen is locked, a menu is open) then qemu will hang until the
12grab can be taken. In the specific case of a headless X server on an autobuilder, once
13the screensaver has kicked in any qemu instance that appears underneath the
14pointer will hang.
15
16I'm not entirely sure why pointer grabs are required (the documentation
17explicitly says it doesn't do grabs when using a tablet, which we are) so wrap
18them in a conditional that can be set by the autobuilder environment, preserving
19the current grabbing behaviour for everyone else.
20
21Upstream-Status: Pending
22Signed-off-by: Ross Burton <ross.burton@intel.com>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023Signed-off-by: Eric BĂ©nard <eric@eukrea.com>
24---
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025 ui/sdl.c | 13 +++++++++++--
26 1 file changed, 11 insertions(+), 2 deletions(-)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027
Brad Bishopd5ae7d92018-06-14 09:52:03 -070028diff --git a/ui/sdl.c b/ui/sdl.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080029index a5fd503c25..ab8d1b1eb1 100644
Brad Bishopd5ae7d92018-06-14 09:52:03 -070030--- a/ui/sdl.c
31+++ b/ui/sdl.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080032@@ -68,6 +68,11 @@ static int idle_counter;
33 static const guint16 *keycode_map;
34 static size_t keycode_maplen;
35
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036+#ifndef True
37+#define True 1
38+#endif
39+static doing_grabs = True;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080040+
Brad Bishop316dfdd2018-06-25 12:45:53 -040041 #define SDL_REFRESH_INTERVAL_BUSY 10
42 #define SDL_MAX_IDLE_COUNT (2 * GUI_REFRESH_INTERVAL_DEFAULT \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080043 / SDL_REFRESH_INTERVAL_BUSY + 1)
44@@ -398,14 +403,16 @@ static void sdl_grab_start(void)
Brad Bishop316dfdd2018-06-25 12:45:53 -040045 }
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046 } else
47 sdl_hide_cursor();
48- SDL_WM_GrabInput(SDL_GRAB_ON);
49+ if (doing_grabs)
50+ SDL_WM_GrabInput(SDL_GRAB_ON);
51 gui_grab = 1;
52 sdl_update_caption();
53 }
54
55 static void sdl_grab_end(void)
56 {
57- SDL_WM_GrabInput(SDL_GRAB_OFF);
58+ if (doing_grabs)
59+ SDL_WM_GrabInput(SDL_GRAB_OFF);
60 gui_grab = 0;
61 sdl_show_cursor();
62 sdl_update_caption();
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080063@@ -945,6 +952,8 @@ static void sdl1_display_init(DisplayState *ds, DisplayOptions *o)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064 * This requires SDL >= 1.2.14. */
65 setenv("SDL_DISABLE_LOCK_KEYS", "1", 1);
66
67+ doing_grabs = (getenv("QEMU_DONT_GRAB") == NULL);
68+
69 flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
70 if (SDL_Init (flags)) {
71 fprintf(stderr, "Could not initialize SDL(%s) - exiting\n",