Skip to content

Commit

Permalink
keybinds: never switch to another monitor with per_monitor (#6665)
Browse files Browse the repository at this point in the history
Co-authored-by: Крылов Александр <[email protected]>
  • Loading branch information
Truenya and Крылов Александр authored Jun 27, 2024
1 parent e4d09aa commit f2dc48d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,16 +1040,20 @@ SWorkspaceIDName getWorkspaceToChangeFromArgs(std::string args, PHLWORKSPACE PCU
return getWorkspaceIDNameFromString(args);
}

const SWorkspaceIDName PPREVWS = PCURRENTWORKSPACE->getPrevWorkspaceIDName(args.contains("_per_monitor"));
const bool PER_MON = args.contains("_per_monitor");
const SWorkspaceIDName PPREVWS = PCURRENTWORKSPACE->getPrevWorkspaceIDName(PER_MON);
// Do nothing if there's no previous workspace, otherwise switch to it.
if (PPREVWS.id == -1) {
Debug::log(LOG, "No previous workspace to change to");
return {WORKSPACE_NOT_CHANGED, ""};
}

const auto ID = PCURRENTWORKSPACE->m_iID;
if (const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(PPREVWS.id); PWORKSPACETOCHANGETO)
if (const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(PPREVWS.id); PWORKSPACETOCHANGETO) {
if (PER_MON && PCURRENTWORKSPACE->m_iMonitorID != PWORKSPACETOCHANGETO->m_iMonitorID)
return {WORKSPACE_NOT_CHANGED, ""};
return {ID, PWORKSPACETOCHANGETO->m_szName};
}

return {ID, PPREVWS.name.empty() ? std::to_string(PPREVWS.id) : PPREVWS.name};
}
Expand Down Expand Up @@ -1678,7 +1682,6 @@ void CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args) {

// get the current workspace
const auto PCURRENTWORKSPACE = g_pCompositor->m_pLastMonitor->activeWorkspace;

if (!PCURRENTWORKSPACE) {
Debug::log(ERR, "moveCurrentWorkspaceToMonitor invalid workspace!");
return;
Expand Down

0 comments on commit f2dc48d

Please sign in to comment.