2007-12-16 Xan Lopez <xan@gnome.org>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Dec 2007 13:20:11 +0000 (13:20 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Dec 2007 13:20:11 +0000 (13:20 +0000)
        Reviewed by Alexey Proskuryakov.

        http://bugs.webkit.org/show_bug.cgi?id=16454
        [GTK] Text input doesn't work consistently on PPC

        * platform/gtk/KeyEventGtk.cpp:
        (WebCore::singleCharacterString):

        UChar is 2 bytes (UTF-16), so transform accordingly from
        gunichar (UCS-4). Fixes keyboard input on big endian systems.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28769 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/gtk/KeyEventGtk.cpp

index 621717c8bee11188b219f3eb0cb0ae657fc1deb5..2598338f1eda483ebbde97a6798679632f5eac2d 100644 (file)
@@ -1,3 +1,16 @@
+2007-12-16  Xan Lopez  <xan@gnome.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16454
+        [GTK] Text input doesn't work consistently on PPC
+
+        * platform/gtk/KeyEventGtk.cpp:
+        (WebCore::singleCharacterString):
+
+        UChar is 2 bytes (UTF-16), so transform accordingly from
+        gunichar (UCS-4). Fixes keyboard input on big endian systems.
+
 2007-12-15  Darin Adler  <darin@apple.com>
 
         Reviewed by Mark Rowe.
index 001da557e17016052b6a9c6bb7f23b26ace71fad..6a58b6f5c3112618d81f998b1b2e18b2fcc3fa7b 100644 (file)
@@ -467,10 +467,21 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode)
 
 }
 
-static inline String singleCharacterString(guint val)
+static String singleCharacterString(guint val)
 {
-    val = gdk_keyval_to_unicode(val);
-    return String((UChar*)&val, 1);
+    glong nwc;
+    String retVal;
+    gunichar c = gdk_keyval_to_unicode(val);
+    gunichar2* uchar16 = g_ucs4_to_utf16(&c, 1, 0, &nwc, 0);
+
+    if (uchar16)
+        retVal = String((UChar*)uchar16, nwc);
+    else
+        retVal = String();
+
+    g_free(uchar16);
+
+    return retVal;
 }
 
 PlatformKeyboardEvent::PlatformKeyboardEvent(GdkEventKey* event)