diff options
-rw-r--r-- | doc/asciidoc/fluxbox-keys.txt | 5 | ||||
-rw-r--r-- | src/WorkspaceCmd.cc | 39 | ||||
-rw-r--r-- | src/WorkspaceCmd.hh | 8 |
3 files changed, 52 insertions, 0 deletions
diff --git a/doc/asciidoc/fluxbox-keys.txt b/doc/asciidoc/fluxbox-keys.txt index 7d295f2..52037ab 100644 --- a/doc/asciidoc/fluxbox-keys.txt +++ b/doc/asciidoc/fluxbox-keys.txt | |||
@@ -434,6 +434,11 @@ doing so. | |||
434 | *ArrangeWindowsStackTop* places the main window on the BOTTOM half of the | 434 | *ArrangeWindowsStackTop* places the main window on the BOTTOM half of the |
435 | screen and the tiled windows on the top half of the screen. | 435 | screen and the tiled windows on the top half of the screen. |
436 | 436 | ||
437 | *Unclutter* 'pattern':: | ||
438 | Arrange all matching windows to reduce the overall window overlap as much | ||
439 | as possible. Windows are not resized. | ||
440 | See *CLIENT PATTERNS* for more about the 'pattern' arguments. | ||
441 | |||
437 | *ShowDesktop*:: | 442 | *ShowDesktop*:: |
438 | Minimizes all windows on the current workspace. If they are already all | 443 | Minimizes all windows on the current workspace. If they are already all |
439 | minimized, then it restores them. | 444 | minimized, then it restores them. |
diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc index 6422c3f..3a1a3b4 100644 --- a/src/WorkspaceCmd.cc +++ b/src/WorkspaceCmd.cc | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "WorkspaceCmd.hh" | 23 | #include "WorkspaceCmd.hh" |
24 | 24 | ||
25 | #include "Layer.hh" | 25 | #include "Layer.hh" |
26 | #include "MinOverlapPlacement.hh" | ||
26 | #include "Workspace.hh" | 27 | #include "Workspace.hh" |
27 | #include "Window.hh" | 28 | #include "Window.hh" |
28 | #include "Screen.hh" | 29 | #include "Screen.hh" |
@@ -203,6 +204,8 @@ FbTk::Command<void> *parseWindowList(const string &command, | |||
203 | } else if (command == "arrangewindowsstackbottom") { | 204 | } else if (command == "arrangewindowsstackbottom") { |
204 | int method = ArrangeWindowsCmd::STACKBOTTOM; | 205 | int method = ArrangeWindowsCmd::STACKBOTTOM; |
205 | return new ArrangeWindowsCmd(method,pat); | 206 | return new ArrangeWindowsCmd(method,pat); |
207 | } else if (command == "unclutter") { | ||
208 | return new UnclutterCmd(pat); | ||
206 | } | 209 | } |
207 | 210 | ||
208 | return 0; | 211 | return 0; |
@@ -220,6 +223,7 @@ REGISTER_COMMAND_PARSER(arrangewindowsstackleft, parseWindowList, void); | |||
220 | REGISTER_COMMAND_PARSER(arrangewindowsstackright, parseWindowList, void); | 223 | REGISTER_COMMAND_PARSER(arrangewindowsstackright, parseWindowList, void); |
221 | REGISTER_COMMAND_PARSER(arrangewindowsstacktop, parseWindowList, void); | 224 | REGISTER_COMMAND_PARSER(arrangewindowsstacktop, parseWindowList, void); |
222 | REGISTER_COMMAND_PARSER(arrangewindowsstackbottom, parseWindowList, void); | 225 | REGISTER_COMMAND_PARSER(arrangewindowsstackbottom, parseWindowList, void); |
226 | REGISTER_COMMAND_PARSER(unclutter, parseWindowList, void); | ||
223 | 227 | ||
224 | } // end anonymous namespace | 228 | } // end anonymous namespace |
225 | 229 | ||
@@ -588,6 +592,41 @@ void ArrangeWindowsCmd::execute() { | |||
588 | } | 592 | } |
589 | } | 593 | } |
590 | 594 | ||
595 | void UnclutterCmd::execute() { | ||
596 | BScreen *screen = Fluxbox::instance()->mouseScreen(); | ||
597 | if (screen == 0) | ||
598 | return; | ||
599 | |||
600 | Workspace *space = screen->currentWorkspace(); | ||
601 | |||
602 | if (space->windowList().empty()) | ||
603 | return; | ||
604 | |||
605 | const int head = screen->getCurrHead(); | ||
606 | Workspace::Windows::iterator win; | ||
607 | Workspace::Windows placed_windows; | ||
608 | |||
609 | // list and clean up | ||
610 | for (win = space->windowList().begin(); win != space->windowList().end(); ++win) { | ||
611 | int winhead = screen->getHead((*win)->fbWindow()); | ||
612 | if ((winhead == head || winhead == 0) && m_pat.match(**win)) { | ||
613 | placed_windows.push_back(*win); | ||
614 | (*win)->move(-(*win)->width(), -(*win)->height()); | ||
615 | } | ||
616 | } | ||
617 | |||
618 | if (placed_windows.empty()) | ||
619 | return; | ||
620 | |||
621 | // place | ||
622 | MinOverlapPlacement mopp; | ||
623 | int x, y; | ||
624 | for (win = placed_windows.begin(); win != placed_windows.end(); ++win) { | ||
625 | mopp.placeWindow(**win, head, x, y); | ||
626 | (*win)->move(x, y); | ||
627 | } | ||
628 | } | ||
629 | |||
591 | REGISTER_COMMAND(showdesktop, ShowDesktopCmd, void); | 630 | REGISTER_COMMAND(showdesktop, ShowDesktopCmd, void); |
592 | 631 | ||
593 | void ShowDesktopCmd::execute() { | 632 | void ShowDesktopCmd::execute() { |
diff --git a/src/WorkspaceCmd.hh b/src/WorkspaceCmd.hh index b118d02..4f294fe 100644 --- a/src/WorkspaceCmd.hh +++ b/src/WorkspaceCmd.hh | |||
@@ -187,6 +187,14 @@ private: | |||
187 | const ClientPattern m_pat; | 187 | const ClientPattern m_pat; |
188 | }; | 188 | }; |
189 | 189 | ||
190 | class UnclutterCmd: public FbTk::Command<void> { | ||
191 | public: | ||
192 | explicit UnclutterCmd(std::string &pat): m_pat(pat.c_str()) { } | ||
193 | void execute(); | ||
194 | private: | ||
195 | const ClientPattern m_pat; | ||
196 | }; | ||
197 | |||
190 | class ShowDesktopCmd: public FbTk::Command<void> { | 198 | class ShowDesktopCmd: public FbTk::Command<void> { |
191 | public: | 199 | public: |
192 | void execute(); | 200 | void execute(); |