Skip to content

Commit 5a801c6

Browse files
committed
apply rustfmt
1 parent 86828a0 commit 5a801c6

File tree

2 files changed

+41
-24
lines changed

2 files changed

+41
-24
lines changed

src/components/app.rs

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ use cosmic::{
1616
alignment::Horizontal,
1717
event::{
1818
self, listen_with,
19-
wayland::{self, LayerEvent, OverlapNotifyEvent, OutputEvent},
19+
wayland::{self, LayerEvent, OutputEvent, OverlapNotifyEvent},
2020
},
2121
keyboard::{Key, key::Named},
2222
platform_specific::shell::commands::activation::request_token,
2323
time,
2424
window::Id as SurfaceId,
2525
},
26-
iced_runtime::platform_specific::wayland::layer_surface::{IcedOutput, SctkLayerSurfaceSettings},
26+
iced_runtime::platform_specific::wayland::layer_surface::{
27+
IcedOutput, SctkLayerSurfaceSettings,
28+
},
2729
iced_winit::commands::layer_surface::{
2830
Anchor, KeyboardInteractivity, destroy_layer_surface, get_layer_surface,
2931
},
@@ -67,8 +69,8 @@ pub struct Args {
6769
pub enum OsdTask {
6870
#[clap(about = "Display external display toggle indicator")]
6971
Display,
70-
#[clap(about = "Show numbers on all displays for identification", name = "identify-displays")]
71-
DisplayIdentifier,
72+
#[clap(about = "Show numbers on all displays for identification")]
73+
IdentifyDisplays,
7274
#[clap(about = "Toggle the on screen display and start the log out timer")]
7375
LogOut,
7476
#[clap(about = "Toggle the on screen display and start the restart timer")]
@@ -117,7 +119,7 @@ impl OsdTask {
117119
.map(msg),
118120
OsdTask::Touchpad => Task::none(),
119121
OsdTask::Display => Task::none(),
120-
OsdTask::DisplayIdentifier => Task::none(),
122+
OsdTask::IdentifyDisplays => Task::none(),
121123
}
122124
}
123125
}
@@ -515,7 +517,9 @@ impl cosmic::Application for App {
515517
if let Some(state) = state {
516518
self.surfaces.insert(id, Surface::OsdIndicator(state));
517519
}
518-
return cmd.map(move |msg| cosmic::action::app(Msg::DisplayIdentifierSurface((id, msg))));
520+
return cmd.map(move |msg| {
521+
cosmic::action::app(Msg::DisplayIdentifierSurface((id, msg)))
522+
});
519523
}
520524
Task::none()
521525
}
@@ -766,7 +770,9 @@ impl cosmic::Application for App {
766770
);
767771

768772
self.surfaces.insert(id, Surface::OsdIndicator(state));
769-
tasks.push(cmd.map(move |msg| cosmic::action::app(Msg::DisplayIdentifierSurface((id, msg)))));
773+
tasks.push(cmd.map(move |msg| {
774+
cosmic::action::app(Msg::DisplayIdentifierSurface((id, msg)))
775+
}));
770776
}
771777

772778
Task::batch(tasks)
@@ -840,10 +846,16 @@ impl cosmic::Application for App {
840846
_ => None,
841847
}));
842848

843-
subscriptions.extend(self.surfaces.iter().filter_map(|(id, surface)| match surface {
844-
Surface::PolkitDialog(state) => Some(state.subscription().with(*id).map(Msg::PolkitDialog)),
845-
Surface::OsdIndicator(_) => None, // OSD indicators don't have subscriptions
846-
}));
849+
subscriptions.extend(
850+
self.surfaces
851+
.iter()
852+
.filter_map(|(id, surface)| match surface {
853+
Surface::PolkitDialog(state) => {
854+
Some(state.subscription().with(*id).map(Msg::PolkitDialog))
855+
}
856+
Surface::OsdIndicator(_) => None, // OSD indicators don't have subscriptions
857+
}),
858+
);
847859
if self.action_to_confirm.is_some() {
848860
subscriptions.push(time::every(Duration::from_millis(1000)).map(|_| Msg::Countdown));
849861
}
@@ -861,9 +873,9 @@ impl cosmic::Application for App {
861873
Surface::PolkitDialog(state) => {
862874
state.view().map(move |msg| Msg::PolkitDialog((id, msg)))
863875
}
864-
Surface::OsdIndicator(state) => {
865-
state.view().map(move |msg| Msg::DisplayIdentifierSurface((id, msg)))
866-
}
876+
Surface::OsdIndicator(state) => state
877+
.view()
878+
.map(move |msg| Msg::DisplayIdentifierSurface((id, msg))),
867879
};
868880
} else if let Some((indicator_id, state)) = &self.indicator {
869881
if id == *indicator_id {
@@ -880,7 +892,7 @@ impl cosmic::Application for App {
880892
OsdTask::ConfirmHeadphones { .. } => "confirm-device-type",
881893
OsdTask::Touchpad => "touchpad",
882894
OsdTask::Display => "external-display",
883-
OsdTask::DisplayIdentifier => "display-identifier",
895+
OsdTask::IdentifyDisplays => "identify-displays",
884896
};
885897

886898
let title = fl!(
@@ -1185,7 +1197,7 @@ impl cosmic::Application for App {
11851197

11861198
Msg::Display(enabled)
11871199
});
1188-
} else if let OsdTask::DisplayIdentifier = cmd {
1200+
} else if let OsdTask::IdentifyDisplays = cmd {
11891201
return cosmic::task::future(async move {
11901202
let Ok(output_lists) = cosmic_randr_shell::list().await else {
11911203
log::error!("Failed to list displays with cosmic-randr");

src/components/osd_indicator.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use crate::{components::app::DisplayMode, config};
55
use cosmic::{
66
Apply, Element, Task,
77
iced::{self, Alignment, Border, Length, window::Id as SurfaceId},
8-
iced_runtime::platform_specific::wayland::layer_surface::{IcedOutput, SctkLayerSurfaceSettings},
8+
iced_runtime::platform_specific::wayland::layer_surface::{
9+
IcedOutput, SctkLayerSurfaceSettings,
10+
},
911
iced_winit::commands::{
1012
layer_surface::{
1113
Anchor, KeyboardInteractivity, Layer, destroy_layer_surface, get_layer_surface,
@@ -40,7 +42,9 @@ impl Params {
4042
Self::DisplayBrightness(_) => "display-brightness-symbolic",
4143
Self::DisplayToggle(DisplayMode::All) => "laptop-symbolic",
4244
Self::DisplayToggle(DisplayMode::External) => "display-symbolic",
43-
Self::DisplayNumber(_) => unreachable!("DisplayNumber uses custom rendering and should not call icon_name()"),
45+
Self::DisplayNumber(_) => {
46+
unreachable!("DisplayNumber uses custom rendering and should not call icon_name()")
47+
}
4448
Self::KeyboardBrightness(_) => "keyboard-brightness-symbolic",
4549
Self::AirplaneMode(true) => "airplane-mode-symbolic",
4650
Self::AirplaneMode(false) => "airplane-mode-disabled-symbolic",
@@ -87,7 +91,6 @@ impl Params {
8791
Self::DisplayNumber(_) => None,
8892
}
8993
}
90-
9194
}
9295

9396
#[derive(Clone, Debug)]
@@ -305,7 +308,9 @@ impl State {
305308
// Large number display
306309
let number_text = widget::text::title1(format!("{}", display_number))
307310
.size(240)
308-
.line_height(cosmic::iced::widget::text::LineHeight::Absolute(cosmic::iced::Pixels(240.0)))
311+
.line_height(cosmic::iced::widget::text::LineHeight::Absolute(
312+
cosmic::iced::Pixels(240.0),
313+
))
309314
.width(Length::Shrink)
310315
.align_x(Alignment::Center)
311316
.align_y(Alignment::Center);
@@ -321,10 +326,10 @@ impl State {
321326

322327
let container = widget::container(content)
323328
.padding([
324-
vertical_padding, // top
325-
horizontal_padding, // right
326-
vertical_padding, // bottom
327-
horizontal_padding, // left
329+
vertical_padding, // top
330+
horizontal_padding, // right
331+
vertical_padding, // bottom
332+
horizontal_padding, // left
328333
])
329334
.width(Length::Shrink)
330335
.height(Length::Shrink)

0 commit comments

Comments
 (0)