forked from AuroraMiddleware/gtk
quartz: make function keys work (again?)
The F keys have no unicode mapping, and UCKeyTranslate() returns
a bogus 0x10 as mapping to unicode. Instead of checking for this
random and undocumented return value, simply assign all function
keys explicitly. This patch also splits the ill-named "known_keys"
array into "modifier_keys" and "function_keys" which is much
more obvious.
(cherry picked from commit 55f9e5cbaf
)
This commit is contained in:
parent
80674d9dc0
commit
8bef74f8ff
@ -136,7 +136,7 @@ const static struct {
|
||||
guint keycode;
|
||||
guint keyval;
|
||||
unsigned int modmask; /* So we can tell when a mod key is pressed/released */
|
||||
} known_keys[] = {
|
||||
} modifier_keys[] = {
|
||||
{ 54, GDK_KEY_Meta_R, NSCommandKeyMask },
|
||||
{ 55, GDK_KEY_Meta_L, NSCommandKeyMask },
|
||||
{ 56, GDK_KEY_Shift_L, NSShiftKeyMask },
|
||||
@ -145,23 +145,29 @@ const static struct {
|
||||
{ 59, GDK_KEY_Control_L, NSControlKeyMask },
|
||||
{ 60, GDK_KEY_Shift_R, NSShiftKeyMask },
|
||||
{ 61, GDK_KEY_Alt_R, NSAlternateKeyMask },
|
||||
{ 62, GDK_KEY_Control_R, NSControlKeyMask },
|
||||
{ 122, GDK_KEY_F1, 0 },
|
||||
{ 120, GDK_KEY_F2, 0 },
|
||||
{ 99, GDK_KEY_F3, 0 },
|
||||
{ 118, GDK_KEY_F4, 0 },
|
||||
{ 96, GDK_KEY_F5, 0 },
|
||||
{ 97, GDK_KEY_F6, 0 },
|
||||
{ 98, GDK_KEY_F7, 0 },
|
||||
{ 100, GDK_KEY_F8, 0 },
|
||||
{ 101, GDK_KEY_F9, 0 },
|
||||
{ 109, GDK_KEY_F10, 0 },
|
||||
{ 103, GDK_KEY_F11, 0 },
|
||||
{ 111, GDK_KEY_F12, 0 },
|
||||
{ 105, GDK_KEY_F13, 0 },
|
||||
{ 107, GDK_KEY_F14, 0 },
|
||||
{ 113, GDK_KEY_F15, 0 },
|
||||
{ 106, GDK_KEY_F16, 0 }
|
||||
{ 62, GDK_KEY_Control_R, NSControlKeyMask }
|
||||
};
|
||||
|
||||
const static struct {
|
||||
guint keycode;
|
||||
guint keyval;
|
||||
} function_keys[] = {
|
||||
{ 122, GDK_KEY_F1 },
|
||||
{ 120, GDK_KEY_F2 },
|
||||
{ 99, GDK_KEY_F3 },
|
||||
{ 118, GDK_KEY_F4 },
|
||||
{ 96, GDK_KEY_F5 },
|
||||
{ 97, GDK_KEY_F6 },
|
||||
{ 98, GDK_KEY_F7 },
|
||||
{ 100, GDK_KEY_F8 },
|
||||
{ 101, GDK_KEY_F9 },
|
||||
{ 109, GDK_KEY_F10 },
|
||||
{ 103, GDK_KEY_F11 },
|
||||
{ 111, GDK_KEY_F12 },
|
||||
{ 105, GDK_KEY_F13 },
|
||||
{ 107, GDK_KEY_F14 },
|
||||
{ 113, GDK_KEY_F15 },
|
||||
{ 106, GDK_KEY_F16 }
|
||||
};
|
||||
|
||||
const static struct {
|
||||
@ -404,7 +410,6 @@ maybe_update_keymap (void)
|
||||
0,
|
||||
&state, 4, &nChars, chars);
|
||||
|
||||
|
||||
/* FIXME: Theoretically, we can get multiple UTF-16 values;
|
||||
* we should convert them to proper unicode and figure
|
||||
* out whether there are really keyboard layouts that
|
||||
@ -470,13 +475,21 @@ maybe_update_keymap (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (known_keys); i++)
|
||||
for (i = 0; i < G_N_ELEMENTS (modifier_keys); i++)
|
||||
{
|
||||
p = keyval_array + known_keys[i].keycode * KEYVALS_PER_KEYCODE;
|
||||
p = keyval_array + modifier_keys[i].keycode * KEYVALS_PER_KEYCODE;
|
||||
|
||||
if (p[0] == 0 && p[1] == 0 &&
|
||||
p[2] == 0 && p[3] == 0)
|
||||
p[0] = known_keys[i].keyval;
|
||||
p[0] = modifier_keys[i].keyval;
|
||||
}
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (function_keys); i++)
|
||||
{
|
||||
p = keyval_array + function_keys[i].keycode * KEYVALS_PER_KEYCODE;
|
||||
|
||||
p[0] = function_keys[i].keyval;
|
||||
p[1] = p[2] = p[3] = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (known_numeric_keys); i++)
|
||||
@ -792,11 +805,11 @@ _gdk_quartz_keys_event_type (NSEvent *event)
|
||||
keycode = [event keyCode];
|
||||
flags = [event modifierFlags];
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (known_keys); i++)
|
||||
for (i = 0; i < G_N_ELEMENTS (modifier_keys); i++)
|
||||
{
|
||||
if (known_keys[i].keycode == keycode)
|
||||
if (modifier_keys[i].keycode == keycode)
|
||||
{
|
||||
if (flags & known_keys[i].modmask)
|
||||
if (flags & modifier_keys[i].modmask)
|
||||
return GDK_KEY_PRESS;
|
||||
else
|
||||
return GDK_KEY_RELEASE;
|
||||
@ -813,12 +826,12 @@ _gdk_quartz_keys_is_modifier (guint keycode)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (known_keys); i++)
|
||||
for (i = 0; i < G_N_ELEMENTS (modifier_keys); i++)
|
||||
{
|
||||
if (known_keys[i].modmask == 0)
|
||||
if (modifier_keys[i].modmask == 0)
|
||||
break;
|
||||
|
||||
if (known_keys[i].keycode == keycode)
|
||||
if (modifier_keys[i].keycode == keycode)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user