yoda: warning cleanup sweep (dead code + clippy --fix) (squashed)

Squash of 4 yoda commits:
- 84437e21 yoda: libcosmic-yoda dead-code purge (14->0 warnings)
- 999db0a4 yoda: cosmic-theme cleanup (4->0 warnings) — workspace at 0 warnings total
- 4743bb8e yoda: cargo clippy --fix on libcosmic-yoda (115->33 warnings)
- 675f3b59 chore: reduce local stack warnings
This commit is contained in:
Lionel DARNIS 2026-05-25 13:02:38 +02:00
parent c85efc6180
commit 4e1080108c
35 changed files with 173 additions and 210 deletions

View file

@ -666,18 +666,15 @@ where
let old_value = Value::new(&old_value);
if state.is_focused()
&& let cursor::State::Index(index) = state.cursor.state(&old_value)
{
if index == old_value.len() {
&& index == old_value.len() {
state.cursor.move_to(self.value.len());
}
}
if let Some(f) = state.is_focused.as_ref().filter(|f| f.focused) {
if f.updated_at != LAST_FOCUS_UPDATE.with(|f| f.get()) {
if let Some(f) = state.is_focused.as_ref().filter(|f| f.focused)
&& f.updated_at != LAST_FOCUS_UPDATE.with(|f| f.get()) {
state.unfocus();
state.emit_unfocus = true;
}
}
if self.is_editable_variant {
if !state.is_focused() {
@ -891,8 +888,8 @@ where
let line_height = self.line_height;
// Disables editing of the editable variant when clicking outside of, or for tab focus changes.
if self.is_editable_variant {
if let Some(ref on_edit) = self.on_toggle_edit {
if self.is_editable_variant
&& let Some(ref on_edit) = self.on_toggle_edit {
let state = tree.state.downcast_mut::<State>();
if !state.is_read_only && state.is_focused.is_some_and(|f| !f.focused) {
state.is_read_only = true;
@ -904,7 +901,6 @@ where
shell.publish((on_edit)(f.focused));
}
}
}
// Calculates the layout of the trailing icon button element.
if !tree.children.is_empty() {
@ -915,9 +911,9 @@ where
trailing_icon_layout = Some(text_layout.children().last().unwrap());
// Enable custom buttons defined on the trailing icon position to be handled.
if !self.is_editable_variant {
if let Some(trailing_layout) = trailing_icon_layout {
let _res = trailing_icon.as_widget_mut().update(
if !self.is_editable_variant
&& let Some(trailing_layout) = trailing_icon_layout {
trailing_icon.as_widget_mut().update(
tree,
event,
trailing_layout,
@ -932,18 +928,16 @@ where
return;
}
}
}
}
}
let state = tree.state.downcast_mut::<State>();
if let Some(on_unfocus) = self.on_unfocus.as_ref() {
if state.emit_unfocus {
if let Some(on_unfocus) = self.on_unfocus.as_ref()
&& state.emit_unfocus {
state.emit_unfocus = false;
shell.publish(on_unfocus.clone());
}
}
let dnd_id = self.dnd_id();
let id = Widget::id(self);
@ -1652,11 +1646,10 @@ pub fn update<'a, Message: Clone + 'static>(
if matches!(state.dragging_state, None | Some(DraggingState::Selection))
&& (!state.is_focused() || (is_editable_variant && state.is_read_only))
{
if !state.is_focused() {
if let Some(on_focus) = on_focus {
if !state.is_focused()
&& let Some(on_focus) = on_focus {
shell.publish(on_focus.clone());
}
}
if state.is_read_only {
state.is_read_only = false;
@ -1681,7 +1674,6 @@ pub fn update<'a, Message: Clone + 'static>(
state.last_click = Some(click);
shell.capture_event();
return;
} else {
state.unfocus();
@ -1717,7 +1709,6 @@ pub fn update<'a, Message: Clone + 'static>(
if cursor.is_over(layout.bounds()) {
shell.capture_event();
}
return;
}
Event::Mouse(mouse::Event::CursorMoved { position })
| Event::Touch(touch::Event::FingerMoved { position, .. }) => {
@ -1800,7 +1791,6 @@ pub fn update<'a, Message: Clone + 'static>(
}
shell.capture_event();
return;
}
}
Event::Keyboard(keyboard::Event::KeyPressed {
@ -1838,14 +1828,13 @@ pub fn update<'a, Message: Clone + 'static>(
{
match clip_key {
Some('c') => {
if !is_secure {
if let Some((start, end)) = state.cursor.selection(value) {
if !is_secure
&& let Some((start, end)) = state.cursor.selection(value) {
clipboard.write(
iced_core::clipboard::Kind::Standard,
value.select(start, end).to_string(),
);
}
}
}
// XXX if we want to allow cutting of secure text, we need to
// update the cache and decide which value to cut
@ -2100,7 +2089,6 @@ pub fn update<'a, Message: Clone + 'static>(
}
shell.capture_event();
return;
}
}
Event::Keyboard(keyboard::Event::KeyReleased { key, .. }) => {
@ -2120,7 +2108,6 @@ pub fn update<'a, Message: Clone + 'static>(
}
shell.capture_event();
return;
}
}
Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => {
@ -2136,7 +2123,6 @@ pub fn update<'a, Message: Clone + 'static>(
state.preedit = matches!(event, input_method::Event::Opened)
.then(input_method::Preedit::new);
shell.capture_event();
return;
}
input_method::Event::Preedit(content, selection) => {
if state.is_focused() {
@ -2146,7 +2132,6 @@ pub fn update<'a, Message: Clone + 'static>(
text_size: Some(size.into()),
});
shell.capture_event();
return;
}
}
input_method::Event::Commit(text) => {
@ -2164,7 +2149,7 @@ pub fn update<'a, Message: Clone + 'static>(
LAST_FOCUS_UPDATE.with(|x| x.set(focus.updated_at));
let mut editor = Editor::new(unsecured_value, &mut state.cursor);
editor.paste(Value::new(&text));
editor.paste(Value::new(text));
let contents = editor.contents();
let unsecured_value = Value::new(&contents);
@ -2184,7 +2169,6 @@ pub fn update<'a, Message: Clone + 'static>(
update_cache(state, &value);
shell.capture_event();
return;
}
}
}
@ -2214,7 +2198,6 @@ pub fn update<'a, Message: Clone + 'static>(
// TODO: restore value in text input
state.dragging_state = None;
shell.capture_event();
return;
}
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
@ -2224,7 +2207,7 @@ pub fn update<'a, Message: Clone + 'static>(
x,
y,
mime_types,
surface,
surface: _surface,
},
)) if *rectangle == Some(dnd_id) => {
cold();
@ -2264,11 +2247,10 @@ pub fn update<'a, Message: Clone + 'static>(
state.cursor.set_affinity(affinity);
state.cursor.move_to(position);
shell.capture_event();
return;
}
}
#[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) =>
{
let state = state();
@ -2293,7 +2275,6 @@ pub fn update<'a, Message: Clone + 'static>(
state.cursor.set_affinity(affinity);
state.cursor.move_to(position);
shell.capture_event();
return;
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Drop)) if *rectangle == Some(dnd_id) => {
@ -2310,8 +2291,6 @@ pub fn update<'a, Message: Clone + 'static>(
};
state.dnd_offer = DndOfferState::Dropped;
}
return;
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
Event::Dnd(DndEvent::Offer(id, OfferEvent::LeaveDestination)) if Some(dnd_id) != *id => {}
@ -2331,7 +2310,6 @@ pub fn update<'a, Message: Clone + 'static>(
}
};
shell.capture_event();
return;
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Data { data, mime_type }))
@ -2368,9 +2346,7 @@ pub fn update<'a, Message: Clone + 'static>(
};
update_cache(state, &value);
shell.capture_event();
return;
}
return;
}
_ => {}
}
@ -2803,11 +2779,11 @@ pub fn draw<'a, Message>(
// draw the end icon in the text input
if let (Some(icon), Some(tree)) = (trailing_icon, trailing_icon_tree) {
let mut children = text_layout.children();
let mut icon_layout = children.next().unwrap();
children.next().unwrap(); // skip text layout
if has_start_icon {
icon_layout = children.next().unwrap();
children.next().unwrap(); // skip start-icon layout
}
icon_layout = children.next().unwrap();
let icon_layout = children.next().unwrap(); // trailing-icon layout
icon.as_widget().draw(
tree,