• R/O
  • HTTP
  • SSH
  • HTTPS

xkeymacs: Commit


Commit MetaInfo

Revision46c3422b3b14145a7e1899bebdf137fac6bfaff4 (tree)
Time2012-01-23 03:07:40
AuthorKazuhiro Fujieda <fujieda@user...>
CommiterKazuhiro Fujieda

Log Message

Separate AppName::SetIMEState from CXkeymacsDll::InitKeyboardProc.
Make the handler of WM_SETTEXT not change the IME state.

Change Summary

Incremental Difference

--- a/xkeymacsdll/AppName.cpp
+++ b/xkeymacsdll/AppName.cpp
@@ -37,6 +37,7 @@ LPCTSTR AppName::GetAppName()
3737
3838 void AppName::SetIMEState(bool on)
3939 {
40+ AppName::Init();
4041 m_IMEState = on;
4142 if (!on)
4243 return;
@@ -51,6 +52,11 @@ void AppName::SetIMEState(bool on)
5152 _tcscpy_s(m_IMEName, m_FallbackIMEName);
5253 }
5354
55+bool AppName::GetIMEState()
56+{
57+ return m_IMEState;
58+}
59+
5460 // The code starting here is derived from work by co <cogood@gmail.com>.
5561 void AppName::CorrectAppName(TCHAR (&text)[WINDOW_TEXT_LENGTH], TCHAR (&appName)[CLASS_NAME_LENGTH])
5662 {
@@ -128,7 +134,7 @@ bool AppName::IsCmdExe(const CString& text)
128134 _T("syswow64\\cmd.exe")
129135 };
130136 for (int i = 0; i < _countof(prompts); ++i)
131- if (text.Right(_tcslen(prompts[i])).CompareNoCase(prompts[i]) == 0)
137+ if (text.Right(static_cast<int>(_tcslen(prompts[i]))).CompareNoCase(prompts[i]) == 0)
132138 return true;
133139 return false;
134140 }
--- a/xkeymacsdll/AppName.h
+++ b/xkeymacsdll/AppName.h
@@ -8,6 +8,7 @@ public:
88 static void Init();
99 static LPCTSTR GetAppName();
1010 static void SetIMEState(bool on);
11+ static bool GetIMEState();
1112 static void CorrectAppName(TCHAR (&text)[WINDOW_TEXT_LENGTH], TCHAR (&appName)[CLASS_NAME_LENGTH]);
1213 static bool IsConsole();
1314 static bool Match(LPCTSTR name);
--- a/xkeymacsdll/xkeymacsdll.cpp
+++ b/xkeymacsdll/xkeymacsdll.cpp
@@ -248,20 +248,24 @@ LRESULT CALLBACK CXkeymacsDll::CallWndProc(int nCode, WPARAM wParam, LPARAM lPar
248248 const CWPSTRUCT *cwps = reinterpret_cast<CWPSTRUCT *>(lParam);
249249 switch (cwps->message) {
250250 case WM_IME_STARTCOMPOSITION:
251- InitKeyboardProc(true);
251+ AppName::SetIMEState(true);
252+ InitKeyboardProc();
252253 break;
253254 case WM_IME_ENDCOMPOSITION:
254- InitKeyboardProc(false);
255+ AppName::SetIMEState(false);
256+ InitKeyboardProc();
255257 break;
256258 case WM_SETFOCUS:
257259 if (cwps->hwnd == GetForegroundWindow()) {
258- InitKeyboardProc(false);
260+ AppName::SetIMEState(false);
261+ InitKeyboardProc();
259262 ShowKeyboardHookState();
260263 }
261264 break;
262265 case WM_NCACTIVATE:
263266 if (cwps->wParam && cwps->hwnd == GetForegroundWindow()) {
264- InitKeyboardProc(false);
267+ AppName::SetIMEState(false);
268+ InitKeyboardProc();
265269 ShowKeyboardHookState();
266270 }
267271 break;
@@ -278,7 +282,7 @@ LRESULT CALLBACK CXkeymacsDll::CallWndRetProc(int nCode, WPARAM wParam, LPARAM l
278282 switch (cwprets->message) {
279283 case WM_SETTEXT:
280284 if (cwprets->hwnd == GetForegroundWindow())
281- InitKeyboardProc(false);
285+ InitKeyboardProc();
282286 break;
283287 case WM_SETCURSOR:
284288 DoSetCursor();
@@ -295,10 +299,12 @@ LRESULT CALLBACK CXkeymacsDll::GetMsgProc(int nCode, WPARAM wParam, LPARAM lPara
295299 const MSG *msg = reinterpret_cast<MSG *>(lParam);
296300 switch (msg->message) {
297301 case WM_IME_STARTCOMPOSITION:
298- InitKeyboardProc(true);
302+ AppName::SetIMEState(true);
303+ InitKeyboardProc();
299304 break;
300305 case WM_IME_ENDCOMPOSITION:
301- InitKeyboardProc(false);
306+ AppName::SetIMEState(false);
307+ InitKeyboardProc();
302308 break;
303309 }
304310 }
@@ -312,18 +318,17 @@ LRESULT CALLBACK CXkeymacsDll::ShellProc(int nCode, WPARAM wParam, LPARAM lParam
312318 TCHAR className[CLASS_NAME_LENGTH];
313319 GetClassName(reinterpret_cast<HWND>(wParam), className, CLASS_NAME_LENGTH);
314320 if (!_tcsicmp(className, _T("ConsoleWindowClass"))) {
315- InitKeyboardProc(false);
321+ AppName::SetIMEState(false);
322+ InitKeyboardProc();
316323 ShowKeyboardHookState();
317324 }
318325 }
319326 return CallNextHookEx(NULL, nCode, wParam, lParam);
320327 }
321328
322-void CXkeymacsDll::InitKeyboardProc(bool imeState)
329+void CXkeymacsDll::InitKeyboardProc()
323330 {
324331 AppName::Init();
325- AppName::SetIMEState(imeState);
326-
327332 if (m_CurrentConfig == NULL ||
328333 _tcsnicmp(m_CurrentConfig->AppName, AppName::GetAppName(), 0xF) || // PROCESSENTRY32 has only 0xF bytes of Name
329334 !CUtils::IsMatchWindowText(m_CurrentConfig->WindowText)) {
@@ -348,7 +353,7 @@ void CXkeymacsDll::InitKeyboardProc(bool imeState)
348353 }
349354 if (m_CurrentConfig->SettingStyle != SETTING_DISABLE &&
350355 (_tcsicmp(m_CurrentConfig->AppName, _T("Default")) || !CUtils::IsDefaultIgnoreApplication()) &&
351- !imeState && CUtils::IsDialog() && m_CurrentConfig->UseDialogSetting)
356+ !AppName::GetIMEState() && CUtils::IsDialog() && m_CurrentConfig->UseDialogSetting)
352357 // Use Dialog Setting
353358 m_CurrentConfig = GetAppConfig(_T("Dialog"), m_CurrentConfig);
354359 m_CmdID = m_CurrentConfig->CmdID;
--- a/xkeymacsdll/xkeymacsdll.h
+++ b/xkeymacsdll/xkeymacsdll.h
@@ -69,7 +69,7 @@ private:
6969 static LRESULT CALLBACK CallWndRetProc(int nCode, WPARAM wParam, LPARAM lParam);
7070 static LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
7171 static LRESULT CALLBACK ShellProc(int nCode, WPARAM wParam, LPARAM lParam);
72- static void InitKeyboardProc(bool imeState);
72+ static void InitKeyboardProc();
7373 static AppConfig* GetAppConfig(LPCTSTR szName, AppConfig* fallback);
7474 static BOOL m_bRightShift;
7575 static BOOL m_bRightControl;
Show on old repository browser