quartz: remove check for keymap changes from update_keymap()

The function is now only called when the keymap has actually
changed. bug #698183.
(cherry picked from commit e62709da2ee6619f26c8446b545418e5f1b9e151)
This commit is contained in:
Michael Natterer 2013-06-20 17:21:25 +02:00 committed by Michael Natterer
parent bbe3554fa9
commit e5e17cf361

View File

@ -82,17 +82,6 @@ _gdk_quartz_display_get_keymap (GdkDisplay *display)
return default_keymap; return default_keymap;
} }
/* Note: we could check only if building against the 10.5 SDK instead, but
* that would make non-xml layouts not work in 32-bit which would be a quite
* bad regression. This way, old unsupported layouts will just not work in
* 64-bit.
*/
#ifdef __LP64__
static TISInputSourceRef current_layout = NULL;
#else
static KeyboardLayoutRef current_layout = NULL;
#endif
/* This is a table of all keyvals. Each keycode gets KEYVALS_PER_KEYCODE entries. /* This is a table of all keyvals. Each keycode gets KEYVALS_PER_KEYCODE entries.
* TThere is 1 keyval per modifier (Nothing, Shift, Alt, Shift+Alt); * TThere is 1 keyval per modifier (Nothing, Shift, Alt, Shift+Alt);
*/ */
@ -270,7 +259,14 @@ static void
update_keymap (void) update_keymap (void)
{ {
const void *chr_data = NULL; const void *chr_data = NULL;
guint *p;
int i;
/* Note: we could check only if building against the 10.5 SDK instead, but
* that would make non-xml layouts not work in 32-bit which would be a quite
* bad regression. This way, old unsupported layouts will just not work in
* 64-bit.
*/
#ifdef __LP64__ #ifdef __LP64__
TISInputSourceRef new_layout = TISCopyCurrentKeyboardLayoutInputSource (); TISInputSourceRef new_layout = TISCopyCurrentKeyboardLayoutInputSource ();
CFDataRef layout_data_ref; CFDataRef layout_data_ref;
@ -282,11 +278,6 @@ update_keymap (void)
KLGetCurrentKeyboardLayout (&new_layout); KLGetCurrentKeyboardLayout (&new_layout);
#endif #endif
if (new_layout != current_layout)
{
guint *p;
int i;
g_free (keyval_array); g_free (keyval_array);
keyval_array = g_new0 (guint, NUM_KEYCODES * KEYVALS_PER_KEYCODE); keyval_array = g_new0 (guint, NUM_KEYCODES * KEYVALS_PER_KEYCODE);
@ -303,6 +294,7 @@ update_keymap (void)
return; return;
} }
#else #else
/* Get the layout kind */ /* Get the layout kind */
KLGetKeyboardLayoutProperty (new_layout, kKLKind, (const void **)&layout_kind); KLGetKeyboardLayoutProperty (new_layout, kKLKind, (const void **)&layout_kind);
@ -339,11 +331,10 @@ update_keymap (void)
int k; int k;
gboolean found = FALSE; gboolean found = FALSE;
/* FIXME: some keyboard layouts (e.g. Russian) use /* FIXME: some keyboard layouts (e.g. Russian) use a
* a different 8-bit character set. We should * different 8-bit character set. We should check
* check for this. Not a serious problem, because * for this. Not a serious problem, because most
* most (all?) of these layouts also have a * (all?) of these layouts also have a uchr version.
* uchr version.
*/ */
uc = macroman2ucs (c); uc = macroman2ucs (c);
@ -409,26 +400,28 @@ update_keymap (void)
0, 0,
&state, 4, &nChars, chars); &state, 4, &nChars, chars);
/* FIXME: Theoretically, we can get multiple UTF-16 values; /* FIXME: Theoretically, we can get multiple UTF-16
* we should convert them to proper unicode and figure * values; we should convert them to proper unicode and
* out whether there are really keyboard layouts that * figure out whether there are really keyboard layouts
* give us more than one character for one keypress. */ * that give us more than one character for one
* keypress.
*/
if (err == noErr && nChars == 1) if (err == noErr && nChars == 1)
{ {
int k; int k;
gboolean found = FALSE; gboolean found = FALSE;
/* A few <Shift><Option>keys return two /* A few <Shift><Option>keys return two characters,
* characters, the first of which is U+00a0, * the first of which is U+00a0, which isn't
* which isn't interesting; so we return the * interesting; so we return the second. More
* second. More sophisticated handling is the * sophisticated handling is the job of a
* job of a GtkIMContext. * GtkIMContext.
* *
* If state isn't zero, it means that it's a * If state isn't zero, it means that it's a dead
* dead key of some sort. Some of those are * key of some sort. Some of those are enumerated in
* enumerated in the special_ucs_table with the * the special_ucs_table with the high nibble set to
* high nibble set to f to push it into the * f to push it into the private use range. Here we
* private use range. Here we do the same. * do the same.
*/ */
if (state != 0) if (state != 0)
chars[nChars - 1] |= 0xf000; chars[nChars - 1] |= 0xf000;
@ -499,11 +492,7 @@ update_keymap (void)
p[0] = known_numeric_keys[i].keypad_keyval; p[0] = known_numeric_keys[i].keypad_keyval;
} }
if (current_layout) g_signal_emit_by_name (default_keymap, "keys-changed");
g_signal_emit_by_name (default_keymap, "keys_changed");
current_layout = new_layout;
}
} }
static PangoDirection static PangoDirection