[wx-dev] Keyboard handling problems

Alex Bligh alex at alex.org.uk
Mon Aug 14 15:55:30 PDT 2006


Vadim Zeitlin wrote:
> On Mon, 14 Aug 2006 22:46:24 +0100 Alex Bligh <alex at alex.org.uk> wrote:
> 
> AB> The right ALT key (ALT-Gr) and windows/start keys appear
> AB> to be on bad terms with wxWidgets GTK.
> 
>  The handling of these keys depends on your X modifiers settings. What does
> xmodmap say in your case?

amb at polonius:~/camelot/XaraLX$ xmodmap
xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x6d)
mod1        Alt_L (0x40),  Alt_L (0x7d),  Meta_L (0x9c)
mod2        Num_Lock (0x4d)
mod3
mod4        Super_L (0x7f),  Hyper_L (0x80)
mod5        Mode_switch (0x5d),  ISO_Level3_Shift (0x71), 
ISO_Level3_Shift (0x7c)

Though what that means I don't really know, as it's
not obvious to me what Meta_L etc. are, nor why
there are 2 scan codes for Alt_L.

> AB> It might be argued that Alt-Gr is "meta" under Unix.
> AB> In which case fine, it should still return a key event,
> AB> and wxGetKeyState should return a "Meta" character.
> 
>  Yes, I think this would be the correct behaviour.

That would be fine...

However, WXK_ALT actually maps to XK_Meta_L.

XK_Meta_R is mapped /to/ WXK_ALT, but nothing maps back to it
(so you can't effectively do a GetKeyState on it); I suspect
this is one of the keys mapped to mod1 (i.e Start).

Equally there are no entries for Super_L or Hyper_L.

> AB> I'm confused as to how this is meant to work. Right now,
> AB> all I'd like to do is to get the status of the keys.
> 
>  I'd suggest debugging wxGetKeyState() from src/unix/utilsx11.cpp. I don't
> know X11 well enough to understand what's going on without looking at what
> the code does without a debugger...

Mmm... thanks for the pointer.

I don't understand how it can be expected to work where more than one
X key maps to the same modifier. IE if key X and key Y are both
modifiers that map to WXK_FOO, then what is wxGetKeyState(WXK_FOO)
meant to return? The status of X or Y? Given xmodmap is fundamentally
not a bijective map, how can this ever work reliably? Saying that it
does somehow seem to work with SHIFT and CONTROL.

Alex




More information about the wx-dev mailing list