X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=util%2Fepist%2Fscreen.cc;h=c3ea4fb5f0e51ff6ef71105669f9286d30c19d0c;hb=48a450083db59085921c79c2bb68dedd0b95821a;hp=de5c29c277d34b4a58d7c72ea51e16cf51710fca;hpb=a991c575800a12afbc19de8bd75b87420934105a;p=chaz%2Fopenbox diff --git a/util/epist/screen.cc b/util/epist/screen.cc index de5c29c2..c3ea4fb5 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -20,6 +20,17 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +/* A few comments about stacked cycling: + * When stacked cycling is turned on, the focused window is always at the top + * (front) of the list (_clients), EXCEPT for when we are in cycling mode. + * (_cycling is true) If we were to add the focused window to the top of the + * stack while we were cycling, we would end in a deadlock between 2 windows. + * When the modifiers are released, the window that has focus (but it's not + * at the top of the stack, since we are cycling) is placed at the top of the + * stack and raised. + * Hooray and Bummy. - Marius + */ + #ifdef HAVE_CONFIG_H # include "../../config.h" #endif // HAVE_CONFIG_H @@ -64,7 +75,7 @@ screen::screen(epist *epist, int number) _info = _epist->getScreenInfo(_number); _root = _info->getRootWindow(); - _config->getBoolValue(Config::stackedCycling, _stacked_cycling); + _config->getValue(Config::stackedCycling, _stacked_cycling); // find a window manager supporting NETWM, waiting for it to load if we must int count = 20; // try for 20 seconds @@ -369,23 +380,23 @@ void screen::handleKeypress(const XEvent &e) { } -void screen::handleKeyrelease(const XEvent &e) { - // we're not interested in non-modifiers - if (!isModifier(e.xkey.keycode)) - return; - +void screen::handleKeyrelease(const XEvent &) { // the only keyrelease event we care about (for now) is when we do stacked // cycling and the modifier is released if (_stacked_cycling && _cycling && nothingIsPressed()) { - XWindow *w = *_active; - // all modifiers have been released. ungrab the keyboard, move the // focused window to the top of the Z-order and raise it ungrabModifiers(); - _clients.remove(w); - _clients.push_front(w); - w->raise(); + if (_active != _clients.end()) { + XWindow *w = *_active; + bool e = _last_active == _active; + _clients.remove(w); + _clients.push_front(w); + _active = _clients.begin(); + if (e) _last_active = _active; + w->raise(); + } _cycling = false; } @@ -454,16 +465,21 @@ void screen::updateClientList() { const WindowList::iterator end = _clients.end(); unsigned long i; - // insert new clients after the active window for (i = 0; i < num; ++i) { for (it = _clients.begin(); it != end; ++it) if (**it == rootclients[i]) break; if (it == end) { // didn't already exist if (doAddWindow(rootclients[i])) { - // cout << "Added window: 0x" << hex << rootclients[i] << dec << endl; - _clients.insert(insert_point, new XWindow(_epist, this, - rootclients[i])); +// cout << "Added window: 0x" << hex << rootclients[i] << dec << endl; + if (_stacked_cycling) { + // insert new clients after the active window + _clients.insert(insert_point, new XWindow(_epist, this, + rootclients[i])); + } else { + // insert new clients at the front of the list + _clients.push_front(new XWindow(_epist, this, rootclients[i])); + } } } } @@ -526,9 +542,22 @@ void screen::updateActiveWindow() { break; } } + _active = it; - if (it != end) - _last_active = it; + + if (_active != end) { + /* if we're not cycling and a window gets focus, add it to the top of the + * cycle stack. + */ + if (_stacked_cycling && !_cycling) { + XWindow *win = *_active; + _clients.remove(win); + _clients.push_front(win); + _active = _clients.begin(); + } + + _last_active = _active; + } /* cout << "Active window is now: "; if (_active == _clients.end()) cout << "None\n"; @@ -621,8 +650,8 @@ void screen::cycleWindow(unsigned int state, const bool forward, } // if the window is on another desktop, we can't use XSetInputFocus, since - // it doesn't imply a woskpace change. - if (t->desktop() == _active_desktop) + // it doesn't imply a workspace change. + if (t->desktop() == _active_desktop || t->desktop() == 0xffffffff) t->focus(false); // focus, but don't raise else t->focus(); // change workspace and focus @@ -672,7 +701,7 @@ void screen::changeWorkspaceVert(const int num) const { int active_desktop = (signed)_active_desktop; int wnum = 0; - _config->getNumberValue(Config::workspaceColumns, width); + _config->getValue(Config::workspaceColumns, width); if (width > num_desktops || width <= 0) return; @@ -704,7 +733,7 @@ void screen::changeWorkspaceHorz(const int num) const { int active_desktop = (signed)_active_desktop; int wnum = 0; - _config->getNumberValue(Config::workspaceColumns, width); + _config->getValue(Config::workspaceColumns, width); if (width > num_desktops || width <= 0) return; @@ -798,21 +827,6 @@ void screen::ungrabModifiers() const { } -bool screen::isModifier(const KeyCode kc) const { - KeySym ks = XKeycodeToKeysym(_epist->getXDisplay(), kc, 0); - - if (ks == XK_Shift_L || ks == XK_Shift_R || - ks == XK_Control_L || ks == XK_Control_R || - ks == XK_Meta_L || ks == XK_Meta_R || - ks == XK_Alt_L || ks == XK_Alt_R || - ks == XK_Super_L || ks == XK_Super_R || - ks == XK_Hyper_L || ks == XK_Hyper_R) - return true; - else - return false; -} - - bool screen::nothingIsPressed(void) const { char keys[32];