diff options
author | Pavel Belyavsky <[email protected]> | 2024-12-10 23:55:05 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2024-12-10 21:55:05 +0100 |
commit | 4d05677e8d398b6fa144eae7a98ad4f2a54acb92 (patch) | |
tree | 0f3e8e90dfc3dabcb40992609f17186f94258574 | |
parent | c16044a5c88ce9a42987b849068a66c11873575d (diff) | |
download | Hyprland-4d05677e8d398b6fa144eae7a98ad4f2a54acb92.tar.gz Hyprland-4d05677e8d398b6fa144eae7a98ad4f2a54acb92.zip |
config: add 'force' option for 'cursor:warp_on_change_workspace' (#8681)
* config: add 'force' option for 'cursor:warp_on_change_workspace'
* manager: throw the expression into the function arguments
* config: fix description of `cursor:warp_on_change_workspace`
-rw-r--r-- | src/config/ConfigDescriptions.hpp | 6 | ||||
-rw-r--r-- | src/desktop/Window.cpp | 6 | ||||
-rw-r--r-- | src/desktop/Window.hpp | 2 | ||||
-rw-r--r-- | src/managers/KeybindManager.cpp | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index a1d4858c..a9ac223a 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -1339,9 +1339,9 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = { }, SConfigOptionDescription{ .value = "cursor:warp_on_change_workspace", - .description = "If true, move the cursor to the last focused window after changing the workspace.", - .type = CONFIG_OPTION_BOOL, - .data = SConfigOptionDescription::SBoolData{false}, + .description = "Move the cursor to the last focused window after changing the workspace. Options: 0 (Disabled), 1 (Enabled), 2 (Force - ignores cursor:no_warps option)", + .type = CONFIG_OPTION_CHOICE, + .data = SConfigOptionDescription::SChoiceData{0, "Disabled,Enabled,Force"}, }, SConfigOptionDescription{ .value = "cursor:default_monitor", diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 7dedaea0..e4651e61 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -1529,15 +1529,15 @@ void CWindow::onX11Configure(CBox box) { g_pHyprRenderer->damageWindow(m_pSelf.lock()); } -void CWindow::warpCursor() { +void CWindow::warpCursor(bool force) { static auto PERSISTENTWARPS = CConfigValue<Hyprlang::INT>("cursor:persistent_warps"); const auto coords = m_vRelativeCursorCoordsOnLastWarp; m_vRelativeCursorCoordsOnLastWarp.x = -1; // reset m_vRelativeCursorCoordsOnLastWarp if (*PERSISTENTWARPS && coords.x > 0 && coords.y > 0 && coords < m_vSize) // don't warp cursor outside the window - g_pCompositor->warpCursorTo(m_vPosition + coords); + g_pCompositor->warpCursorTo(m_vPosition + coords, force); else - g_pCompositor->warpCursorTo(middle()); + g_pCompositor->warpCursorTo(middle(), force); } PHLWINDOW CWindow::getSwallower() { diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 35da010c..fc7ead24 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -470,7 +470,7 @@ class CWindow { void onResourceChangeX11(); std::string fetchTitle(); std::string fetchClass(); - void warpCursor(); + void warpCursor(bool force = false); PHLWINDOW getSwallower(); void unsetWindowData(eOverridePriority priority); bool isX11OverrideRedirect(); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 025a7eb6..2eb04d41 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1202,12 +1202,12 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) { const static auto PWARPONWORKSPACECHANGE = CConfigValue<Hyprlang::INT>("cursor:warp_on_change_workspace"); - if (*PWARPONWORKSPACECHANGE) { + if (*PWARPONWORKSPACECHANGE > 0) { auto PLAST = pWorkspaceToChangeTo->getLastFocusedWindow(); auto HLSurface = CWLSurface::fromResource(g_pSeatManager->state.pointerFocus.lock()); if (PLAST && (!HLSurface || HLSurface->getWindow())) - PLAST->warpCursor(); + PLAST->warpCursor(*PWARPONWORKSPACECHANGE == 2); } return {}; |