xserver: Branch 'master'

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Fri Aug 8 01:21:25 PDT 2008


 hw/xquartz/quartzKeyboard.c |   47 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 3 deletions(-)

New commits:
commit 5accc9b3ce1af539150d59b1800b66783fd3e947
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Aug 8 00:19:41 2008 -0700

    XQuartz: Re-added deprecated code fallback failsafe for keyboard layout on Leopard with some debugging spew.
    (cherry picked from commit 5854e712e9ebc210d2f8de6f5d4fb650944f314a)

diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 5e7a13c..0bfb50b 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -71,6 +71,8 @@
 #include "X11/keysym.h"
 #include "keysym2ucs.h"
 
+#include <Availability.h>
+
 void QuartzXkbUpdate(DeviceIntPtr pDev);
 
 enum {
@@ -1090,6 +1092,7 @@ Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
 /* TODO: Not thread safe */
 unsigned int QuartzSystemKeymapSeed(void) {
     static unsigned int seed = 0;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     static TISInputSourceRef last_key_layout = NULL;
     TISInputSourceRef key_layout;
 
@@ -1106,7 +1109,15 @@ unsigned int QuartzSystemKeymapSeed(void) {
     } else {
         last_key_layout = key_layout;
     }
+#else
+    static KeyboardLayoutRef last_key_layout;
+    KeyboardLayoutRef key_layout;
 
+    KLGetCurrentKeyboardLayout (&key_layout);
+    if (key_layout != last_key_layout)
+        seed++;
+    last_key_layout = key_layout;
+#endif
     return seed;
 }
 
@@ -1148,6 +1159,9 @@ static KeySym make_dead_key(KeySym in) {
 }
 
 Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+    KeyboardLayoutRef key_layout;
+#endif
     const void *chr_data = NULL;
     int num_keycodes = NUM_KEYCODES;
     UInt32 keyboard_type = 0;
@@ -1156,17 +1170,44 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
     KeySym *k;
 
     TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
-    keyboard_type = LMGetKbdType ();
+    keyboard_type = LMGetKbdType();
+
     if (currentKeyLayoutRef) {
       CFDataRef currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
-      if (currentKeyLayoutDataRef) chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
+      if (currentKeyLayoutDataRef)
+          chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
+    }
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+    if (chr_data == NULL) {
+        ErrorF("X11.app: Error detected in determining keyboard layout.  Please report this error at http://xquartz.macosforge.org\n");
+        ErrorF("X11.app: Debug Info: currentKeyLayoutRef=%p, chr_data=%p\n", currentKeyLayoutRef, chr_data);
+
+        KLGetCurrentKeyboardLayout (&key_layout);
+        KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
+
+        if(chr_data != NULL) {
+            ErrorF("X11.app: Fallback succeeded, but this is still a bug.  Please report the above information.\n");
+        }
     }
 
     if (chr_data == NULL) {
+        ErrorF("X11.app: Debug Info: kKLuchrData fallback failed, trying kKLKCHRData.\n", currentKeyLayoutRef, chr_data);
+        KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
+        is_uchr = 0;
+        num_keycodes = 128;
+        
+        if(chr_data != NULL) {
+            ErrorF("X11.app: Fallback succeeded, but this is still a bug.  Please report the above information.\n");
+        }
+    }
+#endif
+
+    if (chr_data == NULL) {
       ErrorF ( "Couldn't get uchr or kchr resource\n");
       return FALSE;
     }
-
+    
     /* Scan the keycode range for the Unicode character that each
        key produces in the four shift states. Then convert that to
        an X11 keysym (which may just the bit that says "this is


More information about the xorg-commit mailing list