better cascade placement! also, it has xinerama support now!

This commit is contained in:
Dana Jansens 2002-07-22 06:02:29 +00:00
parent e943c31bb0
commit 270981e6d7
2 changed files with 49 additions and 19 deletions

View file

@ -48,6 +48,7 @@ using std::string;
#include "i18n.hh"
#include "blackbox.hh"
#include "Clientmenu.hh"
#include "Font.hh"
#include "Netizen.hh"
#include "Screen.hh"
#include "Toolbar.hh"
@ -62,7 +63,10 @@ Workspace::Workspace(BScreen *scrn, unsigned int i) {
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;
@ -143,8 +147,12 @@ void Workspace::removeWindow(BlackboxWindow *w) {
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
}
}
@ -673,7 +681,7 @@ bool Workspace::smartPlacement(Rect& win) {
}
bool Workspace::underMousePlacement(Rect &win) {
bool Workspace::underMousePlacement(Rect &win) const {
int x, y, rx, ry;
Window c, r;
unsigned int m;
@ -714,20 +722,41 @@ bool Workspace::underMousePlacement(Rect &win) {
}
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;
}
@ -748,11 +777,9 @@ void Workspace::placeWindow(BlackboxWindow *win) {
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));

View file

@ -52,7 +52,10 @@ private:
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&);
@ -63,7 +66,7 @@ private:
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);