better cascadePlacement. uses screen.availableArea().
This commit is contained in:
parent
e5685e3cfd
commit
07281446ea
2 changed files with 28 additions and 23 deletions
|
@ -64,7 +64,7 @@ typedef vector<Rect> rectList;
|
||||||
|
|
||||||
Workspace::Workspace(BScreen &scrn, int i) : screen(scrn) {
|
Workspace::Workspace(BScreen &scrn, int i) : screen(scrn) {
|
||||||
|
|
||||||
cascade_x = cascade_y = 32;
|
cascade_x = cascade_y = 0;
|
||||||
|
|
||||||
id = i;
|
id = i;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ Workspace::~Workspace(void) {
|
||||||
const int Workspace::addWindow(OpenboxWindow *w, Bool place) {
|
const int Workspace::addWindow(OpenboxWindow *w, Bool place) {
|
||||||
if (! w) return -1;
|
if (! w) return -1;
|
||||||
|
|
||||||
if (place) placeWindow(w);
|
if (place) placeWindow(*w);
|
||||||
|
|
||||||
w->setWorkspace(id);
|
w->setWorkspace(id);
|
||||||
w->setWindowNumber(windowList->count());
|
w->setWindowNumber(windowList->count());
|
||||||
|
@ -566,24 +566,29 @@ Point *Workspace::colSmartPlacement(const Size &win_size, const Rect &space) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Point *const Workspace::cascadePlacement(const OpenboxWindow *const win){
|
Point *const Workspace::cascadePlacement(const OpenboxWindow &win,
|
||||||
if (((unsigned) cascade_x > (screen.size().w() / 2)) ||
|
const Rect &space) {
|
||||||
((unsigned) cascade_y > (screen.size().h() / 2)))
|
if ((cascade_x + win.area().w() + screen.getBorderWidth() * 2 >
|
||||||
cascade_x = cascade_y = 32;
|
(space.x() + space.w())) ||
|
||||||
|
(cascade_y + win.area().h() + screen.getBorderWidth() * 2 >
|
||||||
|
(space.y() + space.h())))
|
||||||
|
cascade_x = cascade_y = 0;
|
||||||
|
if (cascade_x < space.x() || cascade_y < space.y()) {
|
||||||
|
cascade_x = space.x();
|
||||||
|
cascade_y = space.y();
|
||||||
|
}
|
||||||
|
|
||||||
cascade_x += win->getTitleHeight();
|
Point *p = new Point(cascade_x, cascade_y);
|
||||||
cascade_y += win->getTitleHeight();
|
cascade_x += win.getTitleHeight();
|
||||||
|
cascade_y += win.getTitleHeight();
|
||||||
return new Point(cascade_x, cascade_y);
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Workspace::placeWindow(OpenboxWindow *win) {
|
void Workspace::placeWindow(OpenboxWindow &win) {
|
||||||
ASSERT(win != NULL);
|
|
||||||
|
|
||||||
Rect space = screen.availableArea();
|
Rect space = screen.availableArea();
|
||||||
const Size window_size(win->area().w()+screen.getBorderWidth() * 4,
|
const Size window_size(win.area().w()+screen.getBorderWidth() * 4,
|
||||||
win->area().h()+screen.getBorderWidth() * 4);
|
win.area().h()+screen.getBorderWidth() * 4);
|
||||||
Point *place = NULL;
|
Point *place = NULL;
|
||||||
LinkedListIterator<OpenboxWindow> it(windowList);
|
LinkedListIterator<OpenboxWindow> it(windowList);
|
||||||
|
|
||||||
|
@ -600,14 +605,14 @@ void Workspace::placeWindow(OpenboxWindow *win) {
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
if (place == NULL)
|
if (place == NULL)
|
||||||
place = cascadePlacement(win);
|
place = cascadePlacement(win, space);
|
||||||
|
|
||||||
ASSERT(place != NULL);
|
ASSERT(place != NULL);
|
||||||
if (place->x() + window_size.w() > (signed) screen.size().w())
|
if (place->x() + window_size.w() > (signed) space.x() + space.w())
|
||||||
place->setX(((signed) screen.size().w() - window_size.w()) / 2);
|
place->setX(((signed) space.x() + space.w() - window_size.w()) / 2);
|
||||||
if (place->y() + window_size.h() > (signed) screen.size().h())
|
if (place->y() + window_size.h() > (signed) space.y() + space.h())
|
||||||
place->setY(((signed) screen.size().h() - window_size.h()) / 2);
|
place->setY(((signed) space.y() + space.h() - window_size.h()) / 2);
|
||||||
|
|
||||||
win->configure(place->x(), place->y(), win->area().w(), win->area().h());
|
win.configure(place->x(), place->y(), win.area().w(), win.area().h());
|
||||||
delete place;
|
delete place;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,11 +46,11 @@ private:
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void placeWindow(OpenboxWindow *);
|
void placeWindow(OpenboxWindow &);
|
||||||
Point *bestFitPlacement(const Size &win_size, const Rect &space);
|
Point *bestFitPlacement(const Size &win_size, const Rect &space);
|
||||||
Point *rowSmartPlacement(const Size &win_size, const Rect &space);
|
Point *rowSmartPlacement(const Size &win_size, const Rect &space);
|
||||||
Point *colSmartPlacement(const Size &win_size, const Rect &space);
|
Point *colSmartPlacement(const Size &win_size, const Rect &space);
|
||||||
Point *const cascadePlacement(const OpenboxWindow* window);
|
Point *const cascadePlacement(const OpenboxWindow &window, const Rect &space);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Workspace(BScreen &, int = 0);
|
Workspace(BScreen &, int = 0);
|
||||||
|
|
Loading…
Reference in a new issue