X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=util%2Fepist%2Fscreen.cc;h=1dc32f0231b566c1b8413973ceeff493a78e9275;hb=d06cedce062da73393a585d061b19b6604bbe568;hp=7dfca51fccfe9ffe3efed99ce71004150a416df4;hpb=746c37b24b57ea024cf42e3d0d0d7c0ae3b03b83;p=chaz%2Fopenbox diff --git a/util/epist/screen.cc b/util/epist/screen.cc index 7dfca51f..1dc32f02 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 @@ -457,21 +455,13 @@ void screen::updateActiveWindow() { void screen::execCommand(const string &cmd) const { pid_t pid; if ((pid = fork()) == 0) { - extern char **environ; - - char *const argv[] = { - "sh", - "-c", - const_cast(cmd.c_str()), - 0 - }; // make the command run on the correct screen if (putenv(const_cast(_info->displayString().c_str()))) { cout << "warning: couldn't set environment variable 'DISPLAY'\n"; perror("putenv()"); } - execve("/bin/sh", argv, environ); - exit(127); + execl("/bin/sh", "sh", "-c", cmd.c_str(), NULL); + exit(-1); } else if (pid == -1) { cout << _epist->getApplicationName() << ": Could not fork a process for executing a command\n"; @@ -491,11 +481,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 +500,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; + } }