Add hyprland patches

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-05-25 01:27:07 +01:00
parent 3610611615
commit d995698feb
7 changed files with 168 additions and 44 deletions

View File

@@ -0,0 +1,78 @@
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

@@ -9,6 +9,17 @@
...
}:
{
nixpkgs.overlays = [
(final: prev: {
hyprland = prev.hyprland.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [ ] ++ [
./auto-center.patch
./maxwidth-resolution-mode.patch
];
});
})
];
programs.hyprland.enable = true;
home-manager.users.${user} = {
@@ -106,6 +117,7 @@
general.layout = "master";
master = {
orientation = "center";
slave_count_for_center_master = 0;
mfact = 0.5;
};

View File

@@ -0,0 +1,44 @@
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);

View File

@@ -392,7 +392,7 @@ in
size = mkOption {
type = ints.positive;
default = 32;
default = 24;
description = "The cursor size.";
};
};