chore: reduce local stack warnings

This commit is contained in:
Lionel DARNIS 2026-05-23 20:49:24 +02:00
parent 4743bb8ec9
commit 675f3b59e3
15 changed files with 63 additions and 48 deletions

2
iced

@ -1 +1 @@
Subproject commit 6b069b2b4bc252d8fdc4d2a93ff533376c4f0dee Subproject commit f4870187088a14d398f2075c5ccda611387dcdcc

View file

@ -100,9 +100,10 @@ impl<T: Application> Cosmic<T>
where where
T::Message: Send + 'static, T::Message: Send + 'static,
{ {
pub fn init( pub fn init((core, flags): (Core, T::Flags)) -> (Self, iced::Task<crate::Action<T::Message>>) {
(mut core, flags): (Core, T::Flags), #[cfg(all(feature = "dbus-config", target_os = "linux"))]
) -> (Self, iced::Task<crate::Action<T::Message>>) { let mut core = core;
#[cfg(all(feature = "dbus-config", target_os = "linux"))] #[cfg(all(feature = "dbus-config", target_os = "linux"))]
{ {
use iced_futures::futures::executor::block_on; use iced_futures::futures::executor::block_on;
@ -625,9 +626,9 @@ impl<T: Application> Cosmic<T> {
.app .app
.core() .core()
.main_window_id() .main_window_id()
.is_some_and(|main_id| main_id == id) .is_some_and(|main_id| main_id == _id)
{ {
self.app.core_mut().window.sharp_corners = maximized; self.app.core_mut().window.sharp_corners = _maximized;
} }
} }

View file

@ -284,7 +284,7 @@ where
// app = app.window(window_settings); // app = app.window(window_settings);
core.main_window = Some(iced_core::window::Id::RESERVED); core.main_window = Some(iced_core::window::Id::RESERVED);
} }
let mut app = iced::daemon( let app = iced::daemon(
BootData(Rc::new(RefCell::new(Some(BootDataInner::<App> { BootData(Rc::new(RefCell::new(Some(BootDataInner::<App> {
flags, flags,
core, core,

View file

@ -1,7 +1,7 @@
//! Distribute content vertically. //! Distribute content vertically.
use crate::iced; use crate::iced;
use iced::core::alignment::{self, Alignment}; use iced::core::alignment::{self, Alignment};
use iced::core::event::{self, Event}; use iced::core::event::Event;
use iced::core::layout; use iced::core::layout;
use iced::core::mouse; use iced::core::mouse;
use iced::core::overlay; use iced::core::overlay;

View file

@ -10,11 +10,7 @@ use crate::{
widget::{ widget::{
self, self,
autosize::{self, Autosize, autosize}, autosize::{self, Autosize, autosize},
column::Column,
layer_container, layer_container,
row::Row,
space::horizontal,
space::vertical,
}, },
}; };
@ -217,12 +213,6 @@ impl Context {
icon: widget::icon::Handle, icon: widget::icon::Handle,
) -> crate::widget::Button<'a, Message> { ) -> crate::widget::Button<'a, Message> {
let suggested = self.suggested_size(icon.symbolic); let suggested = self.suggested_size(icon.symbolic);
let (applet_padding_major_axis, applet_padding_minor_axis) = self.suggested_padding(true);
let (horizontal_padding, vertical_padding) = if self.is_horizontal() {
(applet_padding_major_axis, applet_padding_minor_axis)
} else {
(applet_padding_minor_axis, applet_padding_major_axis)
};
let symbolic = icon.symbolic; let symbolic = icon.symbolic;
let icon = widget::icon(icon) let icon = widget::icon(icon)
.class(if symbolic { .class(if symbolic {
@ -465,10 +455,8 @@ impl Context {
&self, &self,
content: impl Into<Element<'a, Message>>, content: impl Into<Element<'a, Message>>,
) -> Autosize<'a, Message, crate::Theme, crate::Renderer> { ) -> Autosize<'a, Message, crate::Theme, crate::Renderer> {
let force_configured = matches!(&self.panel_type, PanelType::Other(n) if n.is_empty());
let w = autosize(content, AUTOSIZE_MAIN_ID.clone()); let w = autosize(content, AUTOSIZE_MAIN_ID.clone());
let mut limits = Limits::NONE; let mut limits = Limits::NONE;
let suggested_window_size = self.suggested_window_size();
if let Some(width) = self if let Some(width) = self
.suggested_bounds .suggested_bounds
@ -579,7 +567,7 @@ pub fn run<App: Application>(flags: App::Flags) -> iced::Result {
// window_settings = window_settings.clone(); // window_settings = window_settings.clone();
core.main_window = Some(iced_core::window::Id::RESERVED); core.main_window = Some(iced_core::window::Id::RESERVED);
} }
let mut app = iced::daemon( let app = iced::daemon(
BootData(Rc::new(RefCell::new(Some(BootDataInner::<App> { BootData(Rc::new(RefCell::new(Some(BootDataInner::<App> {
flags, flags,
core, core,

View file

@ -1,7 +1,7 @@
//! Distribute content horizontally. //! Distribute content horizontally.
use crate::iced; use crate::iced;
use iced::core::alignment::{self, Alignment}; use iced::core::alignment::{self, Alignment};
use iced::core::event::{self, Event}; use iced::core::event::Event;
use iced::core::layout::{self, Layout}; use iced::core::layout::{self, Layout};
use iced::core::mouse; use iced::core::mouse;
use iced::core::overlay; use iced::core::overlay;
@ -10,7 +10,6 @@ use iced::core::widget::{Operation, Tree};
use iced::core::{ use iced::core::{
Clipboard, Element, Length, Padding, Pixels, Rectangle, Shell, Size, Vector, Widget, widget, Clipboard, Element, Length, Padding, Pixels, Rectangle, Shell, Size, Vector, Widget, widget,
}; };
use iced::touch;
/// A container that distributes its contents horizontally. /// A container that distributes its contents horizontally.
/// ///

View file

@ -45,7 +45,7 @@ pub fn subscription<App: ApplicationExt>() -> Subscription<crate::Action<App::Me
std::process::exit(1); std::process::exit(1);
} }
output let _ = output
.send(crate::Action::Cosmic(crate::app::Action::DbusConnection( .send(crate::Action::Cosmic(crate::app::Action::DbusConnection(
conn.clone(), conn.clone(),
))) )))

View file

@ -769,7 +769,7 @@ impl DesktopEntryData {
pub async fn spawn_desktop_exec<S, I, K, V>( pub async fn spawn_desktop_exec<S, I, K, V>(
exec: S, exec: S,
env_vars: I, env_vars: I,
app_id: Option<&str>, _app_id: Option<&str>,
terminal: bool, terminal: bool,
) where ) where
S: AsRef<str>, S: AsRef<str>,
@ -816,13 +816,17 @@ pub async fn spawn_desktop_exec<S, I, K, V>(
// https://systemd.io/DESKTOP_ENVIRONMENTS // https://systemd.io/DESKTOP_ENVIRONMENTS
// //
// Similar to what Gnome sets, for now. // Similar to what Gnome sets, for now.
if let Some(pid) = crate::process::spawn(cmd).await { if let Some(_pid) = crate::process::spawn(cmd).await {
#[cfg(feature = "desktop-systemd-scope")] #[cfg(feature = "desktop-systemd-scope")]
if let Ok(session) = zbus::Connection::session().await { if let Ok(session) = zbus::Connection::session().await {
if let Ok(systemd_manager) = SystemdMangerProxy::new(&session).await { if let Ok(systemd_manager) = SystemdMangerProxy::new(&session).await {
let _ = systemd_manager let _ = systemd_manager
.start_transient_unit( .start_transient_unit(
&format!("app-cosmic-{}-{}.scope", app_id.unwrap_or(&executable), pid), &format!(
"app-cosmic-{}-{}.scope",
_app_id.unwrap_or(&executable),
_pid
),
"fail", "fail",
&[ &[
( (
@ -833,7 +837,7 @@ pub async fn spawn_desktop_exec<S, I, K, V>(
), ),
( (
"PIDs".to_string(), "PIDs".to_string(),
zbus::zvariant::Value::from(vec![pid]) zbus::zvariant::Value::from(vec![_pid])
.try_to_owned() .try_to_owned()
.unwrap(), .unwrap(),
), ),

View file

@ -63,6 +63,17 @@ pub mod font;
#[doc(inline)] #[doc(inline)]
pub use iced; pub use iced;
#[doc(inline)]
pub use iced_core;
#[doc(inline)]
pub use iced_futures;
#[doc(inline)]
pub use iced_runtime;
#[doc(inline)]
pub use iced_widget;
#[doc(inline)]
#[cfg(feature = "wayland")]
pub use iced_winit;
pub mod icon_theme; pub mod icon_theme;
pub mod keyboard_nav; pub mod keyboard_nav;

View file

@ -152,7 +152,7 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
); );
} }
let mut button = if builder.variant.vertical { let button = if builder.variant.vertical {
crate::widget::column::with_children(content) crate::widget::column::with_children(content)
.padding(builder.padding) .padding(builder.padding)
.spacing(builder.spacing) .spacing(builder.spacing)
@ -169,9 +169,11 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
}; };
#[cfg(feature = "a11y")] #[cfg(feature = "a11y")]
{ let button = {
let mut button = button;
button = button.name(builder.name).description(builder.description); button = button.name(builder.name).description(builder.description);
} button
};
let button = button let button = button
.padding(0) .padding(0)

View file

@ -83,7 +83,7 @@ where
.width(builder.width) .width(builder.width)
.height(builder.height); .height(builder.height);
let mut button = super::custom_image_button(content, builder.variant.on_remove) let button = super::custom_image_button(content, builder.variant.on_remove)
.padding(0) .padding(0)
.selected(builder.variant.selected) .selected(builder.variant.selected)
.id(builder.id) .id(builder.id)
@ -91,9 +91,11 @@ where
.class(builder.class); .class(builder.class);
#[cfg(feature = "a11y")] #[cfg(feature = "a11y")]
{ let button = {
let mut button = button;
button = button.name(builder.name).description(builder.description); button = button.name(builder.name).description(builder.description);
} button
};
button.into() button.into()
} }

View file

@ -66,7 +66,7 @@ pub fn icon() -> Handle {
impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Message> { impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Message> {
fn from(mut builder: Button<'a, Message>) -> Element<'a, Message> { fn from(mut builder: Button<'a, Message>) -> Element<'a, Message> {
let mut button: super::Button<'a, Message> = row::with_capacity(2) let button: super::Button<'a, Message> = row::with_capacity(2)
.push({ .push({
// TODO: Avoid allocation // TODO: Avoid allocation
crate::widget::text(builder.label.to_string()) crate::widget::text(builder.label.to_string())
@ -94,13 +94,15 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
.class(builder.class); .class(builder.class);
#[cfg(feature = "a11y")] #[cfg(feature = "a11y")]
{ let button = {
let mut button = button;
if !builder.label.is_empty() { if !builder.label.is_empty() {
button = button.name(builder.label); button = button.name(builder.label);
} }
button = button.description(builder.description); button = button.description(builder.description);
} button
};
if builder.tooltip.is_empty() { if builder.tooltip.is_empty() {
button.into() button.into()

View file

@ -119,7 +119,7 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
.into() .into()
}); });
let mut button: super::Button<'a, Message> = row::with_capacity(3) let button: super::Button<'a, Message> = row::with_capacity(3)
// Optional icon to place before label. // Optional icon to place before label.
.push_maybe(leading_icon) .push_maybe(leading_icon)
// Optional label between icons. // Optional label between icons.
@ -138,13 +138,15 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
.class(builder.class); .class(builder.class);
#[cfg(feature = "a11y")] #[cfg(feature = "a11y")]
{ let button = {
let mut button = button;
if !builder.label.is_empty() { if !builder.label.is_empty() {
button = button.name(builder.label) button = button.name(builder.label)
} }
button = button.description(builder.description); button = button.description(builder.description);
} button
};
if builder.tooltip.is_empty() { if builder.tooltip.is_empty() {
button.into() button.into()

View file

@ -26,7 +26,7 @@ pub fn spin_button<'a, T, M>(
where where
T: Copy + Sub<Output = T> + Add<Output = T> + PartialOrd, T: Copy + Sub<Output = T> + Add<Output = T> + PartialOrd,
{ {
let mut button = SpinButton::new( let button = SpinButton::new(
label, label,
value, value,
step, step,
@ -37,9 +37,11 @@ where
); );
#[cfg(feature = "a11y")] #[cfg(feature = "a11y")]
{ let button = {
let mut button = button;
button = button.name(name.into()); button = button.name(name.into());
} button
};
button button
} }
@ -57,7 +59,7 @@ pub fn vertical<'a, T, M>(
where where
T: Copy + Sub<Output = T> + Add<Output = T> + PartialOrd, T: Copy + Sub<Output = T> + Add<Output = T> + PartialOrd,
{ {
let mut button = SpinButton::new( let button = SpinButton::new(
label, label,
value, value,
step, step,
@ -68,9 +70,11 @@ where
); );
#[cfg(feature = "a11y")] #[cfg(feature = "a11y")]
{ let button = {
let mut button = button;
button = button.name(name.into()); button = button.name(name.into());
} button
};
button button
} }

View file

@ -2198,7 +2198,7 @@ pub fn update<'a, Message: Clone + 'static>(
x, x,
y, y,
mime_types, mime_types,
surface, surface: _surface,
}, },
)) if *rectangle == Some(dnd_id) => { )) if *rectangle == Some(dnd_id) => {
cold(); cold();
@ -2241,7 +2241,7 @@ pub fn update<'a, Message: Clone + 'static>(
} }
} }
#[cfg(all(feature = "wayland", target_os = "linux"))] #[cfg(all(feature = "wayland", target_os = "linux"))]
Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Motion { x, y })) Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Motion { x, y: _ }))
if *rectangle == Some(dnd_id) => if *rectangle == Some(dnd_id) =>
{ {
let state = state(); let state = state();