XQuartz: Use CFEqual to compare keyboards

This commit is contained in:
Jeremy Huddleston 2008-07-09 10:02:41 -07:00
parent b3a208dc99
commit 5538e43b9a

View File

@ -1087,16 +1087,26 @@ Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
return 1;
}
/* TODO: Not thread safe */
unsigned int QuartzSystemKeymapSeed(void) {
static unsigned int seed;
static TISInputSourceRef last_key_layout;
static unsigned int seed = 0;
static TISInputSourceRef last_key_layout = NULL;
TISInputSourceRef key_layout;
key_layout = TISCopyCurrentKeyboardLayoutInputSource();
if (key_layout != last_key_layout) seed++;
last_key_layout = key_layout;
if(last_key_layout) {
if (CFEqual(key_layout, last_key_layout)) {
CFRelease(key_layout);
} else {
seed++;
CFRelease(last_key_layout);
last_key_layout = key_layout;
}
} else {
last_key_layout = key_layout;
}
return seed;
}