core: add auto-center arrangements (#10527)
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
parent
ddb9f8394d
commit
90d0b8ecae
3 changed files with 40 additions and 2 deletions
|
|
@ -2890,6 +2890,30 @@ void CCompositor::arrangeMonitors() {
|
||||||
case eAutoDirs::DIR_AUTO_LEFT: newPosition.x = maxXOffsetLeft - m->m_size.x; break;
|
case eAutoDirs::DIR_AUTO_LEFT: newPosition.x = maxXOffsetLeft - m->m_size.x; break;
|
||||||
case eAutoDirs::DIR_AUTO_RIGHT:
|
case eAutoDirs::DIR_AUTO_RIGHT:
|
||||||
case eAutoDirs::DIR_AUTO_NONE: newPosition.x = maxXOffsetRight; break;
|
case eAutoDirs::DIR_AUTO_NONE: newPosition.x = maxXOffsetRight; break;
|
||||||
|
case eAutoDirs::DIR_AUTO_CENTER_UP: {
|
||||||
|
int width = maxXOffsetRight - maxXOffsetLeft;
|
||||||
|
newPosition.y = maxYOffsetUp - m->m_size.y;
|
||||||
|
newPosition.x = maxXOffsetLeft + (width - m->m_size.x) / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case eAutoDirs::DIR_AUTO_CENTER_DOWN: {
|
||||||
|
int width = maxXOffsetRight - maxXOffsetLeft;
|
||||||
|
newPosition.y = maxYOffsetDown;
|
||||||
|
newPosition.x = maxXOffsetLeft + (width - m->m_size.x) / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case eAutoDirs::DIR_AUTO_CENTER_LEFT: {
|
||||||
|
int height = maxYOffsetDown - maxYOffsetUp;
|
||||||
|
newPosition.x = maxXOffsetLeft - m->m_size.x;
|
||||||
|
newPosition.y = maxYOffsetUp + (height - m->m_size.y) / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case eAutoDirs::DIR_AUTO_CENTER_RIGHT: {
|
||||||
|
int height = maxYOffsetDown - maxYOffsetUp;
|
||||||
|
newPosition.x = maxXOffsetRight;
|
||||||
|
newPosition.y = maxYOffsetUp + (height - m->m_size.y) / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: UNREACHABLE();
|
default: UNREACHABLE();
|
||||||
}
|
}
|
||||||
Debug::log(LOG, "arrangeMonitors: {} auto {:j}", m->m_name, m->m_position);
|
Debug::log(LOG, "arrangeMonitors: {} auto {:j}", m->m_name, m->m_position);
|
||||||
|
|
|
||||||
|
|
@ -2049,10 +2049,20 @@ 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 if (ARGS[2] == "auto-center-right")
|
||||||
|
newrule.autoDir = eAutoDirs::DIR_AUTO_CENTER_RIGHT;
|
||||||
|
else if (ARGS[2] == "auto-center-left")
|
||||||
|
newrule.autoDir = eAutoDirs::DIR_AUTO_CENTER_LEFT;
|
||||||
|
else if (ARGS[2] == "auto-center-up")
|
||||||
|
newrule.autoDir = eAutoDirs::DIR_AUTO_CENTER_UP;
|
||||||
|
else if (ARGS[2] == "auto-center-down")
|
||||||
|
newrule.autoDir = eAutoDirs::DIR_AUTO_CENTER_DOWN;
|
||||||
else {
|
else {
|
||||||
Debug::log(WARN,
|
Debug::log(WARN,
|
||||||
"Invalid auto direction. Valid options are 'auto',"
|
"Invalid auto direction. Valid options are 'auto',"
|
||||||
"'auto-up', 'auto-down', 'auto-left', and 'auto-right'.");
|
"'auto-up', 'auto-down', 'auto-left', 'auto-right',"
|
||||||
|
"'auto-center-up', 'auto-center-down',"
|
||||||
|
"'auto-center-left', and 'auto-center-right'.");
|
||||||
error += "invalid auto direction ";
|
error += "invalid auto direction ";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,11 @@ enum eAutoDirs : uint8_t {
|
||||||
DIR_AUTO_UP,
|
DIR_AUTO_UP,
|
||||||
DIR_AUTO_DOWN,
|
DIR_AUTO_DOWN,
|
||||||
DIR_AUTO_LEFT,
|
DIR_AUTO_LEFT,
|
||||||
DIR_AUTO_RIGHT
|
DIR_AUTO_RIGHT,
|
||||||
|
DIR_AUTO_CENTER_UP,
|
||||||
|
DIR_AUTO_CENTER_DOWN,
|
||||||
|
DIR_AUTO_CENTER_LEFT,
|
||||||
|
DIR_AUTO_CENTER_RIGHT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eCMType : uint8_t {
|
enum eCMType : uint8_t {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue