GNOME Bugzilla – Bug 85780
Add support for extra virtual modifiers
Last modified: 2011-02-04 16:10:23 UTC
When users are choosing extra shortcuts, they should be able to use extra modifer keys on their keyboard, a common one being the "Windows" key mapped to Super. Probably the best way to do this is to use extra high bits in the modifier mask to represent virtual modifiers.
Created attachment 51809 [details] [review] patch (untested)
Created attachment 51810 [details] [review] better patch
Created attachment 51852 [details] [review] working patch This version of the patch adds the XKB implementation, and actually works. One problem with using Meta, Super, Hyper as modifiers is that they seem to be frequently mapped to the same X modifier. E.g this X server has 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 (0x7c) Which means that you can't use Super alone as a modifier. If the mod_mask contains both Hyper and Super, they can only be used together.
I ended up doing things slightly different. GDK adds the virtual modifiers to the event state, but tries to be smart about conflicts. 2005-09-06 Matthias Clasen <mclasen@redhat.com> Add support for extra virtual modifiers: (#85780, Owen Taylor) * tests/testgtk.c (create_key_lookup): Add tests for extra virtual modifiers. * gtk/gtkkeyhash.c (_gtk_key_hash_lookup): Try to match both against Mod2 - Mod5 and against Super, Hyper, Meta. * gtk/gtkaccellabel.c (_gtk_accel_label_class_get_accelerator_label): * gtk/gtkaccelgroup.c (gtk_accelerator_parse) (gtk_accelerator_name): Support Super, Hyper Meta and Mod2 - Mod5. * gdk/x11/gdkkeys-x11.c (struct _GdkKeymapX11): Add a modmap to maintain the information which X modifiers map to virtual modifiers. (get_xkb): Set up the modmap from the XKB tables. (update_keymaps): Set up the modmap from the information returned by XGetModifierMapping in the non-XKB case. * gdk/x11/gdkprivate-x11.h: * gdk/x11/gdkkeys-x11.c (_gdk_keymap_add_virtual_modifiers): New function to set the virtual modifiers in the state. * gdk/x11/gdkevents-x11.c (translate_key_event): Call _gdk_keymap_add_virtual_modifiers here. * gdk/gdktypes.h (GdkModifierType): Add bits for virtual Super, Hyper and Meta modifiers. Also add GDK_ALT_MASK as an alias for GDK_MOD1_MASK.