Files
nix/hosts/common/configs/user/gui/hyprland/maxwidth-resolution-mode.patch
Nikolaos Karaolidis d995698feb Add hyprland patches
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-05-25 01:27:07 +01:00

45 lines
2.2 KiB
Diff

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);