handle all combinations of lock modifiers on keypress
this should be an rc file option
This commit is contained in:
parent
f754eb0ea4
commit
a0cf45a0ef
3 changed files with 49 additions and 1 deletions
|
@ -67,6 +67,11 @@ public:
|
||||||
void removeWindow(XWindow *window);
|
void removeWindow(XWindow *window);
|
||||||
XWindow *findWindow(Window window) const;
|
XWindow *findWindow(Window window) const;
|
||||||
|
|
||||||
|
void getLockModifiers(int &numlockMask, int &scrolllockMask) const {
|
||||||
|
numlockMask = NumLockMask;
|
||||||
|
scrolllockMask = ScrollLockMask;
|
||||||
|
}
|
||||||
|
|
||||||
const ActionList &actions(void) { return _actions; }
|
const ActionList &actions(void) { return _actions; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -155,11 +155,18 @@ void screen::processEvent(const XEvent &e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void screen::handleKeypress(const XEvent &e) {
|
void screen::handleKeypress(const XEvent &e) {
|
||||||
|
int scrolllockMask, numlockMask;
|
||||||
|
|
||||||
ActionList::const_iterator it = _epist->actions().begin();
|
ActionList::const_iterator it = _epist->actions().begin();
|
||||||
ActionList::const_iterator end = _epist->actions().end();
|
ActionList::const_iterator end = _epist->actions().end();
|
||||||
|
|
||||||
|
_epist->getLockModifiers(numlockMask, scrolllockMask);
|
||||||
|
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
|
unsigned int state = e.xkey.state & ~(LockMask|scrolllockMask|numlockMask);
|
||||||
|
|
||||||
if (e.xkey.keycode == it->keycode() &&
|
if (e.xkey.keycode == it->keycode() &&
|
||||||
e.xkey.state == it->modifierMask()) {
|
state == it->modifierMask()) {
|
||||||
switch (it->type()) {
|
switch (it->type()) {
|
||||||
case Action::nextWorkspace:
|
case Action::nextWorkspace:
|
||||||
cycleWorkspace(true);
|
cycleWorkspace(true);
|
||||||
|
@ -491,3 +498,37 @@ void screen::changeWorkspace(const int num) const {
|
||||||
|
|
||||||
_xatom->sendClientMessage(_root, XAtom::net_current_desktop, _root, num);
|
_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);
|
||||||
|
}
|
||||||
|
|
|
@ -80,6 +80,8 @@ public:
|
||||||
void changeWorkspace(const int num) const;
|
void changeWorkspace(const int num) const;
|
||||||
void toggleShaded(const Window win) const;
|
void toggleShaded(const Window win) const;
|
||||||
void execCommand(const std::string &cmd) const;
|
void execCommand(const std::string &cmd) const;
|
||||||
|
|
||||||
|
void grabKey(const KeyCode keyCode, const int modifierMask) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __screen_hh
|
#endif // __screen_hh
|
||||||
|
|
Loading…
Reference in a new issue