From: Dana Jansens Date: Sun, 14 Apr 2002 01:11:51 +0000 (+0000) Subject: added first revision of the BestFit placement type. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=424d476f7cd0ccc2def4f14119cd4fc3171d0159;p=chaz%2Fopenbox added first revision of the BestFit placement type. moved RowSmart placement type out of placeWindow() to its own function like bestFit. Will continue moving other placement types into their own functions. --- diff --git a/AUTHORS b/AUTHORS index c72e75ae..b5cd493f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,9 +6,10 @@ Project Maintainer: 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) -==============================================================================- diff --git a/nls/C/Configmenu.m b/nls/C/Configmenu.m index d01e3c15..f0641355 100644 --- a/nls/C/Configmenu.m +++ b/nls/C/Configmenu.m @@ -28,6 +28,8 @@ $ #SmartCols # Smart Placement (Columns) $ #Cascade # Cascade Placement +$ #BestFit +# Best Fit Placement $ #LeftRight # Left to Right $ #RightLeft diff --git a/src/Configmenu.cc b/src/Configmenu.cc index 97faf779..aa715f1e 100644 --- a/src/Configmenu.cc +++ b/src/Configmenu.cc @@ -215,6 +215,8 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm) : 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, @@ -237,6 +239,10 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm) : case BScreen::CascadePlacement: setItemSelected(2, True); break; + + case BScreen::BestFitPlacement: + setItemSelected(3, True); + break; } Bool rl = (configmenu->screen->getRowPlacementDirection() == @@ -244,11 +250,11 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm) : 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) { @@ -267,6 +273,7 @@ void Configmenu::Placementmenu::itemSelected(int button, int index) { setItemSelected(0, True); setItemSelected(1, False); setItemSelected(2, False); + setItemSelected(3, False); break; @@ -276,6 +283,7 @@ void Configmenu::Placementmenu::itemSelected(int button, int index) { setItemSelected(0, False); setItemSelected(1, True); setItemSelected(2, False); + setItemSelected(3, False); break; @@ -285,22 +293,33 @@ void Configmenu::Placementmenu::itemSelected(int button, int index) { 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; diff --git a/src/Geometry.h b/src/Geometry.h index b2454ac6..ab5b8410 100644 --- a/src/Geometry.h +++ b/src/Geometry.h @@ -19,7 +19,7 @@ // 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{ @@ -99,4 +99,4 @@ public: bool Intersect(const Rect &r) const; }; -#endif // __geomtry_h +#endif // __geometry_h diff --git a/src/Makefile.am b/src/Makefile.am index f44dad32..5bfdc813 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,7 +30,7 @@ CPPFLAGS= @CPPFLAGS@ @SHAPE@ @SLIT@ @INTERLACE@ @ORDEREDPSEUDO@ \ 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 @@ -39,71 +39,73 @@ distclean-local: # 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 diff --git a/src/Makefile.in b/src/Makefile.in index 8f0657c5..4f50404d 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -104,7 +104,7 @@ CPPFLAGS = @CPPFLAGS@ @SHAPE@ @SLIT@ @INTERLACE@ @ORDEREDPSEUDO@ @DEBUG@ @NEWWMS 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 @@ -121,9 +121,9 @@ X_LIBS = @X_LIBS@ 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 = @@ -143,11 +143,12 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) 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) @@ -389,74 +390,76 @@ distclean-local: # 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. diff --git a/src/Screen.h b/src/Screen.h index 13e58a2b..06a0c15c 100644 --- a/src/Screen.h +++ b/src/Screen.h @@ -338,8 +338,8 @@ public: 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, diff --git a/src/Window.h b/src/Window.h index d6e9f809..b2f76242 100644 --- a/src/Window.h +++ b/src/Window.h @@ -32,6 +32,7 @@ #include "BaseDisplay.h" #include "Timer.h" #include "Windowmenu.h" +#include "Geometry.h" // forward declaration class OpenboxWindow; @@ -286,6 +287,25 @@ public: 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); diff --git a/src/Workspace.cc b/src/Workspace.cc index fa1f7990..c31b3efa 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -1,4 +1,5 @@ // Workspace.cc for Openbox +// Copyright (c) 2002 - 2002 Ben Jansens (ben@orodu.net) // Copyright (c) 2001 Sean 'Shaleh' Perry // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) // @@ -41,15 +42,22 @@ #include "Window.h" #include "Workspace.h" #include "Windowmenu.h" +#include "Geometry.h" #ifdef HAVE_STDIO_H # include #endif // HAVE_STDIO_H +#ifdef HAVE_STDLIB_H +# include +#endif // HAVE_STDLIB_H + #ifdef STDC_HEADERS # include #endif // STDC_HEADERS +#include +typedef vector rectList; Workspace::Workspace(BScreen *scrn, int i) { screen = scrn; @@ -322,7 +330,137 @@ void Workspace::shutdown(void) { } } +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 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 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), @@ -351,68 +489,31 @@ void Workspace::placeWindow(OpenboxWindow *win) { int test_x, test_y, place_x = 0, place_y = 0; LinkedListIterator 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; } diff --git a/src/Workspace.h b/src/Workspace.h index f9700bdc..441a8733 100644 --- a/src/Workspace.h +++ b/src/Workspace.h @@ -26,6 +26,7 @@ #include #include "LinkedList.h" +#include "Geometry.h" class BScreen; class Clientmenu; @@ -46,6 +47,8 @@ private: protected: void placeWindow(OpenboxWindow *); + Point *bestFitPlacement(const Size &win_size, const Rect &space); + Point *rowSmartPlacement(const Size &win_size, const Rect &space); public: diff --git a/src/openbox.cc b/src/openbox.cc index f917cc01..d884540b 100644 --- a/src/openbox.cc +++ b/src/openbox.cc @@ -1043,6 +1043,7 @@ void Openbox::save_rc(void) { 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; @@ -1363,6 +1364,8 @@ void Openbox::load_rc(BScreen *screen) { 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