diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llplugin/slplugin/slplugin-objc.mm | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/linden/indra/llplugin/slplugin/slplugin-objc.mm b/linden/indra/llplugin/slplugin/slplugin-objc.mm new file mode 100644 index 0000000..125b264 --- /dev/null +++ b/linden/indra/llplugin/slplugin/slplugin-objc.mm | |||
@@ -0,0 +1,89 @@ | |||
1 | /** | ||
2 | * @file slplugin-objc.mm | ||
3 | * @brief Objective-C++ file for use with the loader shell, so we can use a couple of Cocoa APIs. | ||
4 | * | ||
5 | * @cond | ||
6 | * | ||
7 | * $LicenseInfo:firstyear=2010&license=viewergpl$ | ||
8 | * | ||
9 | * Copyright (c) 2010, Linden Research, Inc. | ||
10 | * | ||
11 | * Second Life Viewer Source Code | ||
12 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
13 | * to you under the terms of the GNU General Public License, version 2.0 | ||
14 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
15 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
16 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
18 | * | ||
19 | * There are special exceptions to the terms and conditions of the GPL as | ||
20 | * it is applied to this Source Code. View the full text of the exception | ||
21 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
22 | * online at | ||
23 | * http://secondlife.com/developers/opensource/flossexception | ||
24 | * | ||
25 | * By copying, modifying or distributing this software, you acknowledge | ||
26 | * that you have read and understood your obligations described above, | ||
27 | * and agree to abide by those obligations. | ||
28 | * | ||
29 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
30 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
31 | * COMPLETENESS OR PERFORMANCE. | ||
32 | * $/LicenseInfo$ | ||
33 | * | ||
34 | * | ||
35 | * @endcond | ||
36 | */ | ||
37 | |||
38 | |||
39 | #include <AppKit/AppKit.h> | ||
40 | |||
41 | #include "slplugin-objc.h" | ||
42 | |||
43 | |||
44 | void setupCocoa() | ||
45 | { | ||
46 | static bool inited = false; | ||
47 | |||
48 | if(!inited) | ||
49 | { | ||
50 | createAutoReleasePool(); | ||
51 | |||
52 | // The following prevents the Cocoa command line parser from trying to open 'unknown' arguements as documents. | ||
53 | // ie. running './secondlife -set Language fr' would cause a pop-up saying can't open document 'fr' | ||
54 | // when init'ing the Cocoa App window. | ||
55 | [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"]; | ||
56 | |||
57 | // This is a bit of voodoo taken from the Apple sample code "CarbonCocoa_PictureCursor": | ||
58 | // http://developer.apple.com/samplecode/CarbonCocoa_PictureCursor/index.html | ||
59 | |||
60 | // Needed for Carbon based applications which call into Cocoa | ||
61 | NSApplicationLoad(); | ||
62 | |||
63 | // Must first call [[[NSWindow alloc] init] release] to get the NSWindow machinery set up so that NSCursor can use a window to cache the cursor image | ||
64 | [[[NSWindow alloc] init] release]; | ||
65 | |||
66 | deleteAutoReleasePool(); | ||
67 | |||
68 | inited = true; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | static NSAutoreleasePool *sPool = NULL; | ||
73 | |||
74 | void createAutoReleasePool() | ||
75 | { | ||
76 | if(!sPool) | ||
77 | { | ||
78 | sPool = [[NSAutoreleasePool alloc] init]; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | void deleteAutoReleasePool() | ||
83 | { | ||
84 | if(sPool) | ||
85 | { | ||
86 | [sPool release]; | ||
87 | sPool = NULL; | ||
88 | } | ||
89 | } | ||