summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeviVanDerMaas <80783230+LeviVanDerMaas@users.noreply.github.com>2025-03-30 03:11:39 +0200
committerGitHub <noreply@github.com>2025-03-30 03:11:39 +0200
commit05eb0aa43ded10f008be3cfcde33fe0bfe6e45b1 (patch)
treee469ec8a71c285f3eecb605a7a1821e450d7ac85 /src
parentfc7223edc08a2e330052e699e91ba35402aa088b (diff)
workspaces: Add binds:hide_special_on_workspace_change (#9728)
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp5
-rw-r--r--src/config/ConfigDescriptions.hpp6
-rw-r--r--src/config/ConfigManager.cpp1
-rw-r--r--src/managers/KeybindManager.cpp15
4 files changed, 23 insertions, 4 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 9aff1bb5..cb94116d 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<Hyprlang::INT>("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 402780e0..3e9563ee 100644
--- a/src/config/ConfigDescriptions.hpp
+++ b/src/config/ConfigDescriptions.hpp
@@ -1247,6 +1247,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.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 "
"going to the previous workspace.",
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index ebbdb7c6..b32a2d03 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 cc912938..9a22a13a 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<Hyprlang::INT>("binds:workspace_back_and_forth");
- static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles");
- static auto PWORKSPACECENTERON = CConfigValue<Hyprlang::INT>("binds:workspace_center_on");
+ static auto PBACKANDFORTH = CConfigValue<Hyprlang::INT>("binds:workspace_back_and_forth");
+ static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles");
+ static auto PWORKSPACECENTERON = CConfigValue<Hyprlang::INT>("binds:workspace_center_on");
+ static auto PHIDESPECIALONWORKSPACECHANGE = CConfigValue<Hyprlang::INT>("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) {