aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-03-13 15:19:25 +0000
committervaxerski <[email protected]>2023-03-13 15:19:25 +0000
commite749af7b60386f4ff414ef3e2e804523046e46a9 (patch)
treedb7999bda973306d2fb7f5159b3499cbe4c0f3b8
parent17deeb07ad4ce1b34bfe22524f9b248c5c6e01e6 (diff)
downloadHyprland-e749af7b60386f4ff414ef3e2e804523046e46a9.tar.gz
Hyprland-e749af7b60386f4ff414ef3e2e804523046e46a9.zip
dispatchers: remember named workspaces in prev
-rw-r--r--src/helpers/MiscFunctions.cpp6
-rw-r--r--src/helpers/Workspace.hpp6
-rw-r--r--src/managers/KeybindManager.cpp31
3 files changed, 26 insertions, 17 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index ab3c826e..de385e9b 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -297,7 +297,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
if (!PWORKSPACE)
return INT_MAX;
- const auto PLASTWORKSPACE = g_pCompositor->getWorkspaceByID(PWORKSPACE->m_iPrevWorkspaceID);
+ const auto PLASTWORKSPACE = g_pCompositor->getWorkspaceByID(PWORKSPACE->m_sPrevWorkspace.iID);
if (!PLASTWORKSPACE)
return INT_MAX;
@@ -470,8 +470,8 @@ int64_t getPPIDof(int64_t pid) {
return 0;
#else
- std::string dir = "/proc/" + std::to_string(pid) + "/status";
- FILE* infile;
+ std::string dir = "/proc/" + std::to_string(pid) + "/status";
+ FILE* infile;
infile = fopen(dir.c_str(), "r");
if (!infile)
diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp
index 2fa29d1c..d70702fd 100644
--- a/src/helpers/Workspace.hpp
+++ b/src/helpers/Workspace.hpp
@@ -23,7 +23,11 @@ class CWorkspace {
uint64_t m_iMonitorID = -1;
// Previous workspace ID is stored during a workspace change, allowing travel
// to the previous workspace.
- int m_iPrevWorkspaceID = -1;
+ struct SPrevWorkspaceData {
+ int iID = -1;
+ std::string name = "";
+ } m_sPrevWorkspace;
+
bool m_bHasFullscreenWindow = false;
eFullscreenMode m_efFullscreenMode = FULLSCREEN_FULL;
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 95144a61..9d652932 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -708,22 +708,22 @@ void CKeybindManager::changeworkspace(std::string args) {
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
// Do nothing if there's no previous workspace, otherwise switch to it.
- if (PCURRENTWORKSPACE->m_iPrevWorkspaceID == -1) {
+ if (PCURRENTWORKSPACE->m_sPrevWorkspace.iID == -1) {
Debug::log(LOG, "No previous workspace to change to");
return;
} else {
- workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID;
+ workspaceToChangeTo = PCURRENTWORKSPACE->m_sPrevWorkspace.iID;
if (const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(workspaceToChangeTo); PWORKSPACETOCHANGETO)
workspaceName = PWORKSPACETOCHANGETO->m_szName;
else
- workspaceName = std::to_string(workspaceToChangeTo);
+ workspaceName = PCURRENTWORKSPACE->m_sPrevWorkspace.name.empty() ? std::to_string(workspaceToChangeTo) : PCURRENTWORKSPACE->m_sPrevWorkspace.name;
// If the previous workspace ID isn't reset, cycles can form when continually going
// to the previous workspace again and again.
static auto* const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue;
if (!*PALLOWWORKSPACECYCLES)
- PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1;
+ PCURRENTWORKSPACE->m_sPrevWorkspace = {-1, ""};
else
isSwitchingToPrevious = true;
}
@@ -741,22 +741,22 @@ void CKeybindManager::changeworkspace(std::string args) {
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
static auto* const PBACKANDFORTH = &g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth")->intValue;
- if (*PBACKANDFORTH && PCURRENTWORKSPACE && PCURRENTWORKSPACE->m_iID == workspaceToChangeTo && PCURRENTWORKSPACE->m_iPrevWorkspaceID != -1 && !internal) {
+ if (*PBACKANDFORTH && PCURRENTWORKSPACE && PCURRENTWORKSPACE->m_iID == workspaceToChangeTo && PCURRENTWORKSPACE->m_sPrevWorkspace.iID != -1 && !internal) {
- const auto PPREVWORKSPACE = g_pCompositor->getWorkspaceByID(PCURRENTWORKSPACE->m_iPrevWorkspaceID);
+ const auto PPREVWORKSPACE = g_pCompositor->getWorkspaceByID(PCURRENTWORKSPACE->m_sPrevWorkspace.iID);
- workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID;
+ workspaceToChangeTo = PCURRENTWORKSPACE->m_sPrevWorkspace.iID;
if (PPREVWORKSPACE)
workspaceName = PPREVWORKSPACE->m_szName;
else
- workspaceName = std::to_string(workspaceToChangeTo);
+ workspaceName = PCURRENTWORKSPACE->m_sPrevWorkspace.name.empty() ? std::to_string(workspaceToChangeTo) : PCURRENTWORKSPACE->m_sPrevWorkspace.name;
// If the previous workspace ID isn't reset, cycles can form when continually going
// to the previous workspace again and again.
static auto* const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue;
if (!*PALLOWWORKSPACECYCLES)
- PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1;
+ PCURRENTWORKSPACE->m_sPrevWorkspace = {-1, ""};
else
isSwitchingToPrevious = true;
@@ -778,9 +778,11 @@ void CKeybindManager::changeworkspace(std::string args) {
const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(workspaceToChangeTo);
- if (!isSwitchingToPrevious && !internal)
+ if (!isSwitchingToPrevious && !internal) {
// Remember previous workspace.
- PWORKSPACETOCHANGETO->m_iPrevWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace;
+ PWORKSPACETOCHANGETO->m_sPrevWorkspace.iID = g_pCompositor->m_pLastMonitor->activeWorkspace;
+ PWORKSPACETOCHANGETO->m_sPrevWorkspace.name = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace)->m_szName;
+ }
if (g_pCompositor->isWorkspaceSpecial(workspaceToChangeTo))
PWORKSPACETOCHANGETO->m_iMonitorID = PMONITOR->ID;
@@ -874,9 +876,12 @@ void CKeybindManager::changeworkspace(std::string args) {
const bool ANOTHERMONITOR = PMONITOR != g_pCompositor->m_pLastMonitor;
- if (!isSwitchingToPrevious)
+ if (!isSwitchingToPrevious) {
// Remember previous workspace.
- PWORKSPACE->m_iPrevWorkspaceID = OLDWORKSPACE;
+ PWORKSPACE->m_sPrevWorkspace.iID = OLDWORKSPACE;
+ if (const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(OLDWORKSPACE); POLDWORKSPACE)
+ PWORKSPACE->m_sPrevWorkspace.name = POLDWORKSPACE->m_szName;
+ }
// start anim on new workspace
PWORKSPACE->startAnim(true, ANIMTOLEFT);