• R/O
  • HTTP
  • SSH
  • HTTPS

xkeymacs: Commit


Commit MetaInfo

Revisiona583dd5c9a78eb14e6b7994ed83cbfb60eb07a5b (tree)
Time2012-01-27 23:58:26
AuthorKazuhiro Fujieda <fujieda@user...>
CommiterKazuhiro Fujieda

Log Message

Modify the code related to m_bHook in CXkeymacsDll.

Change Summary

Incremental Difference

--- a/xkeymacs/mainfrm.cpp
+++ b/xkeymacs/mainfrm.cpp
@@ -352,7 +352,7 @@ void CMainFrame::ShowRightMenu(const ICON_TYPE icon)
352352 popUp->SetDefaultItem(IDC_PROPERTIES);
353353
354354 CString szDisable(MAKEINTRESOURCE(IDS_ENABLE));
355- if (CXkeymacsDll::IsKeyboardHook()) {
355+ if (CXkeymacsDll::GetHookState()) {
356356 szDisable.LoadString(IDS_DISABLE);
357357 }
358358 szDisable += _T("\tCtrl+Q");
@@ -447,7 +447,7 @@ void CMainFrame::OnOptions()
447447 // stop/start keyboard hook
448448 void CMainFrame::OnDisable()
449449 {
450- CXkeymacsDll::ToggleKeyboardHookState();
450+ CXkeymacsDll::ToggleHookState();
451451 }
452452
453453 // Close the Dialog if it is opened.
--- a/xkeymacsdll/Commands.cpp
+++ b/xkeymacsdll/Commands.cpp
@@ -2904,7 +2904,7 @@ BOOL CCommands::IsTemporarilyDisableXKeymacs()
29042904 void CCommands::SetTemporarilyDisableXKeymacs(BOOL bTemporarilyDisableXKeymacs)
29052905 {
29062906 m_bTemporarilyDisableXKeymacs = bTemporarilyDisableXKeymacs;
2907- CXkeymacsDll::ShowKeyboardHookState();
2907+ CXkeymacsDll::ShowHookState();
29082908 }
29092909
29102910 int CCommands::New()
--- a/xkeymacsdll/xkeymacsdll.cpp
+++ b/xkeymacsdll/xkeymacsdll.cpp
@@ -91,7 +91,7 @@ DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
9191 #pragma data_seg(".xkmcs")
9292 Config CXkeymacsDll::m_Config = {0};
9393 bool CXkeymacsDll::m_bEnableKeyboardHook = false;
94-BOOL CXkeymacsDll::m_bHook = TRUE;
94+bool CXkeymacsDll::m_bHook = true;
9595 int CXkeymacsDll::m_nAccelerate = 0;
9696 int CXkeymacsDll::m_nKeyboardSpeed = 31;
9797 HCURSOR CXkeymacsDll::m_hCurrentCursor = NULL;
@@ -206,18 +206,23 @@ void CXkeymacsDll::ReleaseKeyboardHook()
206206 unhook(*phHook);
207207 }
208208
209-void CXkeymacsDll::ToggleKeyboardHookState()
209+void CXkeymacsDll::ToggleHookState()
210210 {
211- m_bHook = !m_bHook;
212- ShowKeyboardHookState();
211+ SetHookState(!m_bHook);
213212 }
214213
215-BOOL CXkeymacsDll::IsKeyboardHook()
214+void CXkeymacsDll::SetHookState(bool enable)
215+{
216+ m_bHook = enable;
217+ ShowHookState();
218+}
219+
220+bool CXkeymacsDll::GetHookState()
216221 {
217222 return m_bHook;
218223 }
219224
220-void CXkeymacsDll::ShowKeyboardHookState()
225+void CXkeymacsDll::ShowHookState()
221226 {
222227 IconMsg msg = {MAIN_ICON,};
223228 if (m_bHook) {
@@ -259,14 +264,14 @@ LRESULT CALLBACK CXkeymacsDll::CallWndProc(int nCode, WPARAM wParam, LPARAM lPar
259264 if (cwps->hwnd == GetForegroundWindow()) {
260265 AppName::SetIMEState(false);
261266 InitKeyboardProc();
262- ShowKeyboardHookState();
267+ ShowHookState();
263268 }
264269 break;
265270 case WM_NCACTIVATE:
266271 if (cwps->wParam && cwps->hwnd == GetForegroundWindow()) {
267272 AppName::SetIMEState(false);
268273 InitKeyboardProc();
269- ShowKeyboardHookState();
274+ ShowHookState();
270275 }
271276 break;
272277 }
@@ -320,7 +325,7 @@ LRESULT CALLBACK CXkeymacsDll::ShellProc(int nCode, WPARAM wParam, LPARAM lParam
320325 if (!_tcsicmp(className, _T("ConsoleWindowClass"))) {
321326 AppName::SetIMEState(false);
322327 InitKeyboardProc();
323- ShowKeyboardHookState();
328+ ShowHookState();
324329 }
325330 }
326331 return CallNextHookEx(NULL, nCode, wParam, lParam);
@@ -502,17 +507,15 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa
502507
503508 int (*fCommand)() = CmdTable::Command(m_CmdID[nType][nKey]);
504509 if (fCommand == CCommands::EnableOrDisableXKeymacs) {
505- ToggleKeyboardHookState();
510+ ToggleHookState();
506511 goto HOOK;
507512 }
508513 if (fCommand == CCommands::EnableXKeymacs) {
509- if (!m_bHook)
510- ToggleKeyboardHookState();
514+ SetHookState(true);
511515 goto HOOK;
512516 }
513517 if (fCommand == CCommands::DisableXKeymacs) {
514- if (m_bHook)
515- ToggleKeyboardHookState();
518+ SetHookState(false);
516519 goto HOOK;
517520 }
518521 if (!m_bHook)
--- a/xkeymacsdll/xkeymacsdll.h
+++ b/xkeymacsdll/xkeymacsdll.h
@@ -28,9 +28,9 @@ public:
2828 static void ResetHooks();
2929 static void ReleaseHooks();
3030 static void ReleaseKeyboardHook();
31- static void ToggleKeyboardHookState();
32- static BOOL IsKeyboardHook();
33- static void ShowKeyboardHookState();
31+ static void ToggleHookState();
32+ static bool GetHookState();
33+ static void ShowHookState();
3434 static void SetM_xTip(LPCTSTR szPath);
3535 static BOOL SendIconMessage(IconMsg *pMsg, DWORD num);
3636 static BOOL IsDown(BYTE bVk, BOOL bPhysicalKey = TRUE);
@@ -63,7 +63,8 @@ private:
6363 static HHOOK m_hHookGetMessage;
6464 static HHOOK m_hHookShell;
6565 static bool m_bEnableKeyboardHook;
66- static BOOL m_bHook;
66+ static bool m_bHook;
67+ static void SetHookState(bool enable);
6768 static DWORD m_nHookAltRelease;
6869 static LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam);
6970 static LRESULT CALLBACK CallWndRetProc(int nCode, WPARAM wParam, LPARAM lParam);
Show on old repository browser