From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BlFFB-0005yy-0i for qemu-devel@nongnu.org; Thu, 15 Jul 2004 19:02:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BlFF9-0005yS-Pj for qemu-devel@nongnu.org; Thu, 15 Jul 2004 19:02:24 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BlFF9-0005y6-8Q for qemu-devel@nongnu.org; Thu, 15 Jul 2004 19:02:23 -0400 Received: from [38.113.3.51] (helo=snickers.hotpop.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BlFCE-0004LO-N1 for qemu-devel@nongnu.org; Thu, 15 Jul 2004 18:59:22 -0400 Received: from phreaker.net (kubrick.hotpop.com [38.113.3.103]) by snickers.hotpop.com (Postfix) with SMTP id 62F0A72EF0 for ; Thu, 15 Jul 2004 21:50:29 +0000 (UTC) Received: from jbrown.mylinuxbox.org (pcp03144805pcs.midval01.tn.comcast.net [68.59.228.236]) by smtp-1.hotpop.com (Postfix) with ESMTP id B0CA61A01D4 for ; Thu, 15 Jul 2004 21:50:26 +0000 (UTC) Date: Thu, 15 Jul 2004 18:59:08 -0400 From: "Jim C. Brown" Message-ID: <20040715225908.GA6237@jbrown.mylinuxbox.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="PNTmBPCT7hxwcZjr" Content-Disposition: inline Subject: [Qemu-devel] no-sdl-grab patch 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 --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This patch adds a command line option, "-no-sdl-grab". If you use this option then qemu won't grab the mouse but instead will have the guest mouse "follow" the host mouse pointer. Ctrl-Shift still works, it toggles following in the same way it toggles grabbing. Press Ctrl-Shift once will have the guest mouse start following the host mouse, press it again and the guest mouse will stop. (This can be used to keep the two pointers in sync with each other.) I find this a convient feature because in no-sdl-grab mode I can switch from one window to the next in the usual way, instead of having to manually release the mouse in a qemu session before switching windows. (This is a matter of personal preference but I find that needing to press Ctrl-Shift can really interrupt my flow of thought.) I'm looking into adding this into the monitor, so you can toggle this in a running qemu session. -- Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection. --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="qemu.diff" diff -ru fresh.qemu/sdl.c qemu/sdl.c --- fresh.qemu/sdl.c Thu Jul 15 13:18:14 2004 +++ qemu/sdl.c Thu Jul 15 13:23:39 2004 @@ -40,6 +40,7 @@ static int gui_fullscreen; static int gui_key_modifier_pressed; static int gui_keysym; +static int saved_grab_with_sdl; static void sdl_update(DisplayState *ds, int x, int y, int w, int h) { @@ -347,8 +348,10 @@ static void sdl_grab_start(void) { - SDL_ShowCursor(0); - SDL_WM_GrabInput(SDL_GRAB_ON); + if (grab_with_sdl) { + SDL_ShowCursor(0); + SDL_WM_GrabInput(SDL_GRAB_ON); + } /* dummy read to avoid moving the mouse */ SDL_GetRelativeMouseState(NULL, NULL); gui_grab = 1; @@ -357,8 +360,10 @@ static void sdl_grab_end(void) { - SDL_WM_GrabInput(SDL_GRAB_OFF); - SDL_ShowCursor(1); + if (grab_with_sdl) { + SDL_WM_GrabInput(SDL_GRAB_OFF); + SDL_ShowCursor(1); + } gui_grab = 0; sdl_update_caption(); } @@ -391,10 +396,13 @@ sdl_resize(ds, screen->w, screen->h); if (gui_fullscreen) { gui_saved_grab = gui_grab; + saved_grab_with_sdl = grab_with_sdl; + grab_with_sdl = 1; sdl_grab_start(); } else { - if (!gui_saved_grab) + if (!gui_saved_grab || !saved_grab_with_sdl) sdl_grab_end(); + grab_with_sdl = saved_grab_with_sdl; } vga_invalidate_display(); vga_update_display(); @@ -525,7 +533,7 @@ } break; case SDL_ACTIVEEVENT: - if (gui_grab && (ev->active.gain & SDL_ACTIVEEVENTMASK) == 0) { + if (grab_with_sdl && gui_grab && (ev->active.gain & SDL_ACTIVEEVENTMASK) == 0) { sdl_grab_end(); } break; diff -ru fresh.qemu/vl.c qemu/vl.c --- fresh.qemu/vl.c Thu Jul 15 13:18:33 2004 +++ qemu/vl.c Thu Jul 15 13:29:52 2004 @@ -138,6 +138,7 @@ int graphic_width = 800; int graphic_height = 600; int graphic_depth = 15; +int grab_with_sdl = 1; TextConsole *vga_console; /***********************************************************/ @@ -2438,6 +2439,7 @@ QEMU_OPTION_cirrusvga, QEMU_OPTION_g, QEMU_OPTION_std_vga, + QEMU_OPTION_no_sdl_grab, QEMU_OPTION_monitor, QEMU_OPTION_serial, }; @@ -2491,9 +2493,9 @@ { "localtime", 0, QEMU_OPTION_localtime }, { "isa", 0, QEMU_OPTION_isa }, { "std-vga", 0, QEMU_OPTION_std_vga }, + { "no-sdl-grab", 0, QEMU_OPTION_no_sdl_grab }, { "monitor", 1, QEMU_OPTION_monitor }, { "serial", 1, QEMU_OPTION_serial }, - /* temporary options */ { "pci", 0, QEMU_OPTION_pci }, { "cirrusvga", 0, QEMU_OPTION_cirrusvga }, @@ -2791,6 +2793,9 @@ break; case QEMU_OPTION_std_vga: cirrus_vga_enabled = 0; + break; + case QEMU_OPTION_no_sdl_grab: + grab_with_sdl = 0; break; case QEMU_OPTION_g: { diff -ru fresh.qemu/vl.h qemu/vl.h --- fresh.qemu/vl.h Thu Jul 15 13:18:36 2004 +++ qemu/vl.h Thu Jul 15 13:24:07 2004 @@ -241,6 +241,7 @@ extern int graphic_width; extern int graphic_height; extern int graphic_depth; +extern int grab_with_sdl; /* XXX: make it dynamic */ #if defined (TARGET_PPC) --PNTmBPCT7hxwcZjr--