[Feat] Custom margin settings - #915
Conversation
|
Check this #867 We already added a margin settings. For now it uses the spacing scale from the DS token but we don't have yet a way to change that scale. |
|
This PR builds on that one. It still allows specifying the margin as in #867, but also allows specifying it in pixels. To make the implementation simpler I removed margin scaling since I think most users would want to work with physical pixels, not scaled pixels; if you want, I can add scaling for just the space size margins, but I think it won't matter to most users. |
|
I would still need to update the docs as in #867, so I've made this PR a draft for now. Please let me know if this is something you would want to merge and I'll update the docs and make any requested changes. |
|
I updated the documentation. Please let me know if there is anything you'd like done differently. |
| BarSurface::Solid => 8., | ||
| BarSurface::Transparent => 0., | ||
| BarSurface::Solid => 0., | ||
| BarSurface::Transparent => 8., |
There was a problem hiding this comment.
I had changed the transparent to be 8 because I removed the padding, but I think the solid should still be 8, so I could probably remove this match and make HEIGHT = 26 instead. I'll push some changes soon.
| Position::Top => top, | ||
| Position::Bottom => bottom, | ||
| Position::Top => bottom, | ||
| Position::Bottom => top, |
There was a problem hiding this comment.
This is because the exclusive zone pushes other windows away from the bar, so when the bar is on the bottom it is the top margin that determines the exclusive zone and vice versa. I've retested this and it seems to work as expected.
Layer-shell accepts negative margins and pushes the surface off screen when it gets one, so `margin = -100` makes the bar vanish with nothing to explain why. TOML also admits `nan` and `inf`, which reach `set_margin` as a saturating cast. Clamp negative and non-finite pixel margins to 0 with a warning, matching how volume_step and max_volume are already handled.
Margins are applied by the compositor outside the bar surface, so unlike the bar height they are not multiplied by scale_factor. That is a change from the previous behaviour and is otherwise silent: a scale_factor of 2 used to double the gap and no longer does.
The bar had a hardcoded `[xxs, xxs]` padding applied only to the transparent surface, so the inset was neither configurable nor available to solid bars. #915 removes that padding in favour of `margin`, which leaves a bar with no configuration sitting flush against the screen edge. `margin` is not a substitute for it. It moves the layer surface itself, so the gap belongs to the compositor: a solid bar stops spanning the full width, and the bar no longer receives clicks or scroll events at the screen edge, which is the easiest place to aim at. Padding keeps the surface where it is and insets only the content, so the solid background still reaches both edges and the whole bar stays reachable. Add `[appearance.bar].padding` with the same CSS shorthand and value types as `margin`, defaulting to `xxs`. `HEIGHT` now describes the content, and the surface is the content plus the vertical padding, so the default reproduces the current transparent height exactly. Padding is drawn inside the surface and therefore scales with `scale_factor`, unlike `margin`, which the compositor applies in screen pixels. Solid bars grow by 8px at the default, which is the intended change: the content is no longer flush against the screen edge.
Closes #351
This allows for custom margin size in pixels without breaking the old margin system, although it removes the scaling that was applied to the old margins.
Samples with config:
edit: wrote out the margins for easier parsing.
P.S. I've really enjoyed Ashell, thank you for making it.