workspaces: Add binds:hide_special_on_workspace_change (#9728)

This commit is contained in:
LeviVanDerMaas 2025-03-30 03:11:39 +02:00 committed by GitHub
parent fc7223edc0
commit 05eb0aa43d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 4 deletions

View File

@ -2117,6 +2117,8 @@ PHLMONITOR CCompositor::getMonitorFromString(const std::string& name) {
} }
void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, PHLMONITOR pMonitor, bool noWarpCursor) { void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, PHLMONITOR pMonitor, bool noWarpCursor) {
static auto PHIDESPECIALONWORKSPACECHANGE = CConfigValue<Hyprlang::INT>("binds:hide_special_on_workspace_change");
if (!pWorkspace || !pMonitor) if (!pWorkspace || !pMonitor)
return; return;
@ -2199,6 +2201,9 @@ void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, PHLMONITOR pMo
pMonitor->activeWorkspace->startAnim(false, false); pMonitor->activeWorkspace->startAnim(false, false);
} }
if (*PHIDESPECIALONWORKSPACECHANGE)
pMonitor->setSpecialWorkspace(nullptr);
setActiveMonitor(pMonitor); setActiveMonitor(pMonitor);
pMonitor->activeWorkspace = pWorkspace; pMonitor->activeWorkspace = pWorkspace;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitor->ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitor->ID);

View File

@ -1246,6 +1246,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.type = CONFIG_OPTION_BOOL, .type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{false}, .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{ SConfigOptionDescription{
.value = "binds:allow_workspace_cycles", .value = "binds:allow_workspace_cycles",
.description = "If enabled, workspaces dont forget their previous workspace, so cycles can be created by switching to the first workspace in a sequence, then endlessly " .description = "If enabled, workspaces dont forget their previous workspace, so cycles can be created by switching to the first workspace in a sequence, then endlessly "

View File

@ -626,6 +626,7 @@ CConfigManager::CConfigManager() {
registerConfigVar("binds:pass_mouse_when_bound", Hyprlang::INT{0}); registerConfigVar("binds:pass_mouse_when_bound", Hyprlang::INT{0});
registerConfigVar("binds:scroll_event_delay", Hyprlang::INT{300}); registerConfigVar("binds:scroll_event_delay", Hyprlang::INT{300});
registerConfigVar("binds:workspace_back_and_forth", Hyprlang::INT{0}); 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:allow_workspace_cycles", Hyprlang::INT{0});
registerConfigVar("binds:workspace_center_on", Hyprlang::INT{1}); registerConfigVar("binds:workspace_center_on", Hyprlang::INT{1});
registerConfigVar("binds:focus_preferred_method", Hyprlang::INT{0}); registerConfigVar("binds:focus_preferred_method", Hyprlang::INT{0});

View File

@ -1215,9 +1215,10 @@ static SWorkspaceIDName getWorkspaceToChangeFromArgs(std::string args, PHLWORKSP
SDispatchResult CKeybindManager::changeworkspace(std::string args) { SDispatchResult CKeybindManager::changeworkspace(std::string args) {
// Workspace_back_and_forth being enabled means that an attempt to switch to // Workspace_back_and_forth being enabled means that an attempt to switch to
// the current workspace will instead switch to the previous. // the current workspace will instead switch to the previous.
static auto PBACKANDFORTH = CConfigValue<Hyprlang::INT>("binds:workspace_back_and_forth"); static auto PBACKANDFORTH = CConfigValue<Hyprlang::INT>("binds:workspace_back_and_forth");
static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles"); static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles");
static auto PWORKSPACECENTERON = CConfigValue<Hyprlang::INT>("binds:workspace_center_on"); 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(); 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 SWorkspaceIDName PPREVWS = args.contains("_per_monitor") ? PMONITOR->getPrevWorkspaceIDName(PCURRENTWORKSPACE->m_iID) : PCURRENTWORKSPACE->getPrevWorkspaceIDName();
const bool BISWORKSPACECURRENT = workspaceToChangeTo == PCURRENTWORKSPACE->m_iID; 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"}; return {.success = false, .error = "Previous workspace doesn't exist"};
}
g_pInputManager->unconstrainMouse(); g_pInputManager->unconstrainMouse();
g_pInputManager->m_bEmptyFocusCursorSet = false; g_pInputManager->m_bEmptyFocusCursorSet = false;
@ -1275,6 +1280,8 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
} else } else
pWorkspaceToChangeTo->rememberPrevWorkspace(PCURRENTWORKSPACE); pWorkspaceToChangeTo->rememberPrevWorkspace(PCURRENTWORKSPACE);
if (*PHIDESPECIALONWORKSPACECHANGE)
PMONITORWORKSPACEOWNER->setSpecialWorkspace(nullptr);
PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true); PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true);
if (PMONITOR != PMONITORWORKSPACEOWNER) { if (PMONITOR != PMONITORWORKSPACEOWNER) {