From e424487704912e05a526a213076793074dbfdc0e Mon Sep 17 00:00:00 2001 From: Votre Nom Date: Tue, 5 May 2026 18:26:08 +0200 Subject: [PATCH] =?UTF-8?q?yoda:=20iced=5Fwinit=20dead-code=20purge=20(29?= =?UTF-8?q?=E2=86=920=20warnings)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed code paths inherited from past refactors that no longer have any reader: - ViewFn type alias (window.rs) - a11y_enabled flag and resized flag (lib.rs) — assigned but never read - BootConfig.fonts/graphics_settings/is_wayland — already passed to run_instance(...) directly; the BootConfig copies were never read - Runner.system_theme oneshot::Sender — stored but no producer ever wired; receiver side already falls back to default - event_loop/control_flow.rs — local ControlFlow enum, all callers use winit::event_loop::ControlFlow - event_loop/proxy.rs — Proxy never constructed - Error::Connect(ConnectError) variant — never constructed - Common.has_focus / ime_pos / ime_size — never read after assignment - SctkPopupData.grab — replicated settings.grab, never read back - SubsurfaceEventVariant::Created.surface field — destructure does `surface: _` everywhere, the value is unused Visibility tightening: - a11y.rs WinitActivationHandler / WinitActionHandler / WinitDeactivationHandler: pub proxy → pub(crate) proxy - conversion::touch_event: pub → private (no external callers) - proxy::Proxy::new: pub → pub(crate) Allow attributes (intentional, not warning-suppression): - conversion::RawImage: #[allow(dead_code)] — fields kept for IconProvider downcast-via-AsAny on winit's side - event_loop::Error: #[allow(dead_code)] — variant payloads kept for Debug, never inspected programmatically - lib.rs Event: #[allow(hidden_glob_reexports)] — intentional shadow of winit::event::Event coming from `pub use winit` - window.rs/lib.rs: #[allow(deprecated)] on enable_ime/disable_ime/ process_event with TODOs for set_ime_* → request_ime_update and try_next → try_recv migrations Five orphan imports also removed (Hash/Hasher, BorrowMut, 3× Compositor). Leyoda 2026 – GPLv3 --- winit/src/a11y.rs | 6 +- winit/src/conversion.rs | 7 +- winit/src/lib.rs | 28 ++------ winit/src/platform_specific/mod.rs | 2 +- .../wayland/event_loop/control_flow.rs | 56 ---------------- .../wayland/event_loop/mod.rs | 6 +- .../wayland/event_loop/proxy.rs | 66 ------------------- .../wayland/event_loop/state.rs | 11 +--- winit/src/platform_specific/wayland/mod.rs | 2 +- .../platform_specific/wayland/sctk_event.rs | 4 +- .../wayland/subsurface_widget.rs | 3 +- winit/src/proxy.rs | 2 +- winit/src/window.rs | 6 +- 13 files changed, 22 insertions(+), 177 deletions(-) delete mode 100644 winit/src/platform_specific/wayland/event_loop/control_flow.rs delete mode 100644 winit/src/platform_specific/wayland/event_loop/proxy.rs diff --git a/winit/src/a11y.rs b/winit/src/a11y.rs index 61fbe630..8f6cf27b 100644 --- a/winit/src/a11y.rs +++ b/winit/src/a11y.rs @@ -7,7 +7,7 @@ use iced_accessibility::accesskit::{ use iced_runtime::core; pub struct WinitActivationHandler { - pub proxy: mpsc::UnboundedSender, + pub(crate) proxy: mpsc::UnboundedSender, pub title: String, } @@ -33,7 +33,7 @@ impl ActivationHandler for WinitActivationHandler { pub struct WinitActionHandler { pub id: core::window::Id, - pub proxy: mpsc::UnboundedSender, + pub(crate) proxy: mpsc::UnboundedSender, } impl iced_accessibility::accesskit::ActionHandler for WinitActionHandler { @@ -48,7 +48,7 @@ impl iced_accessibility::accesskit::ActionHandler for WinitActionHandler { } pub struct WinitDeactivationHandler { - pub proxy: mpsc::UnboundedSender, + pub(crate) proxy: mpsc::UnboundedSender, } impl iced_accessibility::accesskit::DeactivationHandler diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 71af6e2e..5192cb61 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -3,8 +3,6 @@ //! [`winit`]: https://github.com/rust-windowing/winit //! [`iced_runtime`]: https://github.com/iced-rs/iced/tree/0.14/runtime use crate::core::input_method; -use std::hash::Hash; -use std::hash::Hasher; use std::sync::Arc; use crate::core::keyboard; @@ -698,7 +696,7 @@ enum TouchInternal { /// /// [`winit`]: https://github.com/rust-windowing/winit /// [`iced`]: https://github.com/iced-rs/iced/tree/0.12 -pub fn touch_event( +fn touch_event( finger: FingerId, state: TouchInternal, _force: Option, @@ -1591,7 +1589,10 @@ pub fn resize_direction( } } +// Fields are passed through to winit via `IconProvider: AsAny` for potential +// downcast; they are not read directly here. #[derive(Debug)] +#[allow(dead_code)] pub struct RawImage(Vec, Size); impl IconProvider for RawImage {} impl From for winit_core::icon::Icon { diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 32837143..3c5a5d29 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -157,7 +157,8 @@ where let (boot_sender, boot_receiver) = oneshot::channel(); let (control_sender, control_receiver) = mpsc::unbounded(); - let (system_theme_sender, system_theme_receiver) = oneshot::channel(); + // Sender side currently not wired to a producer; receiver gets default. + let (_system_theme_sender, system_theme_receiver) = oneshot::channel(); let instance = Box::pin(run_instance::

( program, @@ -178,9 +179,6 @@ where struct BootConfig { sender: oneshot::Sender<()>, - fonts: Vec>, - graphics_settings: graphics::Settings, - is_wayland: bool, } struct Runner { instance: std::pin::Pin>, @@ -190,7 +188,6 @@ where sender: mpsc::UnboundedSender>, receiver: mpsc::UnboundedReceiver, error: Option, - system_theme: Option>, control_sender: mpsc::UnboundedSender, #[cfg(feature = "a11y")] @@ -207,16 +204,12 @@ where context, boot: Some(BootConfig { sender: boot_sender, - fonts: settings.fonts, - graphics_settings, - is_wayland, }), id: settings.id, sender: event_sender, receiver: control_receiver, control_sender: control_sender.clone(), error: None, - system_theme: Some(system_theme_sender), #[cfg(feature = "a11y")] adapters: Default::default(), @@ -319,12 +312,7 @@ where event_loop: &dyn winit::event_loop::ActiveEventLoop, ) { // create initial window - let Some(BootConfig { - sender, - fonts: _, - graphics_settings: _, - is_wayland: _, - }) = self.boot.take() + let Some(BootConfig { sender }) = self.boot.take() else { return; }; @@ -691,6 +679,7 @@ where } } +#[allow(hidden_glob_reexports)] // intentional: internal Event shadows winit::event::Event from `pub use winit` enum Event { WindowCreated { id: window::Id, @@ -798,9 +787,6 @@ async fn run_instance

( > = None; let mut dnd_surface_id: Option = None; - #[cfg(feature = "a11y")] - let mut a11y_enabled = false; - #[cfg(all(feature = "linux-theme-detection", target_os = "linux"))] let mut system_theme = { let to_mode = |color_scheme| match color_scheme { @@ -1393,7 +1379,6 @@ async fn run_instance

( } let mut uis_stale = false; - let mut resized = false; for (id, window) in window_manager.iter_mut() { if skip && !window.resize_enabled { continue; @@ -1446,7 +1431,6 @@ async fn run_instance

( // FIXME what to do when we are stuck in a configure event/resize request loop // We don't have control over how winit handles this. window.resize_enabled = true; - resized = true; needs_redraw = true; let s = winit::dpi::Size::Logical( requested_size.cast(), @@ -1661,8 +1645,8 @@ async fn run_instance

( events.push((Some(id), conversion::a11y(action_request))); } #[cfg(feature = "a11y")] - Event::AccessibilityEnabled(enabled) => { - a11y_enabled = enabled; + Event::AccessibilityEnabled(_enabled) => { + // a11y enable signal currently unused at this layer } Event::PlatformSpecific(e) => { crate::platform_specific::handle_event( diff --git a/winit/src/platform_specific/mod.rs b/winit/src/platform_specific/mod.rs index 66eda20c..357fb1ec 100644 --- a/winit/src/platform_specific/mod.rs +++ b/winit/src/platform_specific/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; -use iced_graphics::{Compositor, compositor}; +use iced_graphics::compositor; use iced_runtime::{ core::{Vector, window}, user_interface, }; diff --git a/winit/src/platform_specific/wayland/event_loop/control_flow.rs b/winit/src/platform_specific/wayland/event_loop/control_flow.rs deleted file mode 100644 index bc920ed4..00000000 --- a/winit/src/platform_specific/wayland/event_loop/control_flow.rs +++ /dev/null @@ -1,56 +0,0 @@ -/// Set by the user callback given to the [`EventLoop::run`] method. -/// -/// Indicates the desired behavior of the event loop after [`Event::RedrawEventsCleared`] is emitted. -/// -/// Defaults to [`Poll`]. -/// -/// ## Persistency -/// -/// Almost every change is persistent between multiple calls to the event loop closure within a -/// given run loop. The only exception to this is [`ExitWithCode`] which, once set, cannot be unset. -/// Changes are **not** persistent between multiple calls to `run_return` - issuing a new call will -/// reset the control flow to [`Poll`]. -/// -/// [`ExitWithCode`]: Self::ExitWithCode -/// [`Poll`]: Self::Poll -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum ControlFlow { - /// When the current loop iteration finishes, immediately begin a new iteration regardless of - /// whether or not new events are available to process. - /// - /// ## Platform-specific - /// - /// - **Web:** Events are queued and usually sent when `requestAnimationFrame` fires but sometimes - /// the events in the queue may be sent before the next `requestAnimationFrame` callback, for - /// example when the scaling of the page has changed. This should be treated as an implementation - /// detail which should not be relied on. - Poll, - /// When the current loop iteration finishes, suspend the thread until another event arrives. - Wait, - /// When the current loop iteration finishes, suspend the thread until either another event - /// arrives or the given time is reached. - /// - /// Useful for implementing efficient timers. Applications which want to render at the display's - /// native refresh rate should instead use [`Poll`] and the VSync functionality of a graphics API - /// to reduce odds of missed frames. - /// - /// [`Poll`]: Self::Poll - WaitUntil(std::time::Instant), - /// Send a [`LoopDestroyed`] event and stop the event loop. This variant is *sticky* - once set, - /// `control_flow` cannot be changed from `ExitWithCode`, and any future attempts to do so will - /// result in the `control_flow` parameter being reset to `ExitWithCode`. - /// - /// The contained number will be used as exit code. The [`Exit`] constant is a shortcut for this - /// with exit code 0. - /// - /// ## Platform-specific - /// - /// - **Android / iOS / WASM:** The supplied exit code is unused. - /// - **Unix:** On most Unix-like platforms, only the 8 least significant bits will be used, - /// which can cause surprises with negative exit values (`-42` would end up as `214`). See - /// [`std::process::exit`]. - /// - /// [`LoopDestroyed`]: Event::LoopDestroyed - /// [`Exit`]: ControlFlow::Exit - ExitWithCode(i32), -} diff --git a/winit/src/platform_specific/wayland/event_loop/mod.rs b/winit/src/platform_specific/wayland/event_loop/mod.rs index 87d00ec2..d21edcea 100644 --- a/winit/src/platform_specific/wayland/event_loop/mod.rs +++ b/winit/src/platform_specific/wayland/event_loop/mod.rs @@ -1,5 +1,3 @@ -pub mod control_flow; -pub mod proxy; pub mod state; use crate::{ @@ -28,7 +26,7 @@ use cctk::{ reexports::{ calloop::{self, EventLoop}, client::{ - ConnectError, Connection, Proxy, globals::registry_queue_init, + Connection, Proxy, globals::registry_queue_init, }, }, registry::RegistryState, @@ -64,8 +62,8 @@ pub struct SctkEventLoop { pub(crate) state: SctkState, } +#[allow(dead_code)] // payloads kept for Debug; not inspected programmatically pub enum Error { - Connect(ConnectError), Calloop(calloop::Error), Global(GlobalError), NoDisplayHandle, diff --git a/winit/src/platform_specific/wayland/event_loop/proxy.rs b/winit/src/platform_specific/wayland/event_loop/proxy.rs deleted file mode 100644 index bdbc44a4..00000000 --- a/winit/src/platform_specific/wayland/event_loop/proxy.rs +++ /dev/null @@ -1,66 +0,0 @@ -use cctk::sctk::reexports::calloop; -use iced_futures::futures::{ - channel::mpsc, - task::{Context, Poll}, - Sink, -}; -use std::pin::Pin; - -/// An event loop proxy that implements `Sink`. -#[derive(Debug)] -pub struct Proxy { - raw: calloop::channel::Sender, -} - -impl Clone for Proxy { - fn clone(&self) -> Self { - Self { - raw: self.raw.clone(), - } - } -} - -impl Proxy { - /// Creates a new [`Proxy`] from an `EventLoopProxy`. - pub fn new(raw: calloop::channel::Sender) -> Self { - Self { raw } - } - /// send an event - pub fn send_event(&self, message: Message) { - let _ = self.raw.send(message); - } -} - -impl Sink for Proxy { - type Error = mpsc::SendError; - - fn poll_ready( - self: Pin<&mut Self>, - _cx: &mut Context<'_>, - ) -> Poll> { - Poll::Ready(Ok(())) - } - - fn start_send( - self: Pin<&mut Self>, - message: Message, - ) -> Result<(), Self::Error> { - let _ = self.raw.send(message); - - Ok(()) - } - - fn poll_flush( - self: Pin<&mut Self>, - _cx: &mut Context<'_>, - ) -> Poll> { - Poll::Ready(Ok(())) - } - - fn poll_close( - self: Pin<&mut Self>, - _cx: &mut Context<'_>, - ) -> Poll> { - Poll::Ready(Ok(())) - } -} diff --git a/winit/src/platform_specific/wayland/event_loop/state.rs b/winit/src/platform_specific/wayland/event_loop/state.rs index 3d93a015..8be7c639 100644 --- a/winit/src/platform_specific/wayland/event_loop/state.rs +++ b/winit/src/platform_specific/wayland/event_loop/state.rs @@ -33,7 +33,7 @@ use std::{ }; use wayland_backend::client::ObjectId; use winit::{ - dpi::{LogicalPosition, LogicalSize}, + dpi::LogicalSize, platform::wayland::WindowExtWayland, }; @@ -229,9 +229,6 @@ impl CommonSurface { #[derive(Debug, Clone)] pub struct Common { pub(crate) fractional_scale: Option, - pub(crate) has_focus: bool, - pub(crate) ime_pos: LogicalPosition, - pub(crate) ime_size: LogicalSize, pub(crate) size: LogicalSize, pub(crate) requested_size: (Option, Option), pub(crate) wp_viewport: Option, @@ -241,9 +238,6 @@ impl Default for Common { fn default() -> Self { Self { fractional_scale: Default::default(), - has_focus: Default::default(), - ime_pos: Default::default(), - ime_size: Default::default(), size: LogicalSize::new(1, 1), requested_size: (None, None), wp_viewport: None, @@ -336,7 +330,6 @@ pub struct SctkPopupData { pub(crate) parent: PopupParent, pub(crate) toplevel: WlSurface, pub(crate) positioner: Arc, - pub(crate) grab: bool, } #[derive(Debug)] @@ -877,7 +870,6 @@ impl SctkState { parent: parent.clone(), toplevel: toplevel.clone(), positioner: positioner.clone(), - grab: settings.grab, }, last_configure: None, _pending_requests: Default::default(), @@ -1519,7 +1511,6 @@ impl SctkState { SctkEvent::SubsurfaceEvent (crate::sctk_event::SubsurfaceEventVariant::Created{ parent_id, parent, - surface: subsurface, qh: self.queue_handle.clone(), common_surface, surface_id: subsurface_settings.id, diff --git a/winit/src/platform_specific/wayland/mod.rs b/winit/src/platform_specific/wayland/mod.rs index 82304b7c..e613e3b4 100644 --- a/winit/src/platform_specific/wayland/mod.rs +++ b/winit/src/platform_specific/wayland/mod.rs @@ -16,7 +16,7 @@ use cctk::sctk::reexports::client::protocol::wl_surface::WlSurface; use cctk::sctk::seat::keyboard::Modifiers; use cursor_icon::CursorIcon; use iced_futures::futures::channel::mpsc; -use iced_graphics::{Compositor, compositor}; +use iced_graphics::compositor; use iced_runtime::core::{Vector, window}; use raw_window_handle::{HasDisplayHandle, HasWindowHandle, RawWindowHandle}; use sctk_event::SctkEvent; diff --git a/winit/src/platform_specific/wayland/sctk_event.rs b/winit/src/platform_specific/wayland/sctk_event.rs index 8c2b24df..a11ebe66 100755 --- a/winit/src/platform_specific/wayland/sctk_event.rs +++ b/winit/src/platform_specific/wayland/sctk_event.rs @@ -27,7 +27,7 @@ use iced_futures::{ }, futures::{SinkExt, channel::mpsc}, }; -use iced_graphics::{Compositor, compositor}; +use iced_graphics::compositor; use iced_runtime::{ core::{ Point, @@ -282,7 +282,6 @@ pub enum SubsurfaceEventVariant { Created { parent_id: window::Id, parent: WlSurface, - surface: WlSurface, qh: QueueHandle, common_surface: CommonSurface, surface_id: SurfaceId, @@ -1503,7 +1502,6 @@ impl SctkEvent { common, z, parent, - surface: _, qh, surface_id, display, diff --git a/winit/src/platform_specific/wayland/subsurface_widget.rs b/winit/src/platform_specific/wayland/subsurface_widget.rs index 7f15854b..c09e2424 100644 --- a/winit/src/platform_specific/wayland/subsurface_widget.rs +++ b/winit/src/platform_specific/wayland/subsurface_widget.rs @@ -7,7 +7,6 @@ use crate::core::{ widget::{self, Widget}, }; use std::{ - borrow::BorrowMut, cell::RefCell, collections::HashMap, fmt::Debug, @@ -624,7 +623,7 @@ impl Drop for SubsurfaceState { } #[derive(Clone, Debug)] -pub(crate) struct SubsurfaceInstance { +pub struct SubsurfaceInstance { pub(crate) wl_surface: WlSurface, pub(crate) wl_subsurface: WlSubsurface, pub(crate) wp_viewport: WpViewport, diff --git a/winit/src/proxy.rs b/winit/src/proxy.rs index e65de2aa..aabe15c3 100644 --- a/winit/src/proxy.rs +++ b/winit/src/proxy.rs @@ -33,7 +33,7 @@ impl Proxy { const MAX_SIZE: usize = 100; /// Creates a new [`Proxy`] from an `EventLoopProxy`. - pub fn new( + pub(crate) fn new( raw: winit::event_loop::EventLoopProxy, event_sender: mpsc::UnboundedSender>, ) -> (Self, impl Future) { diff --git a/winit/src/window.rs b/winit/src/window.rs index 89368802..ecb2107a 100644 --- a/winit/src/window.rs +++ b/winit/src/window.rs @@ -14,7 +14,7 @@ use crate::core::text; use crate::core::theme::{self, Base}; use crate::core::time::Instant; use crate::core::{ - Color, Element, InputMethod, Padding, Point, Rectangle, Size, Text, Vector, + Color, InputMethod, Padding, Point, Rectangle, Size, Text, Vector, }; use crate::graphics::Compositor; use crate::program::{self, Program}; @@ -26,10 +26,6 @@ use winit::monitor::MonitorHandle; use std::collections::BTreeMap; use std::sync::Arc; -pub(crate) type ViewFn = Arc< - Box Option> + Send + Sync + 'static>, ->; - pub struct WindowManager where P: Program,