qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Drake Wilson <drake@begriffli.ch>
To: qemu-devel@nongnu.org
Cc: 398351@bugs.debian.org, Riku Voipio <riku.voipio@iki.fi>
Subject: [Qemu-devel] Draft patch to permit use of Meta for SDL QEMU GUI
Date: Wed, 6 Aug 2008 11:54:51 -0500	[thread overview]
Message-ID: <20080806165451.GA7056@drache.begriffli.ch> (raw)
In-Reply-To: <20080806144414.GA3343@kos.to>

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

Hello, qemu-devel!

I use QEMU to run virtual machines on a Debian GNU/Linux machine with
AMD64 PC-class hardware.  My X keyboard configuration uses Meta
instead of Alt; even though I have a PC-style keyboard whose keys are
labeled Alt, they are assigned to the Meta keysyms.  I don't believe
this to be unusual.  Unfortunately, it makes it impossible to release
QEMU input grabs, which is likely related to the Debian bug report at
< http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=398351 >.

I've drafted a patch for QEMU's SDL interface to allow the use of
either Alt or Meta.  This appears to work when applied against either
Debianized QEMU 0.9.1 or raw QEMU SVN trunk (r4988) on my machine.
There may be bogosities that I have not noticed, since although it is
a localized change, I have not extensively read the QEMU source code.
This patch is attached in unified diff format, applyable with -p0.

(For those of you reading from the Debian bug, this is slightly
different than my previous posting there, because I noticed that I had
created a few redundant whitespace-changes-only hunks by mistake,
which I have now removed.)

Comments are appreciated from any related source.  Thanks for your
attention.  :-)

   ---> Drake Wilson

[-- Attachment #2: qemu-gui-meta-is-also-alt-2.diff --]
[-- Type: text/x-diff, Size: 2267 bytes --]

--- sdl.c.orig	2008-01-06 13:38:42.000000000 -0600
+++ sdl.c	2008-08-06 08:53:32.000000000 -0500
@@ -40,7 +40,9 @@
 static int gui_key_modifier_pressed;
 static int gui_keysym;
 static int gui_fullscreen_initial_grab;
-static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
+static int gui_grab_mods = KMOD_LALT | KMOD_LCTRL | KMOD_LMETA;
+static int gui_grab_req_all = KMOD_LCTRL; /* possibly modified on init */
+static int gui_grab_req_any = KMOD_LALT | KMOD_LMETA;
 static uint8_t modifiers_state[256];
 static int width, height;
 static SDL_Cursor *sdl_cursor_normal;
@@ -363,13 +365,10 @@
         case SDL_KEYDOWN:
         case SDL_KEYUP:
             if (ev->type == SDL_KEYDOWN) {
-                if (!alt_grab) {
-                    mod_state = (SDL_GetModState() & gui_grab_code) ==
-                                gui_grab_code;
-                } else {
-                    mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) ==
-                                (gui_grab_code | KMOD_LSHIFT);
-                }
+                SDLMod sdl_mod_state = SDL_GetModState();
+                mod_state = (((sdl_mod_state & gui_grab_req_all) ==
+                              gui_grab_req_all) &&
+                             ((sdl_mod_state & gui_grab_req_any) != 0));
                 gui_key_modifier_pressed = mod_state;
                 if (gui_key_modifier_pressed) {
                     int keycode;
@@ -430,12 +429,7 @@
                     }
                 }
             } else if (ev->type == SDL_KEYUP) {
-                if (!alt_grab) {
-                    mod_state = (ev->key.keysym.mod & gui_grab_code);
-                } else {
-                    mod_state = (ev->key.keysym.mod &
-                                 (gui_grab_code | KMOD_LSHIFT));
-                }
+                mod_state = (ev->key.keysym.mod & gui_grab_mods);
                 if (!mod_state) {
                     if (gui_key_modifier_pressed) {
                         gui_key_modifier_pressed = 0;
@@ -630,6 +624,9 @@
     SDL_EnableUNICODE(1);
     gui_grab = 0;
 
+    if (alt_grab)
+        gui_grab_req_all |= KMOD_LSHIFT;
+
     sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0);
     sdl_cursor_normal = SDL_GetCursor();
 

       reply	other threads:[~2008-08-06 17:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080806135849.GA30934@drache.begriffli.ch>
     [not found] ` <20080806144414.GA3343@kos.to>
2008-08-06 16:54   ` Drake Wilson [this message]
2012-02-07  9:57     ` [Qemu-devel] Draft patch to permit use of Meta for SDL QEMU GUI Michael Tokarev

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=20080806165451.GA7056@drache.begriffli.ch \
    --to=drake@begriffli.ch \
    --cc=398351@bugs.debian.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /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).