YaLTeR / niri

A scrollable-tiling Wayland compositor.
https://matrix.to/#/#niri:matrix.org
GNU General Public License v3.0
3.93k stars 118 forks source link

Visible window borders with negative struts for maximized windows due to scale rounding #640

Open sugar700 opened 2 months ago

sugar700 commented 2 months ago

With the following layout configuration (https://git.gay/sugar/nix-config/src/commit/aa22a9fbae6c1a675a462430809e1e19158a9be9/desktop/home-manager/user/niri.nix), borders are visible for maximized windows at 1.25x scale. This doesn't happen at 1x scale.

layout {
    gaps 0
    struts {
        left -6
        right -6
        top -6
        bottom -6
    }
    focus-ring { off; }
    border {
        width 6
        active-color "#f5a9B8"
        inactive-color "#415a0c"
    }
    preset-column-widths
    default-column-width
    center-focused-column "never"
}

screenshot of niri with borders

(after zooming in onto this picture, pink window borders are visible)

This appears to happen due to effective width being 6 * 1.25 = 7.5, which is not an integer, resulting in rounding issues.

I don't know if it is an issue, considering it's not clear what the behavior should be here (fractional scaling rounding issues make everything tricky), but figured I would report it just in case.

System Information

YaLTeR commented 2 months ago

I suspect what's happening here is that negative struts are rounded to physical pixels, then the border size is also rounded to physical pixels, and these two roundings happen to result in 1 px of border being visible. I can't say off the bat whether this is something that can reasonably be fixed in the code (since borders are per-window and it doesn't make sense to take them into account in that particular spot). You could try adjusting the struts or the border width so that it works for your scale and setup.

sugar700 commented 2 months ago

Using 6.4 value for both of those helped avoid this issue in this case (6.4 * 1.25 = 8).