diff --git a/crates/adapters/src/lib.rs b/crates/adapters/src/lib.rs index eb83f27..5d4ea8b 100644 --- a/crates/adapters/src/lib.rs +++ b/crates/adapters/src/lib.rs @@ -7,7 +7,7 @@ pub(crate) mod wayland; pub use rendering::femtovg::popup_window::PopupWindow; pub use wayland::config::WaylandWindowConfig; -pub use wayland::facade::{PopupManagerFacade, RuntimeStateFacade, WindowingSystemFacade}; +pub use wayland::facade::{PopupManagerFacade, ShellContextFacade, WindowingSystemFacade}; pub use wayland::shell_adapter::WaylandWindowingSystem; pub use wayland::surfaces::app_state::AppState; pub use wayland::surfaces::popup_manager::PopupManager; diff --git a/crates/adapters/src/wayland/facade.rs b/crates/adapters/src/wayland/facade.rs index 47b9b68..8511f2a 100644 --- a/crates/adapters/src/wayland/facade.rs +++ b/crates/adapters/src/wayland/facade.rs @@ -3,7 +3,7 @@ use crate::wayland::shell_adapter::WaylandWindowingSystem; use crate::wayland::surfaces::popup_manager::PopupManager; use crate::wayland::surfaces::surface_state::WindowState; use layer_shika_domain::errors::DomainError; -use layer_shika_domain::ports::windowing::RuntimeStatePort; +use layer_shika_domain::ports::windowing::ShellContextPort; use slint_interpreter::ComponentInstance; use std::rc::Rc; use std::result::Result as StdResult; @@ -34,11 +34,11 @@ impl WindowingSystemFacade { } } -pub struct RuntimeStateFacade<'a> { +pub struct ShellContextFacade<'a> { window_state: &'a mut WindowState, } -impl<'a> RuntimeStateFacade<'a> { +impl<'a> ShellContextFacade<'a> { pub fn new(window_state: &'a mut WindowState) -> Self { Self { window_state } } @@ -60,7 +60,7 @@ impl<'a> RuntimeStateFacade<'a> { } } -impl RuntimeStatePort for RuntimeStateFacade<'_> { +impl ShellContextPort for ShellContextFacade<'_> { fn render_frame_if_dirty(&mut self) -> StdResult<(), DomainError> { self.window_state .render_frame_if_dirty() diff --git a/crates/adapters/src/wayland/surfaces/surface_state.rs b/crates/adapters/src/wayland/surfaces/surface_state.rs index 3a8b4ad..a10ac3d 100644 --- a/crates/adapters/src/wayland/surfaces/surface_state.rs +++ b/crates/adapters/src/wayland/surfaces/surface_state.rs @@ -15,7 +15,7 @@ use crate::rendering::femtovg::main_window::FemtoVGWindow; use crate::errors::{LayerShikaError, Result}; use core::result::Result as CoreResult; use layer_shika_domain::errors::DomainError; -use layer_shika_domain::ports::windowing::RuntimeStatePort; +use layer_shika_domain::ports::windowing::ShellContextPort; use slint::{LogicalPosition, PhysicalSize}; use slint::platform::WindowEvent; use slint_interpreter::{ComponentInstance, CompilationResult}; @@ -254,7 +254,7 @@ impl WindowState { } } -impl RuntimeStatePort for WindowState { +impl ShellContextPort for WindowState { fn render_frame_if_dirty(&mut self) -> CoreResult<(), DomainError> { WindowState::render_frame_if_dirty(self).map_err(|e| DomainError::Adapter { source: Box::new(e), diff --git a/crates/composition/src/lib.rs b/crates/composition/src/lib.rs index 6e17718..eda2851 100644 --- a/crates/composition/src/lib.rs +++ b/crates/composition/src/lib.rs @@ -23,7 +23,7 @@ pub use layer_shika_domain::value_objects::popup_request::{ PopupAt, PopupHandle, PopupRequest, PopupSize, }; pub use slint_callbacks::{SlintCallbackContract, SlintCallbackNames}; -pub use system::{EventLoopHandle, RuntimeState, WindowingSystem}; +pub use system::{EventLoopHandle, ShellContext, WindowingSystem}; pub mod calloop { pub use layer_shika_adapters::platform::calloop::{ diff --git a/crates/composition/src/system.rs b/crates/composition/src/system.rs index 55cde5a..64c50af 100644 --- a/crates/composition/src/system.rs +++ b/crates/composition/src/system.rs @@ -48,15 +48,15 @@ impl EventLoopHandle { ) -> StdResult where S: EventSource + 'static, - F: FnMut(S::Event, &mut S::Metadata, RuntimeState<'_>) -> R + 'static, + F: FnMut(S::Event, &mut S::Metadata, ShellContext<'_>) -> R + 'static, { let system = self.system.upgrade().ok_or(Error::SystemDropped)?; let loop_handle = system.borrow().inner_ref().event_loop_handle(); loop_handle .insert_source(source, move |event, metadata, app_state| { - let runtime_state = RuntimeState { app_state }; - callback(event, metadata, runtime_state) + let shell_context = ShellContext { app_state }; + callback(event, metadata, shell_context) }) .map_err(|e| { Error::Adapter( @@ -70,21 +70,21 @@ impl EventLoopHandle { pub fn add_timer(&self, duration: Duration, mut callback: F) -> Result where - F: FnMut(Instant, RuntimeState<'_>) -> TimeoutAction + 'static, + F: FnMut(Instant, ShellContext<'_>) -> TimeoutAction + 'static, { let timer = Timer::from_duration(duration); - self.insert_source(timer, move |deadline, (), runtime_state| { - callback(deadline, runtime_state) + self.insert_source(timer, move |deadline, (), shell_context| { + callback(deadline, shell_context) }) } pub fn add_timer_at(&self, deadline: Instant, mut callback: F) -> Result where - F: FnMut(Instant, RuntimeState<'_>) -> TimeoutAction + 'static, + F: FnMut(Instant, ShellContext<'_>) -> TimeoutAction + 'static, { let timer = Timer::from_deadline(deadline); - self.insert_source(timer, move |deadline, (), runtime_state| { - callback(deadline, runtime_state) + self.insert_source(timer, move |deadline, (), shell_context| { + callback(deadline, shell_context) }) } @@ -94,12 +94,12 @@ impl EventLoopHandle { ) -> Result<(RegistrationToken, channel::Sender)> where T: 'static, - F: FnMut(T, RuntimeState<'_>) + 'static, + F: FnMut(T, ShellContext<'_>) + 'static, { let (sender, receiver) = channel::channel(); - let token = self.insert_source(receiver, move |event, (), runtime_state| { + let token = self.insert_source(receiver, move |event, (), shell_context| { if let channel::Event::Msg(msg) = event { - callback(msg, runtime_state); + callback(msg, shell_context); } })?; Ok((token, sender)) @@ -114,21 +114,21 @@ impl EventLoopHandle { ) -> Result where T: AsFd + 'static, - F: FnMut(RuntimeState<'_>) + 'static, + F: FnMut(ShellContext<'_>) + 'static, { let generic = Generic::new(fd, interest, mode); - self.insert_source(generic, move |_readiness, _fd, runtime_state| { - callback(runtime_state); + self.insert_source(generic, move |_readiness, _fd, shell_context| { + callback(shell_context); Ok(PostAction::Continue) }) } } -pub struct RuntimeState<'a> { +pub struct ShellContext<'a> { app_state: &'a mut AppState, } -impl RuntimeState<'_> { +impl ShellContext<'_> { #[must_use] pub fn component_instance(&self) -> Option<&ComponentInstance> { self.app_state @@ -437,18 +437,18 @@ impl WindowingSystem { loop_handle .insert_source(receiver, move |event, (), app_state| { if let channel::Event::Msg(command) = event { - let mut runtime_state = RuntimeState { app_state }; + let mut shell_context = ShellContext { app_state }; match command { PopupCommand::Show(request) => { if let Err(e) = - runtime_state.show_popup(request, Some(sender_for_handler.clone())) + shell_context.show_popup(request, Some(sender_for_handler.clone())) { log::error!("Failed to show popup: {}", e); } } PopupCommand::Close(handle) => { - if let Err(e) = runtime_state.close_popup(handle) { + if let Err(e) = shell_context.close_popup(handle) { log::error!("Failed to close popup: {}", e); } } @@ -457,7 +457,7 @@ impl WindowingSystem { width, height, } => { - if let Err(e) = runtime_state.resize_popup( + if let Err(e) = shell_context.resize_popup( handle, width, height, diff --git a/crates/domain/src/ports/windowing.rs b/crates/domain/src/ports/windowing.rs index 82e1541..769301b 100644 --- a/crates/domain/src/ports/windowing.rs +++ b/crates/domain/src/ports/windowing.rs @@ -4,6 +4,6 @@ pub trait WindowingSystemPort { fn run(&mut self) -> Result<(), DomainError>; } -pub trait RuntimeStatePort { +pub trait ShellContextPort { fn render_frame_if_dirty(&mut self) -> Result<(), DomainError>; } diff --git a/src/lib.rs b/src/lib.rs index 9a3210f..6379415 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,7 +47,7 @@ pub mod prelude; pub use layer_shika_composition::{ AnchorEdges, Error, EventLoopHandle, KeyboardInteractivity, Layer, LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupAt, PopupHandle, PopupPositioningMode, - PopupRequest, PopupSize, PopupWindow, Result, RuntimeState, SlintCallbackContract, + PopupRequest, PopupSize, PopupWindow, Result, ShellContext, SlintCallbackContract, SlintCallbackNames, WindowingSystem, }; diff --git a/src/prelude.rs b/src/prelude.rs index 3eab030..a275cdb 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -10,7 +10,7 @@ // Core API types pub use crate::{ - Error, EventLoopHandle, LayerShika, PopupWindow, Result, RuntimeState, SlintCallbackContract, + Error, EventLoopHandle, LayerShika, PopupWindow, Result, ShellContext, SlintCallbackContract, SlintCallbackNames, WindowingSystem, };