Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 94 additions & 66 deletions cosmic-app-list/src/app.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cosmic-app-list/src/wayland_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl CaptureData {
// XXX
if !formats.shm_formats.contains(&wl_shm::Format::Abgr8888) {
tracing::error!("No suitable buffer format found");
tracing::warn!("Available formats: {:#?}", formats);
tracing::warn!("Available formats: {formats:#?}");
return None;
}

Expand Down Expand Up @@ -620,7 +620,7 @@ pub(crate) fn wayland_handler(
.insert_source(rx, |event, (), state| match event {
calloop::channel::Event::Msg(req) => match req {
WaylandRequest::Screencopy(handle) => {
state.send_image(handle.clone());
state.send_image(handle);
}
WaylandRequest::Toplevel(req) => match req {
ToplevelRequest::Activate(handle) => {
Expand Down
25 changes: 12 additions & 13 deletions cosmic-applet-a11y/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,21 @@ impl cosmic::Application for CosmicA11yApplet {
Message::TogglePopup => {
if let Some(p) = self.popup.take() {
return destroy_popup(p);
} else {
self.timeline = Timeline::new();
}
self.timeline = Timeline::new();

let new_id = window::Id::unique();
self.popup.replace(new_id);
let new_id = window::Id::unique();
self.popup.replace(new_id);

let popup_settings = self.core.applet.get_popup_settings(
self.core.main_window_id().unwrap(),
new_id,
Some((1, 1)),
None,
None,
);
let popup_settings = self.core.applet.get_popup_settings(
self.core.main_window_id().unwrap(),
new_id,
Some((1, 1)),
None,
None,
);

return get_popup(popup_settings);
}
return get_popup(popup_settings);
}
Message::CloseRequested(id) => {
if Some(id) == self.popup {
Expand Down
5 changes: 2 additions & 3 deletions cosmic-applet-a11y/src/backend/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// SPDX-License-Identifier: GPL-3.0-only

use anyhow;
use cctk::sctk::reexports::calloop::{self, channel::SyncSender};
use cctk::sctk::reexports::calloop;
use cosmic::iced::{
self, Subscription,
futures::{self, SinkExt, StreamExt, channel::mpsc},
futures::{self, SinkExt},
stream,
};
use cosmic_protocols::a11y::v1::client::cosmic_a11y_manager_v1::Filter;
use cosmic_settings_subscriptions::cosmic_a11y_manager::{
self as thread, AccessibilityEvent, AccessibilityRequest,
};
Expand Down
131 changes: 61 additions & 70 deletions cosmic-applet-audio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mod pulse;
static FULL_VOLUME: f64 = Volume::NORMAL.0 as f64;

// Max volume is 150% volume.
static MAX_VOLUME: f64 = FULL_VOLUME + (FULL_VOLUME * 0.5);
static MAX_VOLUME: f64 = FULL_VOLUME * 1.5;

static SHOW_MEDIA_CONTROLS: LazyLock<id::Toggler> = LazyLock::new(id::Toggler::unique);

Expand Down Expand Up @@ -203,16 +203,16 @@ impl Audio {
.icon_button(GO_NEXT)
.on_press(Message::MprisRequest(MprisRequest::Next))
.into(),
)
);
}

Some(match self.core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => Column::with_children(elements)
.align_x(Alignment::Center)
.into(),
PanelAnchor::Top | PanelAnchor::Bottom => Row::with_children(elements)
.align_y(Alignment::Center)
.into(),
PanelAnchor::Left | PanelAnchor::Right => {
Column::from_vec(elements).align_x(Alignment::Center).into()
}
PanelAnchor::Top | PanelAnchor::Bottom => {
Row::from_vec(elements).align_y(Alignment::Center).into()
}
})
} else {
None
Expand Down Expand Up @@ -315,34 +315,34 @@ impl cosmic::Application for Audio {
Message::TogglePopup => {
if let Some(p) = self.popup.take() {
return destroy_popup(p);
} else {
if let Some(conn) = self.pulse_state.connection() {
conn.send(pulse::Message::UpdateConnection);
}
let new_id = window::Id::unique();
self.popup.replace(new_id);
self.timeline = Timeline::new();

self.output_amplification = amplification_sink();
self.input_amplification = amplification_source();

let popup_settings = self.core.applet.get_popup_settings(
self.core.main_window_id().unwrap(),
new_id,
None,
None,
None,
);
}

if let Some(conn) = self.pulse_state.connection() {
conn.send(pulse::Message::GetDefaultSink);
conn.send(pulse::Message::GetDefaultSource);
conn.send(pulse::Message::GetSinks);
conn.send(pulse::Message::GetSources);
}
if let Some(conn) = self.pulse_state.connection() {
conn.send(pulse::Message::UpdateConnection);
}
let new_id = window::Id::unique();
self.popup.replace(new_id);
self.timeline = Timeline::new();

self.output_amplification = amplification_sink();
self.input_amplification = amplification_source();

let popup_settings = self.core.applet.get_popup_settings(
self.core.main_window_id().unwrap(),
new_id,
None,
None,
None,
);

return get_popup(popup_settings);
if let Some(conn) = self.pulse_state.connection() {
conn.send(pulse::Message::GetDefaultSink);
conn.send(pulse::Message::GetDefaultSource);
conn.send(pulse::Message::GetSinks);
conn.send(pulse::Message::GetSources);
}

return get_popup(popup_settings);
}
Message::SetOutputVolume(vol) => {
if self.output_volume == vol {
Expand Down Expand Up @@ -400,7 +400,7 @@ impl cosmic::Application for Audio {
if let PulseState::Connected(connection) = &mut self.pulse_state {
if let Some(device) = &self.current_input {
if let Some(name) = &device.name {
tracing::info!("increasing volume of {}", name);
tracing::info!("increasing volume of {name}");
connection.send(pulse::Message::SetSourceVolumeByName(
name.clone(),
device.volume,
Expand Down Expand Up @@ -432,7 +432,7 @@ impl cosmic::Application for Audio {
connection.send(pulse::Message::SetSourceMuteByName(
name.clone(),
device.mute,
))
));
}
}
}
Expand Down Expand Up @@ -506,7 +506,7 @@ impl cosmic::Application for Audio {
panic!("Subscription error handling is bad. This should never happen.")
}
_ => {
tracing::trace!("Received misc message")
tracing::trace!("Received misc message");
}
}
}
Expand Down Expand Up @@ -559,35 +559,35 @@ impl cosmic::Application for Audio {
MprisRequest::Play => tokio::spawn(async move {
let res = player.play().await;
if let Err(err) = res {
tracing::error!("Error playing: {}", err);
tracing::error!("Error playing: {err}");
}
}),
MprisRequest::Pause => tokio::spawn(async move {
let res = player.pause().await;
if let Err(err) = res {
tracing::error!("Error pausing: {}", err);
tracing::error!("Error pausing: {err}");
}
}),
MprisRequest::Next => tokio::spawn(async move {
let res = player.next().await;
if let Err(err) = res {
tracing::error!("Error playing next: {}", err);
tracing::error!("Error playing next: {err}");
}
}),
MprisRequest::Previous => tokio::spawn(async move {
let res = player.previous().await;
if let Err(err) = res {
tracing::error!("Error playing previous: {}", err);
tracing::error!("Error playing previous: {err}");
}
}),
MprisRequest::Raise => tokio::spawn(async move {
let res = player.media_player().await;
if let Err(err) = res {
tracing::error!("Error fetching MediaPlayer: {}", err);
tracing::error!("Error fetching MediaPlayer: {err}");
} else {
let res = res.unwrap().raise().await;
if let Err(err) = res {
tracing::error!("Error raising client: {}", err);
tracing::error!("Error raising client: {err}");
}
}
}),
Expand Down Expand Up @@ -626,10 +626,10 @@ impl cosmic::Application for Audio {
self.current_output.as_mut().map(|output| {
output
.volume
.set(output.volume.len(), percent_to_volume(value as f64))
.set(output.volume.len(), percent_to_volume(value.into()))
});

self.output_volume = value as f64;
self.output_volume = value.into();
self.output_volume_text = format!("{}%", self.output_volume.round());
}
sub_pulse::Event::SinkMute(value) => {
Expand All @@ -641,10 +641,10 @@ impl cosmic::Application for Audio {
self.current_input.as_mut().map(|input| {
input
.volume
.set(input.volume.len(), percent_to_volume(value as f64))
.set(input.volume.len(), percent_to_volume(value.into()))
});

self.input_volume = value as f64;
self.input_volume = value.into();
self.input_volume_text = format!("{}%", self.input_volume.round());
}
sub_pulse::Event::SourceMute(value) => {
Expand Down Expand Up @@ -726,15 +726,12 @@ impl cosmic::Application for Audio {
.applet
.autosize_window(if let Some(Some(playback_buttons)) = playback_buttons {
match self.core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => Element::from(
Column::with_children([playback_buttons, btn.into()])
.align_x(Alignment::Center),
),
PanelAnchor::Top | PanelAnchor::Bottom => {
Row::with_children([playback_buttons, btn.into()])
.align_y(Alignment::Center)
.into()
PanelAnchor::Left | PanelAnchor::Right => {
Element::from(column![playback_buttons, btn].align_x(Alignment::Center))
}
PanelAnchor::Top | PanelAnchor::Bottom => row![playback_buttons, btn]
.align_y(Alignment::Center)
.into(),
}
} else {
btn.into()
Expand Down Expand Up @@ -842,10 +839,10 @@ impl cosmic::Application for Audio {
};

if let Some(s) = self.player_status.as_ref() {
let mut elements = Vec::with_capacity(5);
let mut elements = Row::with_capacity(5);

if let Some(icon_path) = s.icon.clone() {
elements.push(icon(icon::from_path(icon_path)).size(36).into());
elements = elements.push(icon(icon::from_path(icon_path)).size(36));
}

let title = if let Some(title) = s.title.as_ref() {
Expand Down Expand Up @@ -873,13 +870,12 @@ impl cosmic::Application for Audio {
fl!("unknown-artist")
};

elements.push(
elements = elements.push(
column![
text::body(title).width(Length::Shrink),
text::caption(artists).width(Length::Shrink),
]
.width(Length::FillPortion(5))
.into(),
.width(Length::FillPortion(5)),
);

let mut control_elements = Vec::with_capacity(4);
Expand Down Expand Up @@ -908,24 +904,19 @@ impl cosmic::Application for Audio {
control_elements.push(go_next);
}
let control_cnt = control_elements.len() as u16;
elements.push(
Row::with_children(control_elements)
elements = elements.push(
Row::from_vec(control_elements)
.align_y(Alignment::Center)
.width(Length::FillPortion(control_cnt.saturating_add(1)))
.spacing(8)
.into(),
.spacing(8),
);

audio_content = audio_content
.push(padded_control(divider::horizontal::default()).padding([space_xxs, space_s]));
audio_content = audio_content.push(
menu_button(
Row::with_children(elements)
.align_y(Alignment::Center)
.spacing(8),
)
.on_press(Message::MprisRequest(MprisRequest::Raise))
.padding(menu_control_padding()),
menu_button(elements.align_y(Alignment::Center).spacing(8))
.on_press(Message::MprisRequest(MprisRequest::Raise))
.padding(menu_control_padding()),
);
}
let content = column![
Expand Down
18 changes: 10 additions & 8 deletions cosmic-applet-audio/src/mpris_subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ impl PlayerStatus {

let title = metadata
.title()
.or(pathbuf
.file_name()
.and_then(|s| s.to_str())
.and_then(|s| decode(s).map_or(None, |s| Some(s.into_owned()))))
.or_else(|| {
pathbuf
.file_name()
.and_then(|s| s.to_str())
.and_then(|s| decode(s).map_or(None, |s| Some(s.into_owned())))
})
.map(Cow::from);
let artists = metadata
.artists()
Expand Down Expand Up @@ -164,7 +166,7 @@ impl State {
players.push(player);
}
Err(err) => {
tracing::error!("Failed to add player: {}", err);
tracing::error!("Failed to add player: {err}");
}
}
}
Expand All @@ -190,7 +192,7 @@ impl State {
let player = match MprisPlayer::new(&self.conn, name).await {
Ok(player) => player,
Err(err) => {
tracing::error!("Failed to add player: {}", err);
tracing::error!("Failed to add player: {err}");
return;
}
};
Expand Down Expand Up @@ -243,7 +245,7 @@ async fn run(output: &mut futures::channel::mpsc::Sender<MprisUpdate>) {
let mut state = match State::new().await {
Ok(state) => state,
Err(err) => {
tracing::error!("Failed to monitor for mpris clients: {}", err);
tracing::error!("Failed to monitor for mpris clients: {err}");
return;
}
};
Expand Down Expand Up @@ -273,7 +275,7 @@ async fn run(output: &mut futures::channel::mpsc::Sender<MprisUpdate>) {
Some(Ok(enumerator::Event::Add(name))) => state.add_player(name).await,
Some(Ok(enumerator::Event::Remove(name))) => state.remove_player(name).await,
Some(Err(err)) => {
tracing::error!("Error listening for mpris clients: {:?}", err);
tracing::error!("Error listening for mpris clients: {err:?}");
return;
}
None => {}
Expand Down
Loading
Loading