diff options
author | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2008-11-15 19:45:49 -0800 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2008-11-15 19:52:52 -0800 |
commit | 03f7a66a1ae3f522a49bcc783066d53d69c97262 (patch) | |
tree | e4a5468616e7d2c7125e72d15e8cccb38c53d319 | |
parent | e8112784e8ef80a96ed54eca7e148b424001a38f (diff) |
XQuartz: Don't use TIS on Tiger...
(cherry picked from commit be8ac84c15e7e76c581b9e75cda74139394aa4c7)
-rw-r--r-- | hw/xquartz/X11Application.m | 25 | ||||
-rw-r--r-- | hw/xquartz/quartzKeyboard.c | 18 |
2 files changed, 31 insertions, 12 deletions
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 5d77feaf2..57f680965 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -47,6 +47,7 @@ #include <mach/mach.h> #include <unistd.h> +#include <available.h> #include <Xplugin.h> @@ -65,7 +66,11 @@ extern BOOL xpbproxy_init (void); int X11EnableKeyEquivalents = TRUE, quartzFullscreenMenu = FALSE; int quartzHasRoot = FALSE, quartzEnableRootless = TRUE; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 static TISInputSourceRef last_key_layout; +#else +static KeyboardLayoutRef last_key_layout; +#endif extern int darwinFakeButtons; @@ -869,11 +874,16 @@ void X11ApplicationMain (int argc, char **argv, char **envp) { NSMaxY([[NSScreen mainScreen] visibleFrame]); /* Set the key layout seed before we start the server */ - last_key_layout = TISCopyCurrentKeyboardLayoutInputSource(); - - if(!last_key_layout) { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 + last_key_layout = TISCopyCurrentKeyboardLayoutInputSource(); + + if(!last_key_layout) fprintf(stderr, "X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n"); - } +#else + KLGetCurrentKeyboardLayout(&last_key_layout); + if(!last_key_layout) + fprintf(stderr, "X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n"); +#endif memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap)); if (!QuartzReadSystemKeymap(&keyInfo)) { @@ -1034,6 +1044,7 @@ extern int darwin_modifier_flags; // darwinEvents.c case NSKeyDown: case NSKeyUp: if(darwinSyncKeymap) { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 TISInputSourceRef key_layout = TISCopyCurrentKeyboardLayoutInputSource(); TISInputSourceRef clear; if (CFEqual(key_layout, last_key_layout)) { @@ -1043,6 +1054,12 @@ extern int darwin_modifier_flags; // darwinEvents.c clear = last_key_layout; last_key_layout = key_layout; CFRelease(clear); +#else + KeyboardLayoutRef key_layout; + KLGetCurrentKeyboardLayout(&key_layout); + if(key_layout != last_key_layout) { + last_key_layout = key_layout; +#endif /* Update keyInfo */ pthread_mutex_lock(&keyInfo_mutex); diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c index b462c77e7..2eb5feeca 100644 --- a/hw/xquartz/quartzKeyboard.c +++ b/hw/xquartz/quartzKeyboard.c @@ -44,6 +44,7 @@ #include <stdlib.h> #include <errno.h> #include <sys/stat.h> +#include <available.h> #include "quartzCommon.h" #include "darwin.h" @@ -701,20 +702,19 @@ static KeySym make_dead_key(KeySym in) { } Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) { -#if !defined(__LP64__) +#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 KeyboardLayoutRef key_layout; + int is_uchr = 1; #endif const void *chr_data = NULL; int num_keycodes = NUM_KEYCODES; UInt32 keyboard_type = 0; -#if !defined(__LP64__) - int is_uchr = 1; -#endif int i, j; OSStatus err; KeySym *k; CFDataRef currentKeyLayoutDataRef = NULL; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource(); keyboard_type = LMGetKbdType(); @@ -723,13 +723,15 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) { if (currentKeyLayoutDataRef) chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef); } +#endif -#if !defined(__LP64__) +#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 if (chr_data == NULL) { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 ErrorF("X11.app: Error detected in determining keyboard layout. If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n"); ErrorF("X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n", (unsigned)keyboard_type, currentKeyLayoutRef, currentKeyLayoutDataRef, chr_data); - +#endif KLGetCurrentKeyboardLayout (&key_layout); KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data); @@ -771,7 +773,7 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) { k = info->keyMap + i * GLYPHS_PER_KEY; for (j = 0; j < 4; j++) { -#if !defined(__LP64__) +#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 if (is_uchr) { #endif UniChar s[8]; @@ -797,7 +799,7 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) { k[j] = ucs2keysym (s[0]); if (dead_key_state != 0) k[j] = make_dead_key (k[j]); } -#if !defined(__LP64__) +#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 } else { // kchr UInt32 c, state = 0, state2 = 0; UInt16 code; |