From afb137c7881c622547de6a4d91fc5c18cfe4d4aa Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 20 Feb 2004 19:40:31 +0000 Subject: added SendToNextWorkspace and SendToPrevWorkspace, patch from Mathias Gumz --- src/CurrentWindowCmd.cc | 15 ++++++++++++++- src/CurrentWindowCmd.hh | 20 +++++++++++++++++++- src/FbCommandFactory.cc | 8 +++++++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index 4320f73..44355aa 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/CurrentWindowCmd.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: CurrentWindowCmd.cc,v 1.8 2003/10/26 12:36:55 fluxgen Exp $ +// $Id: CurrentWindowCmd.cc,v 1.9 2004/02/20 19:40:31 fluxgen Exp $ #include "CurrentWindowCmd.hh" @@ -47,6 +47,19 @@ void SendToWorkspaceCmd::real_execute() { fbwindow().screen().sendToWorkspace(m_workspace_num, &fbwindow()); } +void SendToNextWorkspaceCmd::real_execute() { + unsigned int workspace_num= + ( fbwindow().screen().currentWorkspaceID() + m_workspace_num ) % + fbwindow().screen().getNumberOfWorkspaces(); + fbwindow().screen().sendToWorkspace(workspace_num, &fbwindow()); +} + +void SendToPrevWorkspaceCmd::real_execute() { + int workspace_num= fbwindow().screen().currentWorkspaceID() - m_workspace_num; + if ( workspace_num < 0 ) workspace_num+= fbwindow().screen().getNumberOfWorkspaces(); + fbwindow().screen().sendToWorkspace(workspace_num, &fbwindow()); +} + void WindowHelperCmd::execute() { WinClient *client = Fluxbox::instance()->getFocusedWindow(); if (client && client->fbwindow()) // guarantee that fbwindow() exists too diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh index c4c559b..2c22f07 100644 --- a/src/CurrentWindowCmd.hh +++ b/src/CurrentWindowCmd.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: CurrentWindowCmd.hh,v 1.6 2003/10/25 22:11:22 fluxgen Exp $ +// $Id: CurrentWindowCmd.hh,v 1.7 2004/02/20 19:40:31 fluxgen Exp $ #ifndef CURRENTWINDOWCMD_HH #define CURRENTWINDOWCMD_HH @@ -69,6 +69,24 @@ private: const int m_workspace_num; }; +class SendToNextWorkspaceCmd: public WindowHelperCmd { +public: + explicit SendToNextWorkspaceCmd(int workspace_num):m_workspace_num(workspace_num) { } +protected: + void real_execute(); +private: + const int m_workspace_num; +}; + +class SendToPrevWorkspaceCmd: public WindowHelperCmd { +public: + explicit SendToPrevWorkspaceCmd(int workspace_num):m_workspace_num(workspace_num) { } +protected: + void real_execute(); +private: + const int m_workspace_num; +}; + // move cmd, relative position class MoveCmd: public WindowHelperCmd { public: diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc index 9e4ec8f..a275446 100644 --- a/src/FbCommandFactory.cc +++ b/src/FbCommandFactory.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbCommandFactory.cc,v 1.26 2004/01/21 14:11:42 fluxgen Exp $ +// $Id: FbCommandFactory.cc,v 1.27 2004/02/20 19:40:31 fluxgen Exp $ #include "FbCommandFactory.hh" @@ -108,6 +108,8 @@ FbCommandFactory::FbCommandFactory() { "rootmenu", "saverc", "sendtoworkspace", + "sendtonextworkspace", + "sendtoprevworkspace", "setstyle", "setworkspacename", "setworkspacenamedialog", @@ -235,6 +237,10 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, return new CurrentWindowCmd(&FluxboxWindow::toggleDecoration); else if (command == "sendtoworkspace") return new SendToWorkspaceCmd(atoi(arguments.c_str()) - 1); // make 1-indexed to user + else if (command == "sendtonextworkspace") + return new SendToNextWorkspaceCmd(atoi(arguments.c_str())); + else if (command == "sendtoprevworkspace") + return new SendToPrevWorkspaceCmd(atoi(arguments.c_str())); else if (command == "killwindow") return new KillWindowCmd(); else if (command == "nexttab") -- cgit v0.11.2