diff options
author | mathias <mathias> | 2005-06-15 15:17:48 (GMT) |
---|---|---|
committer | mathias <mathias> | 2005-06-15 15:17:48 (GMT) |
commit | d69e300376db05642730792f34e38712f52efbc2 (patch) | |
tree | 97afcfc41bc49aaa05bbd0e7feb4b826f96c074f /src | |
parent | 93b295a1587f91366d16a0d8c7514a4cd841cd38 (diff) | |
download | fluxbox_paul-d69e300376db05642730792f34e38712f52efbc2.zip fluxbox_paul-d69e300376db05642730792f34e38712f52efbc2.tar.bz2 |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/CurrentWindowCmd.cc | 26 | ||||
-rw-r--r-- | src/CurrentWindowCmd.hh | 22 | ||||
-rw-r--r-- | src/FbCommandFactory.cc | 47 |
3 files changed, 81 insertions, 14 deletions
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() { | |||
133 | fbwindow().resize(w, h); | 133 | fbwindow().resize(w, h); |
134 | } | 134 | } |
135 | 135 | ||
136 | MoveToCmd::MoveToCmd(const int step_size_x, const int step_size_y) : | 136 | MoveToCmd::MoveToCmd(const int step_size_x, const int step_size_y, const unsigned int refc) : |
137 | m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } | 137 | m_step_size_x(step_size_x), m_step_size_y(step_size_y), m_refc(refc) { } |
138 | 138 | ||
139 | void MoveToCmd::real_execute() { | 139 | void MoveToCmd::real_execute() { |
140 | fbwindow().move(m_step_size_x, m_step_size_y); | 140 | int x = 0; |
141 | int y = 0; | ||
142 | |||
143 | const int head = fbwindow().screen().getHead(fbwindow().fbWindow()); | ||
144 | |||
145 | if (m_refc & MoveToCmd::LOWER) | ||
146 | y = fbwindow().screen().maxBottom(head) - fbwindow().height() - m_step_size_y; | ||
147 | if (m_refc & MoveToCmd::UPPER) | ||
148 | y = fbwindow().screen().maxTop(head) + m_step_size_y; | ||
149 | if (m_refc & MoveToCmd::RIGHT) | ||
150 | x = fbwindow().screen().maxRight(head) - fbwindow().width() - m_step_size_x; | ||
151 | if (m_refc & MoveToCmd::LEFT) | ||
152 | x = fbwindow().screen().maxLeft(head) + m_step_size_x; | ||
153 | |||
154 | if (m_refc & MoveToCmd::IGNORE_X) | ||
155 | x = fbwindow().x(); | ||
156 | if (m_refc & MoveToCmd::IGNORE_Y) | ||
157 | y = fbwindow().y(); | ||
158 | |||
159 | fbwindow().move(x, y); | ||
141 | } | 160 | } |
142 | 161 | ||
162 | |||
143 | ResizeToCmd::ResizeToCmd(const int step_size_x, const int step_size_y) : | 163 | ResizeToCmd::ResizeToCmd(const int step_size_x, const int step_size_y) : |
144 | m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } | 164 | m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } |
145 | 165 | ||
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: | |||
161 | 161 | ||
162 | class MoveToCmd: public WindowHelperCmd { | 162 | class MoveToCmd: public WindowHelperCmd { |
163 | public: | 163 | public: |
164 | explicit MoveToCmd(const int step_size_x, const int step_size_y); | 164 | enum { |
165 | LEFT = 1 << 0, | ||
166 | RIGHT = 1 << 1, | ||
167 | UPPER = 1 << 2, | ||
168 | LOWER = 1 << 3, | ||
169 | |||
170 | IGNORE_X = 1 << 8, | ||
171 | IGNORE_Y = 1 << 9 | ||
172 | }; | ||
173 | explicit MoveToCmd(const int step_size_x, const int step_size_y, const unsigned int refc); | ||
165 | protected: | 174 | protected: |
166 | void real_execute(); | 175 | void real_execute(); |
167 | 176 | ||
168 | private: | 177 | private: |
169 | const int m_step_size_x; | 178 | const int m_step_size_x; |
170 | const int m_step_size_y; | 179 | const int m_step_size_y; |
180 | const unsigned int m_refc; | ||
171 | }; | 181 | }; |
172 | 182 | ||
173 | // resize cmd | 183 | // resize cmd |
174 | class ResizeToCmd: public WindowHelperCmd{ | 184 | class ResizeToCmd: public WindowHelperCmd{ |
175 | public: | 185 | public: |
176 | explicit ResizeToCmd(int step_size_x, int step_size_y); | 186 | explicit ResizeToCmd(int step_size_x, int step_size_y); |
177 | protected: | 187 | protected: |
178 | void real_execute(); | 188 | void real_execute(); |
179 | |||
180 | private: | 189 | private: |
181 | 190 | const int m_step_size_x; | |
182 | const int m_step_size_x; | 191 | const int m_step_size_y; |
183 | const int m_step_size_y; | ||
184 | }; | 192 | }; |
185 | 193 | ||
186 | class FullscreenCmd: public WindowHelperCmd{ | 194 | 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, | |||
239 | else if (command == "resizevertical") | 239 | else if (command == "resizevertical") |
240 | return new ResizeCmd(0,atoi(arguments.c_str())); | 240 | return new ResizeCmd(0,atoi(arguments.c_str())); |
241 | else if (command == "moveto") { | 241 | else if (command == "moveto") { |
242 | FbTk_istringstream is(arguments.c_str()); | 242 | typedef std::vector<std::string> StringTokens; |
243 | int dx = 0, dy = 0; | 243 | StringTokens tokens; |
244 | is >> dx >> dy; | 244 | FbTk::StringUtil::stringtok<StringTokens>(tokens, arguments); |
245 | return new MoveToCmd(dx,dy); | 245 | |
246 | if (tokens.size() < 2) { | ||
247 | cerr<<"*** WARNING: missing arguments for MoveTo\n"; | ||
248 | return NULL; | ||
249 | } | ||
250 | |||
251 | unsigned int refc = MoveToCmd::UPPER|MoveToCmd::LEFT; | ||
252 | int dx = 0; | ||
253 | int dy = 0; | ||
254 | |||
255 | if (tokens[0][0] == '*') | ||
256 | refc |= MoveToCmd::IGNORE_X; | ||
257 | else | ||
258 | dx = atoi(tokens[0].c_str()); | ||
259 | |||
260 | if (tokens[1][0] == '*' && ! (refc & MoveToCmd::IGNORE_X)) | ||
261 | refc |= MoveToCmd::IGNORE_Y; | ||
262 | else | ||
263 | dy = atoi(tokens[1].c_str()); | ||
264 | |||
265 | if (tokens.size() >= 3) { | ||
266 | tokens[2] = FbTk::StringUtil::toLower(tokens[2]); | ||
267 | if (tokens[2] == "left" || tokens[2] == "upperleft" || tokens[2] == "lowerleft") { | ||
268 | refc |= MoveToCmd::LEFT; | ||
269 | refc &= ~MoveToCmd::RIGHT; | ||
270 | } else if (tokens[2] == "right" || tokens[2] == "upperright" || tokens[2] == "lowerright") { | ||
271 | refc |= MoveToCmd::RIGHT; | ||
272 | refc &= ~MoveToCmd::LEFT; | ||
273 | } | ||
274 | |||
275 | if (tokens[2] == "upper" || tokens[2] == "upperleft" || tokens[2] == "upperright") { | ||
276 | refc |= MoveToCmd::UPPER; | ||
277 | refc &= ~MoveToCmd::LOWER; | ||
278 | } else if (tokens[2] == "lower" || tokens[2] == "lowerleft" || tokens[2] == "lowerright") { | ||
279 | refc |= MoveToCmd::LOWER; | ||
280 | refc &= ~MoveToCmd::UPPER; | ||
281 | } | ||
282 | } | ||
283 | |||
284 | return new MoveToCmd(dx, dy, refc); | ||
246 | } | 285 | } |
247 | else if (command == "move") { | 286 | else if (command == "move") { |
248 | FbTk_istringstream is(arguments.c_str()); | 287 | FbTk_istringstream is(arguments.c_str()); |