Added IME input window white list.

meow-7.2.2
Geenz 2013-05-13 19:39:45 -04:00
parent aa0cb35db5
commit b27899ee0e
4 changed files with 57 additions and 17 deletions

View File

@ -14,12 +14,16 @@
NSWindow *inputWindow;
LLNonInlineTextView *inputView;
NSTimer *frameTimer;
NSString *currentInputLanguage;
}
@property (assign) IBOutlet LLNSWindow *window;
@property (assign) IBOutlet NSWindow *inputWindow;
@property (assign) IBOutlet LLNonInlineTextView *inputView;
@property (retain) NSString *currentInputLanguage;
- (void) mainLoop;
- (void) showInputWindow:(bool)show;
- (void) languageUpdated;
@end

Binary file not shown.

View File

@ -2,9 +2,9 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">12D78</string>
<string key="IBDocument.SystemVersion">12E30</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.37</string>
<string key="IBDocument.AppKitVersion">1187.39</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -329,16 +329,13 @@
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="305280978">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<array class="NSMutableArray" key="NSSubviews"/>
<string key="NSFrameSize">{1024, 600}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:20</string>
</object>
<string key="NSScreenRect">{{0, 0}, {2560, 1440}}</string>
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<string key="NSFrameAutosaveName">Second Life</string>
<int key="NSWindowCollectionBehavior">128</int>
@ -349,7 +346,7 @@
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{272, 176}, {938, 42}}</string>
<int key="NSWTFlags">-1535638528</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowTitle">Input Window</string>
<string key="NSWindowClass">NSPanel</string>
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
@ -536,7 +533,7 @@
<reference key="NSNextKeyView" ref="238626476"/>
<string key="NSReuseIdentifierKey">_NS:21</string>
</object>
<string key="NSScreenRect">{{0, 0}, {2560, 1440}}</string>
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
@ -1112,7 +1109,7 @@
<string key="841.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="941.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES" key="941.NSWindowTemplate.visibleAtLaunch"/>
<boolean value="NO" key="941.NSWindowTemplate.visibleAtLaunch"/>
<array class="NSMutableArray" key="942.IBNSViewMetadataConstraints">
<reference ref="609370450"/>
<reference ref="262904360"/>
@ -1182,6 +1179,14 @@
<string key="minorKey">./Classes/LLNonInlineTextView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSLayoutConstraint</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/NSLayoutConstraint.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>

View File

@ -8,12 +8,14 @@
#import "llappdelegate-objc.h"
#include "llwindowmacosx-objc.h"
#include <Carbon/Carbon.h> // 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