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*:: *FocusLeft* / *FocusRight* / *FocusUp* / *FocusDown*::
Focus to the next window which is located in the direction specified. Focus to the next window which is located in the direction specified.
*ArrangeWindows* 'pattern':: *ArrangeWindows* 'pattern' / *ArrangeWindowsVertical* 'pattern' / *ArrangeWindowsHorizontal* 'pattern'::
Tries to arrange all windows on the current workspace so that they Tries to arrange all windows on the current workspace so that they overlap the
overlap the least amount possible. See *CLIENT PATTERNS* for more about least amount possible. *ArrangeWindowsVertical* prefers vertical splits
the 'pattern' arguments. (windows side by side), whereas *ArrangeWindowsHorizontal* prefers horizontal
splits (windows on top of eachother). See *CLIENT PATTERNS* for more about the
'pattern' arguments.
*ShowDesktop*:: *ShowDesktop*::
Minimizes all windows on the current workspace. If they are already all 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") { else if (command == "prevgroup") {
opts |= FocusableList::LIST_GROUPS; opts |= FocusableList::LIST_GROUPS;
return new PrevWindowCmd(opts, pat); return new PrevWindowCmd(opts, pat);
} else if (command == "arrangewindows") } else if (command == "arrangewindows") {
return new ArrangeWindowsCmd(pat); 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; return 0;
} }
@ -188,6 +196,8 @@ REGISTER_COMMAND_PARSER(nextgroup, parseWindowList, void);
REGISTER_COMMAND_PARSER(prevwindow, parseWindowList, void); REGISTER_COMMAND_PARSER(prevwindow, parseWindowList, void);
REGISTER_COMMAND_PARSER(prevgroup, parseWindowList, void); REGISTER_COMMAND_PARSER(prevgroup, parseWindowList, void);
REGISTER_COMMAND_PARSER(arrangewindows, parseWindowList, void); REGISTER_COMMAND_PARSER(arrangewindows, parseWindowList, void);
REGISTER_COMMAND_PARSER(arrangewindowsvertical, parseWindowList, void);
REGISTER_COMMAND_PARSER(arrangewindowshorizontal, parseWindowList, void);
} // end anonymous namespace } // end anonymous namespace
@ -404,7 +414,8 @@ void ArrangeWindowsCmd::execute() {
// try to get the same number of rows as columns. // try to get the same number of rows as columns.
unsigned int cols = int(sqrt((float)win_count)); // truncate to lower unsigned int cols = int(sqrt((float)win_count)); // truncate to lower
unsigned int rows = int(0.99 + float(win_count) / float(cols)); 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); std::swap(cols, rows);
} }

View file

@ -170,9 +170,16 @@ private:
/// arranges windows in current workspace to rows and columns /// arranges windows in current workspace to rows and columns
class ArrangeWindowsCmd: public FbTk::Command<void> { class ArrangeWindowsCmd: public FbTk::Command<void> {
public: 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(); void execute();
private: private:
const int m_tile_method;
const ClientPattern m_pat; const ClientPattern m_pat;
}; };