aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorBrenno Lemos <[email protected]>2024-05-11 20:03:32 -0300
committerGitHub <[email protected]>2024-05-12 00:03:32 +0100
commit33a7b7bb6b307d6e4a093f75ffdda0419cd7ffaf (patch)
tree8bd1bc79f5a16fb56aa9b81db28f88925b010b89 /src
parent15072831cfd9efccebd1ad27b21c5604f224aa1b (diff)
downloadHyprland-33a7b7bb6b307d6e4a093f75ffdda0419cd7ffaf.tar.gz
Hyprland-33a7b7bb6b307d6e4a093f75ffdda0419cd7ffaf.zip
core: fix on-empty workspace being called too often (#6026)
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp4
-rw-r--r--src/Compositor.hpp2
-rw-r--r--src/desktop/Workspace.cpp12
-rw-r--r--src/desktop/Workspace.hpp6
-rw-r--r--src/managers/KeybindManager.cpp4
5 files changed, 16 insertions, 12 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 9a9ea30b..c532f958 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -2492,7 +2492,7 @@ void CCompositor::forceReportSizesToWindowsOnWorkspace(const int& wid) {
}
}
-PHLWORKSPACE CCompositor::createNewWorkspace(const int& id, const int& monid, const std::string& name) {
+PHLWORKSPACE CCompositor::createNewWorkspace(const int& id, const int& monid, const std::string& name, bool isEmtpy) {
const auto NAME = name == "" ? std::to_string(id) : name;
auto monID = monid;
@@ -2503,7 +2503,7 @@ PHLWORKSPACE CCompositor::createNewWorkspace(const int& id, const int& monid, co
const bool SPECIAL = id >= SPECIAL_WORKSPACE_START && id <= -2;
- const auto PWORKSPACE = m_vWorkspaces.emplace_back(CWorkspace::create(id, monID, NAME, SPECIAL));
+ const auto PWORKSPACE = m_vWorkspaces.emplace_back(CWorkspace::create(id, monID, NAME, SPECIAL, isEmtpy));
PWORKSPACE->m_fAlpha.setValueAndWarp(0);
diff --git a/src/Compositor.hpp b/src/Compositor.hpp
index 8812f8c8..c8bb8743 100644
--- a/src/Compositor.hpp
+++ b/src/Compositor.hpp
@@ -164,7 +164,7 @@ class CCompositor {
void closeWindow(PHLWINDOW);
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
void forceReportSizesToWindowsOnWorkspace(const int&);
- PHLWORKSPACE createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused!
+ PHLWORKSPACE createNewWorkspace(const int&, const int&, const std::string& name = "", bool isEmtpy = true); // will be deleted next frame if left empty and unfocused!
void renameWorkspace(const int&, const std::string& name = "");
void setActiveMonitor(CMonitor*);
bool isWorkspaceSpecial(const int&);
diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp
index b730c9ab..7a836b3b 100644
--- a/src/desktop/Workspace.cpp
+++ b/src/desktop/Workspace.cpp
@@ -2,17 +2,18 @@
#include "../Compositor.hpp"
#include "../config/ConfigValue.hpp"
-PHLWORKSPACE CWorkspace::create(int id, int monitorID, std::string name, bool special) {
- PHLWORKSPACE workspace = makeShared<CWorkspace>(id, monitorID, name, special);
+PHLWORKSPACE CWorkspace::create(int id, int monitorID, std::string name, bool special, bool isEmtpy) {
+ PHLWORKSPACE workspace = makeShared<CWorkspace>(id, monitorID, name, special, isEmtpy);
workspace->init(workspace);
return workspace;
}
-CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special) {
+CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special, bool isEmtpy) {
m_iMonitorID = monitorID;
m_iID = id;
m_szName = name;
m_bIsSpecialWorkspace = special;
+ m_bWasCreatedEmtpy = isEmtpy;
}
void CWorkspace::init(PHLWORKSPACE self) {
@@ -44,8 +45,9 @@ void CWorkspace::init(PHLWORKSPACE self) {
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(self);
m_bPersistent = WORKSPACERULE.isPersistent;
- if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd)
- g_pKeybindManager->spawn(*cmd);
+ if (self->m_bWasCreatedEmtpy)
+ if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd)
+ g_pKeybindManager->spawn(*cmd);
g_pEventManager->postEvent({"createworkspace", m_szName});
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)});
diff --git a/src/desktop/Workspace.hpp b/src/desktop/Workspace.hpp
index 3fae3dfc..17431215 100644
--- a/src/desktop/Workspace.hpp
+++ b/src/desktop/Workspace.hpp
@@ -15,9 +15,9 @@ class CWindow;
class CWorkspace {
public:
- static PHLWORKSPACE create(int id, int monitorID, std::string name, bool special = false);
+ static PHLWORKSPACE create(int id, int monitorID, std::string name, bool special = false, bool isEmtpy = true);
// use create() don't use this
- CWorkspace(int id, int monitorID, std::string name, bool special = false);
+ CWorkspace(int id, int monitorID, std::string name, bool special = false, bool isEmpty = true);
~CWorkspace();
// Workspaces ID-based have IDs > 0
@@ -58,6 +58,8 @@ class CWorkspace {
// last monitor (used on reconnect)
std::string m_szLastMonitor = "";
+ bool m_bWasCreatedEmtpy = true;
+
bool m_bPersistent = false;
// Inert: destroyed and invalid. If this is true, release the ptr you have.
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 286372c4..146dd221 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -1102,7 +1102,7 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
pMonitor = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
g_pCompositor->setActiveMonitor(pMonitor);
} else {
- pWorkspace = g_pCompositor->createNewWorkspace(WORKSPACEID, PWINDOW->m_iMonitorID, workspaceName);
+ pWorkspace = g_pCompositor->createNewWorkspace(WORKSPACEID, PWINDOW->m_iMonitorID, workspaceName, false);
pMonitor = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
}
@@ -1158,7 +1158,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
if (pWorkspace) {
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
} else {
- pWorkspace = g_pCompositor->createNewWorkspace(WORKSPACEID, PWINDOW->m_iMonitorID, workspaceName);
+ pWorkspace = g_pCompositor->createNewWorkspace(WORKSPACEID, PWINDOW->m_iMonitorID, workspaceName, false);
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
}