diff options
| author | vaxerski <vaxry@vaxry.net> | 2022-08-15 15:59:07 +0200 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2022-08-15 15:59:07 +0200 |
| commit | b0b3a5af100d6c68a30230c5b5eafd8087703a99 (patch) | |
| tree | c3529c5397aff49773271687d6af421836dbfee3 /src/managers/KeybindManager.cpp | |
| parent | d47bfe6af1d040f5c5feb607cf24ea0947a4c8e8 (diff) | |
added resizewindowpixel and movewindowpixel
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 108 |
1 files changed, 32 insertions, 76 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index ed953ef1..e08be3f1 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -37,6 +37,8 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["layoutmsg"] = layoutmsg; m_mDispatchers["toggleopaque"] = toggleOpaque; m_mDispatchers["dpms"] = dpms; + m_mDispatchers["movewindowpixel"] = moveWindow; + m_mDispatchers["resizewindowpixel"] = resizeWindow; m_tScrollTimer.reset(); } @@ -1138,107 +1140,61 @@ void CKeybindManager::forceRendererReload(std::string args) { } void CKeybindManager::resizeActive(std::string args) { - if (!args.contains(' ')) - return; - - const auto PWINDOW = g_pCompositor->m_pLastWindow; - - // calc the delta if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) - return; // ignore + return; - std::string x = args.substr(0, args.find_first_of(' ')); - std::string y = args.substr(args.find_first_of(' ') + 1); + const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealSize.goalv()); - if (x == "exact") { - std::string newX = y.substr(0, y.find_first_of(' ')); - std::string newY = y.substr(y.find_first_of(' ') + 1); + g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - g_pCompositor->m_pLastWindow->m_vRealSize.goalv()); - if (!isNumber(newX) || !isNumber(newY)) { - Debug::log(ERR, "resizeTiledWindow: exact args not numbers"); - return; - } + if (g_pCompositor->m_pLastWindow->m_vRealSize.goalv().x > 1 && g_pCompositor->m_pLastWindow->m_vRealSize.goalv().y > 1) + g_pCompositor->m_pLastWindow->m_bHidden = false; +} - const int X = std::stoi(newX); - const int Y = std::stoi(newY); +void CKeybindManager::moveActive(std::string args) { + if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) + return; - if (X < 10 || Y < 10) { - Debug::log(ERR, "resizeTiledWindow: exact args cannot be < 10"); - return; - } + const auto POS = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealPosition.goalv()); - const int DX = X - PWINDOW->m_vRealSize.goalv().x; - const int DY = Y - PWINDOW->m_vRealSize.goalv().y; + g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - g_pCompositor->m_pLastWindow->m_vRealPosition.goalv()); +} - g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(Vector2D(DX, DY)); +void CKeybindManager::moveWindow(std::string args) { - if (PWINDOW->m_vRealSize.goalv().x > 1 && PWINDOW->m_vRealSize.goalv().y > 1) - PWINDOW->m_bHidden = false; + const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1); + const auto MOVECMD = args.substr(0, args.find_first_of(',')); - return; - } + const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX); - if (!isNumber(x) || !isNumber(y)) { - Debug::log(ERR, "resizeTiledWindow: args not numbers"); + if (!PWINDOW) { + Debug::log(ERR, "moveWindow: no window"); return; } - const int X = std::stoi(x); - const int Y = std::stoi(y); + const auto POS = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealPosition.goalv()); - g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(Vector2D(X, Y)); - - if (PWINDOW->m_vRealSize.goalv().x > 1 && PWINDOW->m_vRealSize.goalv().y > 1) - PWINDOW->m_bHidden = false; + g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - PWINDOW->m_vRealPosition.goalv(), PWINDOW); } -void CKeybindManager::moveActive(std::string args) { - if (!args.contains(' ')) - return; - - std::string x = args.substr(0, args.find_first_of(' ')); - std::string y = args.substr(args.find_first_of(' ') + 1); - - if (x == "exact") { - std::string newX = y.substr(0, y.find_first_of(' ')); - std::string newY = y.substr(y.find_first_of(' ') + 1); - - if (!isNumber(newX) || !isNumber(newY)) { - Debug::log(ERR, "moveActive: exact args not numbers"); - return; - } - - const int X = std::stoi(newX); - const int Y = std::stoi(newY); +void CKeybindManager::resizeWindow(std::string args) { - if (X < 0 || Y < 0) { - Debug::log(ERR, "moveActive: exact args cannot be < 0"); - return; - } - - // calc the delta - if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) - return; // ignore - - const auto PWINDOW = g_pCompositor->m_pLastWindow; - - const int DX = X - PWINDOW->m_vRealPosition.goalv().x; - const int DY = Y - PWINDOW->m_vRealPosition.goalv().y; + const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1); + const auto MOVECMD = args.substr(0, args.find_first_of(',')); - g_pLayoutManager->getCurrentLayout()->moveActiveWindow(Vector2D(DX, DY)); + const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX); + if (!PWINDOW) { + Debug::log(ERR, "resizeWindow: no window"); return; } - if (!isNumber(x) || !isNumber(y)) { - Debug::log(ERR, "moveActive: args not numbers"); - return; - } + const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealSize.goalv()); - const int X = std::stoi(x); - const int Y = std::stoi(y); + g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - PWINDOW->m_vRealSize.goalv(), PWINDOW); - g_pLayoutManager->getCurrentLayout()->moveActiveWindow(Vector2D(X, Y)); + if (PWINDOW->m_vRealSize.goalv().x > 1 && PWINDOW->m_vRealSize.goalv().y > 1) + PWINDOW->m_bHidden = false; } void CKeybindManager::circleNext(std::string arg) { |
