all repos — fluxbox @ d69e300376db05642730792f34e38712f52efbc2

custom fork of the fluxbox windowmanager

Enhanced MoveTo, fixes #1074568
  MoveTo <int|*> <int|*> <Reference Corner>
   - * 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
mathias mathias
commit

d69e300376db05642730792f34e38712f52efbc2

parent

93b295a1587f91366d16a0d8c7514a4cd841cd38

4 files changed, 93 insertions(+), 14 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,6 +1,18 @@

(Format: Year/Month/Day) Changes for 0.9.14: *05/06/15: + * Enhanced MoveTo, fixes #1074568 (Mathias) + MoveTo <int|*> <int|*> <Reference Corner> + - * 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)
M src/CurrentWindowCmd.ccsrc/CurrentWindowCmd.cc

@@ -133,12 +133,32 @@ fbwindow().frame().titlebarHeight() + 10);

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) { }
M src/CurrentWindowCmd.hhsrc/CurrentWindowCmd.hh

@@ -161,26 +161,34 @@ };

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{
M src/FbCommandFactory.ccsrc/FbCommandFactory.cc

@@ -239,10 +239,49 @@ return new ResizeCmd(atoi(arguments.c_str()),0);

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<std::string> StringTokens; + StringTokens tokens; + FbTk::StringUtil::stringtok<StringTokens>(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());