summaryrefslogtreecommitdiff
path: root/indra/llwindow/llwindowmacosx-objc.mm
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow/llwindowmacosx-objc.mm')
-rw-r--r--indra/llwindow/llwindowmacosx-objc.mm56
1 files changed, 41 insertions, 15 deletions
diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm
index 5a024eda46..1a64c94b2d 100644
--- a/indra/llwindow/llwindowmacosx-objc.mm
+++ b/indra/llwindow/llwindowmacosx-objc.mm
@@ -29,6 +29,7 @@
#include <Cocoa/Cocoa.h>
#include "llwindowmacosx-objc.h"
#include "llopenglview-objc.h"
+#include "llappdelegate-objc.h"
/*
* These functions are broken out into a separate file because the
@@ -37,6 +38,11 @@
* linden headers with any objective-C++ source.
*/
+int createNSApp(int argc, const char *argv[])
+{
+ return NSApplicationMain(argc, argv);
+}
+
void setupCocoa()
{
static bool inited = false;
@@ -49,15 +55,6 @@ void setupCocoa()
// ie. running './secondlife -set Language fr' would cause a pop-up saying can't open document 'fr'
// when init'ing the Cocoa App window.
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"];
-
- // This is a bit of voodoo taken from the Apple sample code "CarbonCocoa_PictureCursor":
- // http://developer.apple.com/samplecode/CarbonCocoa_PictureCursor/index.html
-
- // Needed for Carbon based applications which call into Cocoa
- // NSApplicationLoad();
-
- // 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
- //[[[NSWindow alloc] init] release];
[pool release];
@@ -65,6 +62,38 @@ void setupCocoa()
}
}
+bool copyToPBoard(const unsigned short *str, unsigned int len)
+{
+ NSPasteboard *pboard = [NSPasteboard generalPasteboard];
+ [pboard clearContents];
+
+ NSArray *contentsToPaste = [[NSArray alloc] initWithObjects:[NSString stringWithCharacters:str length:len], nil];
+
+ return [pboard writeObjects:contentsToPaste];
+}
+
+bool pasteBoardAvailable()
+{
+ NSArray *classArray = [NSArray arrayWithObject:[NSString class]];
+ return [[NSPasteboard generalPasteboard] canReadObjectForClasses:classArray options:[NSDictionary dictionary]];
+}
+
+const unsigned short *copyFromPBoard()
+{
+ NSPasteboard *pboard = [NSPasteboard generalPasteboard];
+ NSArray *classArray = [NSArray arrayWithObject:[NSString class]];
+ NSString *str = NULL;
+ BOOL ok = [pboard canReadObjectForClasses:classArray options:[NSDictionary dictionary]];
+ if (ok)
+ {
+ NSArray *objToPaste = [pboard readObjectsForClasses:classArray options:[NSDictionary dictionary]];
+ str = [objToPaste objectAtIndex:0];
+ }
+ unichar* temp = (unichar*)calloc([str length], sizeof(unichar));
+ [str getCharacters:temp];
+ return temp;
+}
+
CursorRef createImageCursor(const char *fullpath, int hotspotX, int hotspotY)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -287,15 +316,12 @@ void removeGLView(GLViewRef view)
NSWindowRef getMainAppWindow()
{
- [(LLNSWindow*)winRef setAcceptsMouseMovedEvents:TRUE];
+ LLNSWindow *winRef = [(LLAppDelegate*)[[NSApplication sharedApplication] delegate] window];
+
+ [winRef setAcceptsMouseMovedEvents:TRUE];
return winRef;
}
-GLViewRef getGLView()
-{
- return glviewRef;
-}
-
unsigned int getModifiers()
{
return [NSEvent modifierFlags];