From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LNPxX-00007I-SR for qemu-devel@nongnu.org; Thu, 15 Jan 2009 06:00:23 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LNPxV-00005E-BI for qemu-devel@nongnu.org; Thu, 15 Jan 2009 06:00:22 -0500 Received: from [199.232.76.173] (port=35985 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LNPxU-000055-C9 for qemu-devel@nongnu.org; Thu, 15 Jan 2009 06:00:20 -0500 Received: from mail06.svc.cra.dublin.eircom.net ([159.134.118.22]:37637) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1LNPxT-00088z-KX for qemu-devel@nongnu.org; Thu, 15 Jan 2009 06:00:19 -0500 From: Mark McLoughlin Date: Thu, 15 Jan 2009 11:00:17 +0000 Message-Id: <1232017217-29545-1-git-send-email-markmc@redhat.com> Subject: [Qemu-devel] [PATCH] Handle SDL grabs failing Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Mark McLoughlin If a X window is not viewable, XGrabPointer() fails and returns GrabNotViewable. SDL's X backend currently handles this by retrying the grab until the window becomes viewable again. This means e.g. if you Ctrl-Alt-RightArrow to switch workspaces, QEMU tries to grab, SDL blocks because the window isn't viewable and your guest stops executing until you switch back to that workspace again. See this Fedora bug for the gory details: https://bugzilla.redhat.com/480065 Some SDL backends will return SDL_GRAB_OFF from SDL_WM_GrabInput(), so the fix is to make the X backend do this if the grab fails. The only side-effect in QEMU is that if SDL_WM_GrabInput() fails we still change the window title to indicate that it's grabbed, when in fact it's not. This patch fixes that minor issue. Signed-off-by: Mark McLoughlin --- sdl.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sdl.c b/sdl.c index 15427c5..2ce6e81 100644 --- a/sdl.c +++ b/sdl.c @@ -286,9 +286,12 @@ static void sdl_grab_start(void) SDL_WarpMouse(guest_x, guest_y); } else sdl_hide_cursor(); - SDL_WM_GrabInput(SDL_GRAB_ON); - gui_grab = 1; - sdl_update_caption(); + + if (SDL_WM_GrabInput(SDL_GRAB_ON) == SDL_GRAB_ON) { + gui_grab = 1; + sdl_update_caption(); + } else + sdl_show_cursor(); } static void sdl_grab_end(void) -- 1.6.0.6