From c3267106fb599213555829cb76df7848c4ebe23b Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Wed, 9 Jul 2008 10:02:41 -0700 Subject: XQuartz: Use CFEqual to compare keyboards (cherry picked from commit 5538e43b9ae7d06d2f48842b065810ce74286eb6) --- hw/xquartz/quartzKeyboard.c | 20 +++++++++++++++----- 1 file 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; } -- cgit v1.2.3