aboutsummaryrefslogtreecommitdiff
path: root/src/CurrentWindowCmd.cc
diff options
context:
space:
mode:
authorMichael Abbott <michael@araneidae.co.uk>2012-09-29 07:10:48 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2012-10-04 07:36:23 (GMT)
commit391712b9805eda9d56a100f49d69b38863910565 (patch)
tree05d5a6eea9fef53a371676f76ec4c1e1ef0893a1 /src/CurrentWindowCmd.cc
parent7b6ab828c7e5453a2720462156d165707935c9ef (diff)
downloadfluxbox-391712b9805eda9d56a100f49d69b38863910565.zip
fluxbox-391712b9805eda9d56a100f49d69b38863910565.tar.bz2
Add support for nearest corner or edge resizing
Diffstat (limited to 'src/CurrentWindowCmd.cc')
-rw-r--r--src/CurrentWindowCmd.cc41
1 files changed, 34 insertions, 7 deletions
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc
index 4363d0d..6138e64 100644
--- a/src/CurrentWindowCmd.cc
+++ b/src/CurrentWindowCmd.cc
@@ -20,6 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23#include <string.h>
23#include "CurrentWindowCmd.hh" 24#include "CurrentWindowCmd.hh"
24 25
25#include "fluxbox.hh" 26#include "fluxbox.hh"
@@ -369,15 +370,13 @@ void StartMovingCmd::real_execute() {
369FbTk::Command<void> *StartResizingCmd::parse(const string &cmd, const string &args, 370FbTk::Command<void> *StartResizingCmd::parse(const string &cmd, const string &args,
370 bool trusted) { 371 bool trusted) {
371 FluxboxWindow::ResizeModel mode = FluxboxWindow::DEFAULTRESIZE; 372 FluxboxWindow::ResizeModel mode = FluxboxWindow::DEFAULTRESIZE;
373 int corner_size_px = 0;
374 int corner_size_pc = 0;
372 std::vector<string> tokens; 375 std::vector<string> tokens;
373 FbTk::StringUtil::stringtok<std::vector<string> >(tokens, args); 376 FbTk::StringUtil::stringtok<std::vector<string> >(tokens, args);
374 if (!tokens.empty()) { 377 if (!tokens.empty()) {
375 string arg = FbTk::StringUtil::toLower(tokens[0]); 378 string arg = FbTk::StringUtil::toLower(tokens[0]);
376 if (arg == "nearestcorner") 379 if (arg == "center")
377 mode = FluxboxWindow::QUADRANTRESIZE;
378 else if (arg == "nearestedge")
379 mode = FluxboxWindow::NEARESTEDGERESIZE;
380 else if (arg == "center")
381 mode = FluxboxWindow::CENTERRESIZE; 380 mode = FluxboxWindow::CENTERRESIZE;
382 else if (arg == "topleft") 381 else if (arg == "topleft")
383 mode = FluxboxWindow::TOPLEFTRESIZE; 382 mode = FluxboxWindow::TOPLEFTRESIZE;
@@ -395,8 +394,35 @@ FbTk::Command<void> *StartResizingCmd::parse(const string &cmd, const string &ar
395 mode = FluxboxWindow::BOTTOMRESIZE; 394 mode = FluxboxWindow::BOTTOMRESIZE;
396 else if (arg == "bottomright") 395 else if (arg == "bottomright")
397 mode = FluxboxWindow::BOTTOMRIGHTRESIZE; 396 mode = FluxboxWindow::BOTTOMRIGHTRESIZE;
397 else if (arg == "nearestcorner") {
398 mode = FluxboxWindow::EDGEORCORNERRESIZE;
399 corner_size_pc = 100;
400 } else if (arg == "nearestedge") {
401 mode = FluxboxWindow::EDGEORCORNERRESIZE;
402 } else if (arg == "nearestcorneroredge") {
403 mode = FluxboxWindow::EDGEORCORNERRESIZE;
404 /* The NearestCornerOrEdge can be followed by a corner size in
405 * one of three forms:
406 * <size in pixels>
407 * <size in pixels> <size in percent>
408 * <size in percent>%
409 * If no corner size is given then it defaults to 50 pixels, 30%. */
410 if (tokens.size() > 1) {
411 const char * size1 = tokens[1].c_str();
412 if (size1[strlen(size1)-1] == '%')
413 corner_size_pc = atoi(size1);
414 else {
415 corner_size_px = atoi(size1);
416 if (tokens.size() > 2)
417 corner_size_pc = atoi(tokens[2].c_str());
418 }
419 } else {
420 corner_size_px = 50;
421 corner_size_pc = 30;
422 }
423 }
398 } 424 }
399 return new StartResizingCmd(mode); 425 return new StartResizingCmd(mode, corner_size_px, corner_size_pc);
400} 426}
401 427
402REGISTER_COMMAND_PARSER(startresizing, StartResizingCmd::parse, void); 428REGISTER_COMMAND_PARSER(startresizing, StartResizingCmd::parse, void);
@@ -422,7 +448,8 @@ void StartResizingCmd::real_execute() {
422 x -= fbwindow().x() - fbwindow().frame().window().borderWidth(); 448 x -= fbwindow().x() - fbwindow().frame().window().borderWidth();
423 y -= fbwindow().y() - fbwindow().frame().window().borderWidth(); 449 y -= fbwindow().y() - fbwindow().frame().window().borderWidth();
424 450
425 fbwindow().startResizing(x, y, fbwindow().getResizeDirection(x, y, m_mode)); 451 fbwindow().startResizing(x, y, fbwindow().getResizeDirection(
452 x, y, m_mode, m_corner_size_px, m_corner_size_pc));
426} 453}
427 454
428REGISTER_COMMAND(starttabbing, StartTabbingCmd, void); 455REGISTER_COMMAND(starttabbing, StartTabbingCmd, void);