better cascade placement! also, it has xinerama support now!
This commit is contained in:
parent
e943c31bb0
commit
270981e6d7
2 changed files with 49 additions and 19 deletions
|
@ -48,6 +48,7 @@ using std::string;
|
||||||
#include "i18n.hh"
|
#include "i18n.hh"
|
||||||
#include "blackbox.hh"
|
#include "blackbox.hh"
|
||||||
#include "Clientmenu.hh"
|
#include "Clientmenu.hh"
|
||||||
|
#include "Font.hh"
|
||||||
#include "Netizen.hh"
|
#include "Netizen.hh"
|
||||||
#include "Screen.hh"
|
#include "Screen.hh"
|
||||||
#include "Toolbar.hh"
|
#include "Toolbar.hh"
|
||||||
|
@ -62,7 +63,10 @@ Workspace::Workspace(BScreen *scrn, unsigned int i) {
|
||||||
screen = scrn;
|
screen = scrn;
|
||||||
xatom = screen->getBlackbox()->getXAtom();
|
xatom = screen->getBlackbox()->getXAtom();
|
||||||
|
|
||||||
cascade_x = cascade_y = 32;
|
cascade_x = cascade_y = 0;
|
||||||
|
#ifdef XINERAMA
|
||||||
|
cascade_region = 0;
|
||||||
|
#endif // XINERAMA
|
||||||
|
|
||||||
id = i;
|
id = i;
|
||||||
|
|
||||||
|
@ -143,8 +147,12 @@ void Workspace::removeWindow(BlackboxWindow *w) {
|
||||||
for (; it != end; ++it, ++i)
|
for (; it != end; ++it, ++i)
|
||||||
(*it)->setWindowNumber(i);
|
(*it)->setWindowNumber(i);
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0) {
|
||||||
cascade_x = cascade_y = 32;
|
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;
|
int x, y, rx, ry;
|
||||||
Window c, r;
|
Window c, r;
|
||||||
unsigned int m;
|
unsigned int m;
|
||||||
|
@ -714,20 +722,41 @@ bool Workspace::underMousePlacement(Rect &win) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Workspace::cascadePlacement(Rect &win) {
|
bool Workspace::cascadePlacement(Rect &win, const int offset) {
|
||||||
const Rect &availableArea = screen->availableArea();
|
Rect area;
|
||||||
|
|
||||||
if ((cascade_x > static_cast<signed>(availableArea.width() / 2)) ||
|
#ifdef XINERAMA
|
||||||
(cascade_y > static_cast<signed>(availableArea.height() / 2)))
|
if (screen->isXineramaActive() &&
|
||||||
cascade_x = cascade_y = 32;
|
screen->getBlackbox()->doXineramaPlacement()) {
|
||||||
|
area = screen->allAvailableAreas()[cascade_region];
|
||||||
|
} else
|
||||||
|
#endif // XINERAMA
|
||||||
|
area = screen->availableArea();
|
||||||
|
|
||||||
if (cascade_x == 32) {
|
if ((static_cast<signed>(cascade_x + win.width()) > area.right() + 1) ||
|
||||||
cascade_x += availableArea.x();
|
(static_cast<signed>(cascade_y + win.height()) > area.bottom() + 1)) {
|
||||||
cascade_y += availableArea.y();
|
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 == 0) {
|
||||||
|
cascade_x = area.x() + offset;
|
||||||
|
cascade_y = area.y() + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
win.setPos(cascade_x, cascade_y);
|
win.setPos(cascade_x, cascade_y);
|
||||||
|
|
||||||
|
cascade_x += offset;
|
||||||
|
cascade_y += offset;
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,11 +777,9 @@ void Workspace::placeWindow(BlackboxWindow *win) {
|
||||||
break; // handled below
|
break; // handled below
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
if (placed == False) {
|
if (placed == False)
|
||||||
cascadePlacement(new_win);
|
cascadePlacement(new_win, (win->getTitleHeight() +
|
||||||
cascade_x += win->getTitleHeight() + (screen->getBorderWidth() * 2);
|
screen->getBorderWidth() * 2));
|
||||||
cascade_y += win->getTitleHeight() + (screen->getBorderWidth() * 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure the placement was valid
|
// make sure the placement was valid
|
||||||
assert(screen->availableArea().contains(new_win));
|
assert(screen->availableArea().contains(new_win));
|
||||||
|
|
|
@ -52,7 +52,10 @@ private:
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
unsigned int id;
|
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(const Workspace&);
|
||||||
Workspace& operator=(const Workspace&);
|
Workspace& operator=(const Workspace&);
|
||||||
|
@ -63,7 +66,7 @@ private:
|
||||||
StackVector::iterator &stack);
|
StackVector::iterator &stack);
|
||||||
|
|
||||||
void placeWindow(BlackboxWindow *win);
|
void placeWindow(BlackboxWindow *win);
|
||||||
bool cascadePlacement(Rect& win);
|
bool cascadePlacement(Rect& win, const int offset);
|
||||||
bool smartPlacement(Rect& win);
|
bool smartPlacement(Rect& win);
|
||||||
bool underMousePlacement(Rect& win);
|
bool underMousePlacement(Rect& win);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue