moved RowSmart placement type out of placeWindow() to its own function like bestFit. Will continue moving other placement types into their own functions.
Developers:
Ben Jansens (ben@orodu.net)
Scott Moynes (smoynes@nexus.carleton.ca)
+ Ruhi Bloodworth (ruhi@colophon.cjb.net)
Webmaster:
- Please apply :)
+ Nick Jansens (jex@orodu.net)
-==============================================================================-
# Smart Placement (Columns)
$ #Cascade
# Cascade Placement
+$ #BestFit
+# Best Fit Placement
$ #LeftRight
# Left to Right
$ #RightLeft
BScreen::ColSmartPlacement);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuCascade,
"Cascade Placement"), BScreen::CascadePlacement);
+ insert(i18n->getMessage(ConfigmenuSet, ConfigmenuBestFit,
+ "Best Fit Placement"), BScreen::BestFitPlacement);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuLeftRight,
"Left to Right"), BScreen::LeftRight);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuRightLeft,
case BScreen::CascadePlacement:
setItemSelected(2, True);
break;
+
+ case BScreen::BestFitPlacement:
+ setItemSelected(3, True);
+ break;
}
Bool rl = (configmenu->screen->getRowPlacementDirection() ==
tb = (configmenu->screen->getColPlacementDirection() ==
BScreen::TopBottom);
- setItemSelected(3, rl);
- setItemSelected(4, ! rl);
+ setItemSelected(4, rl);
+ setItemSelected(5, ! rl);
- setItemSelected(5, tb);
- setItemSelected(6, ! tb);
+ setItemSelected(6, tb);
+ setItemSelected(7, ! tb);
}
void Configmenu::Placementmenu::itemSelected(int button, int index) {
setItemSelected(0, True);
setItemSelected(1, False);
setItemSelected(2, False);
+ setItemSelected(3, False);
break;
setItemSelected(0, False);
setItemSelected(1, True);
setItemSelected(2, False);
+ setItemSelected(3, False);
break;
setItemSelected(0, False);
setItemSelected(1, False);
setItemSelected(2, True);
+ setItemSelected(3, False);
+
+ break;
+
+ case BScreen::BestFitPlacement:
+ configmenu->screen->savePlacementPolicy(item->function());
+
+ setItemSelected(0, False);
+ setItemSelected(1, False);
+ setItemSelected(2, False);
+ setItemSelected(3, True);
break;
case BScreen::LeftRight:
configmenu->screen->saveRowPlacementDirection(BScreen::LeftRight);
- setItemSelected(3, True);
- setItemSelected(4, False);
+ setItemSelected(4, True);
+ setItemSelected(5, False);
break;
case BScreen::RightLeft:
configmenu->screen->saveRowPlacementDirection(BScreen::RightLeft);
- setItemSelected(3, False);
- setItemSelected(4, True);
+ setItemSelected(4, False);
+ setItemSelected(5, True);
break;
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
-#ifndef __geometru_h
+#ifndef __geometry_h
#define __geometry_h
class Point{
bool Intersect(const Rect &r) const;
};
-#endif // __geomtry_h
+#endif // __geometry_h
bin_PROGRAMS= openbox
-openbox_SOURCES= BaseDisplay.cc Basemenu.cc Clientmenu.cc Configmenu.cc Iconmenu.cc Image.cc LinkedList.cc Netizen.cc Resource.cc Rootmenu.cc Screen.cc Slit.cc Timer.cc Toolbar.cc Window.cc Windowmenu.cc Workspace.cc Workspacemenu.cc openbox.cc bsd-snprintf.c i18n.cc main.cc
+openbox_SOURCES= BaseDisplay.cc Basemenu.cc Clientmenu.cc Configmenu.cc Geometry.cc Iconmenu.cc Image.cc LinkedList.cc Netizen.cc Resource.cc Rootmenu.cc Screen.cc Slit.cc Timer.cc Toolbar.cc Window.cc Windowmenu.cc Workspace.cc Workspacemenu.cc openbox.cc bsd-snprintf.c i18n.cc main.cc
MAINTAINERCLEANFILES= Makefile.in
# local dependencies
+Geometry.o: Geometry.cc Geometry.h
Resource.o: Resource.cc Resource.h
BaseDisplay.o: BaseDisplay.cc i18n.h BaseDisplay.h LinkedList.h \
Timer.h
Basemenu.o: Basemenu.cc i18n.h openbox.h BaseDisplay.h \
- LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
+ LinkedList.h Timer.h Image.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Screen.h Configmenu.h Netizen.h Rootmenu.h \
Workspace.h Workspacemenu.h Resource.h
Clientmenu.o: Clientmenu.cc openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Clientmenu.h Workspace.h Screen.h Configmenu.h Netizen.h \
- Rootmenu.h Workspacemenu.h Resource.h
+ Rootmenu.h Workspacemenu.h Resource.h Geometry.h
Configmenu.o: Configmenu.cc i18n.h Configmenu.h Basemenu.h \
LinkedList.h Screen.h BaseDisplay.h Timer.h Iconmenu.h Netizen.h \
Rootmenu.h Workspace.h Workspacemenu.h openbox.h Image.h \
- Window.h Windowmenu.h Slit.h Toolbar.h Resource.h
+ Window.h Windowmenu.h Slit.h Toolbar.h Resource.h Geometry.h
Icon.o: Iconmenu.cc i18n.h openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Screen.h Configmenu.h Netizen.h Rootmenu.h Workspace.h \
- Workspacemenu.h Toolbar.h Resource.h
+ Workspacemenu.h Toolbar.h Resource.h Geometry.h
Image.o: Image.cc i18n.h BaseDisplay.h LinkedList.h Timer.h \
Image.h
LinkedList.o: LinkedList.cc LinkedList.h
Netizen.o: Netizen.cc Netizen.h BaseDisplay.h LinkedList.h Timer.h \
Screen.h Configmenu.h Basemenu.h openbox.h Image.h Window.h \
Iconmenu.h Windowmenu.h Slit.h Rootmenu.h Workspace.h \
- Workspacemenu.h Resource.h
+ Workspacemenu.h Resource.h Geometry.h
Rootmenu.o: Rootmenu.cc openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Rootmenu.h Screen.h Configmenu.h Netizen.h Workspace.h \
- Workspacemenu.h Resource.h
+ Workspacemenu.h Resource.h Geometry.h
Screen.o: Screen.cc i18n.h bsd-snprintf.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Clientmenu.h Workspace.h Screen.h Configmenu.h \
- Netizen.h Rootmenu.h Workspacemenu.h Toolbar.h Resource.h
+ Netizen.h Rootmenu.h Workspacemenu.h Toolbar.h Resource.h Geometry.h
Slit.o: Slit.cc i18n.h openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Screen.h Configmenu.h Netizen.h Rootmenu.h Workspace.h \
- Workspacemenu.h Toolbar.h Resource.h
+ Workspacemenu.h Toolbar.h Resource.h Geometry.h
Timer.o: Timer.cc BaseDisplay.h LinkedList.h Timer.h
Toolbar.o: Toolbar.cc i18n.h openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Clientmenu.h Workspace.h Rootmenu.h Screen.h Configmenu.h \
- Netizen.h Workspacemenu.h Toolbar.h Resource.h
+ Netizen.h Workspacemenu.h Toolbar.h Resource.h Geometry.h
Window.o: Window.cc i18n.h openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Screen.h Configmenu.h Netizen.h Rootmenu.h Workspace.h \
- Workspacemenu.h Toolbar.h Resource.h
+ Workspacemenu.h Toolbar.h Resource.h Geometry.h
Windowmenu.o: Windowmenu.cc i18n.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Screen.h Configmenu.h Netizen.h Rootmenu.h \
- Workspace.h Workspacemenu.h Resource.h
+ Workspace.h Workspacemenu.h Resource.h Geometry.h
Workspace.o: Workspace.cc i18n.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Clientmenu.h Workspace.h Screen.h \
- Configmenu.h Netizen.h Rootmenu.h Workspacemenu.h Toolbar.h Resource.h
+ Configmenu.h Netizen.h Rootmenu.h Workspacemenu.h Toolbar.h Resource.h \
+ Geometry.h Geometry.h
Workspacemenu.o: Workspacemenu.cc i18n.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Screen.h Configmenu.h Netizen.h Rootmenu.h \
- Workspace.h Workspacemenu.h Toolbar.h Resource.h
+ Workspace.h Workspacemenu.h Toolbar.h Resource.h Geometry.h
openbox.o: openbox.cc i18n.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Clientmenu.h Workspace.h Rootmenu.h \
- Screen.h Configmenu.h Netizen.h Workspacemenu.h Toolbar.h Resource.h
+ Screen.h Configmenu.h Netizen.h Workspacemenu.h Toolbar.h Resource.h Geometry.h
bsd-snprintf.o: bsd-snprintf.c bsd-snprintf.h
i18n.o: i18n.cc i18n.h
main.o: main.cc ../version.h i18n.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
- Windowmenu.h Slit.h Resource.h
+ Windowmenu.h Slit.h Resource.h Geometry.h
bin_PROGRAMS = openbox
-openbox_SOURCES = BaseDisplay.cc Basemenu.cc Clientmenu.cc Configmenu.cc Iconmenu.cc Image.cc LinkedList.cc Netizen.cc Resource.cc Rootmenu.cc Screen.cc Slit.cc Timer.cc Toolbar.cc Window.cc Windowmenu.cc Workspace.cc Workspacemenu.cc openbox.cc bsd-snprintf.c i18n.cc main.cc
+openbox_SOURCES = BaseDisplay.cc Basemenu.cc Clientmenu.cc Configmenu.cc Geometry.cc Iconmenu.cc Image.cc LinkedList.cc Netizen.cc Resource.cc Rootmenu.cc Screen.cc Slit.cc Timer.cc Toolbar.cc Window.cc Windowmenu.cc Workspace.cc Workspacemenu.cc openbox.cc bsd-snprintf.c i18n.cc main.cc
MAINTAINERCLEANFILES = Makefile.in
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
openbox_OBJECTS = BaseDisplay.o Basemenu.o Clientmenu.o Configmenu.o \
-Iconmenu.o Image.o LinkedList.o Netizen.o Resource.o Rootmenu.o \
-Screen.o Slit.o Timer.o Toolbar.o Window.o Windowmenu.o Workspace.o \
-Workspacemenu.o openbox.o bsd-snprintf.o i18n.o main.o
+Geometry.o Iconmenu.o Image.o LinkedList.o Netizen.o Resource.o \
+Rootmenu.o Screen.o Slit.o Timer.o Toolbar.o Window.o Windowmenu.o \
+Workspace.o Workspacemenu.o openbox.o bsd-snprintf.o i18n.o main.o
openbox_LDADD = $(LDADD)
openbox_DEPENDENCIES =
openbox_LDFLAGS =
TAR = tar
GZIP_ENV = --best
DEP_FILES = .deps/BaseDisplay.P .deps/Basemenu.P .deps/Clientmenu.P \
-.deps/Configmenu.P .deps/Iconmenu.P .deps/Image.P .deps/LinkedList.P \
-.deps/Netizen.P .deps/Resource.P .deps/Rootmenu.P .deps/Screen.P \
-.deps/Slit.P .deps/Timer.P .deps/Toolbar.P .deps/Window.P \
-.deps/Windowmenu.P .deps/Workspace.P .deps/Workspacemenu.P \
-.deps/bsd-snprintf.P .deps/i18n.P .deps/main.P .deps/openbox.P
+.deps/Configmenu.P .deps/Geometry.P .deps/Iconmenu.P .deps/Image.P \
+.deps/LinkedList.P .deps/Netizen.P .deps/Resource.P .deps/Rootmenu.P \
+.deps/Screen.P .deps/Slit.P .deps/Timer.P .deps/Toolbar.P \
+.deps/Window.P .deps/Windowmenu.P .deps/Workspace.P \
+.deps/Workspacemenu.P .deps/bsd-snprintf.P .deps/i18n.P .deps/main.P \
+.deps/openbox.P
SOURCES = $(openbox_SOURCES)
OBJECTS = $(openbox_OBJECTS)
# local dependencies
+Geometry.o: Geometry.cc Geometry.h
Resource.o: Resource.cc Resource.h
BaseDisplay.o: BaseDisplay.cc i18n.h BaseDisplay.h LinkedList.h \
Timer.h
Basemenu.o: Basemenu.cc i18n.h openbox.h BaseDisplay.h \
- LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
+ LinkedList.h Timer.h Image.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Screen.h Configmenu.h Netizen.h Rootmenu.h \
Workspace.h Workspacemenu.h Resource.h
Clientmenu.o: Clientmenu.cc openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Clientmenu.h Workspace.h Screen.h Configmenu.h Netizen.h \
- Rootmenu.h Workspacemenu.h Resource.h
+ Rootmenu.h Workspacemenu.h Resource.h Geometry.h
Configmenu.o: Configmenu.cc i18n.h Configmenu.h Basemenu.h \
LinkedList.h Screen.h BaseDisplay.h Timer.h Iconmenu.h Netizen.h \
Rootmenu.h Workspace.h Workspacemenu.h openbox.h Image.h \
- Window.h Windowmenu.h Slit.h Toolbar.h Resource.h
+ Window.h Windowmenu.h Slit.h Toolbar.h Resource.h Geometry.h
Icon.o: Iconmenu.cc i18n.h openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Screen.h Configmenu.h Netizen.h Rootmenu.h Workspace.h \
- Workspacemenu.h Toolbar.h Resource.h
+ Workspacemenu.h Toolbar.h Resource.h Geometry.h
Image.o: Image.cc i18n.h BaseDisplay.h LinkedList.h Timer.h \
Image.h
LinkedList.o: LinkedList.cc LinkedList.h
Netizen.o: Netizen.cc Netizen.h BaseDisplay.h LinkedList.h Timer.h \
Screen.h Configmenu.h Basemenu.h openbox.h Image.h Window.h \
Iconmenu.h Windowmenu.h Slit.h Rootmenu.h Workspace.h \
- Workspacemenu.h Resource.h
+ Workspacemenu.h Resource.h Geometry.h
Rootmenu.o: Rootmenu.cc openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Rootmenu.h Screen.h Configmenu.h Netizen.h Workspace.h \
- Workspacemenu.h Resource.h
+ Workspacemenu.h Resource.h Geometry.h
Screen.o: Screen.cc i18n.h bsd-snprintf.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Clientmenu.h Workspace.h Screen.h Configmenu.h \
- Netizen.h Rootmenu.h Workspacemenu.h Toolbar.h Resource.h
+ Netizen.h Rootmenu.h Workspacemenu.h Toolbar.h Resource.h Geometry.h
Slit.o: Slit.cc i18n.h openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Screen.h Configmenu.h Netizen.h Rootmenu.h Workspace.h \
- Workspacemenu.h Toolbar.h Resource.h
+ Workspacemenu.h Toolbar.h Resource.h Geometry.h
Timer.o: Timer.cc BaseDisplay.h LinkedList.h Timer.h
Toolbar.o: Toolbar.cc i18n.h openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Clientmenu.h Workspace.h Rootmenu.h Screen.h Configmenu.h \
- Netizen.h Workspacemenu.h Toolbar.h Resource.h
+ Netizen.h Workspacemenu.h Toolbar.h Resource.h Geometry.h
Window.o: Window.cc i18n.h openbox.h BaseDisplay.h LinkedList.h \
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
Screen.h Configmenu.h Netizen.h Rootmenu.h Workspace.h \
- Workspacemenu.h Toolbar.h Resource.h
+ Workspacemenu.h Toolbar.h Resource.h Geometry.h
Windowmenu.o: Windowmenu.cc i18n.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Screen.h Configmenu.h Netizen.h Rootmenu.h \
- Workspace.h Workspacemenu.h Resource.h
+ Workspace.h Workspacemenu.h Resource.h Geometry.h
Workspace.o: Workspace.cc i18n.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Clientmenu.h Workspace.h Screen.h \
- Configmenu.h Netizen.h Rootmenu.h Workspacemenu.h Toolbar.h Resource.h
+ Configmenu.h Netizen.h Rootmenu.h Workspacemenu.h Toolbar.h Resource.h \
+ Geometry.h Geometry.h
Workspacemenu.o: Workspacemenu.cc i18n.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Screen.h Configmenu.h Netizen.h Rootmenu.h \
- Workspace.h Workspacemenu.h Toolbar.h Resource.h
+ Workspace.h Workspacemenu.h Toolbar.h Resource.h Geometry.h
openbox.o: openbox.cc i18n.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
Windowmenu.h Slit.h Clientmenu.h Workspace.h Rootmenu.h \
- Screen.h Configmenu.h Netizen.h Workspacemenu.h Toolbar.h Resource.h
+ Screen.h Configmenu.h Netizen.h Workspacemenu.h Toolbar.h Resource.h Geometry.h
bsd-snprintf.o: bsd-snprintf.c bsd-snprintf.h
i18n.o: i18n.cc i18n.h
main.o: main.cc ../version.h i18n.h openbox.h BaseDisplay.h \
LinkedList.h Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
- Windowmenu.h Slit.h Resource.h
+ Windowmenu.h Slit.h Resource.h Geometry.h
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
void updateNetizenWindowRaise(Window);
void updateNetizenWindowLower(Window);
- enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement, LeftRight,
- RightLeft, TopBottom, BottomTop };
+ enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
+ BestFitPlacement, LeftRight, RightLeft, TopBottom, BottomTop };
enum { LeftJustify = 1, RightJustify, CenterJustify };
enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
#include "BaseDisplay.h"
#include "Timer.h"
#include "Windowmenu.h"
+#include "Geometry.h"
// forward declaration
class OpenboxWindow;
inline const unsigned int &getTitleHeight(void) const
{ return frame.title_h; }
+ inline const Point getOrigin() const {
+ return Point(frame.x, frame.y);
+ }
+ inline const Point getClientOrigin() const {
+ return Point(client.x, client.y);
+ }
+ inline const Size getSize() const {
+ return Size(frame.width, frame.height);
+ }
+ inline const Size getClientSize() const {
+ return Size(client.width, client.height);
+ }
+ inline const Rect getArea() const {
+ return Rect(frame.x, frame.y, frame.width, frame.height);
+ }
+ inline const Rect getClientArea() const {
+ return Rect(client.x, client.y, client.width, client.height);
+ }
+
inline void setWindowNumber(int n) { window_number = n; }
Bool validateClient(void);
// Workspace.cc for Openbox
+// Copyright (c) 2002 - 2002 Ben Jansens (ben@orodu.net)
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
//
#include "Window.h"
#include "Workspace.h"
#include "Windowmenu.h"
+#include "Geometry.h"
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif // HAVE_STDIO_H
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif // HAVE_STDLIB_H
+
#ifdef STDC_HEADERS
# include <string.h>
#endif // STDC_HEADERS
+#include <vector>
+typedef vector<Rect> rectList;
Workspace::Workspace(BScreen *scrn, int i) {
screen = scrn;
}
}
+static rectList calcSpace(const OpenboxWindow &win, const rectList &spaces) {
+ rectList result;
+ rectList::const_iterator siter;
+ for(siter=spaces.begin(); siter!=spaces.end(); ++siter) {
+ if(win.getArea().Intersect(*siter)) {
+ //Check for space to the left of the window
+ if(win.getXFrame() > siter->x())
+ result.push_back(Rect(siter->x(), siter->y(),
+ win.getXFrame() - siter->x() - 1,
+ siter->h()));
+ //Check for space above the window
+ if(win.getYFrame() > siter->y())
+ result.push_back(Rect(siter->x(), siter->y(),
+ siter->w(),
+ win.getYFrame() - siter->y() - 1));
+ //Check for space to the right of the window
+ if((win.getXFrame()+win.getWidth()) <
+ (siter->x()+siter->w()))
+ result.push_back(Rect(win.getXFrame() + win.getWidth() + 1,
+ siter->y(),
+ siter->x() + siter->w() -
+ win.getXFrame() - win.getWidth() - 1,
+ siter->h()));
+ //Check for space below the window
+ if((win.getYFrame()+win.getHeight()) <
+ (siter->y()+siter->h()))
+ result.push_back(Rect(siter->x(),
+ win.getYFrame() + win.getHeight() + 1,
+ siter->w(),
+ siter->y() + siter->h()-
+ win.getYFrame() - win.getHeight() - 1));
+
+ }
+ else
+ result.push_back(*siter);
+ }
+ return result;
+}
+
+//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)
+{
+ 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, spaces);
+
+ //Find first space that fits the window
+ best = 0;
+ for (siter=spaces.begin(); siter!=spaces.end(); ++siter) {
+ if ((siter->w() >= win_size.w()) &&
+ (siter->h() >= win_size.h()))
+ best = siter;
+ }
+
+ if (best != 0)
+ return new Point(best->origin());
+ else
+ return new Point(200, 0);
+}
+
+inline Point *Workspace::rowSmartPlacement(const Size &win_size,
+ const Rect &space){
+ bool placed=false;
+ int test_x, test_y, place_x = 0, place_y = 0;
+ int start_pos = 0;
+ int change_y =
+ ((screen->getColPlacementDirection() == BScreen::TopBottom) ? 1 : -1);
+ int change_x =
+ ((screen->getRowPlacementDirection() == BScreen::LeftRight) ? 1 : -1);
+ int delta_x = 8, delta_y = 8;
+ LinkedListIterator<OpenboxWindow> it(windowList);
+
+ test_y = (screen->getColPlacementDirection() == BScreen::TopBottom) ?
+ start_pos : screen->getHeight() - win_size.h() - start_pos;
+
+ while(!placed &&
+ ((screen->getColPlacementDirection() == BScreen::BottomTop) ?
+ test_y > 0 : test_y + win_size.h() < (signed) space.h())) {
+ test_x = (screen->getRowPlacementDirection() == BScreen::LeftRight) ?
+ start_pos : space.w() - win_size.w() - start_pos;
+ while (!placed &&
+ ((screen->getRowPlacementDirection() == BScreen::RightLeft) ?
+ test_x > 0 : test_x + win_size.w() < (signed) space.w())) {
+ placed = true;
+
+ it.reset();
+ for (OpenboxWindow *curr = it.current(); placed && curr;
+ it++, curr = it.current()) {
+ int curr_w = curr->getWidth() + (screen->getBorderWidth() * 4);
+ int curr_h =
+ ((curr->isShaded()) ? curr->getTitleHeight() : curr->getHeight()) +
+ (screen->getBorderWidth() * 4);
+
+ if (curr->getXFrame() < test_x + win_size.w() &&
+ curr->getXFrame() + curr_w > test_x &&
+ curr->getYFrame() < test_y + win_size.h() &&
+ curr->getYFrame() + curr_h > test_y) {
+ placed = false;
+ }
+ }
+
+ // Removed code for checking toolbar and slit
+ // The space passed in should not include either
+
+ if (placed) {
+ place_x = test_x;
+ place_y = test_y;
+
+ break;
+ }
+
+ test_x += (change_x * delta_x);
+ }
+
+ test_y += (change_y * delta_y);
+ }
+ return new Point(place_x, place_y);
+}
+
void Workspace::placeWindow(OpenboxWindow *win) {
+ assert(win != NULL);
+
Bool placed = False;
const int win_w = win->getWidth() + (screen->getBorderWidth() * 4),
int test_x, test_y, place_x = 0, place_y = 0;
LinkedListIterator<OpenboxWindow> it(windowList);
+ Rect space(0, 0,
+ screen->getWidth(),
+ screen->getHeight()
+ );
+ Size window_size(win_w, win_h);
+
switch (screen->getPlacementPolicy()) {
+ case BScreen::BestFitPlacement: {
+ Point *spot = bestFitPlacement(window_size, space);
+ if (spot != NULL) {
+ place_x=spot->x();
+ place_y=spot->y();
+ delete spot;
+ placed=true;
+ }
+ break;
+ }
case BScreen::RowSmartPlacement: {
- test_y = (screen->getColPlacementDirection() == BScreen::TopBottom) ?
- start_pos : screen->getHeight() - win_h - start_pos;
-
- while (!placed &&
- ((screen->getColPlacementDirection() == BScreen::BottomTop) ?
- test_y > 0 : test_y + win_h < (signed) screen->getHeight())) {
- test_x = (screen->getRowPlacementDirection() == BScreen::LeftRight) ?
- start_pos : screen->getWidth() - win_w - start_pos;
-
- while (!placed &&
- ((screen->getRowPlacementDirection() == BScreen::RightLeft) ?
- test_x > 0 : test_x + win_w < (signed) screen->getWidth())) {
- placed = True;
-
- it.reset();
- for (OpenboxWindow *curr = it.current(); placed && curr;
- it++, curr = it.current()) {
- if (curr->isMaximizedFull()) // fully maximized, ignore it
- continue;
- int curr_w = curr->getWidth() + (screen->getBorderWidth() * 4);
- int curr_h =
- ((curr->isShaded()) ? curr->getTitleHeight() : curr->getHeight()) +
- (screen->getBorderWidth() * 4);
-
- if (curr->getXFrame() < test_x + win_w &&
- curr->getXFrame() + curr_w > test_x &&
- curr->getYFrame() < test_y + win_h &&
- curr->getYFrame() + curr_h > test_y) {
- placed = False;
- }
- }
-
- if (placed &&
- (toolbar_x < test_x + win_w &&
- toolbar_x + toolbar_w > test_x &&
- toolbar_y < test_y + win_h &&
- toolbar_y + toolbar_h > test_y)
-#ifdef SLIT
- ||
- (slit_x < test_x + win_w &&
- slit_x + slit_w > test_x &&
- slit_y < test_y + win_h &&
- slit_y + slit_h > test_y)
-#endif // SLIT
- )
- placed = False;
-
- if (placed) {
- place_x = test_x;
- place_y = test_y;
-
- break;
- }
-
- test_x += (change_x * delta_x);
- }
-
- test_y += (change_y * delta_y);
+ Point *spot=rowSmartPlacement(window_size, space);
+ if (spot != NULL) {
+ place_x=spot->x();
+ place_y=spot->y();
+ delete spot;
+ placed=true;
}
-
break;
}
#include <X11/Xlib.h>
#include "LinkedList.h"
+#include "Geometry.h"
class BScreen;
class Clientmenu;
protected:
void placeWindow(OpenboxWindow *);
+ Point *bestFitPlacement(const Size &win_size, const Rect &space);
+ Point *rowSmartPlacement(const Size &win_size, const Rect &space);
public:
switch (screen->getPlacementPolicy()) {
case BScreen::CascadePlacement: placement = "CascadePlacement"; break;
+ case BScreen::BestFitPlacement: placement = "BestFitPlacement"; break;
case BScreen::ColSmartPlacement: placement = "ColSmartPlacement"; break;
default:
case BScreen::RowSmartPlacement: placement = "RowSmartPlacement"; break;
screen->savePlacementPolicy(BScreen::RowSmartPlacement);
else if (0 == strncasecmp(s.c_str(), "ColSmartPlacement", s.length()))
screen->savePlacementPolicy(BScreen::ColSmartPlacement);
+ else if (0 == strncasecmp(s.c_str(), "BestFitPlacement", s.length()))
+ screen->savePlacementPolicy(BScreen::BestFitPlacement);
else
screen->savePlacementPolicy(BScreen::CascadePlacement);
} else