オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Contents of /aquaskk/trunk/platform/mac/src/server/MacInputModeWindow.mm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 59 - (show annotations) (download) (as text)
Fri Oct 17 15:30:50 2008 UTC (15 years, 7 months ago) by t-suwa
File MIME type: text/x-objcsrc
File size: 4286 byte(s)
 r530@milonga:  t_suwa | 2008-10-11 20:45:54 +0900
 - メッセンジャーの初期実装を追加
 
 r531@milonga:  t_suwa | 2008-10-11 20:46:45 +0900
 - SKKMessenger インタフェースの追加
 
 r532@milonga:  t_suwa | 2008-10-11 20:47:41 +0900
 - MacInputSessionParameter のインタフェース修正
 
 r533@milonga:  t_suwa | 2008-10-11 20:47:53 +0900
 - プロジェクトの修正
 
 r534@milonga:  t_suwa | 2008-10-11 21:00:04 +0900
 - SKKState:SKKMessenger に対応
 
 r535@milonga:  t_suwa | 2008-10-11 21:33:51 +0900
 - MessengerWindow.xib を追加
 
 r536@milonga:  t_suwa | 2008-10-11 21:34:09 +0900
 - MessengerWindowController の初期実装を追加
 
 r537@milonga:  t_suwa | 2008-10-11 21:34:30 +0900
 - プロジェクトを修正
 
 r538@milonga:  t_suwa | 2008-10-11 21:35:05 +0900
 - MacMessenger で MessengerWindowController に対応
 
 r539@milonga:  t_suwa | 2008-10-13 21:33:43 +0900
 - 入力モードアイコンの非表示オプションを追加
 
 r540@milonga:  t_suwa | 2008-10-13 21:40:52 +0900
 - enable_input_mode_icon を show_input_mode_icon に改名
 
 r541@milonga:  t_suwa | 2008-10-13 21:41:32 +0900
 - UserDefaults.plist:show_input_mode_icon のデフォルト値を追加
 
 r542@milonga:  t_suwa | 2008-10-13 21:41:55 +0900
 - Preferences.xib:show_input_mode_icon に対応
 
 r543@milonga:  t_suwa | 2008-10-13 21:42:51 +0900
 - SKKBackEnd:ことえり辞書の検索結果をデコードしていなかった不具合を修正
 
 r544@milonga:  t_suwa | 2008-10-15 00:37:56 +0900
 - SKKConstVars:自動ダイナミック補完用のプリファレンスキーを追加
 
 r545@milonga:  t_suwa | 2008-10-15 00:39:19 +0900
 - 自動ダイナミック補完用にインタフェースを変更
 
 r546@milonga:  t_suwa | 2008-10-15 00:41:03 +0900
 - SKKContextBuffer:自動ダイナミック補完用インタフェースを追加
 
 r547@milonga:  t_suwa | 2008-10-15 00:41:27 +0900
 - SKKComposingEditor:自動ダイナミック補完用インタフェースを追加
 
 r548@milonga:  t_suwa | 2008-10-15 00:41:49 +0900
 - SKKInputEngine:自動ダイナミック補完に対応
 
 r549@milonga:  t_suwa | 2008-10-15 00:43:18 +0900
 - MacFrontEnd, MacInputEngineOption:自動ダイナミック補完に対応
 
 r550@milonga:  t_suwa | 2008-10-15 00:46:47 +0900
 - Preferences.xib:自動ダイナミック補完に対応
 
 r551@milonga:  t_suwa | 2008-10-16 23:45:14 +0900
 - CompletionView.*, CompletionWindow.* 自動ダイナミック補完の実装
 
 r552@milonga:  t_suwa | 2008-10-16 23:46:06 +0900
 - SKKFrontEnd:補完用インタフェースを変更
 
 r553@milonga:  t_suwa | 2008-10-16 23:47:23 +0900
 - SKKComposingEditor:補完候補の編集をしないように修正
 
 r554@milonga:  t_suwa | 2008-10-16 23:47:56 +0900
 - SKKContextBuffer:SKKFrontEnd のインタフェースに適応
 
 r555@milonga:  t_suwa | 2008-10-16 23:48:53 +0900
 - MacFrontEnd:SKKFrontEnd のインタフェースに適応
 
 r556@milonga:  t_suwa | 2008-10-16 23:49:39 +0900
 - SKKInputController:補完候補を Deactivate 時に非表示に
 
 r557@milonga:  t_suwa | 2008-10-17 21:37:39 +0900
 - MessengerWindowController を除去
 - MessengerWindow と MessengerView を追加
 
 r558@milonga:  t_suwa | 2008-10-17 21:37:57 +0900
 - MacMessenger:MessengerWindow に対応
 
 r559@milonga:  t_suwa | 2008-10-17 22:36:33 +0900
 - Messenger*:メッセージ表示を改善
 
 r560@milonga:  t_suwa | 2008-10-17 22:41:10 +0900
 - 見出し語と単語の削除時にメッセージを表示
 
 r561@milonga:  t_suwa | 2008-10-18 00:14:30 +0900
 - Completion*:見た目の修正
 
 r562@milonga:  t_suwa | 2008-10-18 00:14:57 +0900
 - MessengerWindow.xib を削除
 - プロジェクトの修正
 
 r563@milonga:  t_suwa | 2008-10-18 00:15:15 +0900
 - MessengerWindow.xib を削除
 
 r564@milonga:  t_suwa | 2008-10-18 00:30:08 +0900
 - MessengerView:ウィンドウ矩形を表示するように修正
 

1 /* -*- ObjC -*-
2
3 MacOS X implementation of the SKK input method.
4
5 Copyright (C) 2008 Tomotaka SUWA <t.suwa@mac.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21 */
22
23 #include "MacInputModeWindow.h"
24 #include "SKKFrontEnd.h"
25 #include "SKKConstVars.h"
26 #include "InputModeWindowController.h"
27 #include <iostream>
28 #include <vector>
29
30 // MacInputModeWindow::Activate() から呼ばれるユーティリティ群
31 namespace {
32 // 左下原点を左上原点に変換する
33 CGPoint FlipPoint(int x, int y) {
34 NSRect screen = [[NSScreen mainScreen] frame];
35
36 return CGPointMake(x, NSHeight(screen) - y);
37 }
38
39 int ActiveProcessID() {
40 NSDictionary* info = [[NSWorkspace sharedWorkspace] activeApplication];
41 NSNumber* pid = [info objectForKey:@"NSApplicationProcessIdentifier"];
42
43 return [pid intValue];
44 }
45
46 typedef std::vector<CGRect> CGRectContainer;
47
48 // プロセス ID に関連したウィンドウ矩形群の取得
49 CGRectContainer CreateWindowBoundsListOf(int pid) {
50 CGRectContainer result;
51 NSArray* array = (NSArray*)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly,
52 kCGNullWindowID);
53 NSEnumerator* enumerator = [array objectEnumerator];
54
55 while(NSDictionary* window = [enumerator nextObject]) {
56 // 引数のプロセス ID でフィルタ
57 NSNumber* owner = [window objectForKey:(NSString*)kCGWindowOwnerPID];
58 if([owner intValue] != pid) continue;
59
60 // デスクトップ全面を覆う Finder のウィンドウは除外
61 NSNumber* level = [window objectForKey:(NSString*)kCGWindowLayer];
62 if([level intValue] == kCGMinimumWindowLevel) continue;
63
64 CGRect rect;
65 NSDictionary* bounds = [window objectForKey:(NSString*)kCGWindowBounds];
66 if(CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)bounds, &rect)) {
67 result.push_back(rect);
68 }
69 }
70
71 [array release];
72
73 return result;
74 }
75 }
76
77 // ============================================================
78
79 MacInputModeWindow::MacInputModeWindow(SKKFrontEnd* frontend)
80 : active_(false)
81 , frontend_(frontend)
82 , mode_(HirakanaInputMode) {
83 controller_ = [InputModeWindowController sharedController];
84 [controller_ changeMode:mode_];
85 }
86
87 void MacInputModeWindow::SelectInputMode(SKKInputMode mode) {
88 if(mode_ != mode) {
89 mode_ = mode;
90
91 if(active_) Activate();
92 }
93 }
94
95 void MacInputModeWindow::Activate() {
96 active_ = true;
97
98 if(!enabled()) return;
99
100 std::pair<int, int> position = frontend_->WindowPosition();
101
102 CGPoint cursor = FlipPoint(position.first, position.second);
103 CGRectContainer list = CreateWindowBoundsListOf(ActiveProcessID());
104
105 // カーソル位置がウィンドウ矩形に含まれていなければ無視する
106 int count = std::count_if(list.begin(), list.end(),
107 std::bind2nd(std::ptr_fun(CGRectContainsPoint), cursor));
108 if(!count) return;
109
110 [controller_ changeMode:mode_];
111 [controller_ show:NSMakePoint(position.first, position.second)
112 level:frontend_->WindowLevel()];
113 }
114
115 void MacInputModeWindow::Deactivate() {
116 [controller_ hide];
117
118 active_ = false;
119 }
120
121 // ------------------------------------------------------------
122
123 bool MacInputModeWindow::enabled() const {
124 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
125
126 [defaults synchronize];
127
128 return [defaults boolForKey:SKKUserDefaultKeys::show_input_mode_icon] == YES;
129 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26