From f166df4d979162ae09b439c87cdc64f2b0981308 Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Wed, 31 Jul 2024 17:34:00 +0200 Subject: Split crates/wayland/src/winit.rs (889 lines) into winit/ Pure reorganization, no behavior change - verified by diffing the function-name and struct-name sets before/after (both identical) plus a full cargo test pass. mod.rs keeps the module doc comment, imports, WaylandPlatform's struct definition, and TARGET_FRAME_TIME, plus mod declarations. The rest splits by concern: - connect.rs: connect(), the ~200-line setup/init function. - run.rs: accept_clients, pump_winit - the small per-poll pair. - render.rs: render_frame, the per-frame render loop (left as one intact ~330-line function, same reasoning as udev's render.rs: its structure is deliberate and already documented inline, not a target for further decomposition in a pure reorganization pass). - capture.rs: capture_offscreen, the screencopy path. - events.rs: handle_winit_event. - platform.rs: `impl Platform for WaylandPlatform`. No tests module existed in the original file, so none was split out. A handful of methods/functions (accept_clients, pump_winit, render_frame, capture_offscreen, handle_winit_event) went from private to pub(super): called across what are now sibling submodules, which Rust's privacy model doesn't let see each other's private items. --- crates/wayland/src/winit/run.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 crates/wayland/src/winit/run.rs (limited to 'crates/wayland/src/winit/run.rs') diff --git a/crates/wayland/src/winit/run.rs b/crates/wayland/src/winit/run.rs new file mode 100644 index 0000000..ed7c4c3 --- /dev/null +++ b/crates/wayland/src/winit/run.rs @@ -0,0 +1,26 @@ +use super::*; +use super::events::handle_winit_event; + +impl WaylandPlatform { + + pub(super) fn accept_clients(&mut self) -> PlatformResult<()> { + if let Some(stream) = self.listener.accept().map_err(err)? { + let client = self.display.handle().insert_client(stream, std::sync::Arc::new(ClientState::default())).map_err(err)?; + self.clients.push(client); + } + Ok(()) + } + + pub(super) fn pump_winit(&mut self) -> PlatformResult { + let mut closed = false; + let state = &mut self.state; + let output = &self.output; + let pump = self.winit_events.dispatch_new_events(|event| { + handle_winit_event(state, output, event, &mut closed); + }); + if matches!(pump, PumpStatus::Exit(_)) { + closed = true; + } + Ok(closed) + } +} -- cgit v1.2.3