qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Jim C. Brown" <jbrown106@phreaker.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] no-sdl-grab patch
Date: Thu, 15 Jul 2004 18:59:08 -0400	[thread overview]
Message-ID: <20040715225908.GA6237@jbrown.mylinuxbox.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 989 bytes --]

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.

[-- Attachment #2: qemu.diff --]
[-- Type: text/plain, Size: 3242 bytes --]

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)

             reply	other threads:[~2004-07-15 23:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-15 22:59 Jim C. Brown [this message]
2004-07-15 23:23 ` [Qemu-devel] no-sdl-grab patch Jim C. Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040715225908.GA6237@jbrown.mylinuxbox.org \
    --to=jbrown106@phreaker.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).