mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 15:05:58 +01:00
find a default workspace smarter
This commit is contained in:
parent
fd43d2bea7
commit
d5352a5d12
4 changed files with 29 additions and 1 deletions
|
@ -1688,6 +1688,18 @@ CMonitor* CConfigManager::getBoundMonitorForWS(std::string wsname) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::string CConfigManager::getBoundMonitorStringForWS(std::string wsname) {
|
||||
for (auto& [ws, mon] : boundWorkspaces) {
|
||||
const auto WSNAME = ws.find("name:") == 0 ? ws.substr(5) : ws;
|
||||
|
||||
if (WSNAME == wsname) {
|
||||
return mon;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void CConfigManager::addExecRule(SExecRequestedRule rule) {
|
||||
execRequestedRules.push_back(rule);
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ public:
|
|||
SMonitorRule getMonitorRuleFor(std::string, std::string displayName = "");
|
||||
|
||||
CMonitor* getBoundMonitorForWS(std::string);
|
||||
std::string getBoundMonitorStringForWS(std::string);
|
||||
|
||||
std::vector<SWindowRule> getMatchingRules(CWindow*);
|
||||
|
||||
|
|
|
@ -240,10 +240,24 @@ bool CMonitor::isMirror() {
|
|||
return pMirrorOf != nullptr;
|
||||
}
|
||||
|
||||
int CMonitor::findAvailableDefaultWS() {
|
||||
for (size_t i = 1; i < INT32_MAX; ++i) {
|
||||
if (g_pCompositor->getWorkspaceByID(i))
|
||||
continue;
|
||||
|
||||
if (const auto BOUND = g_pConfigManager->getBoundMonitorStringForWS(std::to_string(i)); !BOUND.empty() && BOUND != szName)
|
||||
continue;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
return INT32_MAX; // shouldn't be reachable
|
||||
}
|
||||
|
||||
void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
|
||||
// Workspace
|
||||
std::string newDefaultWorkspaceName = "";
|
||||
int64_t WORKSPACEID = monitorRule.defaultWorkspace == "" ? g_pCompositor->m_vWorkspaces.size() + 1 : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName);
|
||||
int64_t WORKSPACEID = monitorRule.defaultWorkspace == "" ? findAvailableDefaultWS() : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName);
|
||||
|
||||
if (WORKSPACEID == INT_MAX || (WORKSPACEID >= SPECIAL_WORKSPACE_START && WORKSPACEID <= -2)) {
|
||||
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
|
||||
|
|
|
@ -83,4 +83,5 @@ public:
|
|||
|
||||
private:
|
||||
void setupDefaultWS(const SMonitorRule&);
|
||||
int findAvailableDefaultWS();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue