From a7e2141edef6550ea83ccc9b737e249c1702cf59 Mon Sep 17 00:00:00 2001 From: crs Date: Mon, 17 Mar 2003 22:32:01 +0000 Subject: [PATCH] Added a log message why the user is locked to the screen. --- lib/platform/CMSWindowsPrimaryScreen.cpp | 265 +++++++++++++++++++++++ lib/platform/CXWindowsPrimaryScreen.cpp | 47 ++-- lib/server/CServer.cpp | 9 +- lib/synergy/CPrimaryScreen.h | 2 + 4 files changed, 296 insertions(+), 27 deletions(-) diff --git a/lib/platform/CMSWindowsPrimaryScreen.cpp b/lib/platform/CMSWindowsPrimaryScreen.cpp index cc3f5d9f..98785b08 100644 --- a/lib/platform/CMSWindowsPrimaryScreen.cpp +++ b/lib/platform/CMSWindowsPrimaryScreen.cpp @@ -21,6 +21,269 @@ #include "CArchMiscWindows.h" #include +// +// map virtual key id to a name +// + +static const char* g_vkToName[] = { + "vk 0x00", + "VK_LBUTTON", + "VK_RBUTTON", + "VK_CANCEL", + "VK_MBUTTON", + "vk 0x05", + "vk 0x06", + "vk 0x07", + "VK_BACK", + "VK_TAB", + "vk 0x0a", + "vk 0x0b", + "VK_CLEAR", + "VK_RETURN", + "vk 0x0e", + "vk 0x0f", + "VK_SHIFT", + "VK_CONTROL", + "VK_MENU", + "VK_PAUSE", + "VK_CAPITAL", + "VK_KANA", + "vk 0x16", + "VK_JUNJA", + "VK_FINAL", + "VK_KANJI", + "vk 0x1a", + "VK_ESCAPE", + "VK_CONVERT", + "VK_NONCONVERT", + "VK_ACCEPT", + "VK_MODECHANGE", + "VK_SPACE", + "VK_PRIOR", + "VK_NEXT", + "VK_END", + "VK_HOME", + "VK_LEFT", + "VK_UP", + "VK_RIGHT", + "VK_DOWN", + "VK_SELECT", + "VK_PRINT", + "VK_EXECUTE", + "VK_SNAPSHOT", + "VK_INSERT", + "VK_DELETE", + "VK_HELP", + "VK_0", + "VK_1", + "VK_2", + "VK_3", + "VK_4", + "VK_5", + "VK_6", + "VK_7", + "VK_8", + "VK_9", + "vk 0x3a", + "vk 0x3b", + "vk 0x3c", + "vk 0x3d", + "vk 0x3e", + "vk 0x3f", + "vk 0x40", + "VK_A", + "VK_B", + "VK_C", + "VK_D", + "VK_E", + "VK_F", + "VK_G", + "VK_H", + "VK_I", + "VK_J", + "VK_K", + "VK_L", + "VK_M", + "VK_N", + "VK_O", + "VK_P", + "VK_Q", + "VK_R", + "VK_S", + "VK_T", + "VK_U", + "VK_V", + "VK_W", + "VK_X", + "VK_Y", + "VK_Z", + "VK_LWIN", + "VK_RWIN", + "VK_APPS", + "vk 0x5e", + "vk 0x5f", + "VK_NUMPAD0", + "VK_NUMPAD1", + "VK_NUMPAD2", + "VK_NUMPAD3", + "VK_NUMPAD4", + "VK_NUMPAD5", + "VK_NUMPAD6", + "VK_NUMPAD7", + "VK_NUMPAD8", + "VK_NUMPAD9", + "VK_MULTIPLY", + "VK_ADD", + "VK_SEPARATOR", + "VK_SUBTRACT", + "VK_DECIMAL", + "VK_DIVIDE", + "VK_F1", + "VK_F2", + "VK_F3", + "VK_F4", + "VK_F5", + "VK_F6", + "VK_F7", + "VK_F8", + "VK_F9", + "VK_F10", + "VK_F11", + "VK_F12", + "VK_F13", + "VK_F14", + "VK_F15", + "VK_F16", + "VK_F17", + "VK_F18", + "VK_F19", + "VK_F20", + "VK_F21", + "VK_F22", + "VK_F23", + "VK_F24", + "vk 0x88", + "vk 0x89", + "vk 0x8a", + "vk 0x8b", + "vk 0x8c", + "vk 0x8d", + "vk 0x8e", + "vk 0x8f", + "VK_NUMLOCK", + "VK_SCROLL", + "vk 0x92", + "vk 0x93", + "vk 0x94", + "vk 0x95", + "vk 0x96", + "vk 0x97", + "vk 0x98", + "vk 0x99", + "vk 0x9a", + "vk 0x9b", + "vk 0x9c", + "vk 0x9d", + "vk 0x9e", + "vk 0x9f", + "VK_LSHIFT", + "VK_RSHIFT", + "VK_LCONTROL", + "VK_RCONTROL", + "VK_LMENU", + "VK_RMENU", + "vk 0xa6", + "vk 0xa7", + "vk 0xa8", + "vk 0xa9", + "vk 0xaa", + "vk 0xab", + "vk 0xac", + "vk 0xad", + "vk 0xae", + "vk 0xaf", + "vk 0xb0", + "vk 0xb1", + "vk 0xb2", + "vk 0xb3", + "vk 0xb4", + "vk 0xb5", + "vk 0xb6", + "vk 0xb7", + "vk 0xb8", + "vk 0xb9", + "vk 0xba", + "vk 0xbb", + "vk 0xbc", + "vk 0xbd", + "vk 0xbe", + "vk 0xbf", + "vk 0xc0", + "vk 0xc1", + "vk 0xc2", + "vk 0xc3", + "vk 0xc4", + "vk 0xc5", + "vk 0xc6", + "vk 0xc7", + "vk 0xc8", + "vk 0xc9", + "vk 0xca", + "vk 0xcb", + "vk 0xcc", + "vk 0xcd", + "vk 0xce", + "vk 0xcf", + "vk 0xd0", + "vk 0xd1", + "vk 0xd2", + "vk 0xd3", + "vk 0xd4", + "vk 0xd5", + "vk 0xd6", + "vk 0xd7", + "vk 0xd8", + "vk 0xd9", + "vk 0xda", + "vk 0xdb", + "vk 0xdc", + "vk 0xdd", + "vk 0xde", + "vk 0xdf", + "vk 0xe0", + "vk 0xe1", + "vk 0xe2", + "vk 0xe3", + "vk 0xe4", + "VK_PROCESSKEY", + "vk 0xe6", + "vk 0xe7", + "vk 0xe8", + "vk 0xe9", + "vk 0xea", + "vk 0xeb", + "vk 0xec", + "vk 0xed", + "vk 0xee", + "vk 0xef", + "vk 0xf0", + "vk 0xf1", + "vk 0xf2", + "vk 0xf3", + "vk 0xf4", + "vk 0xf5", + "VK_ATTN", + "VK_CRSEL", + "VK_EXSEL", + "VK_EREOF", + "VK_PLAY", + "VK_ZOOM", + "VK_NONAME", + "VK_PA1", + "VK_OEM_CLEAR", + "vk 0xff" +}; + // // CMSWindowsPrimaryScreen // @@ -157,6 +420,7 @@ CMSWindowsPrimaryScreen::isLockedToScreen() const // use shadow keyboard state in m_keys for (UInt32 i = 0; i < 256; ++i) { if ((m_keys[i] & 0x80) != 0) { + LOG((CLOG_DEBUG "locked by \"%s\"", g_vkToName[i])); return true; } } @@ -166,6 +430,7 @@ CMSWindowsPrimaryScreen::isLockedToScreen() const for (UInt32 b = 1, j = 0; j < 32; b <<= 1, ++j) { if ((s_mappedKeys[i] & b) != 0) { if (GetAsyncKeyState(i * 32 + j) < 0) { + LOG((CLOG_DEBUG "locked by \"%s\"", g_vkToName[i * 32 + j])); return true; } } diff --git a/lib/platform/CXWindowsPrimaryScreen.cpp b/lib/platform/CXWindowsPrimaryScreen.cpp index 67611c39..69e91951 100644 --- a/lib/platform/CXWindowsPrimaryScreen.cpp +++ b/lib/platform/CXWindowsPrimaryScreen.cpp @@ -150,6 +150,7 @@ CXWindowsPrimaryScreen::isLockedToScreen() const &xRoot, &yRoot, &xWindow, &yWindow, &state)) { if ((state & (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask)) != 0) { + LOG((CLOG_DEBUG "locked by mouse button")); return true; } } @@ -162,32 +163,32 @@ CXWindowsPrimaryScreen::isLockedToScreen() const // locked if any key is down for (unsigned int i = 0; i < sizeof(keyMap); ++i) { if (keyMap[i] != 0) { - // if any key is half-duplex then it'll be down when - // toggled on but shouldn't count as a reason to lock - // to the screen. - if (m_numLockHalfDuplex || m_capsLockHalfDuplex) { - for (unsigned int j = 0; j < 8; ++j) { - if ((keyMap[i] & (1 << j)) != 0) { - const KeyCode keycode = 8 * i + j; - const KeySym keysym = XKeycodeToKeysym(display, - keycode, 0); - if (m_numLockHalfDuplex && keysym == XK_Num_Lock) { - continue; - } - if (m_capsLockHalfDuplex && keysym == XK_Caps_Lock) { - continue; - } - - // non-half-duplex key down - return true; + for (unsigned int j = 0; j < 8; ++j) { + if ((keyMap[i] & (1 << j)) != 0) { + const KeyCode keycode = 8 * i + j; + const KeySym keysym = XKeycodeToKeysym(display, + keycode, 0); + // if any key is half-duplex then it'll be down when + // toggled on but shouldn't count as a reason to lock + // to the screen. + if (m_numLockHalfDuplex && keysym == XK_Num_Lock) { + continue; } + if (m_capsLockHalfDuplex && keysym == XK_Caps_Lock) { + continue; + } + + // non-half-duplex key down + char* name = XKeysymToString(keysym); + if (name == NULL) { + LOG((CLOG_DEBUG "locked by keycode %d", keycode)); + } + else { + LOG((CLOG_DEBUG "locked by \"%s\"", name)); + } + return true; } - - // only half-duplex keys down - continue; } - - return true; } } diff --git a/lib/server/CServer.cpp b/lib/server/CServer.cpp index 65067b1a..2756f025 100644 --- a/lib/server/CServer.cpp +++ b/lib/server/CServer.cpp @@ -897,13 +897,14 @@ CServer::onCommandKey(KeyID /*id*/, KeyModifierMask /*mask*/, bool /*down*/) bool CServer::isLockedToScreenNoLock() const { - // locked if primary says we're locked - if (m_primaryClient->isLockedToScreen()) { + // locked if scroll-lock is toggled on + if ((m_primaryClient->getToggleMask() & KeyModifierScrollLock) != 0) { + LOG((CLOG_DEBUG "locked by ScrollLock")); return true; } - // locked if scroll-lock is toggled on - if ((m_primaryClient->getToggleMask() & KeyModifierScrollLock) != 0) { + // locked if primary says we're locked + if (m_primaryClient->isLockedToScreen()) { return true; } diff --git a/lib/synergy/CPrimaryScreen.h b/lib/synergy/CPrimaryScreen.h index 0ae68e9d..c370d19b 100644 --- a/lib/synergy/CPrimaryScreen.h +++ b/lib/synergy/CPrimaryScreen.h @@ -175,6 +175,8 @@ public: any other reason that the user should not be allowed to switch screens. Active toggle keys (including the scroll lock key) should not be counted as reasons to lock to the screen. + If this method returns true it should log a message on why at + the CLOG_DEBUG level. */ virtual bool isLockedToScreen() const = 0;