diff options
Diffstat (limited to 'intern/ghost/intern/GHOST_SystemCocoa.mm')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.mm | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 236002e9744..095c738e1e0 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -22,6 +22,7 @@ * * Contributors: Maarten Gribnau 05/2001 * Damien Plisson 09/2009 + * Jens Verwiebe 10/2014 * * ***** END GPL LICENSE BLOCK ***** */ @@ -56,6 +57,7 @@ #include "AssertMacros.h" + #pragma mark KeyMap, mouse converters static GHOST_TButtonMask convertButton(int button) @@ -203,6 +205,7 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction) return GHOST_kKeyUnknown; default: + { /* alphanumerical or punctuation key that is remappable in int'l keyboards */ if ((recvChar >= 'A') && (recvChar <= 'Z')) { return (GHOST_TKey) (recvChar - 'A' + GHOST_kKeyA); @@ -211,27 +214,25 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction) return (GHOST_TKey) (recvChar - 'a' + GHOST_kKeyA); } else { - - /* Leopard and Snow Leopard 64bit compatible API*/ - CFDataRef uchrHandle; /*the keyboard layout*/ - TISInputSourceRef kbdTISHandle; - - kbdTISHandle = TISCopyCurrentKeyboardLayoutInputSource(); - uchrHandle = (CFDataRef)TISGetInputSourceProperty(kbdTISHandle,kTISPropertyUnicodeKeyLayoutData); - CFRelease(kbdTISHandle); - - /*get actual character value of the "remappable" keys in int'l keyboards, - if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger), - then fallback on using the received charactersIgnoringModifiers */ - if (uchrHandle) - { - UInt32 deadKeyState=0; - UniCharCount actualStrLength=0; + /* Leopard and Snow Leopard 64bit compatible API*/ + CFDataRef uchrHandle; /*the keyboard layout*/ + TISInputSourceRef kbdTISHandle; - UCKeyTranslate((UCKeyboardLayout*)CFDataGetBytePtr(uchrHandle), rawCode, keyAction, 0, - LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar); + kbdTISHandle = TISCopyCurrentKeyboardLayoutInputSource(); + uchrHandle = (CFDataRef)TISGetInputSourceProperty(kbdTISHandle,kTISPropertyUnicodeKeyLayoutData); + CFRelease(kbdTISHandle); - } + /*get actual character value of the "remappable" keys in int'l keyboards, + if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger), + then fallback on using the received charactersIgnoringModifiers */ + if (uchrHandle) { + UInt32 deadKeyState=0; + UniCharCount actualStrLength=0; + + UCKeyTranslate((UCKeyboardLayout*)CFDataGetBytePtr(uchrHandle), rawCode, keyAction, 0, + LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar); + + } switch (recvChar) { case '-': return GHOST_kKeyMinus; @@ -249,10 +250,29 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction) return GHOST_kKeyUnknown; } } + } } return GHOST_kKeyUnknown; } +#pragma mark Utility functions + +#define FIRSTFILEBUFLG 512 +static bool g_hasFirstFile = false; +static char g_firstFileBuf[512]; + +//TODO:Need to investigate this. Function called too early in creator.c to have g_hasFirstFile == true +extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) +{ + if (g_hasFirstFile) { + strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1); + buf[FIRSTFILEBUFLG - 1] = '\0'; + return 1; + } + else { + return 0; + } +} #pragma mark Cocoa objects @@ -313,8 +333,6 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction) @end - - #pragma mark initialization/finalization GHOST_SystemCocoa::GHOST_SystemCocoa() @@ -512,9 +530,8 @@ GHOST_IWindow* GHOST_SystemCocoa::createWindow( GHOST_TUns32 height, GHOST_TWindowState state, GHOST_TDrawingContextType type, - bool stereoVisual, + GHOST_GLSettings glSettings, const bool exclusive, - const GHOST_TUns16 numOfAASamples, const GHOST_TEmbedderWindowID parentWindow ) { @@ -533,7 +550,7 @@ GHOST_IWindow* GHOST_SystemCocoa::createWindow( // Add contentRect.origin.y to respect docksize bottom = bottom > contentRect.origin.y ? bottom + contentRect.origin.y : contentRect.origin.y; - window = new GHOST_WindowCocoa (this, title, left, bottom, width, height, state, type, stereoVisual, numOfAASamples); + window = new GHOST_WindowCocoa (this, title, left, bottom, width, height, state, type, ((glSettings.flags & GHOST_glStereoVisual) != 0), glSettings.numOfAASamples); if (window->getValid()) { // Store the pointer to the window @@ -636,7 +653,6 @@ GHOST_TSuccess GHOST_SystemCocoa::getButtons(GHOST_Buttons& buttons) const } - #pragma mark Event handlers /** @@ -1573,7 +1589,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr) } - #pragma mark Clipboard get/set GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const |