From b78edef5b6e39822142dd91331a53ab38b147f05 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 10 Sep 2003 14:07:48 +0000 Subject: added move command, thanks Mathias Gumz --- src/CurrentWindowCmd.cc | 27 +++++++-------------------- src/CurrentWindowCmd.hh | 44 +++++++------------------------------------- src/FbCommandFactory.cc | 27 +++++++++++++++++---------- 3 files changed, 31 insertions(+), 67 deletions(-) diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index 894eaa3..4f49362 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.5 2003/09/06 15:43:27 fluxgen Exp $ +// $Id: CurrentWindowCmd.cc,v 1.6 2003/09/10 14:07:48 fluxgen Exp $ #include "CurrentWindowCmd.hh" @@ -63,26 +63,13 @@ FluxboxWindow &WindowHelperCmd::fbwindow() { return *Fluxbox::instance()->getFocusedWindow()->fbwindow(); } -MoveLeftCmd::MoveLeftCmd(int step_size):MoveHelper(step_size) { } -void MoveLeftCmd::real_execute() { - fbwindow().move(fbwindow().x() - stepSize(), - fbwindow().y()); -} - -MoveRightCmd::MoveRightCmd(int step_size):MoveHelper(step_size) { } -void MoveRightCmd::real_execute() { - fbwindow().move(fbwindow().x() + stepSize(), - fbwindow().y()); -} - -MoveDownCmd::MoveDownCmd(int step_size):MoveHelper(step_size) { } -void MoveDownCmd::real_execute() { - fbwindow().move(fbwindow().x(), fbwindow().y() + stepSize()); -} +MoveCmd::MoveCmd(const int step_size_x, const int step_size_y) : + m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } -MoveUpCmd::MoveUpCmd(int step_size):MoveHelper(step_size) { } -void MoveUpCmd::real_execute() { - fbwindow().move(fbwindow().x(), fbwindow().y() - stepSize()); +void MoveCmd::real_execute() { + fbwindow().move( + fbwindow().x() + m_step_size_x, + fbwindow().y() + m_step_size_y ); } ResizeCmd::ResizeCmd(const int step_size_x, const int step_size_y) : diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh index 05015a0..18bcc45 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.4 2003/09/06 15:43:27 fluxgen Exp $ +// $Id: CurrentWindowCmd.hh,v 1.5 2003/09/10 14:07:48 fluxgen Exp $ #ifndef CURRENTWINDOWCMD_HH #define CURRENTWINDOWCMD_HH @@ -69,48 +69,18 @@ private: const int m_workspace_num; }; -class MoveHelper: public WindowHelperCmd { +class MoveCmd: public WindowHelperCmd { public: - explicit MoveHelper(int step_size):m_step_size(step_size) { } -protected: - int stepSize() const { return m_step_size; } - -private: - const int m_step_size; -}; -/// move window to left -class MoveLeftCmd: public MoveHelper { -public: - explicit MoveLeftCmd(int step_size); -protected: - void real_execute(); -}; - -/// move window to right -class MoveRightCmd: public MoveHelper { -public: - explicit MoveRightCmd(int step_size); + explicit MoveCmd(const int step_size_x, const int step_size_y); protected: void real_execute(); -}; - -/// move window up -class MoveUpCmd: public MoveHelper { -public: - explicit MoveUpCmd(int step_size); -protected: - void real_execute(); -}; -/// move window down -class MoveDownCmd: public MoveHelper { -public: - explicit MoveDownCmd(int step_size); -protected: - void real_execute(); +private: + const int m_step_size_x; + const int m_step_size_y; }; -// resize horizontal +// resize cmd class ResizeCmd: public WindowHelperCmd{ public: explicit ResizeCmd(int step_size_x, int step_size_y); diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc index f9e22ce..d7bea89 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.15 2003/09/06 15:43:27 fluxgen Exp $ +// $Id: FbCommandFactory.cc,v 1.16 2003/09/10 14:06:37 fluxgen Exp $ #include "FbCommandFactory.hh" @@ -40,7 +40,7 @@ FbCommandFactory FbCommandFactory::s_autoreg; FbCommandFactory::FbCommandFactory() { // setup commands that we can handle - const char commands[][33] = { + const char commands[][52] = { "arrangewindows", "close", "detachclient", @@ -57,6 +57,7 @@ FbCommandFactory::FbCommandFactory() { "maximizewindow", "minimize", "minimizewindow", + "move", "movedown", "moveleft", "moveright", @@ -133,23 +134,29 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, else if (command == "maximizehorizontal") return new CurrentWindowCmd(&FluxboxWindow::maximizeHorizontal); else if (command == "resize") { - std::istringstream is(arguments); - int dx = 0, dy = 0; - is >> dx >> dy; - return new ResizeCmd(dx, dy); + std::istringstream is(arguments); + int dx = 0, dy = 0; + is >> dx >> dy; + return new ResizeCmd(dx, dy); } else if (command == "resizehorizontal") return new ResizeCmd(atoi(arguments.c_str()),0); else if (command == "resizevertical") return new ResizeCmd(0,atoi(arguments.c_str())); + else if (command == "move") { + std::istringstream is(arguments); + int dx = 0, dy = 0; + is >> dx >> dy; + return new MoveCmd(dx, dy); + } else if (command == "moveright") - return new MoveRightCmd(atoi(arguments.c_str())); + return new MoveCmd(atoi(arguments.c_str()),0); else if (command == "moveleft") - return new MoveLeftCmd(atoi(arguments.c_str())); + return new MoveCmd(-atoi(arguments.c_str()),0); else if (command == "moveup") - return new MoveUpCmd(atoi(arguments.c_str())); + return new MoveCmd(0,-atoi(arguments.c_str())); else if (command == "movedown") - return new MoveDownCmd(atoi(arguments.c_str())); + return new MoveCmd(0,atoi(arguments.c_str())); else if (command == "raise") return new CurrentWindowCmd(&FluxboxWindow::raise); else if (command == "lower") -- cgit v0.11.2