+ string classname = cn;
+ if (sameclass && classname.empty() && target != _clients.end())
+ classname = (*target)->appClass();
+
+ if (target == _clients.end())
+ target = _clients.begin();
+
+ do {
+ if (forward) {
+ ++target;
+ if (target == _clients.end())
+ target = _clients.begin();
+ } else {
+ if (target == _clients.begin())
+ target = _clients.end();
+ --target;
+ }
+ } while (target == _clients.end() ||
+ (*target)->iconic() ||
+ (! alldesktops && (*target)->desktop() != _active_desktop) ||
+ (sameclass && ! classname.empty() &&
+ (*target)->appClass() != classname));
+
+ if (target != _clients.end())
+ (*target)->focus();
+}
+
+
+void screen::cycleWorkspace(const bool forward, const bool loop) const {
+ assert(_managed);
+
+ unsigned int destination = _active_desktop;
+
+ if (forward) {
+ if (destination < _num_desktops - 1)
+ ++destination;
+ else if (loop)
+ destination = 0;
+ } else {
+ if (destination > 0)
+ --destination;
+ else if (loop)
+ destination = _num_desktops - 1;
+ }
+
+ if (destination != _active_desktop)
+ changeWorkspace(destination);
+}
+
+
+void screen::changeWorkspace(const int num) const {
+ assert(_managed);
+
+ _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);