From 07281446ea01d1758ed8cd2aa45d0c94ce1d9830 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 27 Apr 2002 21:15:00 +0000 Subject: [PATCH] better cascadePlacement. uses screen.availableArea(). --- src/Workspace.cc | 47 ++++++++++++++++++++++++++--------------------- src/Workspace.h | 4 ++-- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/Workspace.cc b/src/Workspace.cc index 1c290b75..39210743 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -64,7 +64,7 @@ typedef vector rectList; Workspace::Workspace(BScreen &scrn, int i) : screen(scrn) { - cascade_x = cascade_y = 32; + cascade_x = cascade_y = 0; id = i; @@ -93,7 +93,7 @@ Workspace::~Workspace(void) { const int Workspace::addWindow(OpenboxWindow *w, Bool place) { if (! w) return -1; - if (place) placeWindow(w); + if (place) placeWindow(*w); w->setWorkspace(id); 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){ - if (((unsigned) cascade_x > (screen.size().w() / 2)) || - ((unsigned) cascade_y > (screen.size().h() / 2))) - cascade_x = cascade_y = 32; - - cascade_x += win->getTitleHeight(); - cascade_y += win->getTitleHeight(); +Point *const Workspace::cascadePlacement(const OpenboxWindow &win, + const Rect &space) { + if ((cascade_x + win.area().w() + screen.getBorderWidth() * 2 > + (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(); + } - return new Point(cascade_x, cascade_y); + Point *p = new Point(cascade_x, cascade_y); + cascade_x += win.getTitleHeight(); + cascade_y += win.getTitleHeight(); + return p; } -void Workspace::placeWindow(OpenboxWindow *win) { - ASSERT(win != NULL); - +void Workspace::placeWindow(OpenboxWindow &win) { Rect space = screen.availableArea(); - const Size window_size(win->area().w()+screen.getBorderWidth() * 4, - win->area().h()+screen.getBorderWidth() * 4); + const Size window_size(win.area().w()+screen.getBorderWidth() * 4, + win.area().h()+screen.getBorderWidth() * 4); Point *place = NULL; LinkedListIterator it(windowList); @@ -600,14 +605,14 @@ void Workspace::placeWindow(OpenboxWindow *win) { } // switch if (place == NULL) - place = cascadePlacement(win); + place = cascadePlacement(win, space); ASSERT(place != NULL); - if (place->x() + window_size.w() > (signed) screen.size().w()) - place->setX(((signed) screen.size().w() - window_size.w()) / 2); - if (place->y() + window_size.h() > (signed) screen.size().h()) - place->setY(((signed) screen.size().h() - window_size.h()) / 2); + if (place->x() + window_size.w() > (signed) space.x() + space.w()) + place->setX(((signed) space.x() + space.w() - window_size.w()) / 2); + if (place->y() + window_size.h() > (signed) space.y() + space.h()) + 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; } diff --git a/src/Workspace.h b/src/Workspace.h index c2b92091..12d4dfc2 100644 --- a/src/Workspace.h +++ b/src/Workspace.h @@ -46,11 +46,11 @@ private: protected: - void placeWindow(OpenboxWindow *); + void placeWindow(OpenboxWindow &); Point *bestFitPlacement(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 *const cascadePlacement(const OpenboxWindow* window); + Point *const cascadePlacement(const OpenboxWindow &window, const Rect &space); public: Workspace(BScreen &, int = 0); -- 2.45.2