diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 9aff1bb53..cb94116db 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2117,6 +2117,8 @@ PHLMONITOR CCompositor::getMonitorFromString(const std::string& name) { } void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, PHLMONITOR pMonitor, bool noWarpCursor) { + static auto PHIDESPECIALONWORKSPACECHANGE = CConfigValue("binds:hide_special_on_workspace_change"); + if (!pWorkspace || !pMonitor) return; @@ -2199,6 +2201,9 @@ void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, PHLMONITOR pMo pMonitor->activeWorkspace->startAnim(false, false); } + if (*PHIDESPECIALONWORKSPACECHANGE) + pMonitor->setSpecialWorkspace(nullptr); + setActiveMonitor(pMonitor); pMonitor->activeWorkspace = pWorkspace; g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitor->ID); diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index 402780e00..3e9563eed 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -1246,6 +1246,12 @@ inline static const std::vector CONFIG_OPTIONS = { .type = CONFIG_OPTION_BOOL, .data = SConfigOptionDescription::SBoolData{false}, }, + SConfigOptionDescription{ + .value = "binds:hide_special_on_workspace_change", + .description = "If enabled, changing the active workspace (including to itself) will hide the special workspace on the monitor where the newly active workspace resides.", + .type = CONFIG_OPTION_BOOL, + .data = SConfigOptionDescription::SBoolData{false}, + }, SConfigOptionDescription{ .value = "binds:allow_workspace_cycles", .description = "If enabled, workspaces don’t forget their previous workspace, so cycles can be created by switching to the first workspace in a sequence, then endlessly " diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index ebbdb7c6f..b32a2d03d 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -626,6 +626,7 @@ CConfigManager::CConfigManager() { registerConfigVar("binds:pass_mouse_when_bound", Hyprlang::INT{0}); registerConfigVar("binds:scroll_event_delay", Hyprlang::INT{300}); registerConfigVar("binds:workspace_back_and_forth", Hyprlang::INT{0}); + registerConfigVar("binds:hide_special_on_workspace_change", Hyprlang::INT{0}); registerConfigVar("binds:allow_workspace_cycles", Hyprlang::INT{0}); registerConfigVar("binds:workspace_center_on", Hyprlang::INT{1}); registerConfigVar("binds:focus_preferred_method", Hyprlang::INT{0}); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index cc912938c..9a22a13ac 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1215,9 +1215,10 @@ static SWorkspaceIDName getWorkspaceToChangeFromArgs(std::string args, PHLWORKSP SDispatchResult CKeybindManager::changeworkspace(std::string args) { // Workspace_back_and_forth being enabled means that an attempt to switch to // the current workspace will instead switch to the previous. - static auto PBACKANDFORTH = CConfigValue("binds:workspace_back_and_forth"); - static auto PALLOWWORKSPACECYCLES = CConfigValue("binds:allow_workspace_cycles"); - static auto PWORKSPACECENTERON = CConfigValue("binds:workspace_center_on"); + static auto PBACKANDFORTH = CConfigValue("binds:workspace_back_and_forth"); + static auto PALLOWWORKSPACECYCLES = CConfigValue("binds:allow_workspace_cycles"); + static auto PWORKSPACECENTERON = CConfigValue("binds:workspace_center_on"); + static auto PHIDESPECIALONWORKSPACECHANGE = CConfigValue("binds:hide_special_on_workspace_change"); const auto PMONITOR = g_pCompositor->m_pLastMonitor.lock(); @@ -1239,8 +1240,12 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) { const SWorkspaceIDName PPREVWS = args.contains("_per_monitor") ? PMONITOR->getPrevWorkspaceIDName(PCURRENTWORKSPACE->m_iID) : PCURRENTWORKSPACE->getPrevWorkspaceIDName(); const bool BISWORKSPACECURRENT = workspaceToChangeTo == PCURRENTWORKSPACE->m_iID; - if (BISWORKSPACECURRENT && (!(*PBACKANDFORTH || EXPLICITPREVIOUS) || PPREVWS.id == -1)) + if (BISWORKSPACECURRENT && (!(*PBACKANDFORTH || EXPLICITPREVIOUS) || PPREVWS.id == -1)) { + if (*PHIDESPECIALONWORKSPACECHANGE) + PMONITOR->setSpecialWorkspace(nullptr); + return {.success = false, .error = "Previous workspace doesn't exist"}; + } g_pInputManager->unconstrainMouse(); g_pInputManager->m_bEmptyFocusCursorSet = false; @@ -1275,6 +1280,8 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) { } else pWorkspaceToChangeTo->rememberPrevWorkspace(PCURRENTWORKSPACE); + if (*PHIDESPECIALONWORKSPACECHANGE) + PMONITORWORKSPACEOWNER->setSpecialWorkspace(nullptr); PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true); if (PMONITOR != PMONITORWORKSPACEOWNER) {