After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 85780 - Add support for extra virtual modifiers
Add support for extra virtual modifiers
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
2.0.x
Other Linux
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 606443
 
 
Reported: 2002-06-18 15:19 UTC by Owen Taylor
Modified: 2011-02-04 16:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (untested) (10.82 KB, patch)
2005-09-05 05:34 UTC, Matthias Clasen
none Details | Review
better patch (11.18 KB, patch)
2005-09-05 05:47 UTC, Matthias Clasen
none Details | Review
working patch (20.37 KB, patch)
2005-09-06 05:37 UTC, Matthias Clasen
none Details | Review

Description Owen Taylor 2002-06-18 15:19:07 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.
Comment 1 Matthias Clasen 2005-09-05 05:34:54 UTC
Created attachment 51809 [details] [review]
patch (untested)
Comment 2 Matthias Clasen 2005-09-05 05:47:04 UTC
Created attachment 51810 [details] [review]
better patch
Comment 3 Matthias Clasen 2005-09-06 05:37:53 UTC
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.
Comment 4 Matthias Clasen 2005-09-06 18:34:08 UTC
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.