diff --git a/lib/server/CXWindowsPrimaryScreen.cpp b/lib/server/CXWindowsPrimaryScreen.cpp index 57e0092d..06452696 100644 --- a/lib/server/CXWindowsPrimaryScreen.cpp +++ b/lib/server/CXWindowsPrimaryScreen.cpp @@ -133,6 +133,31 @@ 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; + } + } + + // only half-duplex keys down + continue; + } + return true; } }