mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-04 14:11:59 -07:00
add general:workspace_back_and_forth option
This commit is contained in:
@@ -34,6 +34,7 @@ void CConfigManager::setDefaultVars() {
|
||||
configValues["general:apply_sens_to_raw"].intValue = 0;
|
||||
configValues["general:main_mod"].strValue = "SUPER"; // exposed to the user for easier configuring
|
||||
configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask("SUPER"); // actually used and automatically calculated
|
||||
configValues["general:workspace_back_and_forth"].intValue = 0;
|
||||
|
||||
configValues["general:damage_tracking"].strValue = "full";
|
||||
configValues["general:damage_tracking_internal"].intValue = DAMAGE_TRACKING_FULL;
|
||||
|
@@ -464,8 +464,8 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||
if (PWORKSPACE)
|
||||
workspaceName = PWORKSPACE->m_szName;
|
||||
} else if (args.find("previous") == 0) {
|
||||
const auto P_MONITOR = g_pCompositor->getMonitorFromCursor();
|
||||
const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID(P_MONITOR->activeWorkspace);
|
||||
const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID(
|
||||
g_pCompositor->getMonitorFromCursor()->activeWorkspace);
|
||||
|
||||
// Do nothing if there's no previous workspace, otherwise switch to it.
|
||||
if (P_CURRENT_WORKSPACE->m_iPrevWorkspaceID == -1) {
|
||||
@@ -488,6 +488,21 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Workspace_back_and_forth being enabled means that an attempt to switch to
|
||||
// the current workspace will instead switch to the previous.
|
||||
if (g_pConfigManager->getConfigValuePtr("general:workspace_back_and_forth")->intValue == 1
|
||||
&& g_pCompositor->getMonitorFromCursor()->activeWorkspace == workspaceToChangeTo) {
|
||||
|
||||
const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID(
|
||||
g_pCompositor->getMonitorFromCursor()->activeWorkspace);
|
||||
|
||||
workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID;
|
||||
isSwitchingToPrevious = true;
|
||||
|
||||
// TODO: Add support for cycles
|
||||
P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1;
|
||||
}
|
||||
|
||||
// remove constraints
|
||||
g_pInputManager->unconstrainMouse();
|
||||
|
||||
|
Reference in New Issue
Block a user