refactor: renaming

This commit is contained in:
drendog 2025-11-19 01:47:00 +01:00
parent 3e7bc76bb4
commit f31b039a02
Signed by: dwenya
GPG key ID: 8DD77074645332D0
8 changed files with 32 additions and 32 deletions

View file

@ -7,7 +7,7 @@ pub(crate) mod wayland;
pub use rendering::femtovg::popup_window::PopupWindow; pub use rendering::femtovg::popup_window::PopupWindow;
pub use wayland::config::WaylandWindowConfig; 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::shell_adapter::WaylandWindowingSystem;
pub use wayland::surfaces::app_state::AppState; pub use wayland::surfaces::app_state::AppState;
pub use wayland::surfaces::popup_manager::PopupManager; pub use wayland::surfaces::popup_manager::PopupManager;

View file

@ -3,7 +3,7 @@ use crate::wayland::shell_adapter::WaylandWindowingSystem;
use crate::wayland::surfaces::popup_manager::PopupManager; use crate::wayland::surfaces::popup_manager::PopupManager;
use crate::wayland::surfaces::surface_state::WindowState; use crate::wayland::surfaces::surface_state::WindowState;
use layer_shika_domain::errors::DomainError; 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 slint_interpreter::ComponentInstance;
use std::rc::Rc; use std::rc::Rc;
use std::result::Result as StdResult; 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, window_state: &'a mut WindowState,
} }
impl<'a> RuntimeStateFacade<'a> { impl<'a> ShellContextFacade<'a> {
pub fn new(window_state: &'a mut WindowState) -> Self { pub fn new(window_state: &'a mut WindowState) -> Self {
Self { window_state } 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> { fn render_frame_if_dirty(&mut self) -> StdResult<(), DomainError> {
self.window_state self.window_state
.render_frame_if_dirty() .render_frame_if_dirty()

View file

@ -15,7 +15,7 @@ use crate::rendering::femtovg::main_window::FemtoVGWindow;
use crate::errors::{LayerShikaError, Result}; use crate::errors::{LayerShikaError, Result};
use core::result::Result as CoreResult; use core::result::Result as CoreResult;
use layer_shika_domain::errors::DomainError; 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::{LogicalPosition, PhysicalSize};
use slint::platform::WindowEvent; use slint::platform::WindowEvent;
use slint_interpreter::{ComponentInstance, CompilationResult}; 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> { fn render_frame_if_dirty(&mut self) -> CoreResult<(), DomainError> {
WindowState::render_frame_if_dirty(self).map_err(|e| DomainError::Adapter { WindowState::render_frame_if_dirty(self).map_err(|e| DomainError::Adapter {
source: Box::new(e), source: Box::new(e),

View file

@ -23,7 +23,7 @@ pub use layer_shika_domain::value_objects::popup_request::{
PopupAt, PopupHandle, PopupRequest, PopupSize, PopupAt, PopupHandle, PopupRequest, PopupSize,
}; };
pub use slint_callbacks::{SlintCallbackContract, SlintCallbackNames}; pub use slint_callbacks::{SlintCallbackContract, SlintCallbackNames};
pub use system::{EventLoopHandle, RuntimeState, WindowingSystem}; pub use system::{EventLoopHandle, ShellContext, WindowingSystem};
pub mod calloop { pub mod calloop {
pub use layer_shika_adapters::platform::calloop::{ pub use layer_shika_adapters::platform::calloop::{

View file

@ -48,15 +48,15 @@ impl EventLoopHandle {
) -> StdResult<RegistrationToken, Error> ) -> StdResult<RegistrationToken, Error>
where where
S: EventSource<Ret = R> + 'static, S: EventSource<Ret = R> + '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 system = self.system.upgrade().ok_or(Error::SystemDropped)?;
let loop_handle = system.borrow().inner_ref().event_loop_handle(); let loop_handle = system.borrow().inner_ref().event_loop_handle();
loop_handle loop_handle
.insert_source(source, move |event, metadata, app_state| { .insert_source(source, move |event, metadata, app_state| {
let runtime_state = RuntimeState { app_state }; let shell_context = ShellContext { app_state };
callback(event, metadata, runtime_state) callback(event, metadata, shell_context)
}) })
.map_err(|e| { .map_err(|e| {
Error::Adapter( Error::Adapter(
@ -70,21 +70,21 @@ impl EventLoopHandle {
pub fn add_timer<F>(&self, duration: Duration, mut callback: F) -> Result<RegistrationToken> pub fn add_timer<F>(&self, duration: Duration, mut callback: F) -> Result<RegistrationToken>
where where
F: FnMut(Instant, RuntimeState<'_>) -> TimeoutAction + 'static, F: FnMut(Instant, ShellContext<'_>) -> TimeoutAction + 'static,
{ {
let timer = Timer::from_duration(duration); let timer = Timer::from_duration(duration);
self.insert_source(timer, move |deadline, (), runtime_state| { self.insert_source(timer, move |deadline, (), shell_context| {
callback(deadline, runtime_state) callback(deadline, shell_context)
}) })
} }
pub fn add_timer_at<F>(&self, deadline: Instant, mut callback: F) -> Result<RegistrationToken> pub fn add_timer_at<F>(&self, deadline: Instant, mut callback: F) -> Result<RegistrationToken>
where where
F: FnMut(Instant, RuntimeState<'_>) -> TimeoutAction + 'static, F: FnMut(Instant, ShellContext<'_>) -> TimeoutAction + 'static,
{ {
let timer = Timer::from_deadline(deadline); let timer = Timer::from_deadline(deadline);
self.insert_source(timer, move |deadline, (), runtime_state| { self.insert_source(timer, move |deadline, (), shell_context| {
callback(deadline, runtime_state) callback(deadline, shell_context)
}) })
} }
@ -94,12 +94,12 @@ impl EventLoopHandle {
) -> Result<(RegistrationToken, channel::Sender<T>)> ) -> Result<(RegistrationToken, channel::Sender<T>)>
where where
T: 'static, T: 'static,
F: FnMut(T, RuntimeState<'_>) + 'static, F: FnMut(T, ShellContext<'_>) + 'static,
{ {
let (sender, receiver) = channel::channel(); 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 { if let channel::Event::Msg(msg) = event {
callback(msg, runtime_state); callback(msg, shell_context);
} }
})?; })?;
Ok((token, sender)) Ok((token, sender))
@ -114,21 +114,21 @@ impl EventLoopHandle {
) -> Result<RegistrationToken> ) -> Result<RegistrationToken>
where where
T: AsFd + 'static, T: AsFd + 'static,
F: FnMut(RuntimeState<'_>) + 'static, F: FnMut(ShellContext<'_>) + 'static,
{ {
let generic = Generic::new(fd, interest, mode); let generic = Generic::new(fd, interest, mode);
self.insert_source(generic, move |_readiness, _fd, runtime_state| { self.insert_source(generic, move |_readiness, _fd, shell_context| {
callback(runtime_state); callback(shell_context);
Ok(PostAction::Continue) Ok(PostAction::Continue)
}) })
} }
} }
pub struct RuntimeState<'a> { pub struct ShellContext<'a> {
app_state: &'a mut AppState, app_state: &'a mut AppState,
} }
impl RuntimeState<'_> { impl ShellContext<'_> {
#[must_use] #[must_use]
pub fn component_instance(&self) -> Option<&ComponentInstance> { pub fn component_instance(&self) -> Option<&ComponentInstance> {
self.app_state self.app_state
@ -437,18 +437,18 @@ impl WindowingSystem {
loop_handle loop_handle
.insert_source(receiver, move |event, (), app_state| { .insert_source(receiver, move |event, (), app_state| {
if let channel::Event::Msg(command) = event { if let channel::Event::Msg(command) = event {
let mut runtime_state = RuntimeState { app_state }; let mut shell_context = ShellContext { app_state };
match command { match command {
PopupCommand::Show(request) => { PopupCommand::Show(request) => {
if let Err(e) = 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); log::error!("Failed to show popup: {}", e);
} }
} }
PopupCommand::Close(handle) => { 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); log::error!("Failed to close popup: {}", e);
} }
} }
@ -457,7 +457,7 @@ impl WindowingSystem {
width, width,
height, height,
} => { } => {
if let Err(e) = runtime_state.resize_popup( if let Err(e) = shell_context.resize_popup(
handle, handle,
width, width,
height, height,

View file

@ -4,6 +4,6 @@ pub trait WindowingSystemPort {
fn run(&mut self) -> Result<(), DomainError>; fn run(&mut self) -> Result<(), DomainError>;
} }
pub trait RuntimeStatePort { pub trait ShellContextPort {
fn render_frame_if_dirty(&mut self) -> Result<(), DomainError>; fn render_frame_if_dirty(&mut self) -> Result<(), DomainError>;
} }

View file

@ -47,7 +47,7 @@ pub mod prelude;
pub use layer_shika_composition::{ pub use layer_shika_composition::{
AnchorEdges, Error, EventLoopHandle, KeyboardInteractivity, Layer, LayerShika, OutputGeometry, AnchorEdges, Error, EventLoopHandle, KeyboardInteractivity, Layer, LayerShika, OutputGeometry,
OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupAt, PopupHandle, PopupPositioningMode, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupAt, PopupHandle, PopupPositioningMode,
PopupRequest, PopupSize, PopupWindow, Result, RuntimeState, SlintCallbackContract, PopupRequest, PopupSize, PopupWindow, Result, ShellContext, SlintCallbackContract,
SlintCallbackNames, WindowingSystem, SlintCallbackNames, WindowingSystem,
}; };

View file

@ -10,7 +10,7 @@
// Core API types // Core API types
pub use crate::{ pub use crate::{
Error, EventLoopHandle, LayerShika, PopupWindow, Result, RuntimeState, SlintCallbackContract, Error, EventLoopHandle, LayerShika, PopupWindow, Result, ShellContext, SlintCallbackContract,
SlintCallbackNames, WindowingSystem, SlintCallbackNames, WindowingSystem,
}; };