- return new Point(place_x, place_y);
-}
-
-void Workspace::placeWindow(OpenboxWindow *win) {
- ASSERT(win != NULL);
-
- Bool placed = False;
-
- const int win_w = win->size().w() + (screen.getBorderWidth() * 4),
- win_h = win->size().h() + (screen.getBorderWidth() * 4),
-#ifdef SLIT
- slit_x = screen.getSlit()->getX() - screen.getBorderWidth(),
- slit_y = screen.getSlit()->getY() - screen.getBorderWidth(),
- slit_w = screen.getSlit()->getWidth() +
- (screen.getBorderWidth() * 4),
- slit_h = screen.getSlit()->getHeight() +
- (screen.getBorderWidth() * 4),
-#endif // SLIT
- toolbar_x = screen.getToolbar()->getX() - screen.getBorderWidth(),
- toolbar_y = screen.getToolbar()->getY() - screen.getBorderWidth(),
- toolbar_w = screen.getToolbar()->getWidth() +
- (screen.getBorderWidth() * 4),
- toolbar_h = screen.getToolbar()->getHeight() +
- (screen.getBorderWidth() * 4),
- start_pos = 0,
- change_y =
- ((screen.getColPlacementDirection() == BScreen::TopBottom) ? 1 : -1),
- change_x =
- ((screen.getRowPlacementDirection() == BScreen::LeftRight) ? 1 : -1),
- delta_x = 8, delta_y = 8;
-
- int test_x, test_y, place_x = 0, place_y = 0;
- LinkedListIterator<OpenboxWindow> it(windowList);
-
- Rect space(0, 0,
- screen.size().w(),
- screen.size().h()
- );
- Size window_size(win_w, win_h);
-
- switch (screen.getPlacementPolicy()) {
- case BScreen::BestFitPlacement: {
- Point *spot = bestFitPlacement(window_size, space);
- if (spot != NULL) {
- place_x=spot->x();
- place_y=spot->y();
- delete spot;
- placed=true;
+ return result;
+}
+
+
+static bool rowRLBT(const Rect &first, const Rect &second) {
+ if (first.bottom() == second.bottom())
+ return first.right() > second.right();
+ return first.bottom() > second.bottom();
+}
+
+static bool rowRLTB(const Rect &first, const Rect &second) {
+ if (first.y() == second.y())
+ return first.right() > second.right();
+ return first.y() < second.y();
+}
+
+static bool rowLRBT(const Rect &first, const Rect &second) {
+ if (first.bottom() == second.bottom())
+ return first.x() < second.x();
+ return first.bottom() > second.bottom();
+}
+
+static bool rowLRTB(const Rect &first, const Rect &second) {
+ if (first.y() == second.y())
+ return first.x() < second.x();
+ return first.y() < second.y();
+}
+
+static bool colLRTB(const Rect &first, const Rect &second) {
+ if (first.x() == second.x())
+ return first.y() < second.y();
+ return first.x() < second.x();
+}
+
+static bool colLRBT(const Rect &first, const Rect &second) {
+ if (first.x() == second.x())
+ return first.bottom() > second.bottom();
+ return first.x() < second.x();
+}
+
+static bool colRLTB(const Rect &first, const Rect &second) {
+ if (first.right() == second.right())
+ return first.y() < second.y();
+ return first.right() > second.right();
+}
+
+static bool colRLBT(const Rect &first, const Rect &second) {
+ if (first.right() == second.right())
+ return first.bottom() > second.bottom();
+ return first.right() > second.right();
+}
+
+
+bool Workspace::smartPlacement(Rect& win) {
+ rectList spaces;
+
+ //initially the entire screen is free
+#ifdef XINERAMA
+ if (screen->isXineramaActive() &&
+ screen->getBlackbox()->doXineramaPlacement()) {
+ RectList availableAreas = screen->allAvailableAreas();
+ RectList::iterator it, end = availableAreas.end();
+
+ for (it = availableAreas.begin(); it != end; ++it)
+ spaces.push_back(*it);
+ } else
+#endif // XINERAMA
+ spaces.push_back(screen->availableArea());
+
+ //Find Free Spaces
+ BlackboxWindowList::const_iterator wit = windowList.begin(),
+ end = windowList.end();
+ Rect tmp;
+ for (; wit != end; ++wit) {
+ const BlackboxWindow* const curr = *wit;
+
+ // watch for shaded windows and full-maxed windows
+ if (curr->isShaded()) {
+ if (screen->getPlaceIgnoreShaded()) continue;
+ } else if (curr->isMaximizedFull()) {
+ if (screen->getPlaceIgnoreMaximized()) continue;