]> Dogcows Code - chaz/openbox/commitdiff
Added a fallback for Best Fit to cascade. Also, moved cascade to its own
authorScott Moynes <smoynes@nexus.carleton.ca>
Mon, 15 Apr 2002 02:37:18 +0000 (02:37 +0000)
committerScott Moynes <smoynes@nexus.carleton.ca>
Mon, 15 Apr 2002 02:37:18 +0000 (02:37 +0000)
function. May not be needed.

src/Workspace.cc
src/Workspace.h

index 31c93b9bc8e1806595e16c5b8f320e1367e5756b..df8133deee7ad5d64c701e74da0168e1baef8cd7 100644 (file)
@@ -41,6 +41,7 @@
 #include "Toolbar.h"
 #include "Window.h"
 #include "Workspace.h"
+
 #include "Windowmenu.h"
 #include "Geometry.h"
 #include "Util.h"
@@ -386,17 +387,17 @@ Point *Workspace::bestFitPlacement(const Size &win_size, const Rect &space)
      spaces = calcSpace(*cur, spaces);
   
   //Find first space that fits the window
-  best = 0;
+  best = NULL;
   for (siter=spaces.begin(); siter!=spaces.end(); ++siter) {
     if ((siter->w() >= win_size.w()) &&
         (siter->h() >= win_size.h()))
       best = siter;
   }
 
-  if (best != 0)
+  if (best != NULL)
     return new Point(best->origin());
   else
-    return new Point(200, 0);
+    return NULL; //fall back to cascade
 }
 
 inline Point *Workspace::rowSmartPlacement(const Size &win_size,
@@ -501,7 +502,9 @@ void Workspace::placeWindow(OpenboxWindow *win) {
       place_y=spot->y();
       delete spot;
       placed=true;
-    }
+    }else
+      placed=false;
+      
     break;
   }
   case BScreen::RowSmartPlacement: {
@@ -581,15 +584,10 @@ void Workspace::placeWindow(OpenboxWindow *win) {
   } // switch
 
   if (! placed) {
-    if (((unsigned) cascade_x > (screen.size().w() / 2)) ||
-       ((unsigned) cascade_y > (screen.size().h() / 2)))
-      cascade_x = cascade_y = 32;
-
-    place_x = cascade_x;
-    place_y = cascade_y;
-
-    cascade_x += win->getTitleHeight();
-    cascade_y += win->getTitleHeight();
+    Point *p = cascade(win);
+    place_x=p->x();
+    place_y=p->y();
+    delete p;
   }
   
   if (place_x + win_w > (signed) screen.size().w())
@@ -599,3 +597,14 @@ void Workspace::placeWindow(OpenboxWindow *win) {
 
   win->configure(place_x, place_y, win->size().w(), win->size().h());
 }
+
+Point *Workspace::cascade(const OpenboxWindow *const win){
+  if (((unsigned) cascade_x > (screen.size().w() / 2)) ||
+      ((unsigned) cascade_y > (screen.size().h() / 2)))
+    cascade_x = cascade_y = 32;
+
+  cascade_x += win->getTitleHeight();
+  cascade_y += win->getTitleHeight();
+
+  return new Point(cascade_x, cascade_y);
+}
index d42f30eed376e824efed520634f800b8ca20f5a6..1091f8864e0d36b5ddf25023bc67c8842696d2f9 100644 (file)
@@ -49,7 +49,7 @@ protected:
   void placeWindow(OpenboxWindow *);
   Point *bestFitPlacement(const Size &win_size, const Rect &space);
   Point *rowSmartPlacement(const Size &win_size, const Rect &space);
-
+  Point *cascade(const OpenboxWindow* window);
 
 public:
   Workspace(BScreen &, int = 0);
This page took 0.029176 seconds and 4 git commands to generate.