aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llwindow/llwindowmacosx.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2010-11-13 16:22:02 -0600
committerJacek Antonelli2010-11-14 02:07:52 -0600
commitecd500422dcd1e6f06fc22019070b6ffe6944123 (patch)
tree7bf7af81911f362ed68b335e0655313e72359d8b /linden/indra/llwindow/llwindowmacosx.cpp
parentUse Quicktime plugin on Mac, not GStreamer. (diff)
downloadmeta-impy-ecd500422dcd1e6f06fc22019070b6ffe6944123.zip
meta-impy-ecd500422dcd1e6f06fc22019070b6ffe6944123.tar.gz
meta-impy-ecd500422dcd1e6f06fc22019070b6ffe6944123.tar.bz2
meta-impy-ecd500422dcd1e6f06fc22019070b6ffe6944123.tar.xz
Ported some LLWindowMacOSX changes from Snowglobe 2.
Fixes missing definition for LLWindowMacOSX::getNativeKeyData().
Diffstat (limited to 'linden/indra/llwindow/llwindowmacosx.cpp')
-rw-r--r--linden/indra/llwindow/llwindowmacosx.cpp94
1 files changed, 85 insertions, 9 deletions
diff --git a/linden/indra/llwindow/llwindowmacosx.cpp b/linden/indra/llwindow/llwindowmacosx.cpp
index d68d4df..99daa4d 100644
--- a/linden/indra/llwindow/llwindowmacosx.cpp
+++ b/linden/indra/llwindow/llwindowmacosx.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2009, Linden Research, Inc. 7 * Copyright (c) 2001-2010, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -250,6 +250,7 @@ LLWindowMacOSX::LLWindowMacOSX(const std::string& title, const std::string& name
250 mTSMScriptCode = 0; 250 mTSMScriptCode = 0;
251 mTSMLangCode = 0; 251 mTSMLangCode = 0;
252 mPreeditor = NULL; 252 mPreeditor = NULL;
253 mRawKeyEvent = NULL;
253 mFSAASamples = fsaa_samples; 254 mFSAASamples = fsaa_samples;
254 mForceRebuild = FALSE; 255 mForceRebuild = FALSE;
255 256
@@ -1029,6 +1030,7 @@ void LLWindowMacOSX::hide()
1029 HideWindow(mWindow); 1030 HideWindow(mWindow);
1030} 1031}
1031 1032
1033//virtual
1032void LLWindowMacOSX::minimize() 1034void LLWindowMacOSX::minimize()
1033{ 1035{
1034 setMouseClipping(FALSE); 1036 setMouseClipping(FALSE);
@@ -1036,6 +1038,7 @@ void LLWindowMacOSX::minimize()
1036 CollapseWindow(mWindow, true); 1038 CollapseWindow(mWindow, true);
1037} 1039}
1038 1040
1041//virtual
1039void LLWindowMacOSX::restore() 1042void LLWindowMacOSX::restore()
1040{ 1043{
1041 show(); 1044 show();
@@ -1436,7 +1439,7 @@ static void fixOrigin(void)
1436 ::GetPortBounds(port, &portrect); 1439 ::GetPortBounds(port, &portrect);
1437 if((portrect.left != 0) || (portrect.top != 0)) 1440 if((portrect.left != 0) || (portrect.top != 0))
1438 { 1441 {
1439 // Mozilla sometimes changes our port origin. Fuckers. 1442 // Mozilla sometimes changes our port origin.
1440 ::SetOrigin(0,0); 1443 ::SetOrigin(0,0);
1441 } 1444 }
1442} 1445}
@@ -2128,10 +2131,11 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
2128 { 2131 {
2129 UInt32 modifiers = 0; 2132 UInt32 modifiers = 0;
2130 2133
2134
2131 // First, process the raw event. 2135 // First, process the raw event.
2132 { 2136 {
2133 EventRef rawEvent; 2137 EventRef rawEvent = NULL;
2134 2138
2135 // Get the original event and extract the modifier keys, so we can ignore command-key events. 2139 // Get the original event and extract the modifier keys, so we can ignore command-key events.
2136 if (GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL, sizeof(rawEvent), NULL, &rawEvent) == noErr) 2140 if (GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL, sizeof(rawEvent), NULL, &rawEvent) == noErr)
2137 { 2141 {
@@ -2140,6 +2144,9 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
2140 2144
2141 // and call this function recursively to handle the raw key event. 2145 // and call this function recursively to handle the raw key event.
2142 eventHandler (myHandler, rawEvent); 2146 eventHandler (myHandler, rawEvent);
2147
2148 // save the raw event until we're done processing the unicode input as well.
2149 mRawKeyEvent = rawEvent;
2143 } 2150 }
2144 } 2151 }
2145 2152
@@ -2167,11 +2174,8 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
2167 } 2174 }
2168 else 2175 else
2169 { 2176 {
2170 MASK mask = 0; 2177 MASK mask = LLWindowMacOSX::modifiersToMask(modifiers);
2171 if(modifiers & shiftKey) { mask |= MASK_SHIFT; } 2178
2172 if(modifiers & (cmdKey | controlKey)) { mask |= MASK_CONTROL; }
2173 if(modifiers & optionKey) { mask |= MASK_ALT; }
2174
2175 llassert( actualType == typeUnicodeText ); 2179 llassert( actualType == typeUnicodeText );
2176 2180
2177 // The result is a UTF16 buffer. Pass the characters in turn to handleUnicodeChar. 2181 // The result is a UTF16 buffer. Pass the characters in turn to handleUnicodeChar.
@@ -2193,6 +2197,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
2193 delete[] buffer; 2197 delete[] buffer;
2194 } 2198 }
2195 2199
2200 mRawKeyEvent = NULL;
2196 result = err; 2201 result = err;
2197 } 2202 }
2198 break; 2203 break;
@@ -2267,6 +2272,9 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
2267 GetEventParameter (event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode); 2272 GetEventParameter (event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode);
2268 GetEventParameter (event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); 2273 GetEventParameter (event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
2269 2274
2275 // save the raw event so getNativeKeyData can use it.
2276 mRawKeyEvent = event;
2277
2270 // printf("key event, key code = 0x%08x, char code = 0x%02x (%c), modifiers = 0x%08x\n", keyCode, charCode, (char)charCode, modifiers); 2278 // printf("key event, key code = 0x%08x, char code = 0x%02x (%c), modifiers = 0x%08x\n", keyCode, charCode, (char)charCode, modifiers);
2271 // fflush(stdout); 2279 // fflush(stdout);
2272 2280
@@ -2362,6 +2370,8 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
2362 result = eventNotHandledErr; 2370 result = eventNotHandledErr;
2363 break; 2371 break;
2364 } 2372 }
2373
2374 mRawKeyEvent = NULL;
2365 } 2375 }
2366 break; 2376 break;
2367 2377
@@ -3162,6 +3172,8 @@ void LLWindowMacOSX::spawnWebBrowser(const std::string& escaped_url)
3162 OSStatus result = noErr; 3172 OSStatus result = noErr;
3163 CFURLRef urlRef = NULL; 3173 CFURLRef urlRef = NULL;
3164 3174
3175 llinfos << "Opening URL " << escaped_url << llendl;
3176
3165 CFStringRef stringRef = CFStringCreateWithCString(NULL, escaped_url.c_str(), kCFStringEncodingUTF8); 3177 CFStringRef stringRef = CFStringCreateWithCString(NULL, escaped_url.c_str(), kCFStringEncodingUTF8);
3166 if (stringRef) 3178 if (stringRef)
3167 { 3179 {
@@ -3191,6 +3203,60 @@ void LLWindowMacOSX::spawnWebBrowser(const std::string& escaped_url)
3191 } 3203 }
3192} 3204}
3193 3205
3206LLSD LLWindowMacOSX::getNativeKeyData()
3207{
3208 LLSD result = LLSD::emptyMap();
3209
3210 if(mRawKeyEvent)
3211 {
3212 char char_code = 0;
3213 UInt32 key_code = 0;
3214 UInt32 modifiers = 0;
3215 UInt32 keyboard_type = 0;
3216
3217 GetEventParameter (mRawKeyEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &char_code);
3218 GetEventParameter (mRawKeyEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &key_code);
3219 GetEventParameter (mRawKeyEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
3220 GetEventParameter (mRawKeyEvent, kEventParamKeyboardType, typeUInt32, NULL, sizeof(UInt32), NULL, &keyboard_type);
3221
3222 result["char_code"] = (S32)char_code;
3223 result["key_code"] = (S32)key_code;
3224 result["modifiers"] = (S32)modifiers;
3225 result["keyboard_type"] = (S32)keyboard_type;
3226
3227#if 0
3228 // This causes trouble for control characters -- apparently character codes less than 32 (escape, control-A, etc)
3229 // cause llsd serialization to create XML that the llsd deserializer won't parse!
3230 std::string unicode;
3231 OSStatus err = noErr;
3232 EventParamType actualType = typeUTF8Text;
3233 UInt32 actualSize = 0;
3234 char *buffer = NULL;
3235
3236 err = GetEventParameter (mRawKeyEvent, kEventParamKeyUnicodes, typeUTF8Text, &actualType, 0, &actualSize, NULL);
3237 if(err == noErr)
3238 {
3239 // allocate a buffer and get the actual data.
3240 buffer = new char[actualSize];
3241 err = GetEventParameter (mRawKeyEvent, kEventParamKeyUnicodes, typeUTF8Text, &actualType, actualSize, &actualSize, buffer);
3242 if(err == noErr)
3243 {
3244 unicode.assign(buffer, actualSize);
3245 }
3246 delete[] buffer;
3247 }
3248
3249 result["unicode"] = unicode;
3250#endif
3251
3252 }
3253
3254
3255 lldebugs << "native key data is: " << result << llendl;
3256
3257 return result;
3258}
3259
3194void LLWindowMacOSX::ShellEx(const std::string& command) 3260void LLWindowMacOSX::ShellEx(const std::string& command)
3195{ 3261{
3196 OSStatus result = noErr; 3262 OSStatus result = noErr;
@@ -3392,3 +3458,13 @@ std::vector<std::string> LLWindowMacOSX::getDynamicFallbackFontList()
3392 return std::vector<std::string>(); 3458 return std::vector<std::string>();
3393} 3459}
3394 3460
3461// static
3462MASK LLWindowMacOSX::modifiersToMask(SInt16 modifiers)
3463{
3464 MASK mask = 0;
3465 if(modifiers & shiftKey) { mask |= MASK_SHIFT; }
3466 if(modifiers & (cmdKey | controlKey)) { mask |= MASK_CONTROL; }
3467 if(modifiers & optionKey) { mask |= MASK_ALT; }
3468 return mask;
3469}
3470