OSDN Git Service

Separate SetKeyboardFookFlag(BOOL) in CXkeymacsDll into
authorKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Wed, 11 May 2011 09:29:33 +0000 (18:29 +0900)
committerKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Fri, 10 Jun 2011 08:19:01 +0000 (17:19 +0900)
ToggleKeyboardHookState() and ShowKeyboardHookState(). Replace
SetKeyboardFookFlag() with ShowKeyboardHookState().

xkeymacs/mainfrm.cpp
xkeymacsdll/Commands.cpp
xkeymacsdll/xkeymacsdll.cpp
xkeymacsdll/xkeymacsdll.h

index 6575c0d..6881a36 100644 (file)
@@ -499,11 +499,7 @@ void CMainFrame::OnOptions()
 // stop/start keyboard hook\r
 void CMainFrame::OnDisable() \r
 {\r
-       if (CXkeymacsDll::IsKeyboardHook()) {\r
-               CXkeymacsDll::SetKeyboardHookFlag(FALSE);\r
-       } else {\r
-               CXkeymacsDll::SetKeyboardHookFlag(TRUE);\r
-       }\r
+       CXkeymacsDll::ToggleKeyboardHookState();\r
 }\r
 \r
 // Close the Dialog if it is opened.\r
index b291689..734cde6 100644 (file)
@@ -3184,7 +3184,7 @@ BOOL CCommands::IsTemporarilyDisableXKeymacs()
 void CCommands::SetTemporarilyDisableXKeymacs(BOOL bTemporarilyDisableXKeymacs)\r
 {\r
        m_bTemporarilyDisableXKeymacs = bTemporarilyDisableXKeymacs;\r
-       CXkeymacsDll::SetKeyboardHookFlag();\r
+       CXkeymacsDll::ShowKeyboardHookState();\r
 }\r
 \r
 int CCommands::New()\r
index 80f1b16..ab166eb 100644 (file)
@@ -336,9 +336,14 @@ void CXkeymacsDll::ReleaseHooks()
        unhook(g_hHookDummy);\r
 }\r
 \r
-void CXkeymacsDll::SetKeyboardHookFlag(BOOL bFlag)\r
+void CXkeymacsDll::ToggleKeyboardHookState()\r
+{\r
+       m_bHook = !m_bHook;\r
+       ShowKeyboardHookState();\r
+}\r
+\r
+void CXkeymacsDll::ShowKeyboardHookState()\r
 {\r
-       m_bHook = bFlag;\r
        ICONMSG msg = {MAIN_ICON,};\r
        if (m_bHook) {\r
                if (CCommands::IsTemporarilyDisableXKeymacs()) {\r
@@ -361,14 +366,9 @@ void CXkeymacsDll::SetKeyboardHookFlag(BOOL bFlag)
        DoSetCursor();\r
 }\r
 \r
-// if be keyboard hook, return TRUE\r
 BOOL CXkeymacsDll::IsKeyboardHook()\r
 {\r
-       if (m_bHook) {\r
-               return TRUE;\r
-       }\r
-\r
-       return FALSE;\r
+       return m_bHook;\r
 }\r
 \r
 void CXkeymacsDll::LogCallWndProcMessage(WPARAM wParam, LPARAM lParam)\r
@@ -510,14 +510,14 @@ LRESULT CALLBACK CXkeymacsDll::CallWndProc(int nCode, WPARAM wParam, LPARAM lPar
                case WM_SETFOCUS:\r
                        if (cwps.hwnd == GetForegroundWindow()) {\r
                                InitKeyboardProc(FALSE);\r
-                               SetKeyboardHookFlag(m_bHook);\r
+                               ShowKeyboardHookState();\r
                        }\r
                        break;\r
                case WM_NCACTIVATE:\r
                        if (cwps.wParam) {\r
                                if (cwps.hwnd == GetForegroundWindow()) {\r
                                        InitKeyboardProc(FALSE);\r
-                                       SetKeyboardHookFlag(m_bHook);\r
+                                       ShowKeyboardHookState();\r
                                }\r
                        }\r
                        break;\r
@@ -588,7 +588,7 @@ LRESULT CALLBACK CXkeymacsDll::ShellProc(int nCode, WPARAM wParam, LPARAM lParam
                ::GetClassName((HWND)wParam, className, 255);\r
                if (!_tcsicmp(className, _T("ConsoleWindowClass"))) {\r
                        InitKeyboardProc(FALSE);\r
-                       SetKeyboardHookFlag(m_bHook);\r
+                       ShowKeyboardHookState();\r
                }\r
                break;\r
        }\r
@@ -970,18 +970,18 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa
        }\r
 \r
        if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::EnableOrDisableXKeymacs) {\r
-               SetKeyboardHookFlag(!m_bHook);\r
+               ToggleKeyboardHookState();\r
                goto HOOK;\r
        }\r
        if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::EnableXKeymacs) {\r
                if (!m_bHook) {\r
-                       SetKeyboardHookFlag(!m_bHook);\r
+                       ToggleKeyboardHookState();\r
                }\r
                goto HOOK;\r
        }\r
        if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::DisableXKeymacs) {\r
                if (m_bHook) {\r
-                       SetKeyboardHookFlag(!m_bHook);\r
+                       ToggleKeyboardHookState();\r
                }\r
                goto HOOK;\r
        }\r
@@ -1682,11 +1682,6 @@ int CXkeymacsDll::IsPassThrough(BYTE nKey)
        return CONTINUE;\r
 }\r
 \r
-void CXkeymacsDll::SetKeyboardHookFlag()\r
-{\r
-       SetKeyboardHookFlag(m_bHook);\r
-}\r
-\r
 void CXkeymacsDll::SetFunctionKey(int nFunctionID, int nApplicationID, int nCommandType, int nKey)\r
 {\r
        if (nApplicationID      < 0 || MAX_APP                  <= nApplicationID\r
index 9626495..30093a6 100644 (file)
@@ -95,10 +95,10 @@ public:
        static void ReleaseKey(BYTE bVk);\r
        static void SetFunctionDefinition(int nFunctionID, CString szDefinition);\r
        static void SetFunctionKey(int nFunctionID, int nApplicationID, int nCommandType, int nKey);\r
-       static void SetKeyboardHookFlag();\r
-       static void SetKeyboardHookFlag(BOOL bFlag);\r
        static BOOL Is106Keyboard();\r
        static void Set106Keyboard(BOOL b106Keyboard);\r
+       static void ToggleKeyboardHookState();\r
+       static void ShowKeyboardHookState();\r
        static BOOL SendIconMessage(ICONMSG *pMsg, DWORD num);\r
        CXkeymacsDll();\r
        virtual ~CXkeymacsDll();\r