From 9d6999345e202c785af0f6678986c251e02e4b32 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 2 Jul 2022 20:06:10 +0200 Subject: don't process new focus when cursor constrained --- src/managers/input/InputManager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 9d175fe9..a6358dc1 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -86,6 +86,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { } else { if ((!CONSTRAINTWINDOW->m_bIsX11 && PMONITOR && CONSTRAINTWINDOW->m_iWorkspaceID == PMONITOR->activeWorkspace) || (CONSTRAINTWINDOW->m_bIsX11)) { g_pCompositor->m_sSeat.mouse->constraintActive = true; + didConstraintOnCursor = true; } } } -- cgit v1.2.3 From 0a01ec9926664e20420beee17e7daefc5e11358a Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sun, 3 Jul 2022 15:51:32 +0300 Subject: Fix non-focused windows on WS change Fixes #298 --- src/managers/input/InputManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index a6358dc1..194592cc 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -39,7 +39,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { Vector2D mouseCoords = getMouseCoordsInternal(); const auto MOUSECOORDSFLOORED = mouseCoords.floor(); - if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored) + if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored && !refocus) return; m_vLastCursorPosFloored = MOUSECOORDSFLOORED; -- cgit v1.2.3 From 01228fbc9c785cd04b903a36f4710f04639f11a8 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 3 Jul 2022 22:54:47 +0200 Subject: fix some bugs --- src/managers/input/InputManager.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 194592cc..13833d18 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -392,6 +392,9 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { ASSERT(pKeyboard); + if (!pKeyboard->keyboard->keyboard) + return; + const auto REPEATRATE = HASCONFIG ? g_pConfigManager->getDeviceInt(pKeyboard->name, "repeat_rate") : g_pConfigManager->getInt("input:repeat_rate"); const auto REPEATDELAY = HASCONFIG ? g_pConfigManager->getDeviceInt(pKeyboard->name, "repeat_delay") : g_pConfigManager->getInt("input:repeat_delay"); -- cgit v1.2.3 From c40ef59a3570e2d80a0b15131e6964c3c5e14408 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 4 Jul 2022 16:51:42 +0200 Subject: support monitor names in moving workspaces --- src/managers/KeybindManager.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index cb091c9f..d26b0e92 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -793,15 +793,16 @@ void CKeybindManager::exitHyprland(std::string argz) { } void CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args) { - if (!isNumber(args) && !isDirection(args)) { - Debug::log(ERR, "moveCurrentWorkspaceToMonitor arg not a number or direction!"); - return; - } - - const auto PMONITOR = isDirection(args) ? g_pCompositor->getMonitorInDirection(args[0]) : g_pCompositor->getMonitorFromID(std::stoi(args)); + SMonitor* PMONITOR = nullptr; - if (!PMONITOR) { - Debug::log(ERR, "Ignoring moveCurrentWorkspaceToMonitor: monitor doesnt exist"); + try { + if (!isNumber(args) && !isDirection(args)) { + PMONITOR = g_pCompositor->getMonitorFromName(args); + } else { + PMONITOR = isDirection(args) ? g_pCompositor->getMonitorInDirection(args[0]) : g_pCompositor->getMonitorFromID(std::stoi(args)); + } + } catch (std::exception& e) { + Debug::log(LOG, "moveCurrentWorkspaceToMonitor: caught exception in monitor", e.what()); return; } @@ -821,12 +822,19 @@ void CKeybindManager::moveWorkspaceToMonitor(std::string args) { std::string workspace = args.substr(0, args.find_first_of(' ')); std::string monitor = args.substr(args.find_first_of(' ') + 1); - if (!isNumber(monitor) && !isDirection(monitor)) { - Debug::log(ERR, "moveWorkspaceToMonitor monitor arg not a number or direction!"); + SMonitor* PMONITOR = nullptr; + + try { + if (!isNumber(monitor) && !isDirection(monitor)) { + PMONITOR = g_pCompositor->getMonitorFromName(monitor); + } else { + PMONITOR = isDirection(monitor) ? g_pCompositor->getMonitorInDirection(monitor[0]) : g_pCompositor->getMonitorFromID(std::stoi(monitor)); + } + } catch (std::exception& e) { + Debug::log(LOG, "moveWorkspaceToMonitor: caught exception in monitor", e.what()); return; } - - const auto PMONITOR = isDirection(monitor) ? g_pCompositor->getMonitorInDirection(monitor[0]) : g_pCompositor->getMonitorFromID(std::stoi(monitor)); + if (!PMONITOR){ Debug::log(ERR, "Ignoring moveWorkspaceToMonitor: monitor doesnt exist"); -- cgit v1.2.3 From 9742ac7596b83025c7ab0cf4e92d9db347b4b5c3 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 4 Jul 2022 19:41:55 +0200 Subject: attempt to fix a specialworkspace crash --- src/managers/KeybindManager.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index d26b0e92..061f60a9 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -890,11 +890,16 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) { } } } else { + auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID); + + if (!PSPECIALWORKSPACE) { + // ??? happens sometimes...? + PSPECIALWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique(g_pCompositor->m_pLastMonitor->ID, "special", true)).get(); + } + g_pCompositor->m_pLastMonitor->specialWorkspaceOpen = true; g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID); - const auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID); - PSPECIALWORKSPACE->startAnim(true, true); PSPECIALWORKSPACE->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID; } -- cgit v1.2.3 From cc8b8f595fa5c20b394394fe777451d4873608b3 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 4 Jul 2022 19:58:51 +0200 Subject: disallow workspace special windowrule --- src/managers/KeybindManager.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 061f60a9..4ecf792e 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -891,12 +891,7 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) { } } else { auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID); - - if (!PSPECIALWORKSPACE) { - // ??? happens sometimes...? - PSPECIALWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique(g_pCompositor->m_pLastMonitor->ID, "special", true)).get(); - } - + g_pCompositor->m_pLastMonitor->specialWorkspaceOpen = true; g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID); -- cgit v1.2.3 From dd422abb3359530bf999137ed1fe8bf97eefc2ed Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 5 Jul 2022 16:05:06 +0200 Subject: schedule frames at the end of avar loop --- src/managers/AnimationManager.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index e48b4d1e..7574998d 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -53,15 +53,18 @@ void CAnimationManager::tick() { const auto PWINDOW = (CWindow*)av->m_pWindow; const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace; const auto PLAYER = (SLayerSurface*)av->m_pLayer; + SMonitor* PMONITOR = nullptr; wlr_box WLRBOXPREV = {0,0,0,0}; if (PWINDOW) { WLRBOXPREV = PWINDOW->getFullWindowBoundingBox(); + PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); } else if (PWORKSPACE) { - const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID); + PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID); WLRBOXPREV = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y}; } else if (PLAYER) { WLRBOXPREV = PLAYER->geometry; + PMONITOR = g_pCompositor->getMonitorFromVector(Vector2D(PLAYER->geometry.x, PLAYER->geometry.y) + Vector2D(PLAYER->geometry.width, PLAYER->geometry.height) / 2.f); } // beziers are with a switch unforto @@ -190,6 +193,9 @@ void CAnimationManager::tick() { // set size and pos if valid, but only if damage policy entire (dont if border for example) if (g_pCompositor->windowValidMapped(PWINDOW) && av->m_eDamagePolicy == AVARDAMAGE_ENTIRE) g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv()); + + // manually schedule a frame + wlr_output_schedule_frame(PMONITOR->output); } } -- cgit v1.2.3 From 239aa2cec4373f45ca55be74d5768b42abf1e749 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 6 Jul 2022 11:02:21 +0200 Subject: fix internal workspace changes being clamped --- src/managers/KeybindManager.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 4ecf792e..f5ec0e48 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -253,7 +253,14 @@ void CKeybindManager::changeworkspace(std::string args) { int workspaceToChangeTo = 0; std::string workspaceName = ""; - workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName); + if (args.find("[internal]") == 0) { + workspaceToChangeTo = std::stoi(args.substr(10)); + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToChangeTo); + if (PWORKSPACE) + workspaceName = PWORKSPACE->m_szName; + } else { + workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName); + } if (workspaceToChangeTo == INT_MAX) { Debug::log(ERR, "Error in changeworkspace, invalid value"); @@ -451,7 +458,7 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) { // undo the damage if we are moving to the special workspace if (WORKSPACEID == SPECIAL_WORKSPACE_ID) { - changeworkspace(std::to_string(OLDWORKSPACE->m_iID)); + changeworkspace("[internal]" + std::to_string(OLDWORKSPACE->m_iID)); OLDWORKSPACE->startAnim(true, true, true); toggleSpecialWorkspace(""); g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(false, false, true); @@ -503,8 +510,8 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) { PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToMoveTo); - changeworkspace(std::to_string(OLDWORKSPACEIDONMONITOR)); - changeworkspace(std::to_string(OLDWORKSPACEIDRETURN)); + changeworkspace("[internal]" + std::to_string(OLDWORKSPACEIDONMONITOR)); + changeworkspace("[internal]" + std::to_string(OLDWORKSPACEIDRETURN)); // revert animations PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0,0)); @@ -663,7 +670,7 @@ void CKeybindManager::focusMonitor(std::string arg) { } if (monID > -1 && monID < (int)g_pCompositor->m_vMonitors.size()) { - changeworkspace(std::to_string(g_pCompositor->getMonitorFromID(monID)->activeWorkspace)); + changeworkspace("[internal]" + std::to_string(g_pCompositor->getMonitorFromID(monID)->activeWorkspace)); } else { Debug::log(ERR, "Error in focusMonitor: invalid arg 1"); } @@ -683,7 +690,7 @@ void CKeybindManager::focusMonitor(std::string arg) { } else { for (auto& m : g_pCompositor->m_vMonitors) { if (m->szName == arg) { - changeworkspace(std::to_string(m->activeWorkspace)); + changeworkspace("[internal]" + std::to_string(m->activeWorkspace)); return; } } @@ -1051,7 +1058,7 @@ void CKeybindManager::focusWindow(std::string regexp) { Debug::log(LOG, "Focusing to window name: %s", w->m_szTitle.c_str()); - changeworkspace(std::to_string(w->m_iWorkspaceID)); + changeworkspace("[internal]" + std::to_string(w->m_iWorkspaceID)); g_pCompositor->focusWindow(w.get()); -- cgit v1.2.3 From 0d54451c677498ad5c37510d02abc646ea38f8aa Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 6 Jul 2022 11:12:27 +0200 Subject: fix incorrect mouse pos in fullscreen xdg --- src/managers/input/InputManager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 13833d18..387cf306 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -139,6 +139,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { if (!pFoundWindow->m_bIsX11) { foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); + surfacePos = Vector2D(-1337, -1337); } else { foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); surfacePos = pFoundWindow->m_vRealPosition.vec(); -- cgit v1.2.3 From 8d05dddb98e598da6e487b472399d691fc0b7e85 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 6 Jul 2022 14:58:46 +0200 Subject: fix focus on maximized windows with special open --- src/managers/input/InputManager.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 387cf306..b95a507c 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -155,9 +155,18 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { // then windows if (!foundSurface) { - if (PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) - pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); - else + if (PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) { + + if (PMONITOR->specialWorkspaceOpen) { + pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); + + if (pFoundWindow && pFoundWindow->m_iWorkspaceID != SPECIAL_WORKSPACE_ID) { + pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); + } + } else { + pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); + } + } else pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); if (pFoundWindow) { -- cgit v1.2.3 From 9655d0c13822bdaa5d86fd1153c27c184fd55253 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 6 Jul 2022 15:42:37 +0200 Subject: added support for wlr_idle_inhibitor_v1 --- src/managers/input/IdleInhibitor.cpp | 54 ++++++++++++++++++++++++++++++++++++ src/managers/input/InputManager.hpp | 5 ++++ 2 files changed, 59 insertions(+) create mode 100644 src/managers/input/IdleInhibitor.cpp (limited to 'src/managers') diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp new file mode 100644 index 00000000..3efb40c6 --- /dev/null +++ b/src/managers/input/IdleInhibitor.cpp @@ -0,0 +1,54 @@ +#include "InputManager.hpp" +#include "../../Compositor.hpp" + +void Events::listener_newIdleInhibitor(wl_listener* listener, void* data) { + const auto WLRIDLEINHIBITOR = (wlr_idle_inhibitor_v1*)data; + + if (!WLRIDLEINHIBITOR) + return; + + g_pInputManager->newIdleInhibitor(WLRIDLEINHIBITOR); +} + +void CInputManager::newIdleInhibitor(wlr_idle_inhibitor_v1* pInhibitor) { + const auto PINHIBIT = &m_lIdleInhibitors.emplace_back(); + + Debug::log(LOG, "New idle inhibitor registered"); + + PINHIBIT->pWlrInhibitor = pInhibitor; + + PINHIBIT->hyprListener_Destroy.initCallback(&pInhibitor->events.destroy, [](void* owner, void* data){ + + const auto PINH = (SIdleInhibitor*)owner; + + g_pInputManager->m_lIdleInhibitors.remove(*PINH); + + Debug::log(LOG, "Destroyed an idleinhibitor"); + + g_pInputManager->recheckIdleInhibitorStatus(); + + }, PINHIBIT, "IdleInhibitor"); + + PINHIBIT->pWindow = g_pCompositor->getWindowFromSurface(pInhibitor->surface); + + if (PINHIBIT->pWindow) + Debug::log(LOG, "IdleInhibitor got window %x (%s)", PINHIBIT->pWindow, PINHIBIT->pWindow->m_szTitle.c_str()); + + recheckIdleInhibitorStatus(); +} + +void CInputManager::recheckIdleInhibitorStatus() { + + for (auto& ii : m_lIdleInhibitors) { + if (!ii.pWindow) { + wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false); + return; + } else if (g_pHyprRenderer->shouldRenderWindow(ii.pWindow)) { + wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false); + return; + } + } + + wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, true); + return; +} \ No newline at end of file diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index e28e084b..3c6fb33d 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -56,9 +56,14 @@ public: std::list m_lTabletTools; std::list m_lTabletPads; + // idle inhibitors + std::list m_lIdleInhibitors; + void newTabletTool(wlr_input_device*); void newTabletPad(wlr_input_device*); void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false); + void newIdleInhibitor(wlr_idle_inhibitor_v1*); + void recheckIdleInhibitorStatus(); SKeyboard* m_pActiveKeyboard = nullptr; -- cgit v1.2.3 From f9756d10d4d1c5ea7737cf3a237b1f966d6b7a01 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 6 Jul 2022 16:50:11 +0200 Subject: changed C++ std to C++23, use std::string::contains --- src/managers/AnimationManager.cpp | 2 +- src/managers/KeybindManager.cpp | 22 +++++++++++----------- src/managers/KeybindManager.hpp | 2 +- src/managers/XWaylandManager.cpp | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 7574998d..96b667f9 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -309,7 +309,7 @@ void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) { if (pWindow->m_sAdditionalConfigData.animationStyle != "") { // the window has config'd special anim if (pWindow->m_sAdditionalConfigData.animationStyle.find("slide") == 0) { - if (pWindow->m_sAdditionalConfigData.animationStyle.find(' ') != std::string::npos) { + if (pWindow->m_sAdditionalConfigData.animationStyle.contains(' ')) { // has a direction animationSlide(pWindow, pWindow->m_sAdditionalConfigData.animationStyle.substr(pWindow->m_sAdditionalConfigData.animationStyle.find(' ') + 1), close); } else { diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index f5ec0e48..d33cd0b6 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -49,21 +49,21 @@ void CKeybindManager::removeKeybind(uint32_t mod, const std::string& key) { uint32_t CKeybindManager::stringToModMask(std::string mods) { uint32_t modMask = 0; - if (mods.find("SHIFT") != std::string::npos) + if (mods.contains("SHIFT")) modMask |= WLR_MODIFIER_SHIFT; - if (mods.find("CAPS") != std::string::npos) + if (mods.contains("CAPS")) modMask |= WLR_MODIFIER_CAPS; - if (mods.find("CTRL") != std::string::npos || mods.find("CONTROL") != std::string::npos) + if (mods.contains("CTRL") || mods.contains("CONTROL")) modMask |= WLR_MODIFIER_CTRL; - if (mods.find("ALT") != std::string::npos) + if (mods.contains("ALT")) modMask |= WLR_MODIFIER_ALT; - if (mods.find("MOD2") != std::string::npos) + if (mods.contains("MOD2")) modMask |= WLR_MODIFIER_MOD2; - if (mods.find("MOD3") != std::string::npos) + if (mods.contains("MOD3")) modMask |= WLR_MODIFIER_MOD3; - if (mods.find("SUPER") != std::string::npos || mods.find("WIN") != std::string::npos || mods.find("LOGO") != std::string::npos || mods.find("MOD4") != std::string::npos) + if (mods.contains("SUPER") || mods.contains("WIN") || mods.contains("LOGO") || mods.contains("MOD4")) modMask |= WLR_MODIFIER_LOGO; - if (mods.find("MOD5") != std::string::npos) + if (mods.contains("MOD5")) modMask |= WLR_MODIFIER_MOD5; return modMask; @@ -823,7 +823,7 @@ void CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args) { } void CKeybindManager::moveWorkspaceToMonitor(std::string args) { - if (args.find_first_of(' ') == std::string::npos) + if (!args.contains(' ')) return; std::string workspace = args.substr(0, args.find_first_of(' ')); @@ -925,7 +925,7 @@ void CKeybindManager::forceRendererReload(std::string args) { } void CKeybindManager::resizeActive(std::string args) { - if (args.find_first_of(' ') == std::string::npos) + if (!args.contains(' ')) return; std::string x = args.substr(0, args.find_first_of(' ')); @@ -974,7 +974,7 @@ void CKeybindManager::resizeActive(std::string args) { } void CKeybindManager::moveActive(std::string args) { - if (args.find_first_of(' ') == std::string::npos) + if (!args.contains(' ')) return; std::string x = args.substr(0, args.find_first_of(' ')); diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 31498677..c667a41c 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -7,7 +7,7 @@ #include struct SKeybind { - std::string key = 0; + std::string key = ""; uint32_t modmask = 0; std::string handler = ""; std::string arg = ""; diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 48687163..6bb512ee 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -153,7 +153,7 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) { if (pWindow->m_uSurface.xwayland->role) { try { std::string winrole = std::string(pWindow->m_uSurface.xwayland->role); - if (winrole.find("pop-up") != std::string::npos || winrole.find("task_dialog") != std::string::npos) { + if (winrole.contains("pop-up") || winrole.contains("task_dialog")) { return true; } } catch (std::exception& e) { -- cgit v1.2.3 From 4b796d30c190e14aa39a9540395523cee27bd348 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 7 Jul 2022 11:52:12 +0200 Subject: Added swipe workspace gestures --- src/managers/input/InputManager.hpp | 6 ++ src/managers/input/Swipe.cpp | 149 ++++++++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 src/managers/input/Swipe.cpp (limited to 'src/managers') diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 3c6fb33d..3c91718c 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -65,6 +65,12 @@ public: void newIdleInhibitor(wlr_idle_inhibitor_v1*); void recheckIdleInhibitorStatus(); + void onSwipeBegin(wlr_pointer_swipe_begin_event*); + void onSwipeEnd(wlr_pointer_swipe_end_event*); + void onSwipeUpdate(wlr_pointer_swipe_update_event*); + + SSwipeGesture m_sActiveSwipe; + SKeyboard* m_pActiveKeyboard = nullptr; CTimer m_tmrLastCursorMovement; diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp new file mode 100644 index 00000000..df88782f --- /dev/null +++ b/src/managers/input/Swipe.cpp @@ -0,0 +1,149 @@ +#include "InputManager.hpp" +#include "../../Compositor.hpp" + +void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) { + + static auto *const PSWIPE = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe")->intValue; + + if (e->fingers < 3 || *PSWIPE == 0) + return; + + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); + + Debug::log(LOG, "Starting a swipe from %s", PWORKSPACE->m_szName.c_str()); + + m_sActiveSwipe.pWorkspaceBegin = PWORKSPACE; + m_sActiveSwipe.delta = 0; + m_sActiveSwipe.pMonitor = g_pCompositor->m_pLastMonitor; + m_sActiveSwipe.avgSpeed = 0; + m_sActiveSwipe.speedPoints = 0; +} + +void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) { + + static auto *const PSWIPEPERC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_cancel_ratio")->floatValue; + static auto *const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue; + static auto *const PSWIPEFORC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_min_speed_to_force")->intValue; + + // commit + std::string wsname = ""; + auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname); + auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname); + + const auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); + const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft); + + const auto RENDEROFFSETMIDDLE = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.vec(); + + if ((abs(m_sActiveSwipe.delta) < *PSWIPEDIST * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) || abs(m_sActiveSwipe.delta) < 2) { + // revert + if (m_sActiveSwipe.delta < 0) { + // to left + PWORKSPACEL->m_vRenderOffset = Vector2D({-m_sActiveSwipe.pMonitor->vecSize.x, 0}); + } else { + // to right + PWORKSPACER->m_vRenderOffset = Vector2D({m_sActiveSwipe.pMonitor->vecSize.x, 0}); + } + + m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(); + } else if (m_sActiveSwipe.delta < 0) { + // switch to left + const auto RENDEROFFSET = PWORKSPACEL->m_vRenderOffset.vec(); + + g_pKeybindManager->m_mDispatchers["workspace"]("[internal]" + std::to_string(workspaceIDLeft)); + + PWORKSPACEL->m_vRenderOffset.setValue(RENDEROFFSET); + PWORKSPACEL->m_fAlpha.setValueAndWarp(255.f); + + Debug::log(LOG, "Ended swipe to the left"); + } else { + // switch to right + const auto RENDEROFFSET = PWORKSPACER->m_vRenderOffset.vec(); + + g_pKeybindManager->m_mDispatchers["workspace"]("[internal]" + std::to_string(workspaceIDRight)); + + PWORKSPACER->m_vRenderOffset.setValue(RENDEROFFSET); + PWORKSPACER->m_fAlpha.setValueAndWarp(255.f); + + Debug::log(LOG, "Ended swipe to the right"); + } + + m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE); + m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f); + + PWORKSPACEL->m_bForceRendering = false; + PWORKSPACER->m_bForceRendering = false; + m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = false; + + m_sActiveSwipe.pWorkspaceBegin = nullptr; + + g_pInputManager->refocus(); +} + +void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) { + if (!m_sActiveSwipe.pWorkspaceBegin) + return; + + static auto *const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue; + static auto *const PSWIPEINVR = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_invert")->intValue; + + m_sActiveSwipe.delta += *PSWIPEINVR ? -e->dx : e->dx; + + m_sActiveSwipe.avgSpeed = (m_sActiveSwipe.avgSpeed * m_sActiveSwipe.speedPoints + abs(e->dx)) / (m_sActiveSwipe.speedPoints + 1); + m_sActiveSwipe.speedPoints++; + + std::string wsname = ""; + auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname); + auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname); + + if (workspaceIDLeft == INT_MAX || workspaceIDRight == INT_MAX) + return; + + m_sActiveSwipe.delta = std::clamp(m_sActiveSwipe.delta, (double)-*PSWIPEDIST, (double)*PSWIPEDIST); + + if (m_sActiveSwipe.delta < 0) { + if (workspaceIDLeft > m_sActiveSwipe.pWorkspaceBegin->m_iID){ + m_sActiveSwipe.delta = 0; + return; + } + + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDLeft); + + PWORKSPACE->m_bForceRendering = true; + + if (workspaceIDLeft != workspaceIDRight) { + const auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); + + PWORKSPACER->m_bForceRendering = false; + } + + PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x - m_sActiveSwipe.pMonitor->vecSize.x, 0)); + m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0)); + + g_pCompositor->updateWorkspaceWindowDecos(workspaceIDLeft); + } else { + if (workspaceIDRight < m_sActiveSwipe.pWorkspaceBegin->m_iID){ + m_sActiveSwipe.delta = 0; + return; + } + + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDRight); + + PWORKSPACE->m_bForceRendering = true; + + if (workspaceIDLeft != workspaceIDRight) { + const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft); + + PWORKSPACEL->m_bForceRendering = false; + } + + PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x + m_sActiveSwipe.pMonitor->vecSize.x, 0)); + m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0)); + + g_pCompositor->updateWorkspaceWindowDecos(workspaceIDRight); + } + + g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor); + + g_pCompositor->updateWorkspaceWindowDecos(m_sActiveSwipe.pWorkspaceBegin->m_iID); +} \ No newline at end of file -- cgit v1.2.3 From 22c4ecf496b5ef6485a4cf1713a689c4c6cb10b2 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 7 Jul 2022 13:57:26 +0200 Subject: fixed swiping with one ws --- src/managers/input/Swipe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp index df88782f..692b7fda 100644 --- a/src/managers/input/Swipe.cpp +++ b/src/managers/input/Swipe.cpp @@ -96,7 +96,7 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) { auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname); auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname); - if (workspaceIDLeft == INT_MAX || workspaceIDRight == INT_MAX) + if (workspaceIDLeft == INT_MAX || workspaceIDRight == INT_MAX || workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID) return; m_sActiveSwipe.delta = std::clamp(m_sActiveSwipe.delta, (double)-*PSWIPEDIST, (double)*PSWIPEDIST); -- cgit v1.2.3 From a7b595d9684814285bd71089f500f60b351a00f2 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 7 Jul 2022 19:01:42 +0200 Subject: allow windowrule special again --- src/managers/KeybindManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index d33cd0b6..7f9bb39a 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -898,7 +898,12 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) { } } else { auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID); - + + if (!PSPECIALWORKSPACE) { + // ??? happens sometimes...? + PSPECIALWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique(g_pCompositor->m_pLastMonitor->ID, "special", true)).get(); + } + g_pCompositor->m_pLastMonitor->specialWorkspaceOpen = true; g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID); -- cgit v1.2.3 From aa3bc653423a06f53d8ad2cbfc86d70dfc2710b4 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 7 Jul 2022 19:16:16 +0200 Subject: fix special status when workspace is changed --- src/managers/KeybindManager.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 7f9bb39a..ce99030e 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -284,8 +284,6 @@ void CKeybindManager::changeworkspace(std::string args) { const auto OLDWORKSPACEID = PMONITOR->activeWorkspace; // change it - PMONITOR->specialWorkspaceOpen = false; - if (workspaceToChangeTo != SPECIAL_WORKSPACE_ID) PMONITOR->activeWorkspace = workspaceToChangeTo; else -- cgit v1.2.3 From 96f19d706ae317b89744e6709781903c7b943371 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 7 Jul 2022 20:53:22 +0200 Subject: fix possible swipe crash --- src/managers/input/Swipe.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/managers') diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp index 692b7fda..98f31945 100644 --- a/src/managers/input/Swipe.cpp +++ b/src/managers/input/Swipe.cpp @@ -21,6 +21,9 @@ void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) { void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) { + if (!m_sActiveSwipe.pWorkspaceBegin) + return; // no valid swipe + static auto *const PSWIPEPERC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_cancel_ratio")->floatValue; static auto *const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue; static auto *const PSWIPEFORC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_min_speed_to_force")->intValue; -- cgit v1.2.3 From 75c2a378e3c9368feb57a31710de26decc3da3bc Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 7 Jul 2022 21:47:59 +0200 Subject: unfocus keyboard on refocus null --- src/managers/XWaylandManager.cpp | 4 +++- src/managers/input/InputManager.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/managers') diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 6bb512ee..855cbc2c 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -36,7 +36,9 @@ void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate) wlr_xdg_toplevel_set_activated(wlr_xdg_surface_from_wlr_surface(pSurface)->toplevel, activate); else if (wlr_surface_is_xwayland_surface(pSurface)) { wlr_xwayland_surface_activate(wlr_xwayland_surface_from_wlr_surface(pSurface), activate); - wlr_xwayland_surface_restack(wlr_xwayland_surface_from_wlr_surface(pSurface), NULL, XCB_STACK_MODE_ABOVE); + + if (activate) + wlr_xwayland_surface_restack(wlr_xwayland_surface_from_wlr_surface(pSurface), NULL, XCB_STACK_MODE_ABOVE); } } diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index b95a507c..d5febe66 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -28,6 +28,8 @@ void CInputManager::onMouseWarp(wlr_pointer_motion_absolute_event* e) { void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { + static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; + if (!g_pCompositor->m_bReadyToProcess) return; @@ -194,6 +196,12 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat); + if (refocus) { // if we are forcing a refocus, and we don't find a surface, clear the kb focus too! + g_pCompositor->focusSurface(nullptr); + + g_pCompositor->m_pLastWindow = nullptr; + } + return; } @@ -211,7 +219,6 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { } if (pFoundWindow) { - static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; if (*PFOLLOWMOUSE != 1 && !refocus) { if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating)) { // enter if change floating style -- cgit v1.2.3 From cd0a01f4de6e1489caa35bece331c81dbaab2587 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 8 Jul 2022 09:27:17 +0200 Subject: Added binding by keycodes --- src/managers/KeybindManager.cpp | 29 +++++++++++++++++++---------- src/managers/KeybindManager.hpp | 3 ++- src/managers/input/InputManager.cpp | 4 +++- 3 files changed, 24 insertions(+), 12 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index ce99030e..bb66e83d 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -69,7 +69,7 @@ uint32_t CKeybindManager::stringToModMask(std::string mods) { return modMask; } -bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key) { +bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key, const int& keycode) { bool found = false; if (handleInternalKeybinds(key)) @@ -82,15 +82,24 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap) continue; - // oMg such performance hit!!11! - // this little maneouver is gonna cost us 4µs - const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE); - const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY); - // small TODO: fix 0-9 keys and other modified ones with shift - - if (key != KBKEY && key != KBKEYUPPER) - continue; + if (k.keycode != -1) { + if (keycode != k.keycode) + continue; + + } else { + if (key == 0) + continue; // this is a keycode check run + + // oMg such performance hit!!11! + // this little maneouver is gonna cost us 4µs + const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE); + const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY); + // small TODO: fix 0-9 keys and other modified ones with shift + + if (key != KBKEY && key != KBKEYUPPER) + continue; + } const auto DISPATCHER = m_mDispatchers.find(k.handler); @@ -99,7 +108,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t Debug::log(ERR, "Inavlid handler in a keybind! (handler %s does not exist)", k.handler.c_str()); } else { // call the dispatcher - Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %d)", modmask, KBKEYUPPER); + Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %d)", modmask, key); DISPATCHER->second(k.arg); } diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index c667a41c..08a1cba3 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -8,6 +8,7 @@ struct SKeybind { std::string key = ""; + int keycode = -1; uint32_t modmask = 0; std::string handler = ""; std::string arg = ""; @@ -19,7 +20,7 @@ class CKeybindManager { public: CKeybindManager(); - bool handleKeybinds(const uint32_t&, const xkb_keysym_t&); + bool handleKeybinds(const uint32_t&, const xkb_keysym_t&, const int&); void addKeybind(SKeybind); void removeKeybind(uint32_t, const std::string&); uint32_t stringToModMask(std::string); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index d5febe66..bdcddbe1 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -594,7 +594,9 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar bool found = false; if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) { for (int i = 0; i < syms; ++i) - found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i]) || found; + found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i], 0) || found; + + found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE) || found; } else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) { // hee hee } -- cgit v1.2.3 From 46306e59eb4c393ab96231139bb45b888f274e7c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 8 Jul 2022 09:32:09 +0200 Subject: added keycode support to unbind --- src/managers/KeybindManager.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index bb66e83d..9fed911b 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -41,8 +41,21 @@ void CKeybindManager::addKeybind(SKeybind kb) { void CKeybindManager::removeKeybind(uint32_t mod, const std::string& key) { for (auto it = m_lKeybinds.begin(); it != m_lKeybinds.end(); ++it) { - if (it->modmask == mod && it->key == key) { + if (isNumber(key) && std::stoi(key) > 9) { + const auto KEYNUM = std::stoi(key); + + if (it->modmask == mod && it->keycode == KEYNUM) { + it = m_lKeybinds.erase(it); + + if (it == m_lKeybinds.end()) + break; + } + } + else if (it->modmask == mod && it->key == key) { it = m_lKeybinds.erase(it); + + if (it == m_lKeybinds.end()) + break; } } } -- cgit v1.2.3 From 491b99c61ea19f2e9048f215eace07e126af890b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 8 Jul 2022 11:24:07 +0200 Subject: handle unmanaged X11 setGeometry --- src/managers/AnimationManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 96b667f9..82fb8392 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -191,7 +191,7 @@ void CAnimationManager::tick() { // set size and pos if valid, but only if damage policy entire (dont if border for example) - if (g_pCompositor->windowValidMapped(PWINDOW) && av->m_eDamagePolicy == AVARDAMAGE_ENTIRE) + if (g_pCompositor->windowValidMapped(PWINDOW) && av->m_eDamagePolicy == AVARDAMAGE_ENTIRE && PWINDOW->m_iX11Type != 2) g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv()); // manually schedule a frame -- cgit v1.2.3 From 92e17f29256af4db05ebd17b9f2d013ee3ca37ab Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 8 Jul 2022 12:27:05 +0200 Subject: added rules to hyprctl devices and fixed rules --- src/managers/input/InputManager.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index bdcddbe1..883b5b5e 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -424,7 +424,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_options") : g_pConfigManager->getString("input:kb_options"); try { - if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == std::string(pKeyboard->currentRules.rules) && MODEL == std::string(pKeyboard->currentRules.model) && LAYOUT == std::string(pKeyboard->currentRules.layout) && VARIANT == std::string(pKeyboard->currentRules.variant) && OPTIONS == std::string(pKeyboard->currentRules.options)) { + if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options) { Debug::log(LOG, "Not applying config to keyboard, it did not change."); return; } @@ -446,7 +446,11 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { .variant = VARIANT.c_str(), .options = OPTIONS.c_str()}; - pKeyboard->currentRules = rules; + pKeyboard->currentRules.rules = RULES; + pKeyboard->currentRules.model = MODEL; + pKeyboard->currentRules.variant = VARIANT; + pKeyboard->currentRules.options = OPTIONS; + pKeyboard->currentRules.layout = LAYOUT; const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS); @@ -463,7 +467,11 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { Debug::log(ERR, "Keyboard layout %s with variant %s (rules: %s, model: %s, options: %s) couldn't have been loaded.", rules.layout, rules.variant, rules.rules, rules.model, rules.options); memset(&rules, 0, sizeof(rules)); - pKeyboard->currentRules = rules; + pKeyboard->currentRules.rules = ""; + pKeyboard->currentRules.model = ""; + pKeyboard->currentRules.variant = ""; + pKeyboard->currentRules.options = ""; + pKeyboard->currentRules.layout = ""; KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); } -- cgit v1.2.3 From e6872bddf4c78ebaddbc3de2aa073afc948faf6b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 8 Jul 2022 21:52:52 +0200 Subject: fix minor issues with floating windows and fullscreen --- src/managers/KeybindManager.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 9fed911b..13bdf1e4 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -253,9 +253,6 @@ void CKeybindManager::toggleActiveFloating(std::string args) { moveActiveToWorkspace(std::to_string(g_pCompositor->getMonitorFromID(ACTIVEWINDOW->m_iMonitorID)->activeWorkspace)); } - ACTIVEWINDOW->m_vRealPosition.setValue(ACTIVEWINDOW->m_vRealPosition.vec() + Vector2D(5, 5)); - ACTIVEWINDOW->m_vSize = ACTIVEWINDOW->m_vRealPosition.vec() - Vector2D(10, 10); - g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(ACTIVEWINDOW); } } -- cgit v1.2.3 From c44cafda9723e268dcedd71eb2f9b918429bbd0f Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 9 Jul 2022 18:39:41 +0200 Subject: added cyclenext param previous --- src/managers/KeybindManager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 13bdf1e4..348f0655 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1044,11 +1044,14 @@ void CKeybindManager::moveActive(std::string args) { g_pLayoutManager->getCurrentLayout()->moveActiveWindow(Vector2D(X, Y)); } -void CKeybindManager::circleNext(std::string) { +void CKeybindManager::circleNext(std::string arg) { if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) return; - g_pCompositor->focusWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow)); + if (arg == "last" || arg == "l" || arg == "prev" || arg == "p") + g_pCompositor->focusWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow)); + else + g_pCompositor->focusWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow)); const auto MIDPOINT = g_pCompositor->m_pLastWindow->m_vRealPosition.goalv() + g_pCompositor->m_pLastWindow->m_vRealSize.goalv() / 2.f; -- cgit v1.2.3 From 6f7377f38138af5e41f094fbae90b4f68e94d49b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 9 Jul 2022 23:24:08 +0200 Subject: accumulate mods from all kbs for keybind processing --- src/managers/input/InputManager.cpp | 13 ++++++++++++- src/managers/input/InputManager.hpp | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 883b5b5e..c2c154f1 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -595,7 +595,7 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar const xkb_keysym_t* keysyms; int syms = xkb_state_key_get_syms(pKeyboard->keyboard->keyboard->xkb_state, KEYCODE, &keysyms); - const auto MODS = wlr_keyboard_get_modifiers(pKeyboard->keyboard->keyboard); + const auto MODS = accumulateModsFromAllKBs(); wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); @@ -735,4 +735,15 @@ void CInputManager::updateCapabilities(wlr_input_device* pDev) { } wlr_seat_set_capabilities(g_pCompositor->m_sSeat.seat, m_uiCapabilities); +} + +uint32_t CInputManager::accumulateModsFromAllKBs() { + + uint32_t finalMask = 0; + + for (auto& kb : m_lKeyboards) { + finalMask |= wlr_keyboard_get_modifiers(kb.keyboard->keyboard); + } + + return finalMask; } \ No newline at end of file diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 3c91718c..8cbfcfdb 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -91,6 +91,9 @@ private: STabletTool* ensureTabletToolPresent(wlr_tablet_tool*); void applyConfigToKeyboard(SKeyboard*); + + // for shared mods + uint32_t accumulateModsFromAllKBs(); }; inline std::unique_ptr g_pInputManager; \ No newline at end of file -- cgit v1.2.3 From 2936368e8070fc53dd4095a786be4d92d20c4158 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 11 Jul 2022 14:13:15 +0200 Subject: minor event fixes --- src/managers/XWaylandManager.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/managers') diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 855cbc2c..6ba2fa34 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -223,6 +223,4 @@ void CHyprXWaylandManager::setWindowFullscreen(CWindow* pWindow, bool fullscreen if (pWindow->m_phForeignToplevel) wlr_foreign_toplevel_handle_v1_set_fullscreen(pWindow->m_phForeignToplevel, fullscreen); - - g_pEventManager->postEvent(SHyprIPCEvent("fullscreen", std::to_string((int)fullscreen))); } \ No newline at end of file -- cgit v1.2.3 From ad66c158ba793c424519eaee0a64fb81860f5e3c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 11 Jul 2022 20:23:16 +0200 Subject: don't refocus on virt ptrs --- src/managers/input/InputManager.cpp | 6 +++++- src/managers/input/InputManager.hpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index c2c154f1..8f7c25b1 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -38,6 +38,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { return; } + if (g_pCompositor->m_sSeat.mouse->virt) + return; // don't refocus on virt + Vector2D mouseCoords = getMouseCoordsInternal(); const auto MOUSECOORDSFLOORED = mouseCoords.floor(); @@ -498,11 +501,12 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { Debug::log(LOG, "Set the keyboard layout to %s and variant to %s for keyboard \"%s\"", rules.layout, rules.variant, pKeyboard->keyboard->name); } -void CInputManager::newMouse(wlr_input_device* mouse) { +void CInputManager::newMouse(wlr_input_device* mouse, bool virt) { m_lMice.emplace_back(); const auto PMOUSE = &m_lMice.back(); PMOUSE->mouse = mouse; + PMOUSE->virt = virt; try { PMOUSE->name = std::string(mouse->name); } catch(std::exception& e) { diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 8cbfcfdb..1dacac8e 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -21,7 +21,7 @@ public: void onKeyboardMod(void*, SKeyboard*); void newKeyboard(wlr_input_device*); - void newMouse(wlr_input_device*); + void newMouse(wlr_input_device*, bool virt = false); void destroyKeyboard(SKeyboard*); void destroyMouse(wlr_input_device*); -- cgit v1.2.3 From b55b6c95f2943b8274974b914abd8ab6696ab36f Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 11 Jul 2022 23:09:35 +0200 Subject: update wlroots dep --- src/managers/input/InputManager.cpp | 24 ++++++++++++------------ src/managers/input/Tablets.cpp | 18 +++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 8f7c25b1..fd716d58 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -387,8 +387,8 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) { Debug::log(ERR, "Keyboard had no name???"); // logic error } - PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&keyboard->keyboard->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard"); - PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&keyboard->keyboard->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard"); + PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard"); + PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard"); PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard"); if (m_pActiveKeyboard) @@ -397,7 +397,7 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) { applyConfigToKeyboard(PNEWKEYBOARD); - wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, keyboard->keyboard); + wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(keyboard)); Debug::log(LOG, "New keyboard created, pointers Hypr: %x and WLR: %x", PNEWKEYBOARD, keyboard); } @@ -412,7 +412,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { ASSERT(pKeyboard); - if (!pKeyboard->keyboard->keyboard) + if (!wlr_keyboard_from_input_device(pKeyboard->keyboard)) return; const auto REPEATRATE = HASCONFIG ? g_pConfigManager->getDeviceInt(pKeyboard->name, "repeat_rate") : g_pConfigManager->getInt("input:repeat_rate"); @@ -436,7 +436,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { // we can ignore those and just apply } - wlr_keyboard_set_repeat_info(pKeyboard->keyboard->keyboard, std::max(0, REPEATRATE), std::max(0, REPEATDELAY)); + wlr_keyboard_set_repeat_info(wlr_keyboard_from_input_device(pKeyboard->keyboard), std::max(0, REPEATRATE), std::max(0, REPEATDELAY)); pKeyboard->repeatDelay = REPEATDELAY; pKeyboard->repeatRate = REPEATRATE; @@ -479,7 +479,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); } - wlr_keyboard_set_keymap(pKeyboard->keyboard->keyboard, KEYMAP); + wlr_keyboard_set_keymap(wlr_keyboard_from_input_device(pKeyboard->keyboard), KEYMAP); wlr_keyboard_modifiers wlrMods = {0}; @@ -492,7 +492,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { } if (wlrMods.locked != 0) { - wlr_keyboard_notify_modifiers(pKeyboard->keyboard->keyboard, 0, 0, wlrMods.locked, 0); + wlr_keyboard_notify_modifiers(wlr_keyboard_from_input_device(pKeyboard->keyboard), 0, 0, wlrMods.locked, 0); } xkb_keymap_unref(KEYMAP); @@ -597,7 +597,7 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar const auto KEYCODE = e->keycode + 8; // Because to xkbcommon it's +8 from libinput const xkb_keysym_t* keysyms; - int syms = xkb_state_key_get_syms(pKeyboard->keyboard->keyboard->xkb_state, KEYCODE, &keysyms); + int syms = xkb_state_key_get_syms(wlr_keyboard_from_input_device(pKeyboard->keyboard)->xkb_state, KEYCODE, &keysyms); const auto MODS = accumulateModsFromAllKBs(); @@ -614,14 +614,14 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar } if (!found) { - wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, pKeyboard->keyboard->keyboard); + wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard)); wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, e->time_msec, e->keycode, e->state); } } void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) { - wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, pKeyboard->keyboard->keyboard); - wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &pKeyboard->keyboard->keyboard->modifiers); + wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard)); + wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers); } void CInputManager::refocus() { @@ -746,7 +746,7 @@ uint32_t CInputManager::accumulateModsFromAllKBs() { uint32_t finalMask = 0; for (auto& kb : m_lKeyboards) { - finalMask |= wlr_keyboard_get_modifiers(kb.keyboard->keyboard); + finalMask |= wlr_keyboard_get_modifiers(wlr_keyboard_from_input_device(kb.keyboard)); } return finalMask; diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp index 6a62e58e..ba79c458 100644 --- a/src/managers/input/Tablets.cpp +++ b/src/managers/input/Tablets.cpp @@ -10,7 +10,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { Debug::log(ERR, "Tablet had no name???"); // logic error } - PNEWTABLET->wlrTablet = pDevice->tablet; + PNEWTABLET->wlrTablet = wlr_tablet_from_input_device(pDevice); PNEWTABLET->wlrDevice = pDevice; PNEWTABLET->wlrTabletV2 = wlr_tablet_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice); PNEWTABLET->wlrTablet->data = PNEWTABLET; @@ -27,7 +27,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { Debug::log(LOG, "Removed a tablet"); }, PNEWTABLET, "Tablet"); - PNEWTABLET->hyprListener_Axis.initCallback(&pDevice->tablet->events.axis, [](void* owner, void* data) { + PNEWTABLET->hyprListener_Axis.initCallback(&wlr_tablet_from_input_device(pDevice)->events.axis, [](void* owner, void* data) { const auto EVENT = (wlr_tablet_tool_axis_event*)data; const auto PTAB = (STablet*)owner; @@ -80,7 +80,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { }, PNEWTABLET, "Tablet"); - PNEWTABLET->hyprListener_Tip.initCallback(&pDevice->tablet->events.tip, [](void* owner, void* data) { + PNEWTABLET->hyprListener_Tip.initCallback(&wlr_tablet_from_input_device(pDevice)->events.tip, [](void* owner, void* data) { const auto EVENT = (wlr_tablet_tool_tip_event*)data; const auto PTAB = (STablet*)owner; @@ -98,7 +98,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { }, PNEWTABLET, "Tablet"); - PNEWTABLET->hyprListener_Button.initCallback(&pDevice->tablet->events.button, [](void* owner, void* data) { + PNEWTABLET->hyprListener_Button.initCallback(&wlr_tablet_from_input_device(pDevice)->events.button, [](void* owner, void* data) { const auto EVENT = (wlr_tablet_tool_button_event*)data; const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool); @@ -107,7 +107,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { }, PNEWTABLET, "Tablet"); - PNEWTABLET->hyprListener_Proximity.initCallback(&pDevice->tablet->events.proximity, [](void* owner, void* data) { + PNEWTABLET->hyprListener_Proximity.initCallback(&wlr_tablet_from_input_device(pDevice)->events.proximity, [](void* owner, void* data) { const auto EVENT = (wlr_tablet_tool_proximity_event*)data; const auto PTAB = (STablet*)owner; @@ -165,7 +165,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) { PNEWPAD->wlrTabletPadV2 = wlr_tablet_pad_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice); - PNEWPAD->hyprListener_Button.initCallback(&pDevice->tablet_pad->events.button, [](void* owner, void* data) { + PNEWPAD->hyprListener_Button.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.button, [](void* owner, void* data) { const auto EVENT = (wlr_tablet_pad_button_event*)data; const auto PPAD = (STabletPad*)owner; @@ -175,7 +175,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) { }, PNEWPAD, "Tablet Pad"); - PNEWPAD->hyprListener_Strip.initCallback(&pDevice->tablet_pad->events.strip, [](void* owner, void* data) { + PNEWPAD->hyprListener_Strip.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.strip, [](void* owner, void* data) { const auto EVENT = (wlr_tablet_pad_strip_event*)data; const auto PPAD = (STabletPad*)owner; @@ -184,7 +184,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) { }, PNEWPAD, "Tablet Pad"); - PNEWPAD->hyprListener_Ring.initCallback(&pDevice->tablet_pad->events.strip, [](void* owner, void* data) { + PNEWPAD->hyprListener_Ring.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.strip, [](void* owner, void* data) { const auto EVENT = (wlr_tablet_pad_ring_event*)data; const auto PPAD = (STabletPad*)owner; @@ -193,7 +193,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) { }, PNEWPAD, "Tablet Pad"); - PNEWPAD->hyprListener_Attach.initCallback(&pDevice->tablet_pad->events.strip, [](void* owner, void* data) { + PNEWPAD->hyprListener_Attach.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.strip, [](void* owner, void* data) { const auto TABLET = (wlr_tablet_tool*)data; const auto PPAD = (STabletPad*)owner; -- cgit v1.2.3 From da83ef7b96fdee7396382712f9f2115ef4664666 Mon Sep 17 00:00:00 2001 From: Mathias Zhang Date: Tue, 12 Jul 2022 19:11:54 +0800 Subject: add config drag_lock for touchpad (#353) * add config drag_lock for touchpad * fix err * Update ConfigManager.cpp --- src/managers/input/InputManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index fd716d58..2735e4e3 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -530,6 +530,11 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) { libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED); } + if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "drag_lock") : g_pConfigManager->getInt("input:touchpad:drag_lock")) == 0) + libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_DISABLED); + else + libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED); + if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop) if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "tap-to-click") : g_pConfigManager->getInt("input:touchpad:tap-to-click")) == 1) libinput_device_config_tap_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_ENABLED); @@ -750,4 +755,4 @@ uint32_t CInputManager::accumulateModsFromAllKBs() { } return finalMask; -} \ No newline at end of file +} -- cgit v1.2.3 From 6708f3b1334e8b6a966f424fe04713a4e74d5fdb Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Wed, 13 Jul 2022 18:18:23 +0200 Subject: Fixed TTY switching (#364) --- src/managers/AnimationManager.cpp | 2 +- src/managers/KeybindManager.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 82fb8392..053267e3 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -195,7 +195,7 @@ void CAnimationManager::tick() { g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv()); // manually schedule a frame - wlr_output_schedule_frame(PMONITOR->output); + g_pCompositor->scheduleFrameForMonitor(PMONITOR); } } diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 348f0655..60e4cdd6 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -140,11 +140,11 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) { if (PSESSION) { const int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1; wlr_session_change_vt(PSESSION, TTY); + g_pCompositor->m_bSessionActive = false; for (auto& m : g_pCompositor->m_vMonitors) { - g_pHyprOpenGL->destroyMonitorResources(m.get()); // mark resources as unusable anymore m->noFrameSchedule = true; - m->framesToSkip = 2; + m->framesToSkip = 1; } Debug::log(LOG, "Switched to VT %i, destroyed all render data, frames to skip for each: 2", TTY); @@ -812,8 +812,7 @@ void CKeybindManager::workspaceOpt(std::string args) { } void CKeybindManager::exitHyprland(std::string argz) { - g_pCompositor->cleanupExit(); - exit(0); + g_pCompositor->cleanup(); } void CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args) { -- cgit v1.2.3 From c2215e4efbe4e7351b8ccd12341e3c8dfe23cc39 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 13 Jul 2022 18:33:36 +0200 Subject: fix focus on fullscreen and over --- src/managers/input/InputManager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 2735e4e3..fae530b9 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -169,7 +169,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); } } else { - pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); + pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); + + if (!(pFoundWindow && pFoundWindow->m_bIsFloating && pFoundWindow->m_bCreatedOverFullscreen)) + pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); } } else pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); -- cgit v1.2.3