From 1c1c666f578568425f68671080c822342098e2ee Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Thu, 31 Aug 2023 00:44:40 -0400 Subject: [PATCH] overlays: Patch hyprland window sizes Fixes an issue where 1 pixel gaps would exist where window sizes would otherwise divide evenly. --- overlays/default.nix | 1 + overlays/hyprland.nix | 10 ++++++++++ patches/hyprland-window-sizes.patch | 24 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 overlays/hyprland.nix create mode 100644 patches/hyprland-window-sizes.patch diff --git a/overlays/default.nix b/overlays/default.nix index 855e6c6..59af105 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,5 +1,6 @@ { imports = [ ./alejandra.nix + ./hyprland.nix ]; } diff --git a/overlays/hyprland.nix b/overlays/hyprland.nix new file mode 100644 index 0000000..e25bdfc --- /dev/null +++ b/overlays/hyprland.nix @@ -0,0 +1,10 @@ +{ + nixpkgs.overlays = [ + (final: prev: { + hyprland = prev.hyprland.overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ ../patches/hyprland-window-sizes.patch ]; + }); + }) + ]; +} + diff --git a/patches/hyprland-window-sizes.patch b/patches/hyprland-window-sizes.patch new file mode 100644 index 0000000..0267161 --- /dev/null +++ b/patches/hyprland-window-sizes.patch @@ -0,0 +1,24 @@ +diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp +index 1d22935f..b6093676 100644 +--- a/src/render/Renderer.cpp ++++ b/src/render/Renderer.cpp +@@ -266,7 +266,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* + static auto* const PDIMAROUND = &g_pConfigManager->getConfigValuePtr("decoration:dim_around")->floatValue; + static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; + +- SRenderData renderdata = {pMonitor, time, REALPOS.x, REALPOS.y}; ++ SRenderData renderdata = {pMonitor, time, std::round(REALPOS.x), std::round(REALPOS.y)}; + if (ignorePosition) { + renderdata.x = pMonitor->vecPosition.x; + renderdata.y = pMonitor->vecPosition.y; +@@ -276,8 +276,8 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* + decorate = false; + + renderdata.surface = pWindow->m_pWLSurface.wlr(); +- renderdata.w = std::max(pWindow->m_vRealSize.vec().x, 5.0); // clamp the size to min 5, +- renderdata.h = std::max(pWindow->m_vRealSize.vec().y, 5.0); // otherwise we'll have issues later with invalid boxes ++ renderdata.w = std::round(std::max(pWindow->m_vRealSize.vec().x, 5.0)); // clamp the size to min 5, ++ renderdata.h = std::round(std::max(pWindow->m_vRealSize.vec().y, 5.0)); // otherwise we'll have issues later with invalid boxes + renderdata.dontRound = (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) || (!pWindow->m_sSpecialRenderData.rounding); + renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (pWindow->m_bPinned ? 1.f : PWORKSPACE->m_fAlpha.fl()); + renderdata.alpha = pWindow->m_fActiveInactiveAlpha.fl();