aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathias <mathias>2005-06-15 15:17:48 (GMT)
committermathias <mathias>2005-06-15 15:17:48 (GMT)
commitd69e300376db05642730792f34e38712f52efbc2 (patch)
tree97afcfc41bc49aaa05bbd0e7feb4b826f96c074f
parent93b295a1587f91366d16a0d8c7514a4cd841cd38 (diff)
downloadfluxbox_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
-rw-r--r--ChangeLog12
-rw-r--r--src/CurrentWindowCmd.cc26
-rw-r--r--src/CurrentWindowCmd.hh22
-rw-r--r--src/FbCommandFactory.cc47
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 @@
1(Format: Year/Month/Day) 1(Format: Year/Month/Day)
2Changes for 0.9.14: 2Changes for 0.9.14:
3*05/06/15: 3*05/06/15:
4 * Enhanced MoveTo, fixes #1074568 (Mathias)
5 MoveTo <int|*> <int|*> <Reference Corner>
6 - * means "use current value"
7 - Reference Corner is one of:
8 - UpperLeft, Upper, UpperRight
9 - Left, Right
10 - LowerLeft, Lower, Right
11 examples:
12 MoveTo 0 * Left -> snap to left workspace edge
13 MoveTo * 0 Lower -> snap to lower workspace edge
14 MoveTo 0 0 UpperRight -> snap to upper right workspace corner
15 FbCommandFactory.cc CurrentWindowCmd.cc/hh
4 * Fixes #1198192, vlc to fbgm (Mathias) 16 * Fixes #1198192, vlc to fbgm (Mathias)
5 fluxbox-generate_menu.in 17 fluxbox-generate_menu.in
6 * Fixes #1213003, SendToWorkspace shouldnt follow (Mathias) 18 * 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() {
133 fbwindow().resize(w, h); 133 fbwindow().resize(w, h);
134} 134}
135 135
136MoveToCmd::MoveToCmd(const int step_size_x, const int step_size_y) : 136MoveToCmd::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
139void MoveToCmd::real_execute() { 139void 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
143ResizeToCmd::ResizeToCmd(const int step_size_x, const int step_size_y) : 163ResizeToCmd::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
162class MoveToCmd: public WindowHelperCmd { 162class MoveToCmd: public WindowHelperCmd {
163public: 163public:
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);
165protected: 174protected:
166 void real_execute(); 175 void real_execute();
167 176
168private: 177private:
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
174class ResizeToCmd: public WindowHelperCmd{ 184class ResizeToCmd: public WindowHelperCmd{
175public: 185public:
176 explicit ResizeToCmd(int step_size_x, int step_size_y); 186 explicit ResizeToCmd(int step_size_x, int step_size_y);
177protected: 187protected:
178 void real_execute(); 188 void real_execute();
179
180private: 189private:
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
186class FullscreenCmd: public WindowHelperCmd{ 194class 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());