#include "i18n.hh"
#include "blackbox.hh"
#include "Clientmenu.hh"
+#include "Font.hh"
#include "Netizen.hh"
#include "Screen.hh"
#include "Toolbar.hh"
screen = scrn;
xatom = screen->getBlackbox()->getXAtom();
- cascade_x = cascade_y = 32;
+ cascade_x = cascade_y = 0;
+#ifdef XINERAMA
+ cascade_region = 0;
+#endif // XINERAMA
id = i;
for (; it != end; ++it, ++i)
(*it)->setWindowNumber(i);
- if (i == 0)
- cascade_x = cascade_y = 32;
+ if (i == 0) {
+ cascade_x = cascade_y = 0;
+#ifdef XINERAMA
+ cascade_region = 0;
+#endif // XINERAMA
+ }
}
}
-bool Workspace::underMousePlacement(Rect &win) {
+bool Workspace::underMousePlacement(Rect &win) const {
int x, y, rx, ry;
Window c, r;
unsigned int m;
}
-bool Workspace::cascadePlacement(Rect &win) {
- const Rect &availableArea = screen->availableArea();
+bool Workspace::cascadePlacement(Rect &win, const int offset) {
+ Rect area;
+
+#ifdef XINERAMA
+ if (screen->isXineramaActive() &&
+ screen->getBlackbox()->doXineramaPlacement()) {
+ area = screen->allAvailableAreas()[cascade_region];
+ } else
+#endif // XINERAMA
+ area = screen->availableArea();
- if ((cascade_x > static_cast<signed>(availableArea.width() / 2)) ||
- (cascade_y > static_cast<signed>(availableArea.height() / 2)))
- cascade_x = cascade_y = 32;
+ if ((static_cast<signed>(cascade_x + win.width()) > area.right() + 1) ||
+ (static_cast<signed>(cascade_y + win.height()) > area.bottom() + 1)) {
+ cascade_x = cascade_y = 0;
+#ifdef XINERAMA
+ if (screen->isXineramaActive() &&
+ screen->getBlackbox()->doXineramaPlacement()) {
+ // go to the next xinerama region, and use its area
+ if (++cascade_region >= screen->allAvailableAreas().size())
+ cascade_region = 0;
+ area = screen->allAvailableAreas()[cascade_region];
+ }
+#endif // XINERAMA
+ }
- if (cascade_x == 32) {
- cascade_x += availableArea.x();
- cascade_y += availableArea.y();
+ if (cascade_x == 0) {
+ cascade_x = area.x() + offset;
+ cascade_y = area.y() + offset;
}
win.setPos(cascade_x, cascade_y);
+ cascade_x += offset;
+ cascade_y += offset;
+
return True;
}
break; // handled below
} // switch
- if (placed == False) {
- cascadePlacement(new_win);
- cascade_x += win->getTitleHeight() + (screen->getBorderWidth() * 2);
- cascade_y += win->getTitleHeight() + (screen->getBorderWidth() * 2);
- }
+ if (placed == False)
+ cascadePlacement(new_win, (win->getTitleHeight() +
+ screen->getBorderWidth() * 2));
// make sure the placement was valid
assert(screen->availableArea().contains(new_win));
std::string name;
unsigned int id;
- int cascade_x, cascade_y;
+ unsigned int cascade_x, cascade_y;
+#ifdef XINERAMA
+ unsigned int cascade_region;
+#endif // XINERAMA
Workspace(const Workspace&);
Workspace& operator=(const Workspace&);
StackVector::iterator &stack);
void placeWindow(BlackboxWindow *win);
- bool cascadePlacement(Rect& win);
+ bool cascadePlacement(Rect& win, const int offset);
bool smartPlacement(Rect& win);
bool underMousePlacement(Rect& win);