From 4a3f9ccba2cebaf62d6001c2b700367785a7179c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:17:30 +0200 Subject: move ignore to eventmanager and fix double focus in changeworkspace --- src/managers/KeybindManager.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/managers/KeybindManager.cpp') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 123e560c..96d8ce60 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -280,9 +280,7 @@ void CKeybindManager::changeworkspace(std::string args) { // start anim on new workspace PWORKSPACETOCHANGETO->startAnim(true, ANIMTOLEFT); - // Event ONLY if workspace is actually "changed" and we arent just focusing - if (!m_bSuppressWorkspaceChangeEvents) - g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACETOCHANGETO->m_szName)); + g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACETOCHANGETO->m_szName)); } // If the monitor is not the one our cursor's at, warp to it. @@ -291,9 +289,6 @@ void CKeybindManager::changeworkspace(std::string args) { wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y); } - // focus the first window - g_pCompositor->focusWindow(g_pCompositor->getFirstWindowOnWorkspace(workspaceToChangeTo)); - // set active and deactivate all other in wlr g_pCompositor->deactivateAllWLRWorkspaces(PWORKSPACETOCHANGETO->m_pWlrHandle); PWORKSPACETOCHANGETO->setActive(true); @@ -360,8 +355,7 @@ void CKeybindManager::changeworkspace(std::string args) { g_pInputManager->refocus(); // Event - if (!m_bSuppressWorkspaceChangeEvents) - g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACE->m_szName)); + g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACE->m_szName)); Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo); } @@ -491,7 +485,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) { const auto POLDWORKSPACEONMON = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDONMONITOR); const auto POLDWORKSPACEIDRETURN = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDRETURN); - m_bSuppressWorkspaceChangeEvents = true; + g_pEventManager->m_bIgnoreEvents = true; moveActiveToWorkspace(args); @@ -510,7 +504,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) { POLDWORKSPACEONMON->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); POLDWORKSPACEONMON->m_fAlpha.setValueAndWarp(255.f); - m_bSuppressWorkspaceChangeEvents = false; + g_pEventManager->m_bIgnoreEvents = false; g_pInputManager->refocus(); } -- cgit v1.2.3 From 5541098f2026daed21d87fdaa5c85d8329c8cfbc Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:47:27 +0200 Subject: Added bindl --- src/managers/KeybindManager.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/managers/KeybindManager.cpp') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 96d8ce60..17c606b9 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -72,13 +72,11 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t if (handleInternalKeybinds(key)) return true; - if (g_pCompositor->m_sSeat.exclusiveClient){ - Debug::log(LOG, "Not handling keybinds due to there being an exclusive inhibited client."); - return false; - } + if (g_pCompositor->m_sSeat.exclusiveClient) + Debug::log(LOG, "Keybind handling only locked (inhibitor)"); for (auto& k : m_lKeybinds) { - if (modmask != k.modmask) + if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked)) continue; // oMg such performance hit!!11! -- cgit v1.2.3 From 19d94b87ab639a0b22ea03809502316470de0f7a Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 22 Jun 2022 20:23:20 +0200 Subject: Added keybind submaps --- src/managers/KeybindManager.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/managers/KeybindManager.cpp') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 17c606b9..06075554 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -30,6 +30,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["resizeactive"] = resizeActive; m_mDispatchers["cyclenext"] = circleNext; m_mDispatchers["focuswindowbyclass"] = focusWindowByClass; + m_mDispatchers["submap"] = setSubmap; } void CKeybindManager::addKeybind(SKeybind kb) { @@ -76,7 +77,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t Debug::log(LOG, "Keybind handling only locked (inhibitor)"); for (auto& k : m_lKeybinds) { - if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked)) + if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap) continue; // oMg such performance hit!!11! @@ -935,3 +936,21 @@ void CKeybindManager::focusWindowByClass(std::string clazz) { break; } } + +void CKeybindManager::setSubmap(std::string submap) { + if (submap == "reset" || submap == "") { + m_szCurrentSelectedSubmap = ""; + Debug::log(LOG, "Reset active submap to the default one."); + return; + } + + for (auto& k : g_pKeybindManager->m_lKeybinds) { + if (k.submap == submap) { + m_szCurrentSelectedSubmap = submap; + Debug::log(LOG, "Changed keybind submap to %s", submap.c_str()); + return; + } + } + + Debug::log(ERR, "Cannot set submap %s, submap doesn't exist (wasn't registered!)", submap.c_str()); +} -- cgit v1.2.3 From 31dc70a41a605b09e31bb7394fc0e339a1b82418 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 23 Jun 2022 10:14:59 +0200 Subject: Added exact to resizeActive and added moveactive --- src/managers/KeybindManager.cpp | 81 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'src/managers/KeybindManager.cpp') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 06075554..85fb3919 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -28,6 +28,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["togglespecialworkspace"] = toggleSpecialWorkspace; m_mDispatchers["forcerendererreload"] = forceRendererReload; m_mDispatchers["resizeactive"] = resizeActive; + m_mDispatchers["moveactive"] = moveActive; m_mDispatchers["cyclenext"] = circleNext; m_mDispatchers["focuswindowbyclass"] = focusWindowByClass; m_mDispatchers["submap"] = setSubmap; @@ -892,6 +893,37 @@ void CKeybindManager::resizeActive(std::string args) { 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, "resizeTiledWindow: exact args not numbers"); + return; + } + + const int X = std::stoi(newX); + const int Y = std::stoi(newY); + + if (X < 10 || Y < 10) { + Debug::log(ERR, "resizeTiledWindow: exact args cannot be < 10"); + 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_vRealSize.goalv().x; + const int DY = Y - PWINDOW->m_vRealSize.goalv().y; + + g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(Vector2D(DX, DY)); + + return; + } + if (!isNumber(x) || !isNumber(y)) { Debug::log(ERR, "resizeTiledWindow: args not numbers"); return; @@ -903,6 +935,55 @@ void CKeybindManager::resizeActive(std::string args) { g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(Vector2D(X, Y)); } +void CKeybindManager::moveActive(std::string args) { + if (args.find_first_of(' ') == std::string::npos) + 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); + + if (X < 10 || Y < 10) { + Debug::log(ERR, "moveActive: exact args cannot be < 10"); + 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; + + g_pLayoutManager->getCurrentLayout()->moveActiveWindow(Vector2D(DX, DY)); + + return; + } + + if (!isNumber(x) || !isNumber(y)) { + Debug::log(ERR, "moveActive: args not numbers"); + return; + } + + const int X = std::stoi(x); + const int Y = std::stoi(y); + + g_pLayoutManager->getCurrentLayout()->moveActiveWindow(Vector2D(X, Y)); +} + void CKeybindManager::circleNext(std::string) { if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) return; -- cgit v1.2.3