mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 15:45:59 +01:00
core: fix on-empty workspace being called too often (#6026)
This commit is contained in:
parent
15072831cf
commit
33a7b7bb6b
5 changed files with 16 additions and 12 deletions
|
@ -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;
|
const auto NAME = name == "" ? std::to_string(id) : name;
|
||||||
auto monID = monid;
|
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 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);
|
PWORKSPACE->m_fAlpha.setValueAndWarp(0);
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ class CCompositor {
|
||||||
void closeWindow(PHLWINDOW);
|
void closeWindow(PHLWINDOW);
|
||||||
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
|
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
|
||||||
void forceReportSizesToWindowsOnWorkspace(const int&);
|
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 renameWorkspace(const int&, const std::string& name = "");
|
||||||
void setActiveMonitor(CMonitor*);
|
void setActiveMonitor(CMonitor*);
|
||||||
bool isWorkspaceSpecial(const int&);
|
bool isWorkspaceSpecial(const int&);
|
||||||
|
|
|
@ -2,17 +2,18 @@
|
||||||
#include "../Compositor.hpp"
|
#include "../Compositor.hpp"
|
||||||
#include "../config/ConfigValue.hpp"
|
#include "../config/ConfigValue.hpp"
|
||||||
|
|
||||||
PHLWORKSPACE CWorkspace::create(int id, int monitorID, std::string name, bool special) {
|
PHLWORKSPACE CWorkspace::create(int id, int monitorID, std::string name, bool special, bool isEmtpy) {
|
||||||
PHLWORKSPACE workspace = makeShared<CWorkspace>(id, monitorID, name, special);
|
PHLWORKSPACE workspace = makeShared<CWorkspace>(id, monitorID, name, special, isEmtpy);
|
||||||
workspace->init(workspace);
|
workspace->init(workspace);
|
||||||
return 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_iMonitorID = monitorID;
|
||||||
m_iID = id;
|
m_iID = id;
|
||||||
m_szName = name;
|
m_szName = name;
|
||||||
m_bIsSpecialWorkspace = special;
|
m_bIsSpecialWorkspace = special;
|
||||||
|
m_bWasCreatedEmtpy = isEmtpy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorkspace::init(PHLWORKSPACE self) {
|
void CWorkspace::init(PHLWORKSPACE self) {
|
||||||
|
@ -44,8 +45,9 @@ void CWorkspace::init(PHLWORKSPACE self) {
|
||||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(self);
|
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(self);
|
||||||
m_bPersistent = WORKSPACERULE.isPersistent;
|
m_bPersistent = WORKSPACERULE.isPersistent;
|
||||||
|
|
||||||
if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd)
|
if (self->m_bWasCreatedEmtpy)
|
||||||
g_pKeybindManager->spawn(*cmd);
|
if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd)
|
||||||
|
g_pKeybindManager->spawn(*cmd);
|
||||||
|
|
||||||
g_pEventManager->postEvent({"createworkspace", m_szName});
|
g_pEventManager->postEvent({"createworkspace", m_szName});
|
||||||
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)});
|
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)});
|
||||||
|
|
|
@ -15,9 +15,9 @@ class CWindow;
|
||||||
|
|
||||||
class CWorkspace {
|
class CWorkspace {
|
||||||
public:
|
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
|
// 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();
|
~CWorkspace();
|
||||||
|
|
||||||
// Workspaces ID-based have IDs > 0
|
// Workspaces ID-based have IDs > 0
|
||||||
|
@ -58,6 +58,8 @@ class CWorkspace {
|
||||||
// last monitor (used on reconnect)
|
// last monitor (used on reconnect)
|
||||||
std::string m_szLastMonitor = "";
|
std::string m_szLastMonitor = "";
|
||||||
|
|
||||||
|
bool m_bWasCreatedEmtpy = true;
|
||||||
|
|
||||||
bool m_bPersistent = false;
|
bool m_bPersistent = false;
|
||||||
|
|
||||||
// Inert: destroyed and invalid. If this is true, release the ptr you have.
|
// Inert: destroyed and invalid. If this is true, release the ptr you have.
|
||||||
|
|
|
@ -1102,7 +1102,7 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
||||||
pMonitor = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
|
pMonitor = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
|
||||||
g_pCompositor->setActiveMonitor(pMonitor);
|
g_pCompositor->setActiveMonitor(pMonitor);
|
||||||
} else {
|
} 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);
|
pMonitor = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
|
||||||
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
|
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
|
||||||
}
|
}
|
||||||
|
@ -1158,7 +1158,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
||||||
if (pWorkspace) {
|
if (pWorkspace) {
|
||||||
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
|
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
|
||||||
} else {
|
} 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);
|
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue