diff options
Diffstat (limited to 'src/CurrentWindowCmd.cc')
-rw-r--r-- | src/CurrentWindowCmd.cc | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index dd43d43..44556f5 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/CurrentWindowCmd.cc | |||
@@ -500,27 +500,6 @@ void MoveCmd::real_execute() { | |||
500 | fbwindow().move(fbwindow().x() + m_step_size_x, fbwindow().y() + m_step_size_y); | 500 | fbwindow().move(fbwindow().x() + m_step_size_x, fbwindow().y() + m_step_size_y); |
501 | } | 501 | } |
502 | 502 | ||
503 | namespace { | ||
504 | template <typename Container> | ||
505 | static void parseToken(Container &container, int &d, bool &is_relative, bool &ignore) { | ||
506 | if (container.size() < 1) | ||
507 | return; | ||
508 | |||
509 | d = 0; | ||
510 | is_relative = false; | ||
511 | ignore = false; | ||
512 | if (container[0] == '*') { | ||
513 | ignore = true; | ||
514 | } else if (container[container.size() - 1] == '%') { | ||
515 | // its a percent | ||
516 | is_relative = true; | ||
517 | d = atoi(container.substr(0, container.size() - 1).c_str()); | ||
518 | } else { | ||
519 | d = atoi(container.c_str()); | ||
520 | } | ||
521 | } | ||
522 | } | ||
523 | |||
524 | FbTk::Command<void> *ResizeCmd::parse(const string &command, const string &args, | 503 | FbTk::Command<void> *ResizeCmd::parse(const string &command, const string &args, |
525 | bool trusted) { | 504 | bool trusted) { |
526 | 505 | ||
@@ -536,15 +515,15 @@ FbTk::Command<void> *ResizeCmd::parse(const string &command, const string &args, | |||
536 | bool is_relative_x = false, is_relative_y = false, ignore_x = false, ignore_y = false; | 515 | bool is_relative_x = false, is_relative_y = false, ignore_x = false, ignore_y = false; |
537 | 516 | ||
538 | if (command == "resizehorizontal") { | 517 | if (command == "resizehorizontal") { |
539 | parseToken(tokens[0], dx, is_relative_x, ignore_x); | 518 | dx = FbTk::StringUtil::parseSizeToken(tokens[0], is_relative_x, ignore_x); |
540 | } else if (command == "resizevertical") { | 519 | } else if (command == "resizevertical") { |
541 | parseToken(tokens[0], dy, is_relative_y, ignore_y); | 520 | dy = FbTk::StringUtil::parseSizeToken(tokens[0], is_relative_y, ignore_y); |
542 | } else { | 521 | } else { |
543 | if (tokens.size() < 2) { | 522 | if (tokens.size() < 2) { |
544 | return 0; | 523 | return 0; |
545 | } | 524 | } |
546 | parseToken(tokens[0], dx, is_relative_x, ignore_x); | 525 | dx = FbTk::StringUtil::parseSizeToken(tokens[0], is_relative_x, ignore_x); |
547 | parseToken(tokens[1], dy, is_relative_y, ignore_y); | 526 | dy = FbTk::StringUtil::parseSizeToken(tokens[1], is_relative_y, ignore_y); |
548 | } | 527 | } |
549 | 528 | ||
550 | if (command == "resizeto") { | 529 | if (command == "resizeto") { |
@@ -610,8 +589,8 @@ FbTk::Command<void> *MoveToCmd::parse(const string &cmd, const string &args, | |||
610 | int x = 0, y = 0; | 589 | int x = 0, y = 0; |
611 | bool ignore_x = false, ignore_y = false, is_relative_x = false, is_relative_y = false; | 590 | bool ignore_x = false, ignore_y = false, is_relative_x = false, is_relative_y = false; |
612 | 591 | ||
613 | parseToken(tokens[0], x, is_relative_x, ignore_x); | 592 | x = FbTk::StringUtil::parseSizeToken(tokens[0], is_relative_x, ignore_x); |
614 | parseToken(tokens[1], y, is_relative_y, ignore_y); | 593 | y = FbTk::StringUtil::parseSizeToken(tokens[1], is_relative_y, ignore_y); |
615 | 594 | ||
616 | if (tokens.size() >= 3) { | 595 | if (tokens.size() >= 3) { |
617 | refc = FluxboxWindow::getCorner(tokens[2]); | 596 | refc = FluxboxWindow::getCorner(tokens[2]); |