summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-07-09 10:02:41 -0700
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-07-11 10:13:36 -0700
commitc3267106fb599213555829cb76df7848c4ebe23b (patch)
treef6b58193a6bcde3916ff2d6a402c9c84090ed5e3
parent90dd2de845ae12153296f6f1bff0c87f79c57854 (diff)
XQuartz: Use CFEqual to compare keyboards
(cherry picked from commit 5538e43b9ae7d06d2f48842b065810ce74286eb6)
-rw-r--r--hw/xquartz/quartzKeyboard.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 40d8cbb89..5e7a13c03 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -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;
}