From d69e300376db05642730792f34e38712f52efbc2 Mon Sep 17 00:00:00 2001 From: mathias Date: Wed, 15 Jun 2005 15:17:48 +0000 Subject: Enhanced MoveTo, fixes #1074568 MoveTo - * means "use current value" - Reference Corner is one of: - UpperLeft, Upper, UpperRight - Left, Right - LowerLeft, Lower, Right examples: MoveTo 0 * Left -> snap to left workspace edge MoveTo * 0 Lower -> snap to lower workspace edge MoveTo 0 0 UpperRight -> snap to upper right workspace corner TODO: perhaps add some "aliases" to make it more userfriendly --- ChangeLog | 12 ++++++++++++ src/CurrentWindowCmd.cc | 26 +++++++++++++++++++++++--- src/CurrentWindowCmd.hh | 22 +++++++++++++++------- src/FbCommandFactory.cc | 47 +++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 93 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0fb0d6a..36a23dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,18 @@ (Format: Year/Month/Day) Changes for 0.9.14: *05/06/15: + * Enhanced MoveTo, fixes #1074568 (Mathias) + MoveTo + - * means "use current value" + - Reference Corner is one of: + - UpperLeft, Upper, UpperRight + - Left, Right + - LowerLeft, Lower, Right + examples: + MoveTo 0 * Left -> snap to left workspace edge + MoveTo * 0 Lower -> snap to lower workspace edge + MoveTo 0 0 UpperRight -> snap to upper right workspace corner + FbCommandFactory.cc CurrentWindowCmd.cc/hh * Fixes #1198192, vlc to fbgm (Mathias) fluxbox-generate_menu.in * Fixes #1213003, SendToWorkspace shouldnt follow (Mathias) diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index 834dcad..4db34c1 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/CurrentWindowCmd.cc @@ -133,13 +133,33 @@ void ResizeCmd::real_execute() { fbwindow().resize(w, h); } -MoveToCmd::MoveToCmd(const int step_size_x, const int step_size_y) : - m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } +MoveToCmd::MoveToCmd(const int step_size_x, const int step_size_y, const unsigned int refc) : + m_step_size_x(step_size_x), m_step_size_y(step_size_y), m_refc(refc) { } void MoveToCmd::real_execute() { - fbwindow().move(m_step_size_x, m_step_size_y); + int x = 0; + int y = 0; + + const int head = fbwindow().screen().getHead(fbwindow().fbWindow()); + + if (m_refc & MoveToCmd::LOWER) + y = fbwindow().screen().maxBottom(head) - fbwindow().height() - m_step_size_y; + if (m_refc & MoveToCmd::UPPER) + y = fbwindow().screen().maxTop(head) + m_step_size_y; + if (m_refc & MoveToCmd::RIGHT) + x = fbwindow().screen().maxRight(head) - fbwindow().width() - m_step_size_x; + if (m_refc & MoveToCmd::LEFT) + x = fbwindow().screen().maxLeft(head) + m_step_size_x; + + if (m_refc & MoveToCmd::IGNORE_X) + x = fbwindow().x(); + if (m_refc & MoveToCmd::IGNORE_Y) + y = fbwindow().y(); + + fbwindow().move(x, y); } + ResizeToCmd::ResizeToCmd(const int step_size_x, const int step_size_y) : m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh index 0ef7eca..34fba57 100644 --- a/src/CurrentWindowCmd.hh +++ b/src/CurrentWindowCmd.hh @@ -161,26 +161,34 @@ private: class MoveToCmd: public WindowHelperCmd { public: - explicit MoveToCmd(const int step_size_x, const int step_size_y); + enum { + LEFT = 1 << 0, + RIGHT = 1 << 1, + UPPER = 1 << 2, + LOWER = 1 << 3, + + IGNORE_X = 1 << 8, + IGNORE_Y = 1 << 9 + }; + explicit MoveToCmd(const int step_size_x, const int step_size_y, const unsigned int refc); protected: void real_execute(); private: const int m_step_size_x; const int m_step_size_y; + const unsigned int m_refc; }; // resize cmd class ResizeToCmd: public WindowHelperCmd{ public: - explicit ResizeToCmd(int step_size_x, int step_size_y); + explicit ResizeToCmd(int step_size_x, int step_size_y); protected: - void real_execute(); - + void real_execute(); private: - - const int m_step_size_x; - const int m_step_size_y; + const int m_step_size_x; + const int m_step_size_y; }; class FullscreenCmd: public WindowHelperCmd{ diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc index f3c6f51..8ac4d69 100644 --- a/src/FbCommandFactory.cc +++ b/src/FbCommandFactory.cc @@ -239,10 +239,49 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, else if (command == "resizevertical") return new ResizeCmd(0,atoi(arguments.c_str())); else if (command == "moveto") { - FbTk_istringstream is(arguments.c_str()); - int dx = 0, dy = 0; - is >> dx >> dy; - return new MoveToCmd(dx,dy); + typedef std::vector StringTokens; + StringTokens tokens; + FbTk::StringUtil::stringtok(tokens, arguments); + + if (tokens.size() < 2) { + cerr<<"*** WARNING: missing arguments for MoveTo\n"; + return NULL; + } + + unsigned int refc = MoveToCmd::UPPER|MoveToCmd::LEFT; + int dx = 0; + int dy = 0; + + if (tokens[0][0] == '*') + refc |= MoveToCmd::IGNORE_X; + else + dx = atoi(tokens[0].c_str()); + + if (tokens[1][0] == '*' && ! (refc & MoveToCmd::IGNORE_X)) + refc |= MoveToCmd::IGNORE_Y; + else + dy = atoi(tokens[1].c_str()); + + if (tokens.size() >= 3) { + tokens[2] = FbTk::StringUtil::toLower(tokens[2]); + if (tokens[2] == "left" || tokens[2] == "upperleft" || tokens[2] == "lowerleft") { + refc |= MoveToCmd::LEFT; + refc &= ~MoveToCmd::RIGHT; + } else if (tokens[2] == "right" || tokens[2] == "upperright" || tokens[2] == "lowerright") { + refc |= MoveToCmd::RIGHT; + refc &= ~MoveToCmd::LEFT; + } + + if (tokens[2] == "upper" || tokens[2] == "upperleft" || tokens[2] == "upperright") { + refc |= MoveToCmd::UPPER; + refc &= ~MoveToCmd::LOWER; + } else if (tokens[2] == "lower" || tokens[2] == "lowerleft" || tokens[2] == "lowerright") { + refc |= MoveToCmd::LOWER; + refc &= ~MoveToCmd::UPPER; + } + } + + return new MoveToCmd(dx, dy, refc); } else if (command == "move") { FbTk_istringstream is(arguments.c_str()); -- cgit v0.11.2