[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - vcl/aqua

Caolán McNamara caolanm at redhat.com
Tue Nov 26 02:08:03 PST 2013


 vcl/aqua/source/window/salframeview.mm |   37 +++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

New commits:
commit 5677b7a9e4d33d07e1f5ad9e5d591beb242c2dd6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Nov 25 11:04:41 2013 +0000

    Resolves: fdo#41169 fix MacOSX non-Latin keyboard layout with Latin shortcuts
    
    Change-Id: I168de52d6185d5df9c41fd2d7a68c0ff3f733852
    (cherry picked from commit 82b5172954261e030a42bd6b3f4acc99807d0ee5)
    Reviewed-on: https://gerrit.libreoffice.org/6798
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    Tested-by: Tor Lillqvist <tml at collabora.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/vcl/aqua/source/window/salframeview.mm b/vcl/aqua/source/window/salframeview.mm
index a0715d5..610eb93 100644
--- a/vcl/aqua/source/window/salframeview.mm
+++ b/vcl/aqua/source/window/salframeview.mm
@@ -105,6 +105,38 @@ static sal_uInt16 ImplMapCharCode( sal_Unicode aCode )
     return nKeyCode;
 }
 
+static sal_uInt16 ImplMapKeyCode(sal_uInt16 nKeyCode)
+{
+    /*
+      http://stackoverflow.com/questions/2080312/where-can-i-find-a-list-of-key-codes-for-use-with-cocoas-nsevent-class/2080324#2080324
+      /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h
+     */
+
+    static sal_uInt16 aKeyCodeMap[ 0x80 ] =
+    {
+        KEY_A,               KEY_S,     KEY_D,        KEY_F,      KEY_H,      KEY_G,            KEY_Z,         KEY_X,
+        KEY_C,               KEY_V,     0,            KEY_B,      KEY_Q,      KEY_W,            KEY_E,         KEY_R,
+        KEY_Y,               KEY_T,     KEY_1,        KEY_2,      KEY_3,      KEY_4,            KEY_6,         KEY_5,
+        KEY_EQUAL,           KEY_9,     KEY_7, KEY_SUBTRACT,      KEY_8,      KEY_0, KEY_BRACKETRIGHT,         KEY_0,
+        KEY_U,     KEY_BRACKETLEFT,     KEY_I,        KEY_P, KEY_RETURN,      KEY_L,            KEY_J, KEY_QUOTELEFT,
+        KEY_K,       KEY_SEMICOLON,         0,    KEY_COMMA, KEY_DIVIDE,      KEY_N,            KEY_M,     KEY_POINT,
+        KEY_TAB,         KEY_SPACE, KEY_TILDE,   KEY_DELETE,          0, KEY_ESCAPE,                0,             0,
+              0,      KEY_CAPSLOCK,         0,            0,          0,          0,                0,             0,
+        KEY_F17,       KEY_DECIMAL,         0, KEY_MULTIPLY,          0,    KEY_ADD,		    0,             0,
+              0,                 0,         0,   KEY_DIVIDE, KEY_RETURN,          0,     KEY_SUBTRACT,       KEY_F18,
+        KEY_F19,         KEY_EQUAL,         0,            0,          0,          0,                0,             0,
+              0,                 0,   KEY_F20,            0,          0,          0,                0,             0,
+         KEY_F5,            KEY_F6,    KEY_F7,       KEY_F3,     KEY_F8,     KEY_F9,                0,       KEY_F11,
+              0,           KEY_F13,   KEY_F16,      KEY_F14,          0,    KEY_F10,                0,       KEY_F12,
+              0,           KEY_F15,  KEY_HELP,     KEY_HOME, KEY_PAGEUP, KEY_DELETE,           KEY_F4,       KEY_END,
+         KEY_F2,      KEY_PAGEDOWN,    KEY_F1,     KEY_LEFT,  KEY_RIGHT,   KEY_DOWN,           KEY_UP,		   0
+    };
+
+    if (nKeyCode < SAL_N_ELEMENTS(aKeyCodeMap))
+        return aKeyCodeMap[nKeyCode];
+    return 0;
+}
+
 // store the frame the mouse last entered
 static AquaSalFrame* s_pMouseFrame = NULL;
 // store the last pressed button for enter/exit events
@@ -1444,6 +1476,11 @@ private:
     {
         unichar keyChar = [pUnmodifiedString characterAtIndex: 0];
         sal_uInt16 nKeyCode = ImplMapCharCode( keyChar );
+        if (nKeyCode == 0)
+        {
+            sal_uInt16 nOtherKeyCode = [pEvent keyCode];
+            nKeyCode = ImplMapKeyCode(nOtherKeyCode);
+        }
         if( nKeyCode != 0 )
         {
             // don't send unicodes in the private use area


More information about the Libreoffice-commits mailing list