summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/qemu/qemu/0001-sdl.c-allow-user-to-disable-pointer-grabs.patch
blob: 5b9a1f911c9aa26fe7c9a3aabc384a0eec3cd695 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
From c53ddb5acbee56db6423f369b9f9a9b62501b4af Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@intel.com>
Date: Wed, 18 Sep 2013 14:04:54 +0100
Subject: [PATCH] sdl.c: allow user to disable pointer grabs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When the pointer enters the Qemu window it calls SDL_WM_GrabInput, which calls
XGrabPointer in a busyloop until it returns GrabSuccess. However if there's already
a pointer grab (screen is locked, a menu is open) then qemu will hang until the
grab can be taken.  In the specific case of a headless X server on an autobuilder, once
the screensaver has kicked in any qemu instance that appears underneath the
pointer will hang.

I'm not entirely sure why pointer grabs are required (the documentation
explicitly says it doesn't do grabs when using a tablet, which we are) so wrap
them in a conditional that can be set by the autobuilder environment, preserving
the current grabbing behaviour for everyone else.

Upstream-Status: Pending
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Eric BĂ©nard <eric@eukrea.com>

---
 ui/sdl.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/ui/sdl.c b/ui/sdl.c
index 190b16f5..aa89471d 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -69,6 +69,11 @@ static int idle_counter;
 static const guint16 *keycode_map;
 static size_t keycode_maplen;
 
+#ifndef True
+#define True 1
+#endif
+static doing_grabs = True;
+
 #define SDL_REFRESH_INTERVAL_BUSY 10
 #define SDL_MAX_IDLE_COUNT (2 * GUI_REFRESH_INTERVAL_DEFAULT \
                             / SDL_REFRESH_INTERVAL_BUSY + 1)
@@ -399,14 +404,16 @@ static void sdl_grab_start(void)
         }
     } else
         sdl_hide_cursor();
-    SDL_WM_GrabInput(SDL_GRAB_ON);
+    if (doing_grabs)
+      SDL_WM_GrabInput(SDL_GRAB_ON);
     gui_grab = 1;
     sdl_update_caption();
 }
 
 static void sdl_grab_end(void)
 {
-    SDL_WM_GrabInput(SDL_GRAB_OFF);
+    if (doing_grabs)
+      SDL_WM_GrabInput(SDL_GRAB_OFF);
     gui_grab = 0;
     sdl_show_cursor();
     sdl_update_caption();
@@ -945,6 +952,8 @@ static void sdl1_display_init(DisplayState *ds, DisplayOptions *o)
      * This requires SDL >= 1.2.14. */
     setenv("SDL_DISABLE_LOCK_KEYS", "1", 1);
 
+    doing_grabs = (getenv("QEMU_DONT_GRAB") == NULL);
+
     flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
     if (SDL_Init (flags)) {
         fprintf(stderr, "Could not initialize SDL(%s) - exiting\n",