]> Dogcows Code - chaz/openbox/blobdiff - src/Workspace.cc
merged with 2_1-merged-to-HEAD-2002-09-30
[chaz/openbox] / src / Workspace.cc
index 1cb40b390b61620ba124a5c6caae99c64e630052..67e191107ccb851cf01987cf28fcd77bcb5de1e6 100644 (file)
@@ -85,11 +85,18 @@ void Workspace::addWindow(BlackboxWindow *w, bool place, bool sticky) {
 
   stackingList.push_front(w);
 
-  if (w->isNormal()) {
+  if (! sticky)
+    w->setWorkspace(id);
+  
+  if (! w->isNormal()) {
     if (! sticky) {
-      w->setWorkspace(id);
-      w->setWindowNumber(windowList.size());
+      // just give it some number, else bad things happen as it is assumed to
+      // not be on a workspace
+      w->setWindowNumber(0);
     }
+  } else {
+    if (! sticky)
+      w->setWindowNumber(windowList.size());
 
     windowList.push_back(w);
 
@@ -110,11 +117,6 @@ void Workspace::addWindow(BlackboxWindow *w, bool place, bool sticky) {
         lastfocus = w;
       }
     }
-  } else {
-    w->setWorkspace(id);
-    // just give it some number, else bad things happen as it is assumed to not
-    // be on a workspace
-    w->setWindowNumber(0);
   }
 
   if (! w->isDesktop())
@@ -235,9 +237,10 @@ void Workspace::showAll(void) {
   const BlackboxWindowList::iterator end = stackingList.end();
   for (; it != end; ++it) {
     BlackboxWindow *bw = *it;
-    // not normal windows cant focus from mouse enters anyways, so we dont
-    // need to unmap/remap them on workspace changes
-    if (! bw->isStuck() || bw->isNormal())
+    // sticky windows arent unmapped on a workspace change so we don't have ot
+    // map them, but sometimes on a restart, another app can unmap our sticky
+    // windows, so we map on startup always
+    if (! bw->isStuck() || screen->getBlackbox()->isStartup())
       bw->show();
   }
 }
@@ -252,9 +255,9 @@ void Workspace::hideAll(void) {
   const BlackboxWindowList::iterator end = lst.end();
   for (; it != end; ++it) {
     BlackboxWindow *bw = *it;
-    // not normal windows cant focus from mouse enters anyways, so we dont
-    // need to unmap/remap them on workspace changes
-    if (! bw->isStuck() || bw->isNormal())
+    // don't hide sticky windows, or they'll end up flickering on a workspace
+    // change
+    if (! bw->isStuck())
       bw->withdraw();
   }
 }
@@ -460,7 +463,9 @@ void Workspace::appendStackOrder(BlackboxWindowList &stack_order) const {
   BlackboxWindowList::const_reverse_iterator it = stackingList.rbegin();
   const BlackboxWindowList::const_reverse_iterator end = stackingList.rend();
   for (; it != end; ++it)
-    if ((*it)->isNormal())
+    // don't add desktop wnidows, or sticky windows more than once
+    if (! ( (*it)->isDesktop() ||
+            ((*it)->isStuck() && id != screen->getCurrentWorkspaceID())))
       stack_order.push_back(*it);
 }
 
@@ -528,9 +533,8 @@ void Workspace::setName(const string& new_name) {
 /*
  * Calculate free space available for window placement.
  */
-typedef std::vector<Rect> rectList;
-
-static rectList calcSpace(const Rect &win, const rectList &spaces) {
+Workspace::rectList Workspace::calcSpace(const Rect &win,
+                                         const rectList &spaces) const {
   Rect isect, extra;
   rectList result;
   rectList::const_iterator siter, end = spaces.end();
@@ -551,21 +555,21 @@ static rectList calcSpace(const Rect &win, const rectList &spaces) {
 
     // left
     extra.setCoords(curr.left(), curr.top(),
-                    isect.left() - 1, curr.bottom());
+                    isect.left() - screen->getSnapOffset(), curr.bottom());
     if (extra.valid()) result.push_back(extra);
 
     // top
     extra.setCoords(curr.left(), curr.top(),
-                    curr.right(), isect.top() - 1);
+                    curr.right(), isect.top() - screen->getSnapOffset());
     if (extra.valid()) result.push_back(extra);
 
     // right
-    extra.setCoords(isect.right() + 1, curr.top(),
+    extra.setCoords(isect.right() + screen->getSnapOffset(), curr.top(),
                     curr.right(), curr.bottom());
     if (extra.valid()) result.push_back(extra);
 
     // bottom
-    extra.setCoords(curr.left(), isect.bottom() + 1,
+    extra.setCoords(curr.left(), isect.bottom() + screen->getSnapOffset(),
                     curr.right(), curr.bottom());
     if (extra.valid()) result.push_back(extra);
   }
@@ -632,11 +636,24 @@ bool Workspace::smartPlacement(Rect& win) {
     RectList availableAreas = screen->allAvailableAreas();
     RectList::iterator it, end = availableAreas.end();
 
-    for (it = availableAreas.begin(); it != end; ++it)
+    for (it = availableAreas.begin(); it != end; ++it) {
+      Rect r = *it;
+      r.setRect(r.x() + screen->getSnapOffset(),
+                r.y() + screen->getSnapOffset(),
+                r.width() - screen->getSnapOffset(),
+                r.height() - screen->getSnapOffset());
       spaces.push_back(*it);
+    }
   } else
 #endif // XINERAMA
-    spaces.push_back(screen->availableArea());
+  {
+    Rect r = screen->availableArea();
+    r.setRect(r.x() + screen->getSnapOffset(),
+              r.y() + screen->getSnapOffset(),
+              r.width() - screen->getSnapOffset(),
+              r.height() - screen->getSnapOffset());
+    spaces.push_back(r);
+  }
 
   //Find Free Spaces
   BlackboxWindowList::const_iterator wit = windowList.begin(),
This page took 0.030128 seconds and 4 git commands to generate.