Skip to content

Conversation

Cheong-Lau
Copy link
Contributor

@Cheong-Lau Cheong-Lau commented Oct 4, 2025

Some minor refactors like removing clone()s, replacing with references, using the unstable versions of sort where the original order wasn't likely to matter, etc.

There's also a new std::cmp::Ord impl for ActiveConnectionInfo, which should be heaps better than using format!. I had to also impl std::cmp::PartialCmp manually to do that, but the actual logic there shouldn't matter as long as it agrees with std::cmp::Ord.

@Cheong-Lau
Copy link
Contributor Author

oops, used str::from_utf8 instead of std::str::from_utf8. Turns out the former was only added in 1.87...

Comment on lines -180 to +197
let dots = if toplevels.is_empty() {
(0..1)
.map(|_| {
container(vertical_space().height(Length::Fixed(0.0)))
.padding(app_icon.dot_radius)
.into()
})
.collect_vec()
} else {
(0..1)
.map(|_| {
container(if toplevels.len() == 1 {
vertical_space().height(Length::Fixed(0.0))
} else {
match applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => {
vertical_space().height(app_icon.bar_size)
}
PanelAnchor::Top | PanelAnchor::Bottom => {
horizontal_space().width(app_icon.bar_size)
}
}
})
.padding(app_icon.dot_radius)
.class(theme::style::Container::Custom(Box::new(move |theme| {
let dot_constructor = || {
let space = if toplevels.len() <= 1 {
vertical_space().height(Length::Fixed(0.0))
} else {
match applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => {
vertical_space().height(app_icon.bar_size)
}
PanelAnchor::Top | PanelAnchor::Bottom => {
horizontal_space().width(app_icon.bar_size)
}
}
};
let mut container = container(space).padding(app_icon.dot_radius);

if !toplevels.is_empty() {
container =
container.class(theme::style::Container::Custom(Box::new(move |theme| {
Copy link
Contributor Author

@Cheong-Lau Cheong-Lau Oct 5, 2025

Choose a reason for hiding this comment

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

I refactored this section completely, so I'd like a more thorough check of this part in particular.

I moved the logic of making the Elements into its own closure (better variable names are very welcome!), which should make the same Elements as before, just separate to the collection part and hopefully clearer. Then just make an iterator with std::iter::repeat_with, which avoids the whole mess of mapping and collecting an iterator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant