summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeenz <geenz@geenzo.com>2013-06-17 17:08:48 -0400
committerGeenz <geenz@geenzo.com>2013-06-17 17:08:48 -0400
commit2837ca7a474f92bb363a2a31d184431b636d2809 (patch)
tree8b664875c001f84557549175dad507c0ab095d3c
parent84f287b34e7d7edbd2e897b73008c782aabe60de (diff)
This seems to be on par with viewer-release at this point.
-rw-r--r--indra/llwindow/llopenglview-objc.h1
-rw-r--r--indra/llwindow/llopenglview-objc.mm84
-rwxr-xr-xindra/llwindow/llwindowmacosx-objc.h2
-rwxr-xr-xindra/llwindow/llwindowmacosx-objc.mm4
-rwxr-xr-xindra/llwindow/llwindowmacosx.cpp42
-rwxr-xr-xindra/llwindow/llwindowmacosx.h2
6 files changed, 78 insertions, 57 deletions
diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h
index d4207d598a..b783c41c0b 100644
--- a/indra/llwindow/llopenglview-objc.h
+++ b/indra/llwindow/llopenglview-objc.h
@@ -22,7 +22,6 @@
float mMousePos[2];
bool mHasMarkedText;
unsigned int mMarkedTextLength;
- NSAttributedString *mMarkedText;
bool mMarkedTextAllowed;
}
- (id) initWithSamples:(NSUInteger)samples;
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index c3f0ef4aeb..24de5912f0 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -314,37 +314,34 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void) keyDown:(NSEvent *)theEvent
{
- if (!mHasMarkedText)
- {
- uint keycode = [theEvent keyCode];
- bool acceptsText = callKeyDown(keycode, mModifiers);
- if (acceptsText &&
- !mMarkedTextAllowed &&
- ![(LLAppDelegate*)[NSApp delegate] romanScript] &&
- [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSDeleteCharacter &&
- [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSBackspaceCharacter)
- {
- [(LLAppDelegate*)[NSApp delegate] showInputWindow:true withEvent:theEvent];
- } else
- {
- [[self inputContext] handleEvent:theEvent];
- }
-
- if ([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == NSCarriageReturnCharacter ||
- [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == NSEnterCharacter)
- {
- // callKeyDown won't return the value we expect for enter or return. Handle them as a separate case.
- [[self inputContext] handleEvent:theEvent];
- }
-
- // OS X intentionally does not send us key-up information on cmd-key combinations.
- // This behaviour is not a bug, and only applies to cmd-combinations (no others).
- // Since SL assumes we receive those, we fake it here.
- if (mModifiers & NSCommandKeyMask)
- {
- callKeyUp([theEvent keyCode], mModifiers);
- }
- }
+ uint keycode = [theEvent keyCode];
+ bool acceptsText = callKeyDown(keycode, mModifiers);
+ if (acceptsText &&
+ !mMarkedTextAllowed &&
+ ![(LLAppDelegate*)[NSApp delegate] romanScript] &&
+ [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSDeleteCharacter &&
+ [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSBackspaceCharacter)
+ {
+ [(LLAppDelegate*)[NSApp delegate] showInputWindow:true withEvent:theEvent];
+ } else
+ {
+ [[self inputContext] handleEvent:theEvent];
+ }
+
+ if ([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == NSCarriageReturnCharacter ||
+ [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == NSEnterCharacter)
+ {
+ // callKeyDown won't return the value we expect for enter or return. Handle them as a separate case.
+ [[self inputContext] handleEvent:theEvent];
+ }
+
+ // OS X intentionally does not send us key-up information on cmd-key combinations.
+ // This behaviour is not a bug, and only applies to cmd-combinations (no others).
+ // Since SL assumes we receive those, we fake it here.
+ if (mModifiers & NSCommandKeyMask)
+ {
+ callKeyUp([theEvent keyCode], mModifiers);
+ }
}
- (void)flagsChanged:(NSEvent *)theEvent {
@@ -425,7 +422,6 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
if (mMarkedTextAllowed)
{
-
unsigned int selected[2] = {
selectedRange.location,
selectedRange.length
@@ -442,9 +438,8 @@ attributedStringInfo getSegments(NSAttributedString *str)
setMarkedText(text, selected, replacement, [aString length], segments);
mHasMarkedText = TRUE;
mMarkedTextLength = [aString length];
- mMarkedText = (NSAttributedString*)[aString mutableString];
} else {
- if (mHasMarkedText || ![mMarkedText isEqual: @""])
+ if (mHasMarkedText)
{
[self unmarkText];
}
@@ -454,17 +449,18 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void)commitCurrentPreedit
{
- if (mMarkedText)
+ if (mHasMarkedText)
{
- [self insertText:mMarkedText];
- [[self inputContext] discardMarkedText];
+ if ([[self inputContext] respondsToSelector:@selector(commitEditing)])
+ {
+ [[self inputContext] commitEditing];
+ }
}
}
- (void)unmarkText
{
[[self inputContext] discardMarkedText];
- [mMarkedText setValue:@""];
resetPreedit();
mHasMarkedText = FALSE;
}
@@ -481,6 +477,14 @@ attributedStringInfo getSegments(NSAttributedString *str)
return nil;
}
+- (void)insertText:(id)insertString
+{
+ if (insertString != nil)
+ {
+ [self insertText:insertString replacementRange:NSMakeRange(0, [insertString length])];
+ }
+}
+
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
{
if (!mHasMarkedText)
@@ -490,9 +494,9 @@ attributedStringInfo getSegments(NSAttributedString *str)
callUnicodeCallback([aString characterAtIndex:i], mModifiers);
}
} else {
+ resetPreedit();
// We may never get this point since unmarkText may be called before insertText ever gets called once we submit our text.
// But just in case...
- resetPreedit();
for (NSInteger i = 0; i < [aString length]; i++)
{
@@ -567,7 +571,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
[[self inputContext] discardMarkedText];
[self setString:@""];
[_window orderOut:_window];
- [self insertText:insertString replacementRange:NSMakeRange(0, 0)];
+ [self insertText:insertString replacementRange:NSMakeRange(0, [insertString length])];
}
- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h
index 5b1f22046b..914fc534fb 100755
--- a/indra/llwindow/llwindowmacosx-objc.h
+++ b/indra/llwindow/llwindowmacosx-objc.h
@@ -135,7 +135,7 @@ void resetPreedit();
int wstring_length(const std::basic_string<wchar_t> & wstr, const int woffset, const int utf16_length, int *unaligned);
void setMarkedText(unsigned short *text, unsigned int *selectedRange, unsigned int *replacementRange, long text_len, attributedStringInfo segments);
void getPreeditLocation(float *location, unsigned int length);
-void allowDirectMarkedTextInput(bool allow);
+void allowDirectMarkedTextInput(bool allow, GLViewRef glView);
NSWindowRef getMainAppWindow();
GLViewRef getGLView();
diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm
index 33a8cf34ce..67b5279c0b 100755
--- a/indra/llwindow/llwindowmacosx-objc.mm
+++ b/indra/llwindow/llwindowmacosx-objc.mm
@@ -372,9 +372,9 @@ void commitCurrentPreedit(GLViewRef glView)
[(LLOpenGLView*)glView commitCurrentPreedit];
}
-void allowDirectMarkedTextInput(bool allow)
+void allowDirectMarkedTextInput(bool allow, GLViewRef glView)
{
-
+ [(LLOpenGLView*)glView allowMarkedTextInput:allow];
}
NSWindowRef getMainAppWindow()
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index 16fd7e3382..737ecba368 100755
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -239,6 +239,11 @@ void callFocusLost()
void callRightMouseDown(float *pos, MASK mask)
{
+ if (gWindowImplementation->allowsLanguageInput())
+ {
+ gWindowImplementation->interruptLanguageTextInput();
+ }
+
LLCoordGL outCoords;
outCoords.mX = llround(pos[0]);
outCoords.mY = llround(pos[1]);
@@ -247,6 +252,11 @@ void callRightMouseDown(float *pos, MASK mask)
void callRightMouseUp(float *pos, MASK mask)
{
+ if (gWindowImplementation->allowsLanguageInput())
+ {
+ gWindowImplementation->interruptLanguageTextInput();
+ }
+
LLCoordGL outCoords;
outCoords.mX = llround(pos[0]);
outCoords.mY = llround(pos[1]);
@@ -255,6 +265,11 @@ void callRightMouseUp(float *pos, MASK mask)
void callLeftMouseDown(float *pos, MASK mask)
{
+ if (gWindowImplementation->allowsLanguageInput())
+ {
+ gWindowImplementation->interruptLanguageTextInput();
+ }
+
LLCoordGL outCoords;
outCoords.mX = llround(pos[0]);
outCoords.mY = llround(pos[1]);
@@ -263,6 +278,11 @@ void callLeftMouseDown(float *pos, MASK mask)
void callLeftMouseUp(float *pos, MASK mask)
{
+ if (gWindowImplementation->allowsLanguageInput())
+ {
+ gWindowImplementation->interruptLanguageTextInput();
+ }
+
LLCoordGL outCoords;
outCoords.mX = llround(pos[0]);
outCoords.mY = llround(pos[1]);
@@ -272,6 +292,11 @@ void callLeftMouseUp(float *pos, MASK mask)
void callDoubleClick(float *pos, MASK mask)
{
+ if (gWindowImplementation->allowsLanguageInput())
+ {
+ gWindowImplementation->interruptLanguageTextInput();
+ }
+
LLCoordGL outCoords;
outCoords.mX = llround(pos[0]);
outCoords.mY = llround(pos[1]);
@@ -434,7 +459,7 @@ void setMarkedText(unsigned short *unitext, unsigned int *selectedRange, unsigne
if (gWindowImplementation->getPreeditor())
{
LLPreeditor *preeditor = gWindowImplementation->getPreeditor();
-
+ preeditor->resetPreedit();
// This should be a viable replacement for the kEventParamTextInputSendReplaceRange parameter.
if (replacementRange[0] < replacementRange[1])
{
@@ -444,8 +469,6 @@ void setMarkedText(unsigned short *unitext, unsigned int *selectedRange, unsigne
preeditor->markAsPreedit(location, length);
}
- preeditor->resetPreedit();
-
LLWString fix_str = utf16str_to_wstring(llutf16string(unitext, text_len));
S32 caret_position = fix_str.length();
@@ -1818,6 +1841,8 @@ static long getDictLong (CFDictionaryRef refDict, CFStringRef key)
void LLWindowMacOSX::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b)
{
+ allowDirectMarkedTextInput(b, mGLView);
+
if (preeditor != mPreeditor && !b)
{
// This condition may occur by a call to
@@ -1828,16 +1853,7 @@ void LLWindowMacOSX::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b)
// is not disturbed.
return;
}
-
- if (preeditor == NULL) {
- // If we don't have a pre editor, then we can't accept direct marked text input.
- // We needs an input window (which is handled internally by LLOpenGLView)
- allowDirectMarkedTextInput(false);
- } else {
- // If we have a preeditor, then accept direct marked text input.
- allowDirectMarkedTextInput(true);
- }
-
+
// Take care of old and new preeditors.
if (preeditor != mPreeditor || !b)
{
diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h
index de0340cf74..82195c2700 100755
--- a/indra/llwindow/llwindowmacosx.h
+++ b/indra/llwindow/llwindowmacosx.h
@@ -126,6 +126,8 @@ public:
void getMouseDeltas(float* delta);
void handleDragNDrop(std::string url, LLWindowCallbacks::DragNDropAction action);
+
+ bool allowsLanguageInput() { return mLanguageTextInputAllowed; }
protected:
LLWindowMacOSX(LLWindowCallbacks* callbacks,