Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From 18fb45c34a473c4ba247bb82bcea94b7c3ba493a Mon Sep 17 00:00:00 2001 |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 2 | From: Ross Burton <ross.burton@intel.com> |
| 3 | Date: Wed, 18 Sep 2013 14:04:54 +0100 |
| 4 | Subject: [PATCH] sdl.c: allow user to disable pointer grabs |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | When the pointer enters the Qemu window it calls SDL_WM_GrabInput, which calls |
| 10 | XGrabPointer in a busyloop until it returns GrabSuccess. However if there's already |
| 11 | a pointer grab (screen is locked, a menu is open) then qemu will hang until the |
| 12 | grab can be taken. In the specific case of a headless X server on an autobuilder, once |
| 13 | the screensaver has kicked in any qemu instance that appears underneath the |
| 14 | pointer will hang. |
| 15 | |
| 16 | I'm not entirely sure why pointer grabs are required (the documentation |
| 17 | explicitly says it doesn't do grabs when using a tablet, which we are) so wrap |
| 18 | them in a conditional that can be set by the autobuilder environment, preserving |
| 19 | the current grabbing behaviour for everyone else. |
| 20 | |
| 21 | Upstream-Status: Pending |
| 22 | Signed-off-by: Ross Burton <ross.burton@intel.com> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | Signed-off-by: Eric BĂ©nard <eric@eukrea.com> |
| 24 | --- |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 25 | ui/sdl.c | 13 +++++++++++-- |
| 26 | 1 file changed, 11 insertions(+), 2 deletions(-) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 28 | diff --git a/ui/sdl.c b/ui/sdl.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 29 | index a5fd503c25..ab8d1b1eb1 100644 |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 30 | --- a/ui/sdl.c |
| 31 | +++ b/ui/sdl.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 32 | @@ -68,6 +68,11 @@ static int idle_counter; |
| 33 | static const guint16 *keycode_map; |
| 34 | static size_t keycode_maplen; |
| 35 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | +#ifndef True |
| 37 | +#define True 1 |
| 38 | +#endif |
| 39 | +static doing_grabs = True; |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 40 | + |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 41 | #define SDL_REFRESH_INTERVAL_BUSY 10 |
| 42 | #define SDL_MAX_IDLE_COUNT (2 * GUI_REFRESH_INTERVAL_DEFAULT \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 43 | / SDL_REFRESH_INTERVAL_BUSY + 1) |
| 44 | @@ -398,14 +403,16 @@ static void sdl_grab_start(void) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 45 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | } 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 63 | @@ -945,6 +952,8 @@ static void sdl1_display_init(DisplayState *ds, DisplayOptions *o) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | * 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", |