Soft update

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-07-23 08:48:51 +01:00
parent 129c59dd63
commit f3ca552897
5 changed files with 32 additions and 142 deletions

36
flake.lock generated
View File

@@ -152,11 +152,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1752814804, "lastModified": 1753181343,
"narHash": "sha256-irfg7lnfEpJY+3Cffkluzp2MTVw1Uq9QGxFp6qadcXI=", "narHash": "sha256-CLQfNtUqirNVSYoW/kYbvL4PeeNasmZonaPnjO3+1YQ=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "d0300c8808e41da81d6edfc202f3d3833c157daf", "rev": "0cdfcdbb525b77b951c889b6131047bc374f48fe",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -167,11 +167,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1752687322, "lastModified": 1752950548,
"narHash": "sha256-RKwfXA4OZROjBTQAl9WOZQFm7L8Bo93FQwSJpAiSRvo=", "narHash": "sha256-NS6BLD0lxOrnCiEOcvQCDVPXafX1/ek1dfJHX1nUIzc=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "6e987485eb2c77e5dcc5af4e3c70843711ef9251", "rev": "c87b95e25065c028d31a94f06a62927d18763fdf",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -189,11 +189,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1752908641, "lastModified": 1753254080,
"narHash": "sha256-7fSP4+p5QjWXFbnD4NeVQjtdCSsTMX2yAP1eNDooq4E=", "narHash": "sha256-Z9Q6tI23epzbp9Ox/ujjDdoXXO2OIRJctjPDgnjmgf4=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NUR", "repo": "NUR",
"rev": "ea63ce63073a11274ef327c5eb7f2ebb67606ebe", "rev": "ec8e1c679047de6036c9f9c845f0ae5ff6bb8c49",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -212,11 +212,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1752555591, "lastModified": 1753078133,
"narHash": "sha256-3u29/v6VCHnaXjkMmjgwIGzR4Oul9EVHqxgJB6xTN0w=", "narHash": "sha256-z+cvobe/+6pSVmwVrI+/k4lt7CjsQtfhlMaAlLQcSPY=",
"owner": "icewind1991", "owner": "icewind1991",
"repo": "nvidia-patch-nixos", "repo": "nvidia-patch-nixos",
"rev": "1140fd66d2f7e0be1a72ac9fdc32fffe4bb371e5", "rev": "b5bb7576a5a951cea1a46703f488ac76fa827876",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -288,11 +288,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1752381641, "lastModified": 1752986956,
"narHash": "sha256-R2iDZb94RosuCeuIukacZVVXxzWYr4jn/QI/ax15nW8=", "narHash": "sha256-1AK8+W7d5eNyGRkcWHa+9oIChLJbY6jt7ujSJo+ft4M=",
"owner": "Gerg-L", "owner": "Gerg-L",
"repo": "spicetify-nix", "repo": "spicetify-nix",
"rev": "8f9fd947c52aa6adb6bafe72516eccf186708954", "rev": "51ac0aee7e7ee21ca0874b913f07f9004bc9311f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -323,11 +323,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1752909129, "lastModified": 1753006367,
"narHash": "sha256-Eh8FkMvGRaY71BU/oyZTTzt9RsBIq2E6j0r3eLZ/2kY=", "narHash": "sha256-tzbhc4XttkyEhswByk5R38l+ztN9UDbnj0cTcP6Hp9A=",
"owner": "numtide", "owner": "numtide",
"repo": "treefmt-nix", "repo": "treefmt-nix",
"rev": "0043b95d80b5bf6d61e84d237e2007727f4dd38d", "rev": "421b56313c65a0815a52b424777f55acf0b56ddf",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -1,78 +0,0 @@
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index c6593923..b4d3aaea 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -2890,6 +2890,30 @@ void CCompositor::arrangeMonitors() {
case eAutoDirs::DIR_AUTO_LEFT: newPosition.x = maxXOffsetLeft - m->m_size.x; break;
case eAutoDirs::DIR_AUTO_RIGHT:
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();
}
Debug::log(LOG, "arrangeMonitors: {} auto {:j}", m->m_name, m->m_position);
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index f5f0bed3..3c988a53 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -2046,10 +2046,20 @@ std::optional<std::string> CConfigManager::handleMonitor(const std::string& comm
newrule.autoDir = eAutoDirs::DIR_AUTO_UP;
else if (ARGS[2] == "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 {
Debug::log(WARN,
"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 ";
}
} else {
diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp
index 31777b0c..019a5547 100644
--- a/src/helpers/Monitor.hpp
+++ b/src/helpers/Monitor.hpp
@@ -25,7 +25,11 @@ enum eAutoDirs : uint8_t {
DIR_AUTO_UP,
DIR_AUTO_DOWN,
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 {

View File

@@ -10,8 +10,7 @@
(final: prev: { (final: prev: {
hyprland = prev.hyprland.overrideAttrs (oldAttrs: { hyprland = prev.hyprland.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [ ] ++ [ patches = oldAttrs.patches or [ ] ++ [
./auto-center.patch ./fix-maxwidth-resolution-mode.patch
./maxwidth-resolution-mode.patch
]; ];
}); });
}) })

View File

@@ -0,0 +1,13 @@
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 635c7977..80093c0d 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -2091,6 +2091,8 @@ bool CMonitorRuleParser::parseMode(const std::string& value) {
m_rule.resolution = Vector2D(-1, -1);
else if (value.starts_with("highres"))
m_rule.resolution = Vector2D(-1, -2);
+ else if (value.starts_with("maxwidth"))
+ m_rule.resolution = Vector2D(-1, -3);
else if (parseModeLine(value, m_rule.drmMode)) {
m_rule.resolution = Vector2D(m_rule.drmMode.hdisplay, m_rule.drmMode.vdisplay);
m_rule.refreshRate = float(m_rule.drmMode.vrefresh) / 1000;

View File

@@ -1,44 +0,0 @@
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index f5f0bed3..cfe39b70 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -2013,6 +2013,8 @@ std::optional<std::string> CConfigManager::handleMonitor(const std::string& comm
newrule.resolution = Vector2D(-1, -1);
} else if (ARGS[1].starts_with("highres")) {
newrule.resolution = Vector2D(-1, -2);
+ } else if (ARGS[1].starts_with("maxwidth")) {
+ newrule.resolution = Vector2D(-1, -3);
} else if (parseModeLine(ARGS[1], newrule.drmMode)) {
newrule.resolution = Vector2D(newrule.drmMode.hdisplay, newrule.drmMode.vdisplay);
newrule.refreshRate = float(newrule.drmMode.vrefresh) / 1000;
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index 4dc0942d..72a221f5 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -515,7 +515,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
} else if (RULE->resolution == Vector2D(-1, -2)) {
requestedStr = "highres";
- // sort prioritizing resultion 1st and refresh rate 2nd, then add best 3
+ // sort prioritizing resolution 1st and refresh rate 2nd, then add best 3
addBest3Modes([](auto const& a, auto const& b) {
if (a->pixelSize.x > b->pixelSize.x && a->pixelSize.y > b->pixelSize.y)
return true;
@@ -524,6 +524,17 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
return true;
return false;
});
+ } else if (RULE->resolution == Vector2D(-1, -3)) {
+ requestedStr = "maxwidth";
+
+ // sort prioritizing widest resolution 1st and refresh rate 2nd, then add best 3
+ addBest3Modes([](auto const& a, auto const& b) {
+ if (a->pixelSize.x > b->pixelSize.x)
+ return true;
+ if (a->pixelSize.x == b->pixelSize.x && std::round(a->refreshRate) > std::round(b->refreshRate))
+ return true;
+ return false;
+ });
} else if (RULE->resolution != Vector2D()) {
// user requested mode
requestedStr = std::format("{:X0}@{:.2f}Hz", RULE->resolution, RULE->refreshRate);