mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-12-23 09:15:55 +00:00
refactor: renaming
This commit is contained in:
parent
3e7bc76bb4
commit
f31b039a02
8 changed files with 32 additions and 32 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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::{
|
||||
|
|
|
|||
|
|
@ -48,15 +48,15 @@ impl EventLoopHandle {
|
|||
) -> StdResult<RegistrationToken, Error>
|
||||
where
|
||||
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 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<F>(&self, duration: Duration, mut callback: F) -> Result<RegistrationToken>
|
||||
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<F>(&self, deadline: Instant, mut callback: F) -> Result<RegistrationToken>
|
||||
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<T>)>
|
||||
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<RegistrationToken>
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue