From 09b07e3619a71f142c1a3af41244d756e1230142 Mon Sep 17 00:00:00 2001 From: Geenz Date: Tue, 8 Jan 2013 16:22:54 -0500 Subject: Big change set: - LLAppDelegate header relocated to LLWindow. Definition is still present in secondlife-bin (for compatibility reasons when loading a nib). - Return key handling fixed. - Command key now acts the same as the control key by issuing control character codes when the command key is pressed. - We now retrieve the window pointer directly from the app delegate in LLWindow. --- indra/newview/llappdelegate-objc.mm | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 indra/newview/llappdelegate-objc.mm (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm new file mode 100644 index 0000000000..f5143d7578 --- /dev/null +++ b/indra/newview/llappdelegate-objc.mm @@ -0,0 +1,55 @@ +// +// LLAppDelegate.m +// SecondLife +// +// Created by Geenz on 12/16/12. +// +// + +#import "llappdelegate-objc.h" + +@implementation LLAppDelegate + +@synthesize window; + +- (void)dealloc +{ + [super dealloc]; +} + +- (void) applicationDidFinishLaunching:(NSNotification *)notification +{ + frameTimer = nil; + + if (initViewer()) + { + frameTimer = [NSTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(mainLoop) userInfo:nil repeats:YES]; + } else { + handleQuit(); + } +} + +- (NSApplicationDelegateReply) applicationShouldTerminate:(NSApplication *)sender +{ + if (!runMainLoop()) + { + handleQuit(); + return NSTerminateCancel; + } else { + [frameTimer release]; + cleanupViewer(); + return NSTerminateNow; + } +} + +- (void) mainLoop +{ + bool appExiting = runMainLoop(); + if (appExiting) + { + [frameTimer release]; + [[NSApplication sharedApplication] terminate:self]; + } +} + +@end -- cgit v1.2.3 From c52e6f9c597c67637045134d808a9039f85efc5c Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 23 Jan 2013 09:29:32 -0500 Subject: Refactor the key input handling to make it easier to filter out keys we don't need unicode characters for (such as the arrow keys). --- indra/newview/llappdelegate-objc.mm | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index f5143d7578..9bb10f3204 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -29,6 +29,16 @@ } } +- (void) applicationDidBecomeActive:(NSNotification *)notification +{ + +} + +- (void) applicationDidResignActive:(NSNotification *)notification +{ + +} + - (NSApplicationDelegateReply) applicationShouldTerminate:(NSApplication *)sender { if (!runMainLoop()) -- cgit v1.2.3 From ab4af5d564c2e54a087967f352b09f4ebc55cab3 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 23 Jan 2013 11:01:47 -0500 Subject: Readd event handling for application focus. --- indra/newview/llappdelegate-objc.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 9bb10f3204..9e0e0e35c5 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -31,12 +31,12 @@ - (void) applicationDidBecomeActive:(NSNotification *)notification { - + callWindowFocus(); } - (void) applicationDidResignActive:(NSNotification *)notification { - + callWindowUnfocus(); } - (NSApplicationDelegateReply) applicationShouldTerminate:(NSApplication *)sender -- cgit v1.2.3 From 80a79e5d7b4f37f862b312e848b1d1e7f85b0fa9 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 27 Mar 2013 08:49:45 -0400 Subject: IME support is pretty much finished at this point. --- indra/newview/llappdelegate-objc.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 9e0e0e35c5..5fb5087cd8 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -7,6 +7,7 @@ // #import "llappdelegate-objc.h" +#include "llwindowmacosx-objc.h" @implementation LLAppDelegate -- cgit v1.2.3 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/newview/llappdelegate-objc.mm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'indra/newview/llappdelegate-objc.mm') 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 From b27899ee0e035ebd4072a5e6162678f2afe81053 Mon Sep 17 00:00:00 2001 From: Geenz Date: Mon, 13 May 2013 19:39:45 -0400 Subject: Added IME input window white list. --- indra/newview/llappdelegate-objc.mm | 45 +++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 8da44fcf33..de77447006 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -8,12 +8,14 @@ #import "llappdelegate-objc.h" #include "llwindowmacosx-objc.h" +#include // Used for Text Input Services ("Safe" API - it's well supported) @implementation LLAppDelegate @synthesize window; @synthesize inputWindow; @synthesize inputView; +@synthesize currentInputLanguage; - (void)dealloc { @@ -24,12 +26,16 @@ { frameTimer = nil; + [self languageUpdated]; + if (initViewer()) { frameTimer = [NSTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(mainLoop) userInfo:nil repeats:YES]; } else { handleQuit(); } + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(languageUpdated) name:@"NSTextInputContextKeyboardSelectionDidChangeNotification" object:nil]; } - (void) applicationDidBecomeActive:(NSNotification *)notification @@ -67,15 +73,40 @@ - (void) showInputWindow:(bool)show { - if (show) + // How to add support for new languages with the input window: + // Simply append this array with the language code (ja for japanese, ko for korean, zh for chinese, etc.) + NSArray *authorizedLanguages = [[NSArray alloc] initWithObjects:@"ja", @"ko", @"zh-Hant", @"zh-Hans", nil]; + + if ([authorizedLanguages containsObject:currentInputLanguage]) { - NSLog(@"Showing input window."); - [inputWindow makeKeyAndOrderFront:inputWindow]; - } else { - NSLog(@"Hiding input window."); - [inputWindow orderOut:inputWindow]; - [window makeKeyAndOrderFront:window]; + if (show) + { + NSLog(@"Showing input window."); + [inputWindow makeKeyAndOrderFront:inputWindow]; + } else { + NSLog(@"Hiding input window."); + [inputWindow orderOut:inputWindow]; + [window makeKeyAndOrderFront:window]; + } } } +// This will get called multiple times by NSNotificationCenter. +// It will be called every time that the window focus changes, and every time that the input language gets changed. +// The primary use case for this selector is to update our current input language when the user, for whatever reason, changes the input language. +// This is the more elegant way of handling input language changes instead of checking every time we want to use the input window. + +- (void) languageUpdated +{ + TISInputSourceRef currentInput = TISCopyCurrentKeyboardInputSource(); + CFArrayRef languages = (CFArrayRef)TISGetInputSourceProperty(currentInput, kTISPropertyInputSourceLanguages); + +#if 1 // In the event of ever needing to add new language sources, change this to 1 and watch the terminal for "languages:" + NSLog(@"languages: %@", TISGetInputSourceProperty(currentInput, kTISPropertyInputSourceLanguages)); +#endif + + // Typically the language we want is going to be the very first result in the array. + currentInputLanguage = (NSString*)CFArrayGetValueAtIndex(languages, 0); +} + @end -- cgit v1.2.3 From 93531f3ba85748ba5c9f1d797c4925f55fe8b92c Mon Sep 17 00:00:00 2001 From: Geenz Date: Mon, 17 Jun 2013 08:59:01 -0400 Subject: Insert text into the input window when we attempt to insert text without a pre-editor. Also handle backspace as a special case when determining if the input window needs to be displayed. --- indra/newview/llappdelegate-objc.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index de77447006..b4f9c56b00 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -71,7 +71,7 @@ } } -- (void) showInputWindow:(bool)show +- (void) showInputWindow:(bool)show withText:(id)text { // How to add support for new languages with the input window: // Simply append this array with the language code (ja for japanese, ko for korean, zh for chinese, etc.) @@ -83,6 +83,7 @@ { NSLog(@"Showing input window."); [inputWindow makeKeyAndOrderFront:inputWindow]; + [inputView setMarkedText:text selectedRange:NSMakeRange(0, 1)]; } else { NSLog(@"Hiding input window."); [inputWindow orderOut:inputWindow]; -- cgit v1.2.3 From 440a1ee3bae4ea9553fa57d806f942a472923190 Mon Sep 17 00:00:00 2001 From: Geenz Date: Mon, 17 Jun 2013 09:26:11 -0400 Subject: Move logic involving the input window to keyDown. Pass input events to the input window from there. --- indra/newview/llappdelegate-objc.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index b4f9c56b00..403c307085 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -8,7 +8,7 @@ #import "llappdelegate-objc.h" #include "llwindowmacosx-objc.h" -#include // Used for Text Input Services ("Safe" API - it's well supported) +#include // Used for Text Input Services ("Safe" API - it's supported) @implementation LLAppDelegate -- cgit v1.2.3 From 2253d22eb85a6b4c5e48b9905d807d0ac48b1930 Mon Sep 17 00:00:00 2001 From: Geenz Date: Mon, 17 Jun 2013 10:28:32 -0400 Subject: Have showInputWindow hand off input events to the bottom line input window. --- indra/newview/llappdelegate-objc.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 403c307085..cec9c586e6 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -71,7 +71,7 @@ } } -- (void) showInputWindow:(bool)show withText:(id)text +- (void) showInputWindow:(bool)show withEvent:(NSEvent*)textEvent { // How to add support for new languages with the input window: // Simply append this array with the language code (ja for japanese, ko for korean, zh for chinese, etc.) @@ -83,7 +83,10 @@ { NSLog(@"Showing input window."); [inputWindow makeKeyAndOrderFront:inputWindow]; - [inputView setMarkedText:text selectedRange:NSMakeRange(0, 1)]; + if (textEvent != nil) + { + [[inputView inputContext] handleEvent:textEvent]; + } } else { NSLog(@"Hiding input window."); [inputWindow orderOut:inputWindow]; -- cgit v1.2.3 From 84f287b34e7d7edbd2e897b73008c782aabe60de Mon Sep 17 00:00:00 2001 From: Geenz Date: Mon, 17 Jun 2013 12:31:25 -0400 Subject: Moved detecting if we're using a roman-script language to it's own function in the application delegate. Also consider the delete and backspace characters to be special cases. --- indra/newview/llappdelegate-objc.mm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index cec9c586e6..6b7e613491 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -73,11 +73,7 @@ - (void) showInputWindow:(bool)show withEvent:(NSEvent*)textEvent { - // How to add support for new languages with the input window: - // Simply append this array with the language code (ja for japanese, ko for korean, zh for chinese, etc.) - NSArray *authorizedLanguages = [[NSArray alloc] initWithObjects:@"ja", @"ko", @"zh-Hant", @"zh-Hans", nil]; - - if ([authorizedLanguages containsObject:currentInputLanguage]) + if (![self romanScript]) { if (show) { @@ -85,6 +81,7 @@ [inputWindow makeKeyAndOrderFront:inputWindow]; if (textEvent != nil) { + [[inputView inputContext] discardMarkedText]; [[inputView inputContext] handleEvent:textEvent]; } } else { @@ -105,7 +102,7 @@ TISInputSourceRef currentInput = TISCopyCurrentKeyboardInputSource(); CFArrayRef languages = (CFArrayRef)TISGetInputSourceProperty(currentInput, kTISPropertyInputSourceLanguages); -#if 1 // In the event of ever needing to add new language sources, change this to 1 and watch the terminal for "languages:" +#if 0 // In the event of ever needing to add new language sources, change this to 1 and watch the terminal for "languages:" NSLog(@"languages: %@", TISGetInputSourceProperty(currentInput, kTISPropertyInputSourceLanguages)); #endif @@ -113,4 +110,17 @@ currentInputLanguage = (NSString*)CFArrayGetValueAtIndex(languages, 0); } +- (bool) romanScript +{ + // How to add support for new languages with the input window: + // Simply append this array with the language code (ja for japanese, ko for korean, zh for chinese, etc.) + NSArray *nonRomanScript = [[NSArray alloc] initWithObjects:@"ja", @"ko", @"zh-Hant", @"zh-Hans", nil]; + if ([nonRomanScript containsObject:currentInputLanguage]) + { + return false; + } + + return true; +} + @end -- cgit v1.2.3 From 623077e6a4eef516d445975eaa71d5f67e6767c5 Mon Sep 17 00:00:00 2001 From: Geenz Date: Thu, 27 Jun 2013 15:06:03 -0400 Subject: Added license headers. --- indra/newview/llappdelegate-objc.mm | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 6b7e613491..30476b3d22 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -1,10 +1,28 @@ -// -// LLAppDelegate.m -// SecondLife -// -// Created by Geenz on 12/16/12. -// -// +/** + * @file llappdelegate-objc.mm + * @brief Class implementation for the Mac version's application delegate. + * + * $LicenseInfo:firstyear=2000&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ #import "llappdelegate-objc.h" #include "llwindowmacosx-objc.h" -- cgit v1.2.3