mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 23:06:00 +01:00
config: Default unconfigured monitors to open to the right (#5741)
* config: default unconfigured monitors to open to the right * monitor: improve logging for auto positioning
This commit is contained in:
parent
faa9017043
commit
e87227e00a
2 changed files with 34 additions and 21 deletions
|
@ -2732,7 +2732,7 @@ void CCompositor::arrangeMonitors() {
|
||||||
|
|
||||||
if (m->activeMonitorRule.offset != Vector2D{-INT32_MAX, -INT32_MAX}) {
|
if (m->activeMonitorRule.offset != Vector2D{-INT32_MAX, -INT32_MAX}) {
|
||||||
// explicit.
|
// explicit.
|
||||||
Debug::log(LOG, "arrangeMonitors: {} explicit {:j2}", m->szName, m->activeMonitorRule.offset);
|
Debug::log(LOG, "arrangeMonitors: {} explicit {:j}", m->szName, m->activeMonitorRule.offset);
|
||||||
|
|
||||||
m->moveTo(m->activeMonitorRule.offset);
|
m->moveTo(m->activeMonitorRule.offset);
|
||||||
arranged.push_back(m);
|
arranged.push_back(m);
|
||||||
|
@ -2767,33 +2767,37 @@ void CCompositor::arrangeMonitors() {
|
||||||
|
|
||||||
// Iterates through all non-explicitly placed monitors.
|
// Iterates through all non-explicitly placed monitors.
|
||||||
for (auto& m : toArrange) {
|
for (auto& m : toArrange) {
|
||||||
Debug::log(LOG, "arrangeMonitors: {} auto [{}, {:.2f}]", m->szName, maxXOffsetRight, 0.f);
|
|
||||||
// Moves the monitor to their appropriate position on the x/y axis and
|
// Moves the monitor to their appropriate position on the x/y axis and
|
||||||
// increments/decrements the corresponding max offset.
|
// increments/decrements the corresponding max offset.
|
||||||
if (m->activeMonitorRule.autoDir == eAutoDirs::DIR_AUTO_UP) {
|
Vector2D newPosition = {0, 0};
|
||||||
m->moveTo({0, maxYOffsetUp - m->vecSize.y});
|
switch (m->activeMonitorRule.autoDir) {
|
||||||
maxYOffsetUp = m->vecPosition.y;
|
case eAutoDirs::DIR_AUTO_UP:
|
||||||
} else if (m->activeMonitorRule.autoDir == eAutoDirs::DIR_AUTO_DOWN) {
|
newPosition.y = maxYOffsetUp - m->vecSize.y;
|
||||||
m->moveTo({0, maxYOffsetDown});
|
maxYOffsetUp = newPosition.y;
|
||||||
maxYOffsetDown += m->vecSize.y;
|
break;
|
||||||
} else if (m->activeMonitorRule.autoDir == eAutoDirs::DIR_AUTO_LEFT) {
|
case eAutoDirs::DIR_AUTO_DOWN:
|
||||||
m->moveTo({maxXOffsetLeft - m->vecSize.x, 0});
|
newPosition.y = maxYOffsetDown;
|
||||||
maxXOffsetLeft = m->vecPosition.x;
|
maxYOffsetDown += m->vecSize.y;
|
||||||
} else if (m->activeMonitorRule.autoDir == eAutoDirs::DIR_AUTO_RIGHT) {
|
break;
|
||||||
m->moveTo({maxXOffsetRight, 0});
|
case eAutoDirs::DIR_AUTO_LEFT:
|
||||||
maxXOffsetRight += m->vecSize.x;
|
newPosition.x = maxXOffsetLeft - m->vecSize.x;
|
||||||
} else {
|
maxXOffsetLeft = newPosition.x;
|
||||||
Debug::log(WARN,
|
break;
|
||||||
"Invalid auto direction. Valid options are 'auto',"
|
case eAutoDirs::DIR_AUTO_RIGHT:
|
||||||
"'auto-up', 'auto-down', 'auto-left', and 'auto-right'.");
|
newPosition.x = maxXOffsetRight;
|
||||||
|
maxXOffsetRight += m->vecSize.x;
|
||||||
|
break;
|
||||||
|
default: UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
Debug::log(LOG, "arrangeMonitors: {} auto {:j}", m->szName, m->vecPosition);
|
||||||
|
m->moveTo(newPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset maxXOffsetRight (reuse)
|
// reset maxXOffsetRight (reuse)
|
||||||
// and set xwayland positions aka auto for all
|
// and set xwayland positions aka auto for all
|
||||||
maxXOffsetRight = 0;
|
maxXOffsetRight = 0;
|
||||||
for (auto& m : m_vMonitors) {
|
for (auto& m : m_vMonitors) {
|
||||||
Debug::log(LOG, "arrangeMonitors: {} xwayland [{}, {:.2f}]", m->szName, maxXOffsetRight, 0.f);
|
Debug::log(LOG, "arrangeMonitors: {} xwayland [{}, {}]", m->szName, maxXOffsetRight, 0);
|
||||||
m->vecXWaylandPosition = {maxXOffsetRight, 0};
|
m->vecXWaylandPosition = {maxXOffsetRight, 0};
|
||||||
maxXOffsetRight += (*PXWLFORCESCALEZERO ? m->vecTransformedSize.x : m->vecSize.x);
|
maxXOffsetRight += (*PXWLFORCESCALEZERO ? m->vecTransformedSize.x : m->vecSize.x);
|
||||||
|
|
||||||
|
|
|
@ -966,7 +966,11 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const CMonitor& PMONITOR) {
|
||||||
|
|
||||||
Debug::log(WARN, "No rules configured. Using the default hardcoded one.");
|
Debug::log(WARN, "No rules configured. Using the default hardcoded one.");
|
||||||
|
|
||||||
return SMonitorRule{.name = "", .resolution = Vector2D(0, 0), .offset = Vector2D(-INT32_MAX, -INT32_MAX), .scale = -1}; // 0, 0 is preferred and -1, -1 is auto
|
return SMonitorRule{.autoDir = eAutoDirs::DIR_AUTO_RIGHT,
|
||||||
|
.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(PHLWORKSPACE pWorkspace) {
|
SWorkspaceRule CConfigManager::getWorkspaceRuleFor(PHLWORKSPACE pWorkspace) {
|
||||||
|
@ -1655,7 +1659,12 @@ std::optional<std::string> CConfigManager::handleMonitor(const std::string& comm
|
||||||
newrule.autoDir = eAutoDirs::DIR_AUTO_UP;
|
newrule.autoDir = eAutoDirs::DIR_AUTO_UP;
|
||||||
else if (ARGS[2] == "auto-down")
|
else if (ARGS[2] == "auto-down")
|
||||||
newrule.autoDir = eAutoDirs::DIR_AUTO_DOWN;
|
newrule.autoDir = eAutoDirs::DIR_AUTO_DOWN;
|
||||||
|
else {
|
||||||
|
Debug::log(WARN,
|
||||||
|
"Invalid auto direction. Valid options are 'auto',"
|
||||||
|
"'auto-up', 'auto-down', 'auto-left', and 'auto-right'.");
|
||||||
|
error += "invalid auto direction ";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!ARGS[2].contains("x")) {
|
if (!ARGS[2].contains("x")) {
|
||||||
error += "invalid offset ";
|
error += "invalid offset ";
|
||||||
|
|
Loading…
Reference in a new issue