mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-14 16:45:58 +01:00
add position auto for mon config
This commit is contained in:
parent
5dcbce550f
commit
81308a9cc3
2 changed files with 33 additions and 8 deletions
|
@ -453,6 +453,9 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
||||||
|
|
||||||
nextItem();
|
nextItem();
|
||||||
|
|
||||||
|
if (curitem.find("auto") == 0) {
|
||||||
|
newrule.offset = Vector2D(-1, -1);
|
||||||
|
} else {
|
||||||
newrule.offset.x = stoi(curitem.substr(0, curitem.find_first_of('x')));
|
newrule.offset.x = stoi(curitem.substr(0, curitem.find_first_of('x')));
|
||||||
newrule.offset.y = stoi(curitem.substr(curitem.find_first_of('x') + 1));
|
newrule.offset.y = stoi(curitem.substr(curitem.find_first_of('x') + 1));
|
||||||
|
|
||||||
|
@ -460,6 +463,7 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
||||||
parseError = "invalid offset. Offset cannot be negative.";
|
parseError = "invalid offset. Offset cannot be negative.";
|
||||||
newrule.offset = Vector2D();
|
newrule.offset = Vector2D();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nextItem();
|
nextItem();
|
||||||
|
|
||||||
|
|
|
@ -785,7 +785,14 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the rule isn't already applied
|
// Check if the rule isn't already applied
|
||||||
if (!force && DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1) && DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale && DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1) && pMonitor->transform == pMonitorRule->transform) {
|
if (!force
|
||||||
|
&& DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1)
|
||||||
|
&& DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1)
|
||||||
|
&& DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1)
|
||||||
|
&& pMonitor->scale == pMonitorRule->scale
|
||||||
|
&& ((DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1)) || pMonitorRule->offset == Vector2D(-1, -1))
|
||||||
|
&& pMonitor->transform == pMonitorRule->transform) {
|
||||||
|
|
||||||
Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str());
|
Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -916,9 +923,23 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor();
|
pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor();
|
||||||
pMonitor->vecTransformedSize = Vector2D(x,y);
|
pMonitor->vecTransformedSize = Vector2D(x,y);
|
||||||
|
|
||||||
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, pMonitor->output, (int)pMonitorRule->offset.x, (int)pMonitorRule->offset.y);
|
if (pMonitorRule->offset == Vector2D(-1, -1)) {
|
||||||
|
// let's find manually a sensible position for it, to the right.
|
||||||
|
Vector2D finalPos;
|
||||||
|
|
||||||
//wlr_output_damage_add_whole(pMonitor->damage);
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||||
|
if (m->ID == pMonitor->ID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (m->vecPosition.x + std::ceil(m->vecSize.x) > finalPos.x) {
|
||||||
|
finalPos.x = m->vecPosition.x + std::ceil(m->vecSize.x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pMonitor->vecPosition = finalPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, pMonitor->output, (int)pMonitor->vecPosition.x, (int)pMonitor->vecPosition.y);
|
||||||
|
|
||||||
wlr_output_enable(pMonitor->output, true);
|
wlr_output_enable(pMonitor->output, true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue