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:
crs 2002-05-24 14:37:12 +00:00
parent a0b25b9d4a
commit 34c587e864
6 changed files with 58 additions and 2 deletions

View File

@ -255,6 +255,12 @@ KeyModifierMask CMSWindowsPrimaryScreen::getToggleMask() const
return mask; return mask;
} }
bool CMSWindowsPrimaryScreen::isLockedToScreen() const
{
// FIXME
return false;
}
void CMSWindowsPrimaryScreen::onOpenDisplay() void CMSWindowsPrimaryScreen::onOpenDisplay()
{ {
assert(m_window == NULL); assert(m_window == NULL);

View File

@ -27,6 +27,7 @@ public:
virtual SInt32 getJumpZoneSize() const; virtual SInt32 getJumpZoneSize() const;
virtual void getClipboard(ClipboardID, IClipboard*) const; virtual void getClipboard(ClipboardID, IClipboard*) const;
virtual KeyModifierMask getToggleMask() const; virtual KeyModifierMask getToggleMask() const;
virtual bool isLockedToScreen() const;
protected: protected:
// CMSWindowsScreen overrides // CMSWindowsScreen overrides

View File

@ -489,7 +489,17 @@ void CServer::onMouseWheel(SInt32 delta)
bool CServer::isLockedToScreen() const bool CServer::isLockedToScreen() const
{ {
// FIXME // locked if primary says we're locked
if (m_primary->isLockedToScreen()) {
return true;
}
// locked if scroll-lock is toggled on
if ((m_primary->getToggleMask() & KeyModifierScrollLock) != 0) {
return true;
}
// not locked
return false; return false;
} }

View File

@ -424,8 +424,9 @@ KeyModifierMask CXWindowsPrimaryScreen::getToggleMask() const
int xRoot, yRoot, xWindow, yWindow; int xRoot, yRoot, xWindow, yWindow;
unsigned int state; unsigned int state;
if (!XQueryPointer(display, m_window, &root, &window, if (!XQueryPointer(display, m_window, &root, &window,
&xRoot, &yRoot, &xWindow, &yWindow, &state)) &xRoot, &yRoot, &xWindow, &yWindow, &state)) {
return 0; return 0;
}
// convert to KeyModifierMask // convert to KeyModifierMask
KeyModifierMask mask = 0; KeyModifierMask mask = 0;
@ -439,6 +440,38 @@ KeyModifierMask CXWindowsPrimaryScreen::getToggleMask() const
return mask; 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() void CXWindowsPrimaryScreen::onOpenDisplay()
{ {
assert(m_window == None); assert(m_window == None);

View File

@ -25,6 +25,7 @@ public:
virtual SInt32 getJumpZoneSize() const; virtual SInt32 getJumpZoneSize() const;
virtual void getClipboard(ClipboardID, IClipboard*) const; virtual void getClipboard(ClipboardID, IClipboard*) const;
virtual KeyModifierMask getToggleMask() const; virtual KeyModifierMask getToggleMask() const;
virtual bool isLockedToScreen() const;
protected: protected:
// CXWindowsScreen overrides // CXWindowsScreen overrides

View File

@ -84,6 +84,11 @@ public:
// the returned mask should have the corresponding bit set for // the returned mask should have the corresponding bit set for
// each toggle key that is active. // each toggle key that is active.
virtual KeyModifierMask getToggleMask() const = 0; virtual KeyModifierMask getToggleMask() const = 0;
// return true if any key or button is being pressed or if there's
// any other reason that the user should not be allowed to switch
// screens.
virtual bool isLockedToScreen() const = 0;
}; };
#endif #endif