From 2656b1f405dcf3b67d644bf47b02a64886ef2ca4 Mon Sep 17 00:00:00 2001 From: Geenz Date: Mon, 1 Apr 2013 08:15:12 -0400 Subject: First pass at adding a viable replacement for TSM's old UseInputWindow method (which is now deprecated with seemingly no Cocoa replacement). --- indra/llwindow/llappdelegate-objc.h | 6 +- indra/llwindow/llopenglview-objc.h | 12 +- indra/llwindow/llopenglview-objc.mm | 22 +- indra/llwindow/llwindowmacosx-objc.h | 2 + indra/llwindow/llwindowmacosx-objc.mm | 10 + indra/llwindow/llwindowmacosx.cpp | 14 +- indra/newview/SecondLife.nib | Bin 7403 -> 12997 bytes indra/newview/SecondLife.xib | 381 +++++++++++++++++++++++++++++++++- indra/newview/llappdelegate-objc.mm | 15 ++ 9 files changed, 444 insertions(+), 18 deletions(-) (limited to 'indra') diff --git a/indra/llwindow/llappdelegate-objc.h b/indra/llwindow/llappdelegate-objc.h index 6a4794f3c3..e7f6ecd5fc 100644 --- a/indra/llwindow/llappdelegate-objc.h +++ b/indra/llwindow/llappdelegate-objc.h @@ -11,11 +11,15 @@ @interface LLAppDelegate : NSObject { LLNSWindow *window; + NSWindow *inputWindow; + LLNonInlineTextView *inputView; NSTimer *frameTimer; } @property (assign) IBOutlet LLNSWindow *window; +@property (assign) IBOutlet NSWindow *inputWindow; +@property (assign) IBOutlet LLNonInlineTextView *inputView; - (void) mainLoop; - +- (void) showInputWindow:(bool)show; @end diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h index 5f972b1a98..6b21148bb6 100644 --- a/indra/llwindow/llopenglview-objc.h +++ b/indra/llwindow/llopenglview-objc.h @@ -12,9 +12,6 @@ #import #include -// Some nasty shovelling of LLOpenGLView from LLNativeBindings to prevent any C++ <-> Obj-C interop oddities. -// Redraw callback handling removed (for now) due to being unneeded in the patch that preceeds this addition. - @interface LLOpenGLView : NSOpenGLView { std::string mLastDraggedUrl; @@ -44,6 +41,15 @@ @end +@interface LLNonInlineTextView : NSTextView +{ + LLOpenGLView *glview; +} + +- (void) setGLView:(LLOpenGLView*)view; + +@end + @interface LLNSWindow : NSWindow - (NSPoint)convertToScreenFromLocalPoint:(NSPoint)point relativeToView:(NSView *)view; diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 376d238c90..a6ef35a8eb 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -501,9 +501,25 @@ attributedStringInfo getSegments(NSAttributedString *str) @end -// We use a custom NSWindow for our event handling. -// Why not an NSWindowController you may ask? -// Answer: this is easier. +@implementation LLNonInlineTextView + +- (void) setGLView:(LLOpenGLView *)view +{ + glview = view; +} + +- (void) insertText:(id)insertString +{ + [self insertText:insertString replacementRange:NSMakeRange(0, 0)]; +} + +- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange +{ + [glview insertText:aString replacementRange:replacementRange]; + [_window orderOut:_window]; +} + +@end @implementation LLNSWindow diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index 1d05db14b2..14a0c22d66 100644 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -90,6 +90,8 @@ void setWindowPos(NSWindowRef window, float* pos); void closeWindow(NSWindowRef window); void removeGLView(GLViewRef view); void makeFirstResponder(NSWindowRef window, GLViewRef view); +void setupInputWindow(NSWindowRef window, GLViewRef view); +void showInputWindow(bool show); // These are all implemented in llwindowmacosx.cpp. // This is largely for easier interop between Obj-C and C++ (at least in the viewer's case due to the BOOL vs. BOOL conflict) diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index 43f853bfd1..0eef8c9f83 100644 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -362,6 +362,16 @@ void removeGLView(GLViewRef view) [(LLOpenGLView*)view release]; } +void setupInputWindow(NSWindowRef window, GLViewRef glview) +{ + [[(LLAppDelegate*)[NSApp delegate] inputView] setGLView:(LLOpenGLView*)glview]; +} + +void showInputWindow(bool show) +{ + [(LLAppDelegate*)[NSApp delegate] showInputWindow:show]; +} + NSWindowRef getMainAppWindow() { LLNSWindow *winRef = [(LLAppDelegate*)[[NSApplication sharedApplication] delegate] window]; diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 6f66da66a4..2d0f981b3e 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -191,6 +191,8 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks, //start with arrow cursor initCursors(); setCursor( UI_CURSOR_ARROW ); + + allowLanguageTextInput(NULL, FALSE); } mCallbacks = callbacks; @@ -513,18 +515,22 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits // Get the view instead. mGLView = createOpenGLView(mWindow, mFSAASamples, !disable_vsync); mContext = getCGLContextObj(mGLView); + // Since we just created the context, it needs to be set up. glNeedsInit = TRUE; gGLManager.mVRAM = getVramSize(mGLView); } - + + // This sets up our view to recieve text from our non-inline text input window. + setupInputWindow(mWindow, mGLView); + // Hook up the context to a drawable if(mContext != NULL) { - LL_INFOS("Window") << "Setting CGL Context..." << LL_ENDL; - LL_DEBUGS("Window") << "createContext: setting current context" << LL_ENDL; + + U32 err = CGLSetCurrentContext(mContext); if (err != kCGLNoError) { @@ -1888,6 +1894,8 @@ void LLWindowMacOSX::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b) return; } + showInputWindow(!b); + // Take care of old and new preeditors. if (preeditor != mPreeditor || !b) { diff --git a/indra/newview/SecondLife.nib b/indra/newview/SecondLife.nib index f55ddaabcd..0b0ff5308b 100644 Binary files a/indra/newview/SecondLife.nib and b/indra/newview/SecondLife.nib differ diff --git a/indra/newview/SecondLife.xib b/indra/newview/SecondLife.xib index 7d20b7fd7c..fdfea49c42 100644 --- a/indra/newview/SecondLife.xib +++ b/indra/newview/SecondLife.xib @@ -11,9 +11,13 @@ 3084 + IBNSLayoutConstraint NSCustomObject NSMenu NSMenuItem + NSScrollView + NSScroller + NSTextView NSView NSWindowTemplate @@ -340,6 +344,202 @@ 128 YES + + 31 + 2 + {{272, 176}, {938, 42}} + -1535638528 + Window + NSPanel + + + + + 256 + + + + 256 + + + + 2304 + + + + 2322 + + Apple HTML pasteboard type + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple PNG pasteboard type + Apple URL pasteboard type + CorePasteboardFlavorType 0x6D6F6F76 + NSColor pasteboard type + NSFilenamesPboardType + NSStringPboardType + NeXT Encapsulated PostScript v1.2 pasteboard type + NeXT RTFD pasteboard type + NeXT Rich Text Format v1.0 pasteboard type + NeXT TIFF v4.0 pasteboard type + NeXT font pasteboard type + NeXT ruler pasteboard type + WebURLsWithTitlesPboardType + public.url + + {938, 42} + + + + _NS:13 + + + + + + + + + + + + 166 + + + + 938 + 1 + + + 67121127 + 0 + + + 3 + MQA + + + + 6 + System + selectedTextBackgroundColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + selectedTextColor + + 3 + MAA + + + + + + + 1 + MCAwIDEAA + + + {8, -8} + 13 + + + + + + 1 + + 6 + {939, 10000000} + + + + {{1, 1}, {938, 42}} + + + + _NS:11 + + + + {4, 5} + + 79691776 + + + + + + file://localhost/Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Resources/DVTIbeamCursor.tiff + + + + + 3 + MCAwAA + + + + 4 + + + + 256 + {{923, 1}, {16, 42}} + + + + _NS:83 + NO + + _doScroller: + 0.96666666666666667 + + + + -2147483392 + {{-100, -100}, {87, 18}} + + + + _NS:33 + NO + 1 + + _doScroller: + 1 + 0.94565218687057495 + + + {{-1, -1}, {940, 44}} + + + + _NS:9 + 133138 + + + + 0.25 + 4 + 1 + + + {938, 42} + + + + _NS:21 + + {{0, 0}, {2560, 1440}} + {10000000000000, 10000000000000} + YES + @@ -471,6 +671,22 @@ 850 + + + inputWindow + + + + 953 + + + + inputView + + + + 954 + @@ -726,6 +942,131 @@ + + 941 + + + + + + + + 942 + + + + + + 4 + 0 + + 4 + 1 + + -1 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + -1 + + 1000 + + 8 + 29 + 3 + + + + 3 + 0 + + 3 + 1 + + -1 + + 1000 + + 8 + 29 + 3 + + + + 5 + 0 + + 5 + 1 + + -1 + + 1000 + + 8 + 29 + 3 + + + + + + 943 + + + + + + + + + + 944 + + + + + 945 + + + + + 946 + + + + + 949 + + + + + 950 + + + + + 951 + + + + + 952 + + + @@ -770,12 +1111,31 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + LLNonInlineTextView + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - 940 + 954 @@ -783,13 +1143,18 @@ LLAppDelegate NSObject - LLOpenGLView + LLNonInlineTextView + NSWindow LLNSWindow - - glview - LLOpenGLView + + inputView + LLNonInlineTextView + + + inputWindow + NSWindow window @@ -810,11 +1175,11 @@ - LLOpenGLView - NSOpenGLView + LLNonInlineTextView + NSTextView IBProjectSource - ./Classes/LLOpenGLView.h + ./Classes/LLNonInlineTextView.h diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 5fb5087cd8..8da44fcf33 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -12,6 +12,8 @@ @implementation LLAppDelegate @synthesize window; +@synthesize inputWindow; +@synthesize inputView; - (void)dealloc { @@ -63,4 +65,17 @@ } } +- (void) showInputWindow:(bool)show +{ + if (show) + { + NSLog(@"Showing input window."); + [inputWindow makeKeyAndOrderFront:inputWindow]; + } else { + NSLog(@"Hiding input window."); + [inputWindow orderOut:inputWindow]; + [window makeKeyAndOrderFront:window]; + } +} + @end -- cgit v1.2.3