From a0cf45a0ef5f7e2cbf0833f4d8655131912400cc Mon Sep 17 00:00:00 2001 From: Scott Moynes Date: Sun, 21 Jul 2002 22:35:43 +0000 Subject: [PATCH] handle all combinations of lock modifiers on keypress this should be an rc file option --- util/epist/epist.hh | 5 +++++ util/epist/screen.cc | 43 ++++++++++++++++++++++++++++++++++++++++++- util/epist/screen.hh | 2 ++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/util/epist/epist.hh b/util/epist/epist.hh index 7bd0d276..c0687e02 100644 --- a/util/epist/epist.hh +++ b/util/epist/epist.hh @@ -67,6 +67,11 @@ public: void removeWindow(XWindow *window); XWindow *findWindow(Window window) const; + void getLockModifiers(int &numlockMask, int &scrolllockMask) const { + numlockMask = NumLockMask; + scrolllockMask = ScrollLockMask; + } + const ActionList &actions(void) { return _actions; } }; diff --git a/util/epist/screen.cc b/util/epist/screen.cc index 78f3a9d0..1086ce4a 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -155,11 +155,18 @@ void screen::processEvent(const XEvent &e) { } void screen::handleKeypress(const XEvent &e) { + int scrolllockMask, numlockMask; + ActionList::const_iterator it = _epist->actions().begin(); ActionList::const_iterator end = _epist->actions().end(); + + _epist->getLockModifiers(numlockMask, scrolllockMask); + for (; it != end; ++it) { + unsigned int state = e.xkey.state & ~(LockMask|scrolllockMask|numlockMask); + if (e.xkey.keycode == it->keycode() && - e.xkey.state == it->modifierMask()) { + state == it->modifierMask()) { switch (it->type()) { case Action::nextWorkspace: cycleWorkspace(true); @@ -491,3 +498,37 @@ void screen::changeWorkspace(const int num) const { _xatom->sendClientMessage(_root, XAtom::net_current_desktop, _root, num); } + +void screen::grabKey(const KeyCode keyCode, const int modifierMask) const { + + Display *display = _epist->getXDisplay(); + int numlockMask, scrolllockMask; + + _epist->getLockModifiers(numlockMask, scrolllockMask); + + XGrabKey(display, keyCode, modifierMask, + _root, True, GrabModeAsync, GrabModeAsync); + XGrabKey(display, keyCode, + modifierMask|LockMask, + _root, True, GrabModeAsync, GrabModeAsync); + XGrabKey(display, keyCode, + modifierMask|scrolllockMask, + _root, True, GrabModeAsync, GrabModeAsync); + XGrabKey(display, keyCode, + modifierMask|numlockMask, + _root, True, GrabModeAsync, GrabModeAsync); + + XGrabKey(display, keyCode, + modifierMask|LockMask|scrolllockMask, + _root, True, GrabModeAsync, GrabModeAsync); + XGrabKey(display, keyCode, + modifierMask|scrolllockMask|numlockMask, + _root, True, GrabModeAsync, GrabModeAsync); + XGrabKey(display, keyCode, + modifierMask|numlockMask|LockMask, + _root, True, GrabModeAsync, GrabModeAsync); + + XGrabKey(display, keyCode, + modifierMask|numlockMask|LockMask|scrolllockMask, + _root, True, GrabModeAsync, GrabModeAsync); +} diff --git a/util/epist/screen.hh b/util/epist/screen.hh index 4c3a47c2..be30baa5 100644 --- a/util/epist/screen.hh +++ b/util/epist/screen.hh @@ -80,6 +80,8 @@ public: void changeWorkspace(const int num) const; void toggleShaded(const Window win) const; void execCommand(const std::string &cmd) const; + + void grabKey(const KeyCode keyCode, const int modifierMask) const; }; #endif // __screen_hh -- 2.45.2