summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-12-20 22:16:13 +0000
committerGitHub <noreply@github.com>2025-12-20 22:16:13 +0000
commitb9bef6955487b75d13cfedd230bdc4adafedd115 (patch)
tree21400bb6bbb37651ad8e2f3338d2fa5e317b4098 /src/managers
parent70f54a1e1ba3478a56faf82431b2770bd727431d (diff)
Desktop/history: Move history to desktop (#12676)
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/KeybindManager.cpp40
-rw-r--r--src/managers/KeybindManager.hpp2
-rw-r--r--src/managers/input/UnifiedWorkspaceSwipeGesture.cpp3
3 files changed, 17 insertions, 28 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 101374ad..c4d8734e 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -1,6 +1,8 @@
#include "../config/ConfigValue.hpp"
#include "../devices/IKeyboard.hpp"
#include "../desktop/state/FocusState.hpp"
+#include "../desktop/history/WindowHistoryTracker.hpp"
+#include "../desktop/history/WorkspaceHistoryTracker.hpp"
#include "../managers/SeatManager.hpp"
#include "../protocols/LayerShell.hpp"
#include "../protocols/ShortcutsInhibit.hpp"
@@ -360,7 +362,6 @@ bool CKeybindManager::tryMoveFocusToMonitor(PHLMONITOR monitor) {
const auto PNEWMAINWORKSPACE = monitor->m_activeWorkspace;
g_pInputManager->unconstrainMouse();
- PNEWMAINWORKSPACE->rememberPrevWorkspace(PWORKSPACE);
const auto PNEWWORKSPACE = monitor->m_activeSpecialWorkspace ? monitor->m_activeSpecialWorkspace : PNEWMAINWORKSPACE;
@@ -384,7 +385,7 @@ bool CKeybindManager::tryMoveFocusToMonitor(PHLMONITOR monitor) {
return true;
}
-void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveFocusHistory, bool forceFSCycle) {
+void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool forceFSCycle) {
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
static auto PNOWARPS = CConfigValue<Hyprlang::INT>("cursor:no_warps");
@@ -397,10 +398,10 @@ void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveF
g_pInputManager->unconstrainMouse();
if (PLASTWINDOW && PLASTWINDOW->m_workspace == PWINDOWTOCHANGETO->m_workspace && PLASTWINDOW->isFullscreen())
- Desktop::focusState()->fullWindowFocus(PWINDOWTOCHANGETO, nullptr, preserveFocusHistory, forceFSCycle);
+ Desktop::focusState()->fullWindowFocus(PWINDOWTOCHANGETO, nullptr, forceFSCycle);
else {
updateRelativeCursorCoords();
- Desktop::focusState()->fullWindowFocus(PWINDOWTOCHANGETO, nullptr, preserveFocusHistory, forceFSCycle);
+ Desktop::focusState()->fullWindowFocus(PWINDOWTOCHANGETO, nullptr, forceFSCycle);
PWINDOWTOCHANGETO->warpCursor();
// Move mouse focus to the new window if required by current follow_mouse and warp modes
@@ -1187,7 +1188,8 @@ static SWorkspaceIDName getWorkspaceToChangeFromArgs(std::string args, PHLWORKSP
}
const bool PER_MON = args.contains("_per_monitor");
- const SWorkspaceIDName PPREVWS = PER_MON ? PMONITOR->getPrevWorkspaceIDName(PCURRENTWORKSPACE->m_id) : PCURRENTWORKSPACE->getPrevWorkspaceIDName();
+ const SWorkspaceIDName PPREVWS = PER_MON ? Desktop::History::workspaceTracker()->previousWorkspaceIDName(PCURRENTWORKSPACE, PMONITOR.lock()) :
+ Desktop::History::workspaceTracker()->previousWorkspaceIDName(PCURRENTWORKSPACE);
// Do nothing if there's no previous workspace, otherwise switch to it.
if (PPREVWS.id == -1 || PPREVWS.id == PCURRENTWORKSPACE->m_id) {
Log::logger->log(Log::DEBUG, "No previous workspace to change to");
@@ -1205,7 +1207,6 @@ 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 PHIDESPECIALONWORKSPACECHANGE = CConfigValue<Hyprlang::INT>("binds:hide_special_on_workspace_change");
@@ -1226,7 +1227,8 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
if (workspaceToChangeTo == WORKSPACE_NOT_CHANGED)
return {};
- const SWorkspaceIDName PPREVWS = args.contains("_per_monitor") ? PMONITOR->getPrevWorkspaceIDName(PCURRENTWORKSPACE->m_id) : PCURRENTWORKSPACE->getPrevWorkspaceIDName();
+ const SWorkspaceIDName PPREVWS = args.contains("_per_monitor") ? Desktop::History::workspaceTracker()->previousWorkspaceIDName(PCURRENTWORKSPACE, PMONITOR) :
+ Desktop::History::workspaceTracker()->previousWorkspaceIDName(PCURRENTWORKSPACE);
const bool BISWORKSPACECURRENT = workspaceToChangeTo == PCURRENTWORKSPACE->m_id;
if (BISWORKSPACECURRENT && (!(*PBACKANDFORTH || EXPLICITPREVIOUS) || PPREVWS.id == -1)) {
@@ -1261,14 +1263,6 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
Desktop::focusState()->rawMonitorFocus(PMONITORWORKSPACEOWNER);
- if (BISWORKSPACECURRENT) {
- if (*PALLOWWORKSPACECYCLES)
- pWorkspaceToChangeTo->rememberPrevWorkspace(PCURRENTWORKSPACE);
- else if (!EXPLICITPREVIOUS && !*PBACKANDFORTH)
- pWorkspaceToChangeTo->rememberPrevWorkspace(nullptr);
- } else
- pWorkspaceToChangeTo->rememberPrevWorkspace(PCURRENTWORKSPACE);
-
if (*PHIDESPECIALONWORKSPACECHANGE)
PMONITORWORKSPACEOWNER->setSpecialWorkspace(nullptr);
PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true);
@@ -1419,8 +1413,6 @@ SDispatchResult CKeybindManager::moveActiveToWorkspace(std::string args) {
else if (POLDWS->m_isSpecialWorkspace)
POLDWS->m_monitor.lock()->setSpecialWorkspace(nullptr);
- pWorkspace->rememberPrevWorkspace(POLDWS);
-
pMonitor->changeWorkspace(pWorkspace);
Desktop::focusState()->fullWindowFocus(PWINDOW);
@@ -1514,7 +1506,7 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
// Found window in direction, switch to it
if (PWINDOWTOCHANGETO) {
- switchToWindow(PWINDOWTOCHANGETO, false, *PFULLCYCLE && PLASTWINDOW->isFullscreen());
+ switchToWindow(PWINDOWTOCHANGETO, *PFULLCYCLE && PLASTWINDOW->isFullscreen());
return {};
}
@@ -1571,9 +1563,9 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
}
SDispatchResult CKeybindManager::focusUrgentOrLast(std::string args) {
- const auto PWINDOWURGENT = g_pCompositor->getUrgentWindow();
- const auto PWINDOWPREV = Desktop::focusState()->window() ? (Desktop::focusState()->windowHistory().size() < 2 ? nullptr : Desktop::focusState()->windowHistory()[1].lock()) :
- (Desktop::focusState()->windowHistory().empty() ? nullptr : Desktop::focusState()->windowHistory()[0].lock());
+ const auto& HISTORY = Desktop::History::windowTracker()->fullHistory();
+ const auto PWINDOWURGENT = g_pCompositor->getUrgentWindow();
+ const auto PWINDOWPREV = Desktop::focusState()->window() ? (HISTORY.size() < 2 ? nullptr : HISTORY[1].lock()) : (HISTORY.empty() ? nullptr : HISTORY[0].lock());
if (!PWINDOWURGENT && !PWINDOWPREV)
return {.success = false, .error = "Window not found"};
@@ -1584,8 +1576,8 @@ SDispatchResult CKeybindManager::focusUrgentOrLast(std::string args) {
}
SDispatchResult CKeybindManager::focusCurrentOrLast(std::string args) {
- const auto PWINDOWPREV = Desktop::focusState()->window() ? (Desktop::focusState()->windowHistory().size() < 2 ? nullptr : Desktop::focusState()->windowHistory()[1].lock()) :
- (Desktop::focusState()->windowHistory().empty() ? nullptr : Desktop::focusState()->windowHistory()[0].lock());
+ const auto& HISTORY = Desktop::History::windowTracker()->fullHistory();
+ const auto PWINDOWPREV = Desktop::focusState()->window() ? (HISTORY.size() < 2 ? nullptr : HISTORY[1].lock()) : (HISTORY.empty() ? nullptr : HISTORY[0].lock());
if (!PWINDOWPREV)
return {.success = false, .error = "Window not found"};
@@ -2064,7 +2056,7 @@ SDispatchResult CKeybindManager::focusWorkspaceOnCurrentMonitor(std::string args
}
static auto PBACKANDFORTH = CConfigValue<Hyprlang::INT>("binds:workspace_back_and_forth");
- const auto PREVWS = pWorkspace->getPrevWorkspaceIDName();
+ const auto PREVWS = Desktop::History::workspaceTracker()->previousWorkspaceIDName(pWorkspace);
if (*PBACKANDFORTH && PCURRMONITOR->activeWorkspaceID() == workspaceID && PREVWS.id != -1) {
// Workspace to focus is previous workspace
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index b5b200db..d4b1bf66 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -164,7 +164,7 @@ class CKeybindManager {
static void moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir = "");
static void moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowInDirection);
- static void switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveFocusHistory = false, bool forceFSCycle = false);
+ static void switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool forceFSCycle = false);
static uint64_t spawnRawProc(std::string, PHLWORKSPACE pInitialWorkspace, const std::string& execRuleToken = "");
static uint64_t spawnWithRules(std::string, PHLWORKSPACE pInitialWorkspace);
diff --git a/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp b/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp
index c952c0c8..c2c8a72a 100644
--- a/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp
+++ b/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp
@@ -246,7 +246,6 @@ void CUnifiedWorkspaceSwipeGesture::end() {
else {
m_monitor->changeWorkspace(g_pCompositor->createNewWorkspace(workspaceIDLeft, m_monitor->m_id));
PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
- PWORKSPACEL->rememberPrevWorkspace(m_workspaceBegin);
}
PWORKSPACEL->m_renderOffset->setValue(RENDEROFFSET);
@@ -273,7 +272,6 @@ void CUnifiedWorkspaceSwipeGesture::end() {
else {
m_monitor->changeWorkspace(g_pCompositor->createNewWorkspace(workspaceIDRight, m_monitor->m_id));
PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight);
- PWORKSPACER->rememberPrevWorkspace(m_workspaceBegin);
}
PWORKSPACER->m_renderOffset->setValue(RENDEROFFSET);
@@ -292,7 +290,6 @@ void CUnifiedWorkspaceSwipeGesture::end() {
pSwitchedTo = PWORKSPACER;
}
- pSwitchedTo->rememberPrevWorkspace(m_workspaceBegin);
g_pHyprRenderer->damageMonitor(m_monitor.lock());