ui-egui: fix Windows clippy in desktop_theme (#872)

Bus is a unit struct off Linux, so Bus::default() tripped
clippy::default_constructed_unit_structs on Windows and macOS. Each
platform's Bus now has a plain constructor.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas 2026-10-12 05:36:02 -04:00 committed by GitHub
parent de8a3daf31
commit 956963e9d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 4 deletions

View File

@ -16,7 +16,7 @@ const POLL: Duration = Duration::from_secs(4);
/// there is no session bus or no portal to ask (a bare X server, a container), so the caller
/// keeps whatever it chose itself.
pub fn prefers_dark() -> Option<bool> {
read(&mut Bus::default())
read(&mut Bus::new())
}
/// Watches the desktop and reports its choice when it changes. [`prefers_dark`] covers the
@ -38,7 +38,7 @@ impl DesktopTheme {
let started = std::thread::Builder::new().name("wordcraft-desktop-theme".into()).spawn(move || {
// One session-bus connection for the life of the watcher, opened again only after
// it fails.
let mut bus = Bus::default();
let mut bus = Bus::new();
let mut last = read(&mut bus);
if tx.send(last).is_err() {
return;
@ -81,13 +81,27 @@ impl DesktopTheme {
/// The watcher's session-bus connection, kept between polls.
#[cfg(target_os = "linux")]
#[derive(Default)]
struct Bus(Option<zbus::blocking::Connection>);
#[cfg(target_os = "linux")]
impl Bus {
/// No connection yet: the first read opens one.
fn new() -> Self {
Bus(None)
}
}
/// Elsewhere there is no session bus to keep.
#[cfg(not(target_os = "linux"))]
#[derive(Default)]
struct Bus;
#[cfg(not(target_os = "linux"))]
impl Bus {
fn new() -> Self {
Bus
}
}
/// Ask the portal once, over `bus`'s connection (opened when there is none). D-Bus calls
/// block, so this belongs off the UI thread. A connection whose calls all fail is dropped, so
/// the next poll opens a fresh one (the bus or portal may have restarted).