aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/managers
diff options
context:
space:
mode:
authorPhilip Damianik <[email protected]>2023-10-10 18:34:28 +0200
committerGitHub <[email protected]>2023-10-10 17:34:28 +0100
commitac1bd47653f7d07a77fb3e0e32c0863bb0dced2e (patch)
treeb0ab120bd8807c5a5490a6ecd10d83fac5ed879e /src/managers
parent8abb6e1cee3e967ff414af0d6a1a31ebced95f5b (diff)
downloadHyprland-ac1bd47653f7d07a77fb3e0e32c0863bb0dced2e.tar.gz
Hyprland-ac1bd47653f7d07a77fb3e0e32c0863bb0dced2e.zip
dispatchers: Add option to center the cursor on the focused window when switching workspaces (#3528)
* Add option for centering on workspace when switching workspace * Add option for centering on workspace when switching workspace --------- Co-authored-by: vaxerski <[email protected]>
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/KeybindManager.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index c86804d6..eb100870 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -804,6 +804,7 @@ void CKeybindManager::changeworkspace(std::string args) {
// the current workspace will instead switch to the previous.
static auto* const PBACKANDFORTH = &g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth")->intValue;
static auto* const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue;
+ static auto* const PWORKSPACECENTERON = &g_pConfigManager->getConfigValuePtr("binds:workspace_center_on")->intValue;
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
@@ -863,9 +864,13 @@ void CKeybindManager::changeworkspace(std::string args) {
PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true);
if (PMONITOR != PMONITORWORKSPACEOWNER) {
- g_pCompositor->warpCursorTo(PMONITORWORKSPACEOWNER->middle());
- if (const auto PLAST = pWorkspaceToChangeTo->getLastFocusedWindow(); PLAST)
+ Vector2D middle = PMONITORWORKSPACEOWNER->middle();
+ if (const auto PLAST = pWorkspaceToChangeTo->getLastFocusedWindow(); PLAST) {
g_pCompositor->focusWindow(PLAST);
+ if (*PWORKSPACECENTERON == 1)
+ middle = PLAST->middle();
+ }
+ g_pCompositor->warpCursorTo(middle);
}
if (BISWORKSPACECURRENT) {
@@ -1083,7 +1088,7 @@ void CKeybindManager::swapActive(std::string args) {
return;
g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, PWINDOWTOCHANGETO);
- g_pCompositor->warpCursorTo(PLASTWINDOW->m_vRealPosition.vec() + PLASTWINDOW->m_vRealSize.vec() / 2.0);
+ g_pCompositor->warpCursorTo(PLASTWINDOW->middle());
}
void CKeybindManager::moveActiveTo(std::string args) {