added 'ArrangeWindowsVertical' to actions

This commit is contained in:
John K Pate 2010-09-13 22:58:59 +01:00 committed by Mathias Gumz
parent d3eabeb805
commit f1f7bebf37
3 changed files with 28 additions and 8 deletions

View file

@ -395,10 +395,12 @@ doing so.
*FocusLeft* / *FocusRight* / *FocusUp* / *FocusDown*::
Focus to the next window which is located in the direction specified.
*ArrangeWindows* 'pattern'::
Tries to arrange all windows on the current workspace so that they
overlap the least amount possible. See *CLIENT PATTERNS* for more about
the 'pattern' arguments.
*ArrangeWindows* 'pattern' / *ArrangeWindowsVertical* 'pattern' / *ArrangeWindowsHorizontal* 'pattern'::
Tries to arrange all windows on the current workspace so that they overlap the
least amount possible. *ArrangeWindowsVertical* prefers vertical splits
(windows side by side), whereas *ArrangeWindowsHorizontal* prefers horizontal
splits (windows on top of eachother). See *CLIENT PATTERNS* for more about the
'pattern' arguments.
*ShowDesktop*::
Minimizes all windows on the current workspace. If they are already all

View file

@ -177,8 +177,16 @@ FbTk::Command<void> *parseWindowList(const string &command,
else if (command == "prevgroup") {
opts |= FocusableList::LIST_GROUPS;
return new PrevWindowCmd(opts, pat);
} else if (command == "arrangewindows")
return new ArrangeWindowsCmd(pat);
} else if (command == "arrangewindows") {
int method = ArrangeWindowsCmd::UNSPECIFIED;
return new ArrangeWindowsCmd(method,pat);
} else if (command == "arrangewindowsvertical") {
int method = ArrangeWindowsCmd::VERTICAL;
return new ArrangeWindowsCmd(method,pat);
} else if (command == "arrangewindowshorizontal") {
int method = ArrangeWindowsCmd::HORIZONTAL;
return new ArrangeWindowsCmd(method,pat);
}
return 0;
}
@ -188,6 +196,8 @@ REGISTER_COMMAND_PARSER(nextgroup, parseWindowList, void);
REGISTER_COMMAND_PARSER(prevwindow, parseWindowList, void);
REGISTER_COMMAND_PARSER(prevgroup, parseWindowList, void);
REGISTER_COMMAND_PARSER(arrangewindows, parseWindowList, void);
REGISTER_COMMAND_PARSER(arrangewindowsvertical, parseWindowList, void);
REGISTER_COMMAND_PARSER(arrangewindowshorizontal, parseWindowList, void);
} // end anonymous namespace
@ -404,7 +414,8 @@ void ArrangeWindowsCmd::execute() {
// try to get the same number of rows as columns.
unsigned int cols = int(sqrt((float)win_count)); // truncate to lower
unsigned int rows = int(0.99 + float(win_count) / float(cols));
if (max_width<max_height) { // rotate
if ( (m_tile_method == VERTICAL) || // rotate if the user has asked for it or automagically
( (m_tile_method == UNSPECIFIED) && (max_width<max_height)) ) {
std::swap(cols, rows);
}

View file

@ -170,9 +170,16 @@ private:
/// arranges windows in current workspace to rows and columns
class ArrangeWindowsCmd: public FbTk::Command<void> {
public:
ArrangeWindowsCmd(std::string &pat): m_pat(pat.c_str()) { }
enum {
UNSPECIFIED,
VERTICAL,
HORIZONTAL
};
explicit ArrangeWindowsCmd(int tile_method, std::string &pat):
m_tile_method( tile_method ), m_pat(pat.c_str()) { }
void execute();
private:
const int m_tile_method;
const ClientPattern m_pat;
};