xserver: Branch 'xorg-server-1.4-apple'

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Sat Nov 15 19:46:11 PST 2008


 hw/xquartz/X11Application.m |   25 +++++++++++++++++++++----
 hw/xquartz/quartzKeyboard.c |   18 ++++++++++--------
 2 files changed, 31 insertions(+), 12 deletions(-)

New commits:
commit be8ac84c15e7e76c581b9e75cda74139394aa4c7
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sat Nov 15 19:45:49 2008 -0800

    XQuartz: Don't use TIS on Tiger...

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index aa3b753..95f8b46 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;
 
@@ -868,11 +873,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)) {
@@ -1033,6 +1043,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)) {
@@ -1042,6 +1053,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 b462c77..2eb5fee 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;


More information about the xorg-commit mailing list