all repos — fluxbox @ a5b5be5e09ef4488d7dcebf2091e94b8e4d6e727

custom fork of the fluxbox windowmanager

Add "Unclutter" command

Unclutter the desktop by using the MinOverlapPlacement
for all matching windows.

REQUEST: 248
Thomas Lübking thomas.luebking@gmail.com
commit

a5b5be5e09ef4488d7dcebf2091e94b8e4d6e727

parent

8a6623040ea543f20712dbcb1ed2f9456118961c

3 files changed, 52 insertions(+), 0 deletions(-)

jump to
M doc/asciidoc/fluxbox-keys.txtdoc/asciidoc/fluxbox-keys.txt

@@ -434,6 +434,11 @@ screen, and the tiled windows on the bottom half of the screen.

*ArrangeWindowsStackTop* places the main window on the BOTTOM half of the screen and the tiled windows on the top half of the screen. +*Unclutter* 'pattern':: + Arrange all matching windows to reduce the overall window overlap as much + as possible. Windows are not resized. + See *CLIENT PATTERNS* for more about the 'pattern' arguments. + *ShowDesktop*:: Minimizes all windows on the current workspace. If they are already all minimized, then it restores them.
M src/WorkspaceCmd.ccsrc/WorkspaceCmd.cc

@@ -23,6 +23,7 @@

#include "WorkspaceCmd.hh" #include "Layer.hh" +#include "MinOverlapPlacement.hh" #include "Workspace.hh" #include "Window.hh" #include "Screen.hh"

@@ -203,6 +204,8 @@ return new ArrangeWindowsCmd(method,pat);

} else if (command == "arrangewindowsstackbottom") { int method = ArrangeWindowsCmd::STACKBOTTOM; return new ArrangeWindowsCmd(method,pat); + } else if (command == "unclutter") { + return new UnclutterCmd(pat); } return 0;

@@ -220,6 +223,7 @@ REGISTER_COMMAND_PARSER(arrangewindowsstackleft, parseWindowList, void);

REGISTER_COMMAND_PARSER(arrangewindowsstackright, parseWindowList, void); REGISTER_COMMAND_PARSER(arrangewindowsstacktop, parseWindowList, void); REGISTER_COMMAND_PARSER(arrangewindowsstackbottom, parseWindowList, void); +REGISTER_COMMAND_PARSER(unclutter, parseWindowList, void); } // end anonymous namespace

@@ -585,6 +589,41 @@ default:

// Shouldn't happen. break; } + } +} + +void UnclutterCmd::execute() { + BScreen *screen = Fluxbox::instance()->mouseScreen(); + if (screen == 0) + return; + + Workspace *space = screen->currentWorkspace(); + + if (space->windowList().empty()) + return; + + const int head = screen->getCurrHead(); + Workspace::Windows::iterator win; + Workspace::Windows placed_windows; + + // list and clean up + for (win = space->windowList().begin(); win != space->windowList().end(); ++win) { + int winhead = screen->getHead((*win)->fbWindow()); + if ((winhead == head || winhead == 0) && m_pat.match(**win)) { + placed_windows.push_back(*win); + (*win)->move(-(*win)->width(), -(*win)->height()); + } + } + + if (placed_windows.empty()) + return; + + // place + MinOverlapPlacement mopp; + int x, y; + for (win = placed_windows.begin(); win != placed_windows.end(); ++win) { + mopp.placeWindow(**win, head, x, y); + (*win)->move(x, y); } }
M src/WorkspaceCmd.hhsrc/WorkspaceCmd.hh

@@ -187,6 +187,14 @@ const int m_tile_method;

const ClientPattern m_pat; }; +class UnclutterCmd: public FbTk::Command<void> { +public: + explicit UnclutterCmd(std::string &pat): m_pat(pat.c_str()) { } + void execute(); +private: + const ClientPattern m_pat; +}; + class ShowDesktopCmd: public FbTk::Command<void> { public: void execute();