add SendToNextHead/SendToPrevHead commands, plus some cleanup in CurrentWindowCmd
Mark Tiefenbruck mark@fluxbox.org
5 files changed,
60 insertions(+),
76 deletions(-)
M
doc/asciidoc/fluxbox-keys.txt
→
doc/asciidoc/fluxbox-keys.txt
@@ -292,6 +292,12 @@ *SetHead* 'number'::
Moves the window to the given display head. Only available when fluxbox has been compiled with Xinerama support. +*SendToNextHead* ['offset'] / *SendToPrevHead* ['offset']:: + Sends the current window to the next/previous display head. If you + specify an 'offset' greater than *1*, it will move the window that many + heads. If this takes the window beyond the total number of heads, it + will wrap around to the beginning. + Workspace Commands ~~~~~~~~~~~~~~~~~~ These commands affect the entire workspace (or "desktop" as it is sometimes
M
doc/fluxbox-keys.5
→
doc/fluxbox-keys.5
@@ -1,11 +1,11 @@
.\" Title: fluxbox-keys .\" Author: .\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/> -.\" Date: 08/20/2008 +.\" Date: 08/21/2008 .\" Manual: .\" Source: .\" -.TH "FLUXBOX\-KEYS" "5" "08/20/2008" "" "" +.TH "FLUXBOX\-KEYS" "5" "08/21/2008" "" "" .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only)@@ -380,6 +380,14 @@ .PP
\fBSetHead\fR \fInumber\fR .RS 4 Moves the window to the given display head\. Only available when fluxbox has been compiled with Xinerama support\. +.RE +.PP +\fBSendToNextHead\fR [\fIoffset\fR] / \fBSendToPrevHead\fR [\fIoffset\fR] +.RS 4 +Sends the current window to the next/previous display head\. If you specify an +\fIoffset\fR +greater than +\fB1\fR, it will move the window that many heads\. If this takes the window beyond the total number of heads, it will wrap around to the beginning\. .RE .SS "Workspace Commands" These commands affect the entire workspace (or "desktop" as it is sometimes called)\.
M
src/CurrentWindowCmd.cc
→
src/CurrentWindowCmd.cc
@@ -157,7 +157,7 @@ namespace {
FbTk::Command<void> *parseIntCmd(const string &command, const string &args, bool trusted) { - int num = (command == "sethead" ? 0 : 1); + int num = 1; FbTk_istringstream iss(args.c_str()); iss >> num; if (command == "sethead")@@ -167,16 +167,19 @@ return new GoToTabCmd(num);
else if (command == "sendtonextworkspace") return new SendToNextWorkspaceCmd(num); else if (command == "sendtoprevworkspace") - return new SendToPrevWorkspaceCmd(num); + return new SendToNextWorkspaceCmd(-num); else if (command == "taketonextworkspace") - return new TakeToNextWorkspaceCmd(num); + return new SendToNextWorkspaceCmd(num, true); else if (command == "taketoprevworkspace") - return new TakeToPrevWorkspaceCmd(num); + return new SendToNextWorkspaceCmd(-num, true); else if (command == "sendtoworkspace") - // workspaces appear 1-indexed to the user, hence the minus 1 - return new SendToWorkspaceCmd(num-1); + return new SendToWorkspaceCmd(num); else if (command == "taketoworkspace") - return new TakeToWorkspaceCmd(num-1); + return new SendToWorkspaceCmd(num, true); + else if (command == "sendtonexthead") + return new SendToNextHeadCmd(num); + else if (command == "sendtoprevhead") + return new SendToNextHeadCmd(-num); return 0; }@@ -188,6 +191,8 @@ REGISTER_COMMAND_PARSER(taketonextworkspace, parseIntCmd, void);
REGISTER_COMMAND_PARSER(taketoprevworkspace, parseIntCmd, void); REGISTER_COMMAND_PARSER(sendtoworkspace, parseIntCmd, void); REGISTER_COMMAND_PARSER(taketoworkspace, parseIntCmd, void); +REGISTER_COMMAND_PARSER(sendtonexthead, parseIntCmd, void); +REGISTER_COMMAND_PARSER(sendtoprevhead, parseIntCmd, void); FbTk::Command<void> *parseFocusCmd(const string &command, const string &args, bool trusted) {@@ -205,49 +210,35 @@
}; // end anonymous namespace void SetHeadCmd::real_execute() { - fbwindow().setOnHead(m_head); + int num = m_head; + int total = fbwindow().screen().numHeads(); + if (num < 0) num += total + 1; + if (num < 1) num = 1; + if (num > total) num = total; + fbwindow().setOnHead(num); } void SendToWorkspaceCmd::real_execute() { - fbwindow().screen().sendToWorkspace(m_workspace_num, &fbwindow(), false); + int num = m_workspace_num; + int total = fbwindow().screen().numberOfWorkspaces(); + if (num < 0) num += total + 1; + if (num < 1) num = 1; + if (num > total) num = total; + fbwindow().screen().sendToWorkspace(num-1, &fbwindow(), m_take); } void SendToNextWorkspaceCmd::real_execute() { - const int ws_nr = - ( fbwindow().workspaceNumber() + m_delta ) % - fbwindow().screen().numberOfWorkspaces(); - fbwindow().screen().sendToWorkspace(ws_nr, &fbwindow(), false); + int total = fbwindow().screen().numberOfWorkspaces(); + const int ws_nr = (total + (fbwindow().workspaceNumber() + m_delta % total)) % total; + fbwindow().screen().sendToWorkspace(ws_nr, &fbwindow(), m_take); } -void SendToPrevWorkspaceCmd::real_execute() { - int ws_nr = (fbwindow().workspaceNumber() - m_delta ); - if ( ws_nr < 0 ) - ws_nr += fbwindow().screen().numberOfWorkspaces(); - - ws_nr = ws_nr % fbwindow().screen().numberOfWorkspaces(); - - fbwindow().screen().sendToWorkspace(ws_nr, &fbwindow(), false); -} - -void TakeToWorkspaceCmd::real_execute() { - fbwindow().screen().sendToWorkspace(m_workspace_num, &fbwindow()); -} - -void TakeToNextWorkspaceCmd::real_execute() { - unsigned int ws_nr = - ( fbwindow().workspaceNumber() + m_delta) % - fbwindow().screen().numberOfWorkspaces(); - fbwindow().screen().sendToWorkspace(ws_nr, &fbwindow()); -} - -void TakeToPrevWorkspaceCmd::real_execute() { - int ws_nr = (fbwindow().workspaceNumber() - m_delta); - if ( ws_nr < 0 ) - ws_nr += fbwindow().screen().numberOfWorkspaces(); - - ws_nr = ws_nr % fbwindow().screen().numberOfWorkspaces(); - - fbwindow().screen().sendToWorkspace(ws_nr, &fbwindow()); +void SendToNextHeadCmd::real_execute() { + int total = fbwindow().screen().numHeads(); + if (total < 2) + return; + int num = (total + fbwindow().getOnHead() - 1 + (m_delta % total)) % total; + fbwindow().setOnHead(1 + num); } void GoToTabCmd::real_execute() {
M
src/CurrentWindowCmd.hh
→
src/CurrentWindowCmd.hh
@@ -74,58 +74,34 @@ };
class SendToWorkspaceCmd: public WindowHelperCmd { public: - explicit SendToWorkspaceCmd(int workspace_num):m_workspace_num(workspace_num) { } + explicit SendToWorkspaceCmd(int workspace_num, bool take = false): + m_workspace_num(workspace_num), m_take(take) { } protected: void real_execute(); private: const int m_workspace_num; + const bool m_take; }; class SendToNextWorkspaceCmd: public WindowHelperCmd { public: - explicit SendToNextWorkspaceCmd(int delta):m_delta(delta) { } -protected: - void real_execute(); -private: - const int m_delta; -}; - -class SendToPrevWorkspaceCmd: public WindowHelperCmd { -public: - explicit SendToPrevWorkspaceCmd(int delta):m_delta(delta) { } -protected: - void real_execute(); -private: - const int m_delta; -}; - -class TakeToWorkspaceCmd : public WindowHelperCmd { -public: - explicit TakeToWorkspaceCmd(int workspace_num) : m_workspace_num(workspace_num) { } -protected: - void real_execute(); -private: - const int m_workspace_num; -}; - -class TakeToNextWorkspaceCmd : public WindowHelperCmd { -public: - explicit TakeToNextWorkspaceCmd(int delta) : m_delta(delta) { } + explicit SendToNextWorkspaceCmd(int delta, bool take = false): + m_delta(delta), m_take(take) { } protected: void real_execute(); private: const int m_delta; + const bool m_take; }; -class TakeToPrevWorkspaceCmd : public WindowHelperCmd { +class SendToNextHeadCmd: public WindowHelperCmd { public: - explicit TakeToPrevWorkspaceCmd(int delta) : m_delta(delta) { } + explicit SendToNextHeadCmd(int delta): m_delta(delta) { } protected: void real_execute(); private: const int m_delta; }; - // goto tab class GoToTabCmd: public WindowHelperCmd {