summaryrefslogtreecommitdiff
path: root/src/CurrentWindowCmd.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/CurrentWindowCmd.cc')
-rw-r--r--src/CurrentWindowCmd.cc59
1 files changed, 16 insertions, 43 deletions
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc
index f8c7b4b..28d7ecd 100644
--- a/src/CurrentWindowCmd.cc
+++ b/src/CurrentWindowCmd.cc
@@ -410,65 +410,38 @@ FbTk::Command<void> *MoveToCmd::parse(const string &cmd, const string &args,
410 if (tokens.size() < 2) 410 if (tokens.size() < 2)
411 return 0; 411 return 0;
412 412
413 unsigned int refc = MoveToCmd::UPPER|MoveToCmd::LEFT; 413 FluxboxWindow::ReferenceCorner refc = FluxboxWindow::LEFTTOP;
414 int dx = 0, dy = 0; 414 int x = 0, y = 0;
415 bool ignore_x = false, ignore_y = false;
415 416
416 if (tokens[0][0] == '*') 417 if (tokens[0][0] == '*')
417 refc |= MoveToCmd::IGNORE_X; 418 ignore_x = true;
418 else 419 else
419 dx = atoi(tokens[0].c_str()); 420 x = atoi(tokens[0].c_str());
420 421
421 if (tokens[1][0] == '*' && ! (refc & MoveToCmd::IGNORE_X)) 422 if (tokens[1][0] == '*' && !ignore_x)
422 refc |= MoveToCmd::IGNORE_Y; 423 ignore_y = true;
423 else 424 else
424 dy = atoi(tokens[1].c_str()); 425 y = atoi(tokens[1].c_str());
425 426
426 if (tokens.size() >= 3) { 427 if (tokens.size() >= 3) {
427 tokens[2] = FbTk::StringUtil::toLower(tokens[2]); 428 refc = FluxboxWindow::getCorner(tokens[2]);
428 if (tokens[2] == "left" || tokens[2] == "upperleft" || tokens[2] == "lowerleft") { 429 if (refc == FluxboxWindow::ERROR)
429 refc |= MoveToCmd::LEFT; 430 refc = FluxboxWindow::LEFTTOP;
430 refc &= ~MoveToCmd::RIGHT;
431 } else if (tokens[2] == "right" || tokens[2] == "upperright" || tokens[2] == "lowerright") {
432 refc |= MoveToCmd::RIGHT;
433 refc &= ~MoveToCmd::LEFT;
434 }
435
436 if (tokens[2] == "upper" || tokens[2] == "upperleft" || tokens[2] == "upperright") {
437 refc |= MoveToCmd::UPPER;
438 refc &= ~MoveToCmd::LOWER;
439 } else if (tokens[2] == "lower" || tokens[2] == "lowerleft" || tokens[2] == "lowerright") {
440 refc |= MoveToCmd::LOWER;
441 refc &= ~MoveToCmd::UPPER;
442 }
443 } 431 }
444 432
445 return new MoveToCmd(dx, dy, refc); 433 return new MoveToCmd(x, y, ignore_x, ignore_y, refc);
446
447} 434}
448 435
449REGISTER_COMMAND_PARSER(moveto, MoveToCmd::parse, void); 436REGISTER_COMMAND_PARSER(moveto, MoveToCmd::parse, void);
450 437
451MoveToCmd::MoveToCmd(const int step_size_x, const int step_size_y, const unsigned int refc) :
452 m_step_size_x(step_size_x), m_step_size_y(step_size_y), m_refc(refc) { }
453
454void MoveToCmd::real_execute() { 438void MoveToCmd::real_execute() {
455 int x = 0; 439 int x = m_pos_x, y = m_pos_y;
456 int y = 0;
457
458 const int head = fbwindow().screen().getHead(fbwindow().fbWindow());
459
460 if (m_refc & MoveToCmd::LOWER)
461 y = fbwindow().screen().maxBottom(head) - fbwindow().height() - 2 * fbwindow().frame().window().borderWidth() - m_step_size_y;
462 if (m_refc & MoveToCmd::UPPER)
463 y = fbwindow().screen().maxTop(head) + m_step_size_y;
464 if (m_refc & MoveToCmd::RIGHT)
465 x = fbwindow().screen().maxRight(head) - fbwindow().width() - 2 * fbwindow().frame().window().borderWidth() - m_step_size_x;
466 if (m_refc & MoveToCmd::LEFT)
467 x = fbwindow().screen().maxLeft(head) + m_step_size_x;
468 440
469 if (m_refc & MoveToCmd::IGNORE_X) 441 fbwindow().translateCoords(x, y, m_corner);
442 if (m_ignore_x)
470 x = fbwindow().x(); 443 x = fbwindow().x();
471 if (m_refc & MoveToCmd::IGNORE_Y) 444 if (m_ignore_y)
472 y = fbwindow().y(); 445 y = fbwindow().y();
473 446
474 fbwindow().move(x, y); 447 fbwindow().move(x, y);