X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=util%2Fepist%2Fscreen.cc;h=c4f0520be54e9e34f90f1ebb14f62ec6ca13441b;hb=d8967bd534ff10a234fed17059fb92d985be9176;hp=1dc32f0231b566c1b8413973ceeff493a78e9275;hpb=d7bf31c5b5e449aab104da8ed7844b1023fa5d46;p=chaz%2Fopenbox diff --git a/util/epist/screen.cc b/util/epist/screen.cc index 1dc32f02..c4f0520b 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -70,7 +70,7 @@ screen::screen(epist *epist, int number) } if (_managed) cout << "Found compatible window manager '" << _wm_name << "' for screen " - << _number << ".\n"; + << _number << ".\n"; else { cout << "Unable to find a compatible window manager for screen " << _number << ".\n"; @@ -146,163 +146,160 @@ 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() && - state == it->modifierMask()) { - switch (it->type()) { - case Action::nextScreen: - _epist->cycleScreen(_number, true); - return; + // Mask out the lock modifiers. We want our keys to always work + // This should be made an option + unsigned int state = e.xkey.state & ~(LockMask|scrolllockMask|numlockMask); + const Action *it = _epist->getKeyTree().getAction(e, state, this); + + if (!it) + return; - case Action::prevScreen: - _epist->cycleScreen(_number, false); - return; + switch (it->type()) { + case Action::nextScreen: + _epist->cycleScreen(_number, true); + return; - case Action::nextWorkspace: - cycleWorkspace(true); - return; + case Action::prevScreen: + _epist->cycleScreen(_number, false); + return; - case Action::prevWorkspace: - cycleWorkspace(false); - return; + case Action::nextWorkspace: + cycleWorkspace(true); + return; - case Action::nextWindow: - cycleWindow(true); - return; + case Action::prevWorkspace: + cycleWorkspace(false); + return; - case Action::prevWindow: - cycleWindow(false); - return; + case Action::nextWindow: + cycleWindow(true); + return; - case Action::nextWindowOnAllWorkspaces: - cycleWindow(true, false, true); - return; + case Action::prevWindow: + cycleWindow(false); + return; - case Action::prevWindowOnAllWorkspaces: - cycleWindow(false, false, true); - return; + case Action::nextWindowOnAllWorkspaces: + cycleWindow(true, false, true); + return; - case Action::nextWindowOnAllScreens: - cycleWindow(true, true); - return; + case Action::prevWindowOnAllWorkspaces: + cycleWindow(false, false, true); + return; - case Action::prevWindowOnAllScreens: - cycleWindow(false, true); - return; + case Action::nextWindowOnAllScreens: + cycleWindow(true, true); + return; - case Action::nextWindowOfClass: - cycleWindow(true, false, false, true, it->string()); - return; + case Action::prevWindowOnAllScreens: + cycleWindow(false, true); + return; - case Action::prevWindowOfClass: - cycleWindow(false, false, false, true, it->string()); - return; + case Action::nextWindowOfClass: + cycleWindow(true, false, false, true, it->string()); + return; - case Action::nextWindowOfClassOnAllWorkspaces: - cycleWindow(true, false, true, true, it->string()); - return; + case Action::prevWindowOfClass: + cycleWindow(false, false, false, true, it->string()); + return; + + case Action::nextWindowOfClassOnAllWorkspaces: + cycleWindow(true, false, true, true, it->string()); + return; + + case Action::prevWindowOfClassOnAllWorkspaces: + cycleWindow(false, false, true, true, it->string()); + return; - case Action::prevWindowOfClassOnAllWorkspaces: - cycleWindow(false, false, true, true, it->string()); - return; + case Action::changeWorkspace: + changeWorkspace(it->number()); + return; - case Action::changeWorkspace: - changeWorkspace(it->number()); - return; + case Action::execute: + execCommand(it->string()); + return; - case Action::execute: - execCommand(it->string()); - return; + default: + break; + } - default: - break; - } + // these actions require an active window + if (_active != _clients.end()) { + XWindow *window = *_active; + + switch (it->type()) { + case Action::iconify: + window->iconify(); + return; + + case Action::close: + window->close(); + return; + + case Action::raise: + window->raise(); + return; - // these actions require an active window - if (_active != _clients.end()) { - XWindow *window = *_active; - - switch (it->type()) { - case Action::iconify: - window->iconify(); - return; - - case Action::close: - window->close(); - return; - - case Action::raise: - window->raise(); - return; - - case Action::lower: - window->lower(); - return; - - case Action::sendToWorkspace: - window->sendTo(it->number()); - return; - - case Action::toggleomnipresent: - if (window->desktop() == 0xffffffff) - window->sendTo(_active_desktop); - else - window->sendTo(0xffffffff); - return; - - case Action::moveWindowUp: - window->move(window->x(), window->y() - it->number()); - return; + case Action::lower: + window->lower(); + return; + + case Action::sendToWorkspace: + window->sendTo(it->number()); + return; + + case Action::toggleomnipresent: + if (window->desktop() == 0xffffffff) + window->sendTo(_active_desktop); + else + window->sendTo(0xffffffff); + return; + + case Action::moveWindowUp: + window->move(window->x(), window->y() - it->number()); + return; - case Action::moveWindowDown: - window->move(window->x(), window->y() + it->number()); - return; + case Action::moveWindowDown: + window->move(window->x(), window->y() + it->number()); + return; - case Action::moveWindowLeft: - window->move(window->x() - it->number(), window->y()); - return; + case Action::moveWindowLeft: + window->move(window->x() - it->number(), window->y()); + return; - case Action::moveWindowRight: - window->move(window->x() + it->number(), window->y()); - return; + case Action::moveWindowRight: + window->move(window->x() + it->number(), window->y()); + return; - case Action::resizeWindowWidth: - window->resize(window->width() + it->number(), window->height()); - return; + case Action::resizeWindowWidth: + window->resize(it->number(), 0); + return; - case Action::resizeWindowHeight: - window->resize(window->width(), window->height() + it->number()); - return; + case Action::resizeWindowHeight: + window->resize(0, it->number()); + return; - case Action::toggleshade: - window->shade(! window->shaded()); - return; + case Action::toggleshade: + window->shade(! window->shaded()); + return; - case Action::toggleMaximizeHorizontal: - window->toggleMaximize(XWindow::Max_Horz); - return; + case Action::toggleMaximizeHorizontal: + window->toggleMaximize(XWindow::Max_Horz); + return; - case Action::toggleMaximizeVertical: - window->toggleMaximize(XWindow::Max_Vert); - return; + case Action::toggleMaximizeVertical: + window->toggleMaximize(XWindow::Max_Vert); + return; - case Action::toggleMaximizeFull: - window->toggleMaximize(XWindow::Max_Full); - return; + case Action::toggleMaximizeFull: + window->toggleMaximize(XWindow::Max_Full); + return; - default: - assert(false); // unhandled action type! - break; - } - } + default: + assert(false); // unhandled action type! + break; } } } @@ -376,7 +373,7 @@ void screen::updateClientList() { break; if (it == end) { // didn't already exist if (doAddWindow(rootclients[i])) { -// cout << "Added window: 0x" << hex << rootclients[i] << dec << endl; + // cout << "Added window: 0x" << hex << rootclients[i] << dec << endl; _clients.insert(insert_point, new XWindow(_epist, this, rootclients[i])); } @@ -396,7 +393,7 @@ void screen::updateClientList() { if (**it2 == rootclients[i]) break; if (i == num) { // no longer exists -// cout << "Removed window: 0x" << hex << (*it2)->window() << dec << endl; + // cout << "Removed window: 0x" << hex << (*it2)->window() << dec << endl; // watch for the active and last-active window if (it2 == _active) _active = _clients.end(); @@ -445,10 +442,10 @@ void screen::updateActiveWindow() { if (it != end) _last_active = it; -/* cout << "Active window is now: "; - if (_active == _clients.end()) cout << "None\n"; - else cout << "0x" << hex << (*_active)->window() << dec << endl; -*/ + /* cout << "Active window is now: "; + if (_active == _clients.end()) cout << "None\n"; + else cout << "0x" << hex << (*_active)->window() << dec << endl; + */ } @@ -481,8 +478,8 @@ void screen::cycleWindow(const bool forward, const bool allscreens, classname = (*_active)->appClass(); WindowList::const_iterator target = _active, - begin = _clients.begin(), - end = _clients.end(); + begin = _clients.begin(), + end = _clients.end(); while (1) { if (forward) { @@ -490,8 +487,6 @@ void screen::cycleWindow(const bool forward, const bool allscreens, target = begin; } else { ++target; - if (target == end) - target = begin; } } else { if (target == begin) @@ -503,6 +498,10 @@ void screen::cycleWindow(const bool forward, const bool allscreens, if (target == _active) return; + // start back at the beginning of the loop + if (target == end) + continue; + // determine if this window is invalid for cycling to const XWindow *t = *target; if (t->iconic()) continue; @@ -581,3 +580,21 @@ void screen::grabKey(const KeyCode keyCode, const int modifierMask) const { modifierMask|numlockMask|LockMask|scrolllockMask, _root, True, GrabModeAsync, GrabModeAsync); } + +void screen::ungrabKey(const KeyCode keyCode, const int modifierMask) const { + + Display *display = _epist->getXDisplay(); + int numlockMask, scrolllockMask; + + _epist->getLockModifiers(numlockMask, scrolllockMask); + + XUngrabKey(display, keyCode, modifierMask, _root); + XUngrabKey(display, keyCode, modifierMask|LockMask, _root); + XUngrabKey(display, keyCode, modifierMask|scrolllockMask, _root); + XUngrabKey(display, keyCode, modifierMask|numlockMask, _root); + XUngrabKey(display, keyCode, modifierMask|LockMask|scrolllockMask, _root); + XUngrabKey(display, keyCode, modifierMask|scrolllockMask|numlockMask, _root); + XUngrabKey(display, keyCode, modifierMask|numlockMask|LockMask, _root); + XUngrabKey(display, keyCode, modifierMask|numlockMask|LockMask| + scrolllockMask, _root); +}