xserver: Branch 'master'

Ben Byer bbyer at kemper.freedesktop.org
Thu Sep 20 18:06:18 PDT 2007


 hw/darwin/quartz/quartzKeyboard.c |   54 +++++++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 21 deletions(-)

New commits:
diff-tree 742d5d6adc4d4a1b6fceeb3443d7931e107462f7 (from 374bd88d1025835fe36ca0ff6620eb1d3b0a06b0)
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Sep 20 18:03:51 2007 -0700

    XDarwin: Fixes to quartzKeyboard.c to prevent a crash using certain non-US keyboards

diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index b498c77..f81ef0a 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -4,7 +4,7 @@
    Code to build a keymap using the Carbon Keyboard Layout API,
    which is supported on Mac OS X 10.2 and newer.
 
-   Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+   Copyright (c) 2003, 2007 Apple Inc.
 
    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated documentation files
@@ -214,35 +214,45 @@ Bool
 DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
 {
     KeyboardLayoutRef key_layout;
-    const void *chr_data;
+    const void *chr_data = NULL;
     int num_keycodes = NUM_KEYCODES;
     UInt32 keyboard_type = 0;
     int is_uchr, i, j;
     OSStatus err;
     KeySym *k;
 
-    KLGetCurrentKeyboardLayout (&key_layout);
-    KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
-
+    TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
+    if (currentKeyLayoutRef) 
+      {
+	CFDataRef currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
+	if (currentKeyLayoutDataRef)
+	  chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
+      }
+    
     if (chr_data != NULL)
     {
-        is_uchr = 1;
-        keyboard_type = LMGetKbdType ();
-    }
-    else
-    {
-        KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
-
-        if (chr_data == NULL)
-        {
-            ErrorF ( "Couldn't get uchr or kchr resource\n");
-            return FALSE;
-        }
-
-        is_uchr = 0;
-        num_keycodes = 128;
-    }    
+      KLGetCurrentKeyboardLayout (&key_layout);
+      KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
 
+      if (chr_data != NULL)
+	{
+	  is_uchr = 1;
+	  keyboard_type = LMGetKbdType ();
+	}
+      else
+	{
+	  KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
+	  
+	  if (chr_data == NULL)
+	    {
+	      ErrorF ( "Couldn't get uchr or kchr resource\n");
+	      return FALSE;
+	    }
+	  
+	  is_uchr = 0;
+	  num_keycodes = 128;
+	}    
+    }
 
     /* Scan the keycode range for the Unicode character that each
        key produces in the four shift states. Then convert that to
@@ -367,6 +377,8 @@ DarwinModeReadSystemKeymap (darwinKeyboa
         }
     }
 
+    if(currentKeyLayoutRef) CFRelease(currentKeyLayoutRef);
+
     return TRUE;
 }
 


More information about the xorg-commit mailing list