mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 05:45:59 +01:00
core: match all workspace rules instead of the first one only (#5340)
This commit is contained in:
parent
1aed45f61d
commit
5e8c25d498
7 changed files with 91 additions and 38 deletions
|
@ -1260,8 +1260,13 @@ void CCompositor::sanityCheckWorkspaces() {
|
|||
auto it = m_vWorkspaces.begin();
|
||||
while (it != m_vWorkspaces.end()) {
|
||||
|
||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(it->get());
|
||||
if (WORKSPACERULE.isPersistent) {
|
||||
const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(it->get());
|
||||
bool isPersistent = false;
|
||||
for (auto& wsRule : WORKSPACERULES) {
|
||||
if (wsRule.isPersistent)
|
||||
isPersistent = true;
|
||||
}
|
||||
if (isPersistent) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
|
@ -1288,8 +1293,10 @@ void CCompositor::sanityCheckWorkspaces() {
|
|||
continue;
|
||||
}
|
||||
if (!WORKSPACE->m_bOnCreatedEmptyExecuted) {
|
||||
if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd)
|
||||
for (auto& wsRule : WORKSPACERULES) {
|
||||
if (auto cmd = wsRule.onCreatedEmptyRunCmd)
|
||||
g_pKeybindManager->spawn(*cmd);
|
||||
}
|
||||
|
||||
WORKSPACE->m_bOnCreatedEmptyExecuted = true;
|
||||
}
|
||||
|
|
|
@ -956,11 +956,13 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const CMonitor& PMONITOR) {
|
|||
return SMonitorRule{.name = "", .resolution = Vector2D(0, 0), .offset = Vector2D(-INT32_MAX, -INT32_MAX), .scale = -1}; // 0, 0 is preferred and -1, -1 is auto
|
||||
}
|
||||
|
||||
SWorkspaceRule CConfigManager::getWorkspaceRuleFor(CWorkspace* pWorkspace) {
|
||||
const auto IT = std::find_if(m_dWorkspaceRules.begin(), m_dWorkspaceRules.end(), [&](const auto& other) { return pWorkspace->matchesStaticSelector(other.workspaceString); });
|
||||
if (IT == m_dWorkspaceRules.end())
|
||||
return SWorkspaceRule{};
|
||||
return *IT;
|
||||
std::vector<SWorkspaceRule> CConfigManager::getWorkspaceRulesFor(CWorkspace* pWorkspace) {
|
||||
std::vector<SWorkspaceRule> results;
|
||||
for (auto& rule : m_dWorkspaceRules) {
|
||||
if (pWorkspace->matchesStaticSelector(rule.workspaceString))
|
||||
results.push_back(rule);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow, bool dynamic, bool shadowExec) {
|
||||
|
|
|
@ -105,7 +105,7 @@ class CConfigManager {
|
|||
static std::string getMainConfigPath();
|
||||
|
||||
SMonitorRule getMonitorRuleFor(const CMonitor&);
|
||||
SWorkspaceRule getWorkspaceRuleFor(CWorkspace*);
|
||||
std::vector<SWorkspaceRule> getWorkspaceRulesFor(CWorkspace*);
|
||||
std::string getDefaultWorkspaceFor(const std::string&);
|
||||
|
||||
CMonitor* getBoundMonitorForWS(const std::string&);
|
||||
|
|
|
@ -1089,7 +1089,7 @@ float CWindow::rounding() {
|
|||
|
||||
void CWindow::updateSpecialRenderData() {
|
||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID);
|
||||
const auto WORKSPACERULE = PWORKSPACE ? g_pConfigManager->getWorkspaceRuleFor(PWORKSPACE) : SWorkspaceRule{};
|
||||
const auto WORKSPACERULES = PWORKSPACE ? g_pConfigManager->getWorkspaceRulesFor(PWORKSPACE) : std::vector<SWorkspaceRule>{};
|
||||
bool border = true;
|
||||
|
||||
static auto PNOBORDERONFLOATING = CConfigValue<Hyprlang::INT>("general:no_border_on_floating");
|
||||
|
@ -1097,11 +1097,24 @@ void CWindow::updateSpecialRenderData() {
|
|||
if (m_bIsFloating && *PNOBORDERONFLOATING == 1)
|
||||
border = false;
|
||||
|
||||
m_sSpecialRenderData.border = WORKSPACERULE.border.value_or(border);
|
||||
m_sSpecialRenderData.borderSize = WORKSPACERULE.borderSize.value_or(-1);
|
||||
m_sSpecialRenderData.decorate = WORKSPACERULE.decorate.value_or(true);
|
||||
m_sSpecialRenderData.rounding = WORKSPACERULE.rounding.value_or(true);
|
||||
m_sSpecialRenderData.shadow = WORKSPACERULE.shadow.value_or(true);
|
||||
m_sSpecialRenderData.border = border;
|
||||
m_sSpecialRenderData.borderSize = -1;
|
||||
m_sSpecialRenderData.decorate = true;
|
||||
m_sSpecialRenderData.rounding = true;
|
||||
m_sSpecialRenderData.shadow = true;
|
||||
|
||||
for (auto& wsRule : WORKSPACERULES) {
|
||||
if (wsRule.border.has_value())
|
||||
m_sSpecialRenderData.border = wsRule.border.value();
|
||||
if (wsRule.borderSize.has_value())
|
||||
m_sSpecialRenderData.borderSize = wsRule.borderSize.value();
|
||||
if (wsRule.decorate.has_value())
|
||||
m_sSpecialRenderData.decorate = wsRule.decorate.value();
|
||||
if (wsRule.rounding.has_value())
|
||||
m_sSpecialRenderData.rounding = wsRule.rounding.value();
|
||||
if (wsRule.shadow.has_value())
|
||||
m_sSpecialRenderData.shadow = wsRule.shadow.value();
|
||||
}
|
||||
}
|
||||
|
||||
int CWindow::getRealBorderSize() {
|
||||
|
|
|
@ -24,9 +24,11 @@ CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special) {
|
|||
m_vRenderOffset.registerVar();
|
||||
m_fAlpha.registerVar();
|
||||
|
||||
const auto RULEFORTHIS = g_pConfigManager->getWorkspaceRuleFor(this);
|
||||
if (RULEFORTHIS.defaultName.has_value())
|
||||
m_szName = RULEFORTHIS.defaultName.value();
|
||||
const auto RULESFORTHIS = g_pConfigManager->getWorkspaceRulesFor(this);
|
||||
for (auto& rule : RULESFORTHIS) {
|
||||
if (rule.defaultName.has_value())
|
||||
m_szName = rule.defaultName.value();
|
||||
}
|
||||
|
||||
g_pEventManager->postEvent({"createworkspace", m_szName});
|
||||
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)});
|
||||
|
|
|
@ -128,7 +128,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
|||
const auto PWINDOW = pNode->pWindow;
|
||||
// get specific gaps and rules for this workspace,
|
||||
// if user specified them in config
|
||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(pNode->workspaceID));
|
||||
const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(g_pCompositor->getWorkspaceByID(pNode->workspaceID));
|
||||
|
||||
if (!g_pCompositor->windowExists(PWINDOW)) {
|
||||
Debug::log(ERR, "Node {} holding invalid {}!!", pNode, PWINDOW);
|
||||
|
@ -147,8 +147,14 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
|||
auto* const PGAPSIN = (CCssGapData*)(PGAPSINDATA.ptr())->getData();
|
||||
auto* const PGAPSOUT = (CCssGapData*)(PGAPSOUTDATA.ptr())->getData();
|
||||
|
||||
auto gapsIn = WORKSPACERULE.gapsIn.value_or(*PGAPSIN);
|
||||
auto gapsOut = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT);
|
||||
auto gapsIn = *PGAPSIN;
|
||||
auto gapsOut = *PGAPSOUT;
|
||||
for (auto& wsRule : WORKSPACERULES) {
|
||||
if (wsRule.gapsIn.has_value())
|
||||
gapsIn = wsRule.gapsIn.value();
|
||||
if (wsRule.gapsOut.has_value())
|
||||
gapsOut = wsRule.gapsOut.value();
|
||||
}
|
||||
|
||||
CBox nodeBox = pNode->box;
|
||||
nodeBox.round();
|
||||
|
@ -161,10 +167,17 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
|||
if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) &&
|
||||
(NODESONWORKSPACE == 1 || (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
|
||||
|
||||
PWINDOW->m_sSpecialRenderData.border = WORKSPACERULE.border.value_or(*PNOGAPSWHENONLY == 2);
|
||||
PWINDOW->m_sSpecialRenderData.decorate = WORKSPACERULE.decorate.value_or(true);
|
||||
PWINDOW->m_sSpecialRenderData.rounding = false;
|
||||
PWINDOW->m_sSpecialRenderData.shadow = false;
|
||||
PWINDOW->m_sSpecialRenderData.border = (*PNOGAPSWHENONLY == 2);
|
||||
PWINDOW->m_sSpecialRenderData.decorate = true;
|
||||
|
||||
for (auto& wsRule : WORKSPACERULES) {
|
||||
if (wsRule.border.has_value())
|
||||
PWINDOW->m_sSpecialRenderData.border = wsRule.border.value();
|
||||
if (wsRule.decorate.has_value())
|
||||
PWINDOW->m_sSpecialRenderData.decorate = wsRule.decorate.value();
|
||||
}
|
||||
|
||||
PWINDOW->updateWindowDecos();
|
||||
|
||||
|
|
|
@ -44,11 +44,14 @@ SMasterWorkspaceData* CHyprMasterLayout::getMasterWorkspaceData(const int& ws) {
|
|||
const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
|
||||
PWORKSPACEDATA->workspaceID = ws;
|
||||
static auto PORIENTATION = CConfigValue<std::string>("master:orientation");
|
||||
const auto layoutoptsForWs = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(ws)).layoutopts;
|
||||
const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(g_pCompositor->getWorkspaceByID(ws));
|
||||
|
||||
std::string orientationForWs = *PORIENTATION;
|
||||
|
||||
if (layoutoptsForWs.contains("orientation"))
|
||||
orientationForWs = layoutoptsForWs.at("orientation");
|
||||
for (auto& wsRule : WORKSPACERULES) {
|
||||
if (wsRule.layoutopts.contains("orientation"))
|
||||
orientationForWs = wsRule.layoutopts.at("orientation");
|
||||
}
|
||||
|
||||
if (orientationForWs == "top") {
|
||||
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
||||
|
@ -626,7 +629,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
|||
const auto PWINDOW = pNode->pWindow;
|
||||
// get specific gaps and rules for this workspace,
|
||||
// if user specified them in config
|
||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID));
|
||||
const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID));
|
||||
|
||||
if (PWINDOW->m_bIsFullscreen && !pNode->ignoreFullscreenChecks)
|
||||
return;
|
||||
|
@ -640,8 +643,14 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
|||
auto* PGAPSIN = (CCssGapData*)(PGAPSINDATA.ptr())->getData();
|
||||
auto* PGAPSOUT = (CCssGapData*)(PGAPSOUTDATA.ptr())->getData();
|
||||
|
||||
auto gapsIn = WORKSPACERULE.gapsIn.value_or(*PGAPSIN);
|
||||
auto gapsOut = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT);
|
||||
auto gapsIn = *PGAPSIN;
|
||||
auto gapsOut = *PGAPSOUT;
|
||||
for (auto& wsRule : WORKSPACERULES) {
|
||||
if (wsRule.gapsIn.has_value())
|
||||
gapsIn = wsRule.gapsIn.value();
|
||||
if (wsRule.gapsOut.has_value())
|
||||
gapsOut = wsRule.gapsOut.value();
|
||||
}
|
||||
|
||||
if (!g_pCompositor->windowValidMapped(PWINDOW)) {
|
||||
Debug::log(ERR, "Node {} holding invalid {}!!", pNode, PWINDOW);
|
||||
|
@ -655,10 +664,17 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
|||
(getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 ||
|
||||
(PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
|
||||
|
||||
PWINDOW->m_sSpecialRenderData.border = WORKSPACERULE.border.value_or(*PNOGAPSWHENONLY == 2);
|
||||
PWINDOW->m_sSpecialRenderData.decorate = WORKSPACERULE.decorate.value_or(true);
|
||||
PWINDOW->m_sSpecialRenderData.rounding = false;
|
||||
PWINDOW->m_sSpecialRenderData.shadow = false;
|
||||
PWINDOW->m_sSpecialRenderData.border = (*PNOGAPSWHENONLY == 2);
|
||||
PWINDOW->m_sSpecialRenderData.decorate = true;
|
||||
|
||||
for (auto& wsRule : WORKSPACERULES) {
|
||||
if (wsRule.border.has_value())
|
||||
PWINDOW->m_sSpecialRenderData.border = wsRule.border.value();
|
||||
if (wsRule.decorate.has_value())
|
||||
PWINDOW->m_sSpecialRenderData.decorate = wsRule.decorate.value();
|
||||
}
|
||||
|
||||
PWINDOW->updateWindowDecos();
|
||||
|
||||
|
|
Loading…
Reference in a new issue