all repos — openbox @ 7eb8d6966ccf3d7e1068137ec64bfd2a366a9dac

openbox fork - make it a bit more like ryudo

new row and column placement, using a modified bestfit. These don't work right yet, nor does bestfit, but they are coming.
Dana Jansens danakj@orodu.net
commit

7eb8d6966ccf3d7e1068137ec64bfd2a366a9dac

parent

f994c778d8e307d99884e8554a361dd4ddb0e106

1 files changed, 108 insertions(+), 2 deletions(-)

jump to
M src/Workspace.ccsrc/Workspace.cc

@@ -59,6 +59,7 @@ # include <string.h>

#endif // HAVE_STRING_H #include <vector> +#include <algorithm> typedef vector<Rect> rectList; Workspace::Workspace(BScreen &scrn, int i) : screen(scrn) {

@@ -371,11 +372,35 @@ }

return result; } + +bool incWidth(const Rect &first, const Rect &second) { + return first.x() < second.x(); +} + + +bool decWidth(const Rect &first, const Rect &second) { + if (second.x() == first.x()) + return second.w() < first.w(); + return second.x() < first.x(); +} + + +bool incHeight(const Rect &first, const Rect &second) { + return first.y() < second.y(); +} + + +bool decHeight(const Rect &first, const Rect &second) { + if (second.y() == first.y()) + return second.h() < first.h(); + return second.y() < first.y(); +} + + //BestFitPlacement finds the smallest free space that fits the window //to be placed. It currentl ignores whether placement is right to left or top //to bottom. -Point *Workspace::bestFitPlacement(const Size &win_size, const Rect &space) -{ +Point *Workspace::bestFitPlacement(const Size &win_size, const Rect &space) { const Rect *best; rectList spaces; LinkedListIterator<OpenboxWindow> it(windowList);

@@ -410,6 +435,46 @@ } else

return NULL; //fall back to cascade } + +Point *Workspace::rowSmartPlacement(const Size &win_size, const Rect &space) { + const Rect *best; + rectList spaces; + LinkedListIterator<OpenboxWindow> it(windowList); + rectList::const_iterator siter; + spaces.push_back(space); //initially the entire screen is free + it.reset(); + + //Find Free Spaces + for (OpenboxWindow *cur=it.current(); cur!=NULL; it++, cur=it.current()) + spaces = calcSpace(cur->area().Inflate(screen.getBorderWidth() * 4), + spaces); + + //Sort the spaces by placement choice + if (screen.rowPlacementDirection() == BScreen::TopBottom) + sort(spaces.begin(),spaces.end(),incHeight); + else + sort(spaces.begin(),spaces.end(),decHeight); + + //Find first space that fits the window + best = NULL; + for (siter=spaces.begin(); siter!=spaces.end(); ++siter) + if ((siter->w() >= win_size.w()) && (siter->h() >= win_size.h())) { + best = siter; + break; + } + + if (best != NULL) { + Point *pt = new Point(best->origin()); + if (screen.colPlacementDirection() != BScreen::TopBottom) + pt->setY(pt->y() + (best->h() - win_size.h())); + if (screen.rowPlacementDirection() != BScreen::LeftRight) + pt->setX(pt->x() + (best->w() - win_size.w())); + return pt; + } else + return NULL; //fall back to cascade +} + +/* inline Point *Workspace::rowSmartPlacement(const Size &win_size, const Rect &space){ bool placed=false;

@@ -469,7 +534,47 @@ return new Point(place_x, place_y);

else return NULL; // fall back to cascade } +*/ +Point *Workspace::colSmartPlacement(const Size &win_size, const Rect &space) { + const Rect *best; + rectList spaces; + LinkedListIterator<OpenboxWindow> it(windowList); + rectList::const_iterator siter; + spaces.push_back(space); //initially the entire screen is free + it.reset(); + + //Find Free Spaces + for (OpenboxWindow *cur=it.current(); cur!=NULL; it++, cur=it.current()) + spaces = calcSpace(cur->area().Inflate(screen.getBorderWidth() * 4), + spaces); + + //Sort the spaces by placement choice + if (screen.rowPlacementDirection() == BScreen::LeftRight) + sort(spaces.begin(),spaces.end(),incWidth); + else + sort(spaces.begin(),spaces.end(),decWidth); + + //Find first space that fits the window + best = NULL; + for (siter=spaces.begin(); siter!=spaces.end(); ++siter) + if ((siter->w() >= win_size.w()) && (siter->h() >= win_size.h())) { + best = siter; + break; + } + + if (best != NULL) { + Point *pt = new Point(best->origin()); + if (screen.colPlacementDirection() != BScreen::TopBottom) + pt->setY(pt->y() + (best->h() - win_size.h())); + if (screen.rowPlacementDirection() != BScreen::LeftRight) + pt->setX(pt->x() + (best->w() - win_size.w())); + return pt; + } else + return NULL; //fall back to cascade +} + +/* inline Point * Workspace::colSmartPlacement(const Size &win_size, const Rect &space){ Point *pt;

@@ -531,6 +636,7 @@ return pt;

else return NULL; } +*/ Point *const Workspace::cascadePlacement(const OpenboxWindow *const win){ if (((unsigned) cascade_x > (screen.size().w() / 2)) ||