[gtk+] quartz: resolve the modifier confusion on the Mac
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] quartz: resolve the modifier confusion on the Mac
- Date: Mon, 26 Sep 2011 14:02:47 +0000 (UTC)
commit a99d14f61c673415a335ab5932023507c775a1b8
Author: Michael Natterer <mitch lanedo com>
Date: Fri Sep 16 15:54:03 2011 +0200
quartz: resolve the modifier confusion on the Mac
- map Alt/Option to MOD1
- map Command to MOD2
- map MOD2 to the virtual Meta
- improve/fix (?) group handling in gdkkeys-quartz.c
gdk/quartz/gdkevents-quartz.c | 8 +++++---
gdk/quartz/gdkkeys-quartz.c | 18 +++++++++++++-----
2 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index f7f42ac..546fa23 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -223,8 +223,10 @@ get_keyboard_modifiers_from_ns_event (NSEvent *nsevent)
modifiers |= GDK_SHIFT_MASK;
if (nsflags & NSControlKeyMask)
modifiers |= GDK_CONTROL_MASK;
- if (nsflags & NSCommandKeyMask)
+ if (nsflags & NSAlternateKeyMask)
modifiers |= GDK_MOD1_MASK;
+ if (nsflags & NSCommandKeyMask)
+ modifiers |= GDK_MOD2_MASK;
return modifiers;
}
@@ -912,7 +914,7 @@ fill_key_event (GdkWindow *window,
{
case GDK_KEY_Meta_R:
case GDK_KEY_Meta_L:
- mask = GDK_MOD1_MASK;
+ mask = GDK_MOD2_MASK;
break;
case GDK_KEY_Shift_R:
case GDK_KEY_Shift_L:
@@ -923,7 +925,7 @@ fill_key_event (GdkWindow *window,
break;
case GDK_KEY_Alt_R:
case GDK_KEY_Alt_L:
- mask = GDK_MOD5_MASK;
+ mask = GDK_MOD1_MASK;
break;
case GDK_KEY_Control_R:
case GDK_KEY_Control_L:
diff --git a/gdk/quartz/gdkkeys-quartz.c b/gdk/quartz/gdkkeys-quartz.c
index 70c9596..9c925ae 100644
--- a/gdk/quartz/gdkkeys-quartz.c
+++ b/gdk/quartz/gdkkeys-quartz.c
@@ -561,8 +561,8 @@ gdk_quartz_keymap_get_entries_for_keyval (GdkKeymap *keymap,
(*n_keys)++;
key.keycode = i / KEYVALS_PER_KEYCODE;
- key.group = 0;
- key.level = i % KEYVALS_PER_KEYCODE;
+ key.group = (i % KEYVALS_PER_KEYCODE) >= 2;
+ key.level = i % 2;
g_array_append_val (keys_array, key);
}
@@ -617,7 +617,7 @@ gdk_quartz_keymap_get_entries_for_keycode (GdkKeymap *keymap,
GdkKeymapKey key;
key.keycode = hardware_keycode;
- key.group = i / 2;
+ key.group = i >= 2;
key.level = i % 2;
g_array_append_val (keys_array, key);
@@ -673,6 +673,11 @@ translate_keysym (guint hardware_keycode,
tmp_keyval = upper;
}
+ if (effective_group)
+ *effective_group = group;
+ if (effective_level)
+ *effective_level = level;
+
return tmp_keyval;
}
@@ -727,14 +732,17 @@ static void
gdk_quartz_keymap_add_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
- /* FIXME: For now, we've mimiced the Windows backend. */
+ if (*state & GDK_MOD2_MASK)
+ *state |= GDK_META_MASK;
}
static gboolean
gdk_quartz_keymap_map_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
- /* FIXME: For now, we've mimiced the Windows backend. */
+ if (*state & GDK_META_MASK)
+ *state |= GDK_MOD2_MASK;
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]