summaryrefslogtreecommitdiff
path: root/src/desktop
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-04-24 16:16:46 +0100
committerVaxry <vaxry@vaxry.net>2024-04-24 16:16:52 +0100
commit608eff600d31879519aa64b795b45709ebfac267 (patch)
tree10279d23e8c41e29ca91f91c83b386bb3cb2abca /src/desktop
parent81bb4eb2f6e385431dab0ae664bb59f35c8c069e (diff)
tokens: add more modes to initial_workspace_tracking
1 is single-shot, 2 is persistent fixes #5732
Diffstat (limited to 'src/desktop')
-rw-r--r--src/desktop/Window.cpp29
-rw-r--r--src/desktop/Window.hpp7
2 files changed, 34 insertions, 2 deletions
diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp
index 8dcfc397..cebdad49 100644
--- a/src/desktop/Window.cpp
+++ b/src/desktop/Window.cpp
@@ -385,9 +385,20 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
if (m_pWorkspace == pWorkspace)
return;
+ static auto PINITIALWSTRACKING = CConfigValue<Hyprlang::INT>("misc:initial_workspace_tracking");
+
if (!m_szInitialWorkspaceToken.empty()) {
- g_pTokenManager->removeToken(g_pTokenManager->getToken(m_szInitialWorkspaceToken));
- m_szInitialWorkspaceToken = "";
+ const auto TOKEN = g_pTokenManager->getToken(m_szInitialWorkspaceToken);
+ if (TOKEN) {
+ if (*PINITIALWSTRACKING == 2) {
+ // persistent
+ SInitialWorkspaceToken token = std::any_cast<SInitialWorkspaceToken>(TOKEN->data);
+ if (token.primaryOwner == this) {
+ token.workspace = pWorkspace->getConfigName();
+ TOKEN->data = token;
+ }
+ }
+ }
}
static auto PCLOSEONLASTSPECIAL = CConfigValue<Hyprlang::INT>("misc:close_special_on_empty");
@@ -468,6 +479,20 @@ void CWindow::onUnmap() {
if (g_pInputManager->currentlyDraggedWindow == this)
g_pInputManager->currentlyDraggedWindow = nullptr;
+ static auto PINITIALWSTRACKING = CConfigValue<Hyprlang::INT>("misc:initial_workspace_tracking");
+
+ if (!m_szInitialWorkspaceToken.empty()) {
+ const auto TOKEN = g_pTokenManager->getToken(m_szInitialWorkspaceToken);
+ if (TOKEN) {
+ if (*PINITIALWSTRACKING == 2) {
+ // persistent token, but the first window got removed so the token is gone
+ SInitialWorkspaceToken token = std::any_cast<SInitialWorkspaceToken>(TOKEN->data);
+ if (token.primaryOwner == this)
+ g_pTokenManager->removeToken(TOKEN);
+ }
+ }
+ }
+
m_iLastWorkspace = m_pWorkspace->m_iID;
m_vRealPosition.setCallbackOnEnd(unregisterVar);
diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp
index cc4d1757..7b298552 100644
--- a/src/desktop/Window.hpp
+++ b/src/desktop/Window.hpp
@@ -14,6 +14,8 @@
#include "DesktopTypes.hpp"
#include "../helpers/signal/Signal.hpp"
+class CWindow;
+
enum eIdleInhibitMode {
IDLEINHIBIT_NONE = 0,
IDLEINHIBIT_ALWAYS,
@@ -188,6 +190,11 @@ struct SWindowRule {
std::string szWorkspace = ""; // empty means any
};
+struct SInitialWorkspaceToken {
+ CWindow* primaryOwner = nullptr;
+ std::string workspace;
+};
+
class CWindow {
public:
CWindow();