qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Draft patch to permit use of Meta for SDL QEMU GUI
       [not found] ` <20080806144414.GA3343@kos.to>
@ 2008-08-06 16:54   ` Drake Wilson
  2012-02-07  9:57     ` Michael Tokarev
  0 siblings, 1 reply; 2+ messages in thread
From: Drake Wilson @ 2008-08-06 16:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: 398351, Riku Voipio

[-- 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();
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] Draft patch to permit use of Meta for SDL QEMU GUI
  2008-08-06 16:54   ` [Qemu-devel] Draft patch to permit use of Meta for SDL QEMU GUI Drake Wilson
@ 2012-02-07  9:57     ` Michael Tokarev
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Tokarev @ 2012-02-07  9:57 UTC (permalink / raw)
  To: Drake Wilson; +Cc: 398351, Riku Voipio, qemu-devel

Replying to an old message...

On 06.08.2008 20:54, Drake Wilson wrote:
> 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

This is archived at, for example,
http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg00208.html

So far it looks like this is the only report about this problem.
This message has never been answered.

What do people think about this issue now?

(The patch does not apply since the code changed significanly,
but the idea is the same).

Thanks,

/mjt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-07  9:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20080806135849.GA30934@drache.begriffli.ch>
     [not found] ` <20080806144414.GA3343@kos.to>
2008-08-06 16:54   ` [Qemu-devel] Draft patch to permit use of Meta for SDL QEMU GUI Drake Wilson
2012-02-07  9:57     ` Michael Tokarev

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).