]> Dogcows Code - chaz/openbox/blobdiff - util/epist/screen.cc
wait for 20 seconds instead of 20 milliseconds for a netwm window manager to appear
[chaz/openbox] / util / epist / screen.cc
index 7dfca51fccfe9ffe3efed99ce71004150a416df4..39b11d25d3b064d1fb7270eef991a4be4dc4a017 100644 (file)
@@ -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,22 @@ 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();
+  }
 }
 
 
This page took 0.022898 seconds and 4 git commands to generate.