13
0

OS X: fix the handling of SUPER,HYPER,META (see code comment for more)

This commit is contained in:
Paul Davis 2016-02-21 10:40:28 -05:00
parent 13552140a2
commit 344cf05540

View File

@ -143,18 +143,6 @@ Keyboard::Keyboard ()
RelevantModifierKeyMask = (GdkModifierType) gtk_accelerator_get_default_mod_mask ();
#ifdef __APPLE__
/* Remove SUPER,HYPER,META.
*
* GTK on OS X adds META when Command is pressed for various indefensible reasons, since
* it also uses MOD2 to indicate Command.
*/
RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~GDK_SUPER_MASK);
RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~GDK_HYPER_MASK);
RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~GDK_META_MASK);
#endif
RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | PrimaryModifier);
RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | SecondaryModifier);
RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask | TertiaryModifier);
@ -164,6 +152,29 @@ Keyboard::Keyboard ()
gtk_accelerator_set_default_mod_mask (RelevantModifierKeyMask);
#ifdef __APPLE__
/* Remove SUPER,HYPER,META.
*
* GTK on OS X adds META when Command is pressed for various indefensible reasons, since
* it also uses MOD2 to indicate Command. Our code assumes that each
* modifier (Primary, Secondary etc.) is represented by a single bit in
* the modifier mask, but GTK's (STUPID) design uses two (MOD2 + META)
* to represent the Command key. Some discussion about this is here:
* https://bugzilla.gnome.org/show_bug.cgi?id=692597
*
* We cannot do this until AFTER we told GTK what the default modifier
* was, because otherwise it will fail to recognize MOD2-META-<key> as
* an accelerator.
*
* Note that in the tabbed branch, we no longer use GTK accelerators
* for functional purposes, so this is as critical for that branch.
*/
RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~GDK_SUPER_MASK);
RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~GDK_HYPER_MASK);
RelevantModifierKeyMask = GdkModifierType (RelevantModifierKeyMask & ~GDK_META_MASK);
#endif
snooper_id = gtk_key_snooper_install (_snooper, (gpointer) this);
}