mirror of
https://github.com/debauchee/barrier.git
synced 2026-02-12 06:35:04 +08:00
added support for locking to a screen when the sroll lock is
toggled on or when any key or button is pressed. fully implemented on X but stubbed out for now on win32.
This commit is contained in:
@@ -424,8 +424,9 @@ KeyModifierMask CXWindowsPrimaryScreen::getToggleMask() const
|
||||
int xRoot, yRoot, xWindow, yWindow;
|
||||
unsigned int state;
|
||||
if (!XQueryPointer(display, m_window, &root, &window,
|
||||
&xRoot, &yRoot, &xWindow, &yWindow, &state))
|
||||
&xRoot, &yRoot, &xWindow, &yWindow, &state)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// convert to KeyModifierMask
|
||||
KeyModifierMask mask = 0;
|
||||
@@ -439,6 +440,38 @@ KeyModifierMask CXWindowsPrimaryScreen::getToggleMask() const
|
||||
return mask;
|
||||
}
|
||||
|
||||
bool CXWindowsPrimaryScreen::isLockedToScreen() const
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
|
||||
// query the pointer to get the button state
|
||||
Window root, window;
|
||||
int xRoot, yRoot, xWindow, yWindow;
|
||||
unsigned int state;
|
||||
if (XQueryPointer(display, m_window, &root, &window,
|
||||
&xRoot, &yRoot, &xWindow, &yWindow, &state)) {
|
||||
if ((state & (Button1Mask | Button2Mask | Button3Mask |
|
||||
Button4Mask | Button5Mask)) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// get logical keyboard state
|
||||
char keyMap[32];
|
||||
memset(keyMap, 0, sizeof(keyMap));
|
||||
XQueryKeymap(display, keyMap);
|
||||
|
||||
// locked if any key is down
|
||||
for (unsigned int i = 0; i < sizeof(keyMap); ++i) {
|
||||
if (keyMap[i] != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// not locked
|
||||
return false;
|
||||
}
|
||||
|
||||
void CXWindowsPrimaryScreen::onOpenDisplay()
|
||||
{
|
||||
assert(m_window == None);
|
||||
|
||||
Reference in New Issue
Block a user