X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=util%2Fepist%2Fscreen.cc;h=e91685a89a68e2899da294ddcdf12ba00fd68c7d;hb=cd6c4ebcb27b796b214296aefd78a41235dd8640;hp=7dfca51fccfe9ffe3efed99ce71004150a416df4;hpb=746c37b24b57ea024cf42e3d0d0d7c0ae3b03b83;p=chaz%2Fopenbox diff --git a/util/epist/screen.cc b/util/epist/screen.cc index 7dfca51f..e91685a8 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -60,15 +60,12 @@ screen::screen(epist *epist, int number) _info = _epist->getScreenInfo(_number); _root = _info->getRootWindow(); - cout << "root window on screen " << _number << ": 0x" << hex << _root << - dec << endl; - // find a window manager supporting NETWM, waiting for it to load if we must int count = 20; // try for 20 seconds _managed = false; while (! (_epist->doShutdown() || _managed || count <= 0)) { if (! (_managed = findSupportingWM())) - usleep(1000); + sleep(1); --count; } if (_managed) @@ -421,7 +418,8 @@ const XWindow *screen::lastActiveWindow() const { // find a window if one exists WindowList::const_iterator it, end = _clients.end(); for (it = _clients.begin(); it != end; ++it) - if ((*it)->getScreen() == this) + if ((*it)->getScreen() == this && ! (*it)->iconic() && + ((*it)->desktop() == 0xffffffff || (*it)->desktop() == _active_desktop)) return *it; // no windows on this screen @@ -491,11 +489,10 @@ void screen::cycleWindow(const bool forward, const bool allscreens, classname = (*_active)->appClass(); WindowList::const_iterator target = _active, - first = _active, begin = _clients.begin(), end = _clients.end(); - do { + while (1) { if (forward) { if (target == end) { target = begin; @@ -511,18 +508,23 @@ void screen::cycleWindow(const bool forward, const bool allscreens, } // must be no window to focus - if (target == first) + if (target == _active) return; - } while ((*target)->iconic() || - (! allscreens && (*target)->getScreen() != this) || - (! alldesktops && - (*target)->desktop() != _active_desktop && - (*target)->desktop() != 0xffffffff) || - (sameclass && ! classname.empty() && - (*target)->appClass() != classname)); - - if (target != _clients.end()) - (*target)->focus(); + + // determine if this window is invalid for cycling to + const XWindow *t = *target; + if (t->iconic()) continue; + if (! allscreens && t->getScreen() != this) continue; + if (! alldesktops && ! (t->desktop() == _active_desktop || + t->desktop() == 0xffffffff)) continue; + if (sameclass && ! classname.empty() && + t->appClass() != classname) continue; + if (! t->canFocus()) continue; + + // found a good window! + t->focus(); + return; + } }