diff options
author | Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com> | 2016-02-11 19:35:10 (GMT) |
---|---|---|
committer | Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com> | 2016-02-28 13:55:36 (GMT) |
commit | 53de872163d61c87fa8128767ebbc218599f3835 (patch) | |
tree | 582749e335f9acfcbc29e3aa0887eb4960a32829 /src/CurrentWindowCmd.cc | |
parent | 22866c4d30f5b289c429c5ca88d800200db4fc4f (diff) | |
download | fluxbox-53de872163d61c87fa8128767ebbc218599f3835.zip fluxbox-53de872163d61c87fa8128767ebbc218599f3835.tar.bz2 |
Mixed relative and absolute values for apps
Allow setting relative value for x and y or width and height separately in
the apps configuration file. This makes these settings compatible with ones
available in the keys file.
Previous buggy behavior:
If someone has specified, e.g. "[Dimensions] {50% 100}" it was parsed as
"{50% 100%}" not as "{50% 100px}" which was inconsistent with the "keys"
configuration file.
From now on it is possible to write something like this:
[app]
[Position] (RIGHT) {50% 0}
[Dimensions] {300 100%}
[end]
Signed-off-by: Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com>
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]); |