Skip to content

[Feat] Custom margin settings - #915

Merged
MalpenZibo merged 8 commits into
MalpenZibo:mainfrom
r3dArch:feat/improve-margin-settings
Sep 17, 2026
Merged

MalpenZibo merged 8 commits into
MalpenZibo:mainfrom
r3dArch:feat/improve-margin-settings

Conversation

@r3dArch

@r3dArch r3dArch commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

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:

1 margin = [10, 20] 2 margin = "xs" 3 margin = 20 4 margin = [50, 20] 5 margin = [10, 20, 30, 40] 6 margin = [10, "xxl", 30, 40]

edit: wrote out the margins for easier parsing.

P.S. I've really enjoyed Ashell, thank you for making it.

@MalpenZibo

Copy link
Copy Markdown
Owner

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.

@r3dArch

r3dArch commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

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.

@r3dArch
r3dArch marked this pull request as draft August 12, 2026 21:49
@r3dArch

r3dArch commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

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.

@r3dArch
r3dArch marked this pull request as ready for review August 18, 2026 23:05
@r3dArch

r3dArch commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

I updated the documentation. Please let me know if there is anything you'd like done differently.

Comment thread src/outputs.rs Outdated
Comment on lines +147 to +148
BarSurface::Solid => 8.,
BarSurface::Transparent => 0.,
BarSurface::Solid => 0.,
BarSurface::Transparent => 8.,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it the opposite now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/outputs.rs
Comment on lines -168 to +161
Position::Top => top,
Position::Bottom => bottom,
Position::Top => bottom,
Position::Bottom => top,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@MalpenZibo MalpenZibo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@MalpenZibo
MalpenZibo merged commit 3b475d5 into MalpenZibo:main Sep 17, 2026
5 checks passed
MalpenZibo added a commit that referenced this pull request Sep 17, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Appearance - Custom margin & padding

2 participants