mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-12-12 14:25:54 +00:00
refactor: rename window to surface to avoid misleading
This commit is contained in:
parent
8c9e5fb92c
commit
21e636aabf
29 changed files with 390 additions and 386 deletions
|
|
@ -7,11 +7,11 @@ pub(crate) mod wayland;
|
||||||
pub use rendering::femtovg::popup_window::PopupWindow;
|
pub use rendering::femtovg::popup_window::PopupWindow;
|
||||||
|
|
||||||
pub use wayland::config::{MultiSurfaceConfig, ShellSurfaceConfig, WaylandSurfaceConfig};
|
pub use wayland::config::{MultiSurfaceConfig, ShellSurfaceConfig, WaylandSurfaceConfig};
|
||||||
pub use wayland::facade::WindowingSystemFacade;
|
pub use wayland::facade::ShellSystemFacade;
|
||||||
pub use wayland::shell_adapter::WaylandWindowingSystem;
|
pub use wayland::shell_adapter::WaylandShellSystem;
|
||||||
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;
|
||||||
pub use wayland::surfaces::surface_state::WindowState;
|
pub use wayland::surfaces::surface_state::SurfaceState;
|
||||||
|
|
||||||
pub mod platform {
|
pub mod platform {
|
||||||
pub use slint;
|
pub use slint;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::wayland::surfaces::app_state::AppState;
|
use crate::wayland::surfaces::app_state::AppState;
|
||||||
use crate::wayland::surfaces::display_metrics::DisplayMetrics;
|
use crate::wayland::surfaces::display_metrics::DisplayMetrics;
|
||||||
use crate::wayland::surfaces::surface_state::WindowState;
|
use crate::wayland::surfaces::surface_state::SurfaceState;
|
||||||
use layer_shika_domain::value_objects::output_info::OutputGeometry;
|
use layer_shika_domain::value_objects::output_info::OutputGeometry;
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::{
|
use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::{
|
||||||
|
|
@ -50,7 +50,7 @@ impl Dispatch<ZwlrLayerSurfaceV1, ()> for AppState {
|
||||||
height,
|
height,
|
||||||
} => {
|
} => {
|
||||||
let layer_surface_id = layer_surface.id();
|
let layer_surface_id = layer_surface.id();
|
||||||
let Some(window) = state.get_output_by_layer_surface_mut(&layer_surface_id) else {
|
let Some(surface) = state.get_output_by_layer_surface_mut(&layer_surface_id) else {
|
||||||
info!(
|
info!(
|
||||||
"Could not find window for layer surface {:?}",
|
"Could not find window for layer surface {:?}",
|
||||||
layer_surface_id
|
layer_surface_id
|
||||||
|
|
@ -58,12 +58,12 @@ impl Dispatch<ZwlrLayerSurfaceV1, ()> for AppState {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
window.handle_layer_surface_configure(layer_surface, serial, width, height);
|
surface.handle_layer_surface_configure(layer_surface, serial, width, height);
|
||||||
}
|
}
|
||||||
zwlr_layer_surface_v1::Event::Closed => {
|
zwlr_layer_surface_v1::Event::Closed => {
|
||||||
let layer_surface_id = layer_surface.id();
|
let layer_surface_id = layer_surface.id();
|
||||||
if let Some(window) = state.get_output_by_layer_surface_mut(&layer_surface_id) {
|
if let Some(surface) = state.get_output_by_layer_surface_mut(&layer_surface_id) {
|
||||||
window.handle_layer_surface_closed();
|
surface.handle_layer_surface_closed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
@ -98,8 +98,8 @@ impl Dispatch<WlOutput, ()> for AppState {
|
||||||
width, height, is_current, is_preferred
|
width, height, is_current, is_preferred
|
||||||
);
|
);
|
||||||
if is_current {
|
if is_current {
|
||||||
for window in state.all_windows_for_output_mut(&output_id) {
|
for surface in state.all_surfaces_for_output_mut(&output_id) {
|
||||||
window.handle_output_mode(width, height);
|
surface.handle_output_mode(width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -203,13 +203,13 @@ impl Dispatch<WlPointer, ()> for AppState {
|
||||||
let surface_id = surface.id();
|
let surface_id = surface.id();
|
||||||
|
|
||||||
if let Some(key) = state.get_key_by_surface(&surface_id).cloned() {
|
if let Some(key) = state.get_key_by_surface(&surface_id).cloned() {
|
||||||
if let Some(window) = state.get_window_by_key_mut(&key) {
|
if let Some(layer_surface) = state.get_surface_by_key_mut(&key) {
|
||||||
window.handle_pointer_enter(serial, &surface, surface_x, surface_y);
|
layer_surface.handle_pointer_enter(serial, &surface, surface_x, surface_y);
|
||||||
}
|
}
|
||||||
state.set_active_surface_key(Some(key));
|
state.set_active_surface_key(Some(key));
|
||||||
} else if let Some(key) = state.get_key_by_popup(&surface_id).cloned() {
|
} else if let Some(key) = state.get_key_by_popup(&surface_id).cloned() {
|
||||||
if let Some(window) = state.get_window_by_key_mut(&key) {
|
if let Some(layer_surface) = state.get_surface_by_key_mut(&key) {
|
||||||
window.handle_pointer_enter(serial, &surface, surface_x, surface_y);
|
layer_surface.handle_pointer_enter(serial, &surface, surface_x, surface_y);
|
||||||
}
|
}
|
||||||
state.set_active_surface_key(Some(key));
|
state.set_active_surface_key(Some(key));
|
||||||
}
|
}
|
||||||
|
|
@ -220,14 +220,14 @@ impl Dispatch<WlPointer, ()> for AppState {
|
||||||
surface_y,
|
surface_y,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if let Some(window) = state.active_surface_mut() {
|
if let Some(surface) = state.active_surface_mut() {
|
||||||
window.handle_pointer_motion(surface_x, surface_y);
|
surface.handle_pointer_motion(surface_x, surface_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_pointer::Event::Leave { .. } => {
|
wl_pointer::Event::Leave { .. } => {
|
||||||
if let Some(window) = state.active_surface_mut() {
|
if let Some(surface) = state.active_surface_mut() {
|
||||||
window.handle_pointer_leave();
|
surface.handle_pointer_leave();
|
||||||
}
|
}
|
||||||
state.set_active_surface_key(None);
|
state.set_active_surface_key(None);
|
||||||
}
|
}
|
||||||
|
|
@ -237,8 +237,8 @@ impl Dispatch<WlPointer, ()> for AppState {
|
||||||
state: button_state,
|
state: button_state,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if let Some(window) = state.active_surface_mut() {
|
if let Some(surface) = state.active_surface_mut() {
|
||||||
window.handle_pointer_button(serial, button_state);
|
surface.handle_pointer_button(serial, button_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
@ -259,8 +259,8 @@ impl Dispatch<WpFractionalScaleV1, ()> for AppState {
|
||||||
let scale_float = DisplayMetrics::scale_factor_from_120ths(scale);
|
let scale_float = DisplayMetrics::scale_factor_from_120ths(scale);
|
||||||
info!("Fractional scale received: {scale_float} ({scale}x)");
|
info!("Fractional scale received: {scale_float} ({scale}x)");
|
||||||
|
|
||||||
for window in state.all_outputs_mut() {
|
for surface in state.all_outputs_mut() {
|
||||||
window.handle_fractional_scale(proxy, scale);
|
surface.handle_fractional_scale(proxy, scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -276,7 +276,7 @@ impl Dispatch<XdgWmBase, ()> for AppState {
|
||||||
_qhandle: &QueueHandle<Self>,
|
_qhandle: &QueueHandle<Self>,
|
||||||
) {
|
) {
|
||||||
if let xdg_wm_base::Event::Ping { serial } = event {
|
if let xdg_wm_base::Event::Ping { serial } = event {
|
||||||
WindowState::handle_xdg_wm_base_ping(xdg_wm_base, serial);
|
SurfaceState::handle_xdg_wm_base_ping(xdg_wm_base, serial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -298,10 +298,10 @@ impl Dispatch<XdgPopup, ()> for AppState {
|
||||||
height,
|
height,
|
||||||
} => {
|
} => {
|
||||||
let popup_id = xdg_popup.id();
|
let popup_id = xdg_popup.id();
|
||||||
for window in state.all_outputs_mut() {
|
for surface in state.all_outputs_mut() {
|
||||||
if let Some(popup_manager) = window.popup_manager() {
|
if let Some(popup_manager) = surface.popup_manager() {
|
||||||
if popup_manager.find_by_xdg_popup(&popup_id).is_some() {
|
if popup_manager.find_by_xdg_popup(&popup_id).is_some() {
|
||||||
window.handle_xdg_popup_configure(xdg_popup, x, y, width, height);
|
surface.handle_xdg_popup_configure(xdg_popup, x, y, width, height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -311,14 +311,14 @@ impl Dispatch<XdgPopup, ()> for AppState {
|
||||||
info!("XdgPopup dismissed by compositor");
|
info!("XdgPopup dismissed by compositor");
|
||||||
let popup_id = xdg_popup.id();
|
let popup_id = xdg_popup.id();
|
||||||
|
|
||||||
for window in state.all_outputs_mut() {
|
for surface in state.all_outputs_mut() {
|
||||||
let popup_handle = window
|
let popup_handle = surface
|
||||||
.popup_manager()
|
.popup_manager()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|pm| pm.find_by_xdg_popup(&popup_id));
|
.and_then(|pm| pm.find_by_xdg_popup(&popup_id));
|
||||||
|
|
||||||
if popup_handle.is_some() {
|
if popup_handle.is_some() {
|
||||||
window.handle_xdg_popup_done(xdg_popup);
|
surface.handle_xdg_popup_done(xdg_popup);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -327,8 +327,8 @@ impl Dispatch<XdgPopup, ()> for AppState {
|
||||||
info!("XdgPopup repositioned with token {token}");
|
info!("XdgPopup repositioned with token {token}");
|
||||||
|
|
||||||
let popup_id = xdg_popup.id();
|
let popup_id = xdg_popup.id();
|
||||||
for window in state.all_outputs_mut() {
|
for surface in state.all_outputs_mut() {
|
||||||
if let Some(popup_manager) = window.popup_manager() {
|
if let Some(popup_manager) = surface.popup_manager() {
|
||||||
if let Some(handle) = popup_manager.find_by_xdg_popup(&popup_id) {
|
if let Some(handle) = popup_manager.find_by_xdg_popup(&popup_id) {
|
||||||
info!("Committing popup surface after reposition");
|
info!("Committing popup surface after reposition");
|
||||||
popup_manager.commit_popup_surface(handle.key());
|
popup_manager.commit_popup_surface(handle.key());
|
||||||
|
|
@ -353,10 +353,10 @@ impl Dispatch<XdgSurface, ()> for AppState {
|
||||||
) {
|
) {
|
||||||
if let xdg_surface::Event::Configure { serial } = event {
|
if let xdg_surface::Event::Configure { serial } = event {
|
||||||
let xdg_surface_id = xdg_surface.id();
|
let xdg_surface_id = xdg_surface.id();
|
||||||
for window in state.all_outputs_mut() {
|
for surface in state.all_outputs_mut() {
|
||||||
if let Some(popup_manager) = window.popup_manager() {
|
if let Some(popup_manager) = surface.popup_manager() {
|
||||||
if popup_manager.find_by_xdg_surface(&xdg_surface_id).is_some() {
|
if popup_manager.find_by_xdg_surface(&xdg_surface_id).is_some() {
|
||||||
window.handle_xdg_surface_configure(xdg_surface, serial);
|
surface.handle_xdg_surface_configure(xdg_surface, serial);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::wayland::surfaces::surface_state::WindowState;
|
use crate::wayland::surfaces::surface_state::SurfaceState;
|
||||||
use log::info;
|
use log::info;
|
||||||
use slint::{
|
use slint::{
|
||||||
PhysicalSize,
|
PhysicalSize,
|
||||||
|
|
@ -24,7 +24,7 @@ use wayland_protocols::xdg::shell::client::{
|
||||||
xdg_wm_base::XdgWmBase,
|
xdg_wm_base::XdgWmBase,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl WindowState {
|
impl SurfaceState {
|
||||||
#[allow(clippy::cast_possible_truncation)]
|
#[allow(clippy::cast_possible_truncation)]
|
||||||
#[allow(clippy::cast_sign_loss)]
|
#[allow(clippy::cast_sign_loss)]
|
||||||
#[allow(clippy::cast_precision_loss)]
|
#[allow(clippy::cast_precision_loss)]
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
use crate::errors::Result;
|
use crate::errors::Result;
|
||||||
use crate::wayland::shell_adapter::WaylandWindowingSystem;
|
use crate::wayland::shell_adapter::WaylandShellSystem;
|
||||||
use slint_interpreter::ComponentInstance;
|
use slint_interpreter::ComponentInstance;
|
||||||
|
|
||||||
pub struct WindowingSystemFacade {
|
pub struct ShellSystemFacade {
|
||||||
inner: WaylandWindowingSystem,
|
inner: WaylandShellSystem,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowingSystemFacade {
|
impl ShellSystemFacade {
|
||||||
pub fn new(inner: WaylandWindowingSystem) -> Self {
|
pub fn new(inner: WaylandShellSystem) -> Self {
|
||||||
Self { inner }
|
Self { inner }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_ref(&self) -> &WaylandWindowingSystem {
|
pub fn inner_ref(&self) -> &WaylandShellSystem {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_mut(&mut self) -> &mut WaylandWindowingSystem {
|
pub fn inner_mut(&mut self) -> &mut WaylandShellSystem {
|
||||||
&mut self.inner
|
&mut self.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,8 +105,7 @@ impl GlobalContext {
|
||||||
info!("Viewporter protocol not available");
|
info!("Viewporter protocol not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
let render_context_manager =
|
let render_context_manager = RenderContextManager::new(&connection.display().id())?;
|
||||||
RenderContextManager::new(&connection.display().id())?;
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
compositor,
|
compositor,
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@ use crate::{
|
||||||
rendering::egl::context_factory::RenderContextFactory,
|
rendering::egl::context_factory::RenderContextFactory,
|
||||||
wayland::{
|
wayland::{
|
||||||
config::{LayerSurfaceConfig, WaylandSurfaceConfig},
|
config::{LayerSurfaceConfig, WaylandSurfaceConfig},
|
||||||
shell_adapter::WaylandWindowingSystem,
|
shell_adapter::WaylandShellSystem,
|
||||||
surfaces::{
|
surfaces::{
|
||||||
app_state::AppState,
|
app_state::AppState,
|
||||||
event_context::SharedPointerSerial,
|
event_context::SharedPointerSerial,
|
||||||
layer_surface::{SurfaceCtx, SurfaceSetupParams},
|
layer_surface::{SurfaceCtx, SurfaceSetupParams},
|
||||||
popup_manager::{PopupContext, PopupManager},
|
popup_manager::{PopupContext, PopupManager},
|
||||||
surface_builder::WindowStateBuilder,
|
surface_builder::SurfaceStateBuilder,
|
||||||
surface_state::WindowState,
|
surface_state::SurfaceState,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -141,14 +141,14 @@ impl OutputManager {
|
||||||
output_id, is_primary
|
output_id, is_primary
|
||||||
);
|
);
|
||||||
|
|
||||||
let (window, main_surface_id) =
|
let (surface, main_surface_id) =
|
||||||
self.create_window_for_output(&pending_output.proxy, output_id, queue_handle)?;
|
self.create_window_for_output(&pending_output.proxy, output_id, queue_handle)?;
|
||||||
|
|
||||||
app_state.add_output(
|
app_state.add_output(
|
||||||
output_id,
|
output_id,
|
||||||
&self.config.surface_name,
|
&self.config.surface_name,
|
||||||
main_surface_id,
|
main_surface_id,
|
||||||
window,
|
surface,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -159,7 +159,7 @@ impl OutputManager {
|
||||||
output: &WlOutput,
|
output: &WlOutput,
|
||||||
_output_id: &ObjectId,
|
_output_id: &ObjectId,
|
||||||
queue_handle: &QueueHandle<AppState>,
|
queue_handle: &QueueHandle<AppState>,
|
||||||
) -> Result<(WindowState, ObjectId)> {
|
) -> Result<(SurfaceState, ObjectId)> {
|
||||||
let setup_params = SurfaceSetupParams {
|
let setup_params = SurfaceSetupParams {
|
||||||
compositor: &self.context.compositor,
|
compositor: &self.context.compositor,
|
||||||
output,
|
output,
|
||||||
|
|
@ -174,13 +174,13 @@ impl OutputManager {
|
||||||
let surface_ctx = SurfaceCtx::setup(&setup_params, &self.layer_surface_config);
|
let surface_ctx = SurfaceCtx::setup(&setup_params, &self.layer_surface_config);
|
||||||
let main_surface_id = surface_ctx.surface.id();
|
let main_surface_id = surface_ctx.surface.id();
|
||||||
|
|
||||||
let window = WaylandWindowingSystem::initialize_renderer(
|
let window = WaylandShellSystem::initialize_renderer(
|
||||||
&surface_ctx.surface,
|
&surface_ctx.surface,
|
||||||
&self.config,
|
&self.config,
|
||||||
&self.context.render_factory,
|
&self.context.render_factory,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let mut builder = WindowStateBuilder::new()
|
let mut builder = SurfaceStateBuilder::new()
|
||||||
.with_component_definition(self.config.component_definition.clone())
|
.with_component_definition(self.config.component_definition.clone())
|
||||||
.with_compilation_result(self.config.compilation_result.clone())
|
.with_compilation_result(self.config.compilation_result.clone())
|
||||||
.with_surface(Rc::clone(&surface_ctx.surface))
|
.with_surface(Rc::clone(&surface_ctx.surface))
|
||||||
|
|
@ -202,7 +202,7 @@ impl OutputManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut window_state =
|
let mut window_state =
|
||||||
WindowState::new(builder).map_err(|e| LayerShikaError::WindowConfiguration {
|
SurfaceState::new(builder).map_err(|e| LayerShikaError::WindowConfiguration {
|
||||||
message: e.to_string(),
|
message: e.to_string(),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ use crate::wayland::{
|
||||||
surfaces::{
|
surfaces::{
|
||||||
app_state::AppState,
|
app_state::AppState,
|
||||||
event_context::SharedPointerSerial,
|
event_context::SharedPointerSerial,
|
||||||
surface_builder::{PlatformWrapper, WindowStateBuilder},
|
surface_builder::{PlatformWrapper, SurfaceStateBuilder},
|
||||||
surface_state::WindowState,
|
surface_state::SurfaceState,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1;
|
use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1;
|
||||||
|
|
@ -23,7 +23,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
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::WindowingSystemPort;
|
use layer_shika_domain::ports::shell::ShellSystemPort;
|
||||||
use layer_shika_domain::value_objects::output_handle::OutputHandle;
|
use layer_shika_domain::value_objects::output_handle::OutputHandle;
|
||||||
use layer_shika_domain::value_objects::output_info::OutputInfo;
|
use layer_shika_domain::value_objects::output_info::OutputInfo;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
|
|
@ -49,7 +49,7 @@ struct OutputSetup {
|
||||||
output_id: ObjectId,
|
output_id: ObjectId,
|
||||||
main_surface_id: ObjectId,
|
main_surface_id: ObjectId,
|
||||||
window: Rc<FemtoVGWindow>,
|
window: Rc<FemtoVGWindow>,
|
||||||
builder: WindowStateBuilder,
|
builder: SurfaceStateBuilder,
|
||||||
shell_surface_name: String,
|
shell_surface_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,14 +64,14 @@ struct OutputManagerParams<'a> {
|
||||||
shared_serial: &'a Rc<SharedPointerSerial>,
|
shared_serial: &'a Rc<SharedPointerSerial>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WaylandWindowingSystem {
|
pub struct WaylandShellSystem {
|
||||||
state: AppState,
|
state: AppState,
|
||||||
connection: Rc<Connection>,
|
connection: Rc<Connection>,
|
||||||
event_queue: EventQueue<AppState>,
|
event_queue: EventQueue<AppState>,
|
||||||
event_loop: EventLoop<'static, AppState>,
|
event_loop: EventLoop<'static, AppState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaylandWindowingSystem {
|
impl WaylandShellSystem {
|
||||||
pub fn new(config: &WaylandSurfaceConfig) -> Result<Self> {
|
pub fn new(config: &WaylandSurfaceConfig) -> Result<Self> {
|
||||||
info!("Initializing WindowingSystem");
|
info!("Initializing WindowingSystem");
|
||||||
let (connection, mut event_queue) = Self::init_wayland_connection()?;
|
let (connection, mut event_queue) = Self::init_wayland_connection()?;
|
||||||
|
|
@ -172,7 +172,7 @@ impl WaylandWindowingSystem {
|
||||||
|
|
||||||
let window = Self::initialize_renderer(&surface_ctx.surface, config, &render_factory)?;
|
let window = Self::initialize_renderer(&surface_ctx.surface, config, &render_factory)?;
|
||||||
|
|
||||||
let mut builder = WindowStateBuilder::new()
|
let mut builder = SurfaceStateBuilder::new()
|
||||||
.with_component_definition(config.component_definition.clone())
|
.with_component_definition(config.component_definition.clone())
|
||||||
.with_compilation_result(config.compilation_result.clone())
|
.with_compilation_result(config.compilation_result.clone())
|
||||||
.with_surface(Rc::clone(&surface_ctx.surface))
|
.with_surface(Rc::clone(&surface_ctx.surface))
|
||||||
|
|
@ -234,7 +234,7 @@ impl WaylandWindowingSystem {
|
||||||
let mut layer_surfaces = Vec::new();
|
let mut layer_surfaces = Vec::new();
|
||||||
|
|
||||||
for setup in setups {
|
for setup in setups {
|
||||||
let mut per_output_window = WindowState::new(setup.builder).map_err(|e| {
|
let mut per_output_surface = SurfaceState::new(setup.builder).map_err(|e| {
|
||||||
LayerShikaError::WindowConfiguration {
|
LayerShikaError::WindowConfiguration {
|
||||||
message: e.to_string(),
|
message: e.to_string(),
|
||||||
}
|
}
|
||||||
|
|
@ -242,20 +242,20 @@ impl WaylandWindowingSystem {
|
||||||
|
|
||||||
let popup_manager = Rc::new(PopupManager::new(
|
let popup_manager = Rc::new(PopupManager::new(
|
||||||
popup_context.clone(),
|
popup_context.clone(),
|
||||||
Rc::clone(per_output_window.display_metrics()),
|
Rc::clone(per_output_surface.display_metrics()),
|
||||||
));
|
));
|
||||||
|
|
||||||
per_output_window.set_popup_manager(Rc::clone(&popup_manager));
|
per_output_surface.set_popup_manager(Rc::clone(&popup_manager));
|
||||||
per_output_window.set_shared_pointer_serial(Rc::clone(shared_serial));
|
per_output_surface.set_shared_pointer_serial(Rc::clone(shared_serial));
|
||||||
|
|
||||||
popup_managers.push(Rc::clone(&popup_manager));
|
popup_managers.push(Rc::clone(&popup_manager));
|
||||||
layer_surfaces.push(per_output_window.layer_surface());
|
layer_surfaces.push(per_output_surface.layer_surface());
|
||||||
|
|
||||||
app_state.add_shell_surface(
|
app_state.add_shell_surface(
|
||||||
&setup.output_id,
|
&setup.output_id,
|
||||||
&setup.shell_surface_name,
|
&setup.shell_surface_name,
|
||||||
setup.main_surface_id,
|
setup.main_surface_id,
|
||||||
per_output_window,
|
per_output_surface,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -447,7 +447,7 @@ impl WaylandWindowingSystem {
|
||||||
let window =
|
let window =
|
||||||
Self::initialize_renderer(&surface_ctx.surface, config, &render_factory)?;
|
Self::initialize_renderer(&surface_ctx.surface, config, &render_factory)?;
|
||||||
|
|
||||||
let mut builder = WindowStateBuilder::new()
|
let mut builder = SurfaceStateBuilder::new()
|
||||||
.with_component_definition(config.component_definition.clone())
|
.with_component_definition(config.component_definition.clone())
|
||||||
.with_compilation_result(config.compilation_result.clone())
|
.with_compilation_result(config.compilation_result.clone())
|
||||||
.with_surface(Rc::clone(&surface_ctx.surface))
|
.with_surface(Rc::clone(&surface_ctx.surface))
|
||||||
|
|
@ -542,14 +542,14 @@ impl WaylandWindowingSystem {
|
||||||
if popup_manager.has_pending_popup() {
|
if popup_manager.has_pending_popup() {
|
||||||
info!("Found pending popup in output #{}", idx);
|
info!("Found pending popup in output #{}", idx);
|
||||||
|
|
||||||
let popup_window = popup_manager
|
let popup_surface = popup_manager
|
||||||
.create_pending_popup(&queue_handle_clone, layer_surface, serial)
|
.create_pending_popup(&queue_handle_clone, layer_surface, serial)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
PlatformError::Other(format!("Failed to create popup: {e}"))
|
PlatformError::Other(format!("Failed to create popup: {e}"))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
info!("Popup created successfully for output #{}", idx);
|
info!("Popup created successfully for output #{}", idx);
|
||||||
return Ok(popup_window as Rc<dyn WindowAdapter>);
|
return Ok(popup_surface as Rc<dyn WindowAdapter>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -594,23 +594,22 @@ impl WaylandWindowingSystem {
|
||||||
|
|
||||||
update_timers_and_animations();
|
update_timers_and_animations();
|
||||||
|
|
||||||
for window in self.state.all_outputs() {
|
for surface in self.state.all_outputs() {
|
||||||
window
|
surface.window().render_frame_if_dirty().map_err(|e| {
|
||||||
.window()
|
RenderingError::Operation {
|
||||||
.render_frame_if_dirty()
|
|
||||||
.map_err(|e| RenderingError::Operation {
|
|
||||||
message: e.to_string(),
|
message: e.to_string(),
|
||||||
})?;
|
}
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Initial configuration complete, requesting final render");
|
info!("Initial configuration complete, requesting final render");
|
||||||
for window in self.state.all_outputs() {
|
for surface in self.state.all_outputs() {
|
||||||
RenderableWindow::request_redraw(window.window().as_ref());
|
RenderableWindow::request_redraw(surface.window().as_ref());
|
||||||
}
|
}
|
||||||
update_timers_and_animations();
|
update_timers_and_animations();
|
||||||
for window in self.state.all_outputs() {
|
for surface in self.state.all_outputs() {
|
||||||
window
|
surface
|
||||||
.window()
|
.window()
|
||||||
.render_frame_if_dirty()
|
.render_frame_if_dirty()
|
||||||
.map_err(|e| RenderingError::Operation {
|
.map_err(|e| RenderingError::Operation {
|
||||||
|
|
@ -668,15 +667,15 @@ impl WaylandWindowingSystem {
|
||||||
|
|
||||||
update_timers_and_animations();
|
update_timers_and_animations();
|
||||||
|
|
||||||
for window in shared_data.all_outputs() {
|
for surface in shared_data.all_outputs() {
|
||||||
window
|
surface
|
||||||
.window()
|
.window()
|
||||||
.render_frame_if_dirty()
|
.render_frame_if_dirty()
|
||||||
.map_err(|e| RenderingError::Operation {
|
.map_err(|e| RenderingError::Operation {
|
||||||
message: e.to_string(),
|
message: e.to_string(),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if let Some(popup_manager) = window.popup_manager() {
|
if let Some(popup_manager) = surface.popup_manager() {
|
||||||
popup_manager
|
popup_manager
|
||||||
.render_popups()
|
.render_popups()
|
||||||
.map_err(|e| RenderingError::Operation {
|
.map_err(|e| RenderingError::Operation {
|
||||||
|
|
@ -698,10 +697,10 @@ impl WaylandWindowingSystem {
|
||||||
.ok_or_else(|| LayerShikaError::InvalidInput {
|
.ok_or_else(|| LayerShikaError::InvalidInput {
|
||||||
message: "No outputs available".into(),
|
message: "No outputs available".into(),
|
||||||
})
|
})
|
||||||
.map(WindowState::component_instance)
|
.map(SurfaceState::component_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn state(&self) -> Result<&WindowState> {
|
pub fn state(&self) -> Result<&SurfaceState> {
|
||||||
self.state
|
self.state
|
||||||
.primary_output()
|
.primary_output()
|
||||||
.ok_or_else(|| LayerShikaError::InvalidInput {
|
.ok_or_else(|| LayerShikaError::InvalidInput {
|
||||||
|
|
@ -714,9 +713,9 @@ impl WaylandWindowingSystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowingSystemPort for WaylandWindowingSystem {
|
impl ShellSystemPort for WaylandShellSystem {
|
||||||
fn run(&mut self) -> CoreResult<(), DomainError> {
|
fn run(&mut self) -> CoreResult<(), DomainError> {
|
||||||
WaylandWindowingSystem::run(self).map_err(|e| DomainError::Adapter {
|
WaylandShellSystem::run(self).map_err(|e| DomainError::Adapter {
|
||||||
source: Box::new(e),
|
source: Box::new(e),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use super::event_context::SharedPointerSerial;
|
use super::event_context::SharedPointerSerial;
|
||||||
use super::surface_state::WindowState;
|
use super::surface_state::SurfaceState;
|
||||||
use crate::wayland::managed_proxies::ManagedWlPointer;
|
use crate::wayland::managed_proxies::ManagedWlPointer;
|
||||||
use crate::wayland::outputs::{OutputManager, OutputMapping};
|
use crate::wayland::outputs::{OutputManager, OutputMapping};
|
||||||
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
||||||
|
|
@ -11,7 +11,7 @@ use std::rc::Rc;
|
||||||
use wayland_client::Proxy;
|
use wayland_client::Proxy;
|
||||||
use wayland_client::backend::ObjectId;
|
use wayland_client::backend::ObjectId;
|
||||||
|
|
||||||
pub type PerOutputWindow = WindowState;
|
pub type PerOutputSurface = SurfaceState;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct ShellSurfaceKey {
|
pub struct ShellSurfaceKey {
|
||||||
|
|
@ -31,7 +31,7 @@ impl ShellSurfaceKey {
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
output_registry: OutputRegistry,
|
output_registry: OutputRegistry,
|
||||||
output_mapping: OutputMapping,
|
output_mapping: OutputMapping,
|
||||||
surfaces: HashMap<ShellSurfaceKey, PerOutputWindow>,
|
surfaces: HashMap<ShellSurfaceKey, PerOutputSurface>,
|
||||||
surface_to_key: HashMap<ObjectId, ShellSurfaceKey>,
|
surface_to_key: HashMap<ObjectId, ShellSurfaceKey>,
|
||||||
_pointer: ManagedWlPointer,
|
_pointer: ManagedWlPointer,
|
||||||
shared_pointer_serial: Rc<SharedPointerSerial>,
|
shared_pointer_serial: Rc<SharedPointerSerial>,
|
||||||
|
|
@ -80,7 +80,7 @@ impl AppState {
|
||||||
output_id: &ObjectId,
|
output_id: &ObjectId,
|
||||||
surface_name: &str,
|
surface_name: &str,
|
||||||
main_surface_id: ObjectId,
|
main_surface_id: ObjectId,
|
||||||
surface_state: PerOutputWindow,
|
surface_state: PerOutputSurface,
|
||||||
) {
|
) {
|
||||||
let handle = self.output_mapping.get(output_id).unwrap_or_else(|| {
|
let handle = self.output_mapping.get(output_id).unwrap_or_else(|| {
|
||||||
let h = self.output_mapping.insert(output_id.clone());
|
let h = self.output_mapping.insert(output_id.clone());
|
||||||
|
|
@ -101,12 +101,12 @@ impl AppState {
|
||||||
output_id: &ObjectId,
|
output_id: &ObjectId,
|
||||||
surface_name: &str,
|
surface_name: &str,
|
||||||
main_surface_id: ObjectId,
|
main_surface_id: ObjectId,
|
||||||
surface_state: PerOutputWindow,
|
surface_state: PerOutputSurface,
|
||||||
) {
|
) {
|
||||||
self.add_shell_surface(output_id, surface_name, main_surface_id, surface_state);
|
self.add_shell_surface(output_id, surface_name, main_surface_id, surface_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_output(&mut self, handle: OutputHandle) -> Vec<PerOutputWindow> {
|
pub fn remove_output(&mut self, handle: OutputHandle) -> Vec<PerOutputSurface> {
|
||||||
self.output_registry.remove(handle);
|
self.output_registry.remove(handle);
|
||||||
|
|
||||||
let keys_to_remove: Vec<_> = self
|
let keys_to_remove: Vec<_> = self
|
||||||
|
|
@ -118,8 +118,8 @@ impl AppState {
|
||||||
|
|
||||||
let mut removed = Vec::new();
|
let mut removed = Vec::new();
|
||||||
for key in keys_to_remove {
|
for key in keys_to_remove {
|
||||||
if let Some(window) = self.surfaces.remove(&key) {
|
if let Some(surface) = self.surfaces.remove(&key) {
|
||||||
removed.push(window);
|
removed.push(surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,65 +128,68 @@ impl AppState {
|
||||||
removed
|
removed
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_window_by_key(&self, key: &ShellSurfaceKey) -> Option<&PerOutputWindow> {
|
pub fn get_surface_by_key(&self, key: &ShellSurfaceKey) -> Option<&PerOutputSurface> {
|
||||||
self.surfaces.get(key)
|
self.surfaces.get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_window_by_key_mut(&mut self, key: &ShellSurfaceKey) -> Option<&mut PerOutputWindow> {
|
pub fn get_surface_by_key_mut(
|
||||||
|
&mut self,
|
||||||
|
key: &ShellSurfaceKey,
|
||||||
|
) -> Option<&mut PerOutputSurface> {
|
||||||
self.surfaces.get_mut(key)
|
self.surfaces.get_mut(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_window_by_name(
|
pub fn get_surface_by_name(
|
||||||
&self,
|
&self,
|
||||||
output_handle: OutputHandle,
|
output_handle: OutputHandle,
|
||||||
shell_window_name: &str,
|
shell_window_name: &str,
|
||||||
) -> Option<&PerOutputWindow> {
|
) -> Option<&PerOutputSurface> {
|
||||||
let key = ShellSurfaceKey::new(output_handle, shell_window_name);
|
let key = ShellSurfaceKey::new(output_handle, shell_window_name);
|
||||||
self.surfaces.get(&key)
|
self.surfaces.get(&key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_window_by_name_mut(
|
pub fn get_surface_by_name_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
output_handle: OutputHandle,
|
output_handle: OutputHandle,
|
||||||
shell_window_name: &str,
|
shell_window_name: &str,
|
||||||
) -> Option<&mut PerOutputWindow> {
|
) -> Option<&mut PerOutputSurface> {
|
||||||
let key = ShellSurfaceKey::new(output_handle, shell_window_name);
|
let key = ShellSurfaceKey::new(output_handle, shell_window_name);
|
||||||
self.surfaces.get_mut(&key)
|
self.surfaces.get_mut(&key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_by_output_id(&self, output_id: &ObjectId) -> Option<&PerOutputWindow> {
|
pub fn get_output_by_output_id(&self, output_id: &ObjectId) -> Option<&PerOutputSurface> {
|
||||||
self.output_mapping
|
self.output_mapping
|
||||||
.get(output_id)
|
.get(output_id)
|
||||||
.and_then(|handle| self.get_first_window_for_output(handle))
|
.and_then(|handle| self.get_first_surface_for_output(handle))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_by_output_id_mut(
|
pub fn get_output_by_output_id_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
output_id: &ObjectId,
|
output_id: &ObjectId,
|
||||||
) -> Option<&mut PerOutputWindow> {
|
) -> Option<&mut PerOutputSurface> {
|
||||||
self.output_mapping
|
self.output_mapping
|
||||||
.get(output_id)
|
.get(output_id)
|
||||||
.and_then(|handle| self.get_first_window_for_output_mut(handle))
|
.and_then(|handle| self.get_first_surface_for_output_mut(handle))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_first_window_for_output(&self, handle: OutputHandle) -> Option<&PerOutputWindow> {
|
fn get_first_surface_for_output(&self, handle: OutputHandle) -> Option<&PerOutputSurface> {
|
||||||
self.surfaces
|
self.surfaces
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(k, _)| k.output_handle == handle)
|
.find(|(k, _)| k.output_handle == handle)
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_first_window_for_output_mut(
|
fn get_first_surface_for_output_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
handle: OutputHandle,
|
handle: OutputHandle,
|
||||||
) -> Option<&mut PerOutputWindow> {
|
) -> Option<&mut PerOutputSurface> {
|
||||||
self.surfaces
|
self.surfaces
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|(k, _)| k.output_handle == handle)
|
.find(|(k, _)| k.output_handle == handle)
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_by_surface(&self, surface_id: &ObjectId) -> Option<&PerOutputWindow> {
|
pub fn get_output_by_surface(&self, surface_id: &ObjectId) -> Option<&PerOutputSurface> {
|
||||||
self.surface_to_key
|
self.surface_to_key
|
||||||
.get(surface_id)
|
.get(surface_id)
|
||||||
.and_then(|key| self.surfaces.get(key))
|
.and_then(|key| self.surfaces.get(key))
|
||||||
|
|
@ -195,7 +198,7 @@ impl AppState {
|
||||||
pub fn get_output_by_surface_mut(
|
pub fn get_output_by_surface_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
surface_id: &ObjectId,
|
surface_id: &ObjectId,
|
||||||
) -> Option<&mut PerOutputWindow> {
|
) -> Option<&mut PerOutputSurface> {
|
||||||
self.surface_to_key
|
self.surface_to_key
|
||||||
.get(surface_id)
|
.get(surface_id)
|
||||||
.and_then(|key| self.surfaces.get_mut(key))
|
.and_then(|key| self.surfaces.get_mut(key))
|
||||||
|
|
@ -204,10 +207,10 @@ impl AppState {
|
||||||
pub fn get_output_by_layer_surface_mut(
|
pub fn get_output_by_layer_surface_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
layer_surface_id: &ObjectId,
|
layer_surface_id: &ObjectId,
|
||||||
) -> Option<&mut PerOutputWindow> {
|
) -> Option<&mut PerOutputSurface> {
|
||||||
self.surfaces
|
self.surfaces
|
||||||
.values_mut()
|
.values_mut()
|
||||||
.find(|window| window.layer_surface().as_ref().id() == *layer_surface_id)
|
.find(|surface| surface.layer_surface().as_ref().id() == *layer_surface_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_key_by_surface(&self, surface_id: &ObjectId) -> Option<&ShellSurfaceKey> {
|
pub fn get_key_by_surface(&self, surface_id: &ObjectId) -> Option<&ShellSurfaceKey> {
|
||||||
|
|
@ -245,46 +248,48 @@ impl AppState {
|
||||||
self.active_surface_key.as_ref()
|
self.active_surface_key.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn active_surface_mut(&mut self) -> Option<&mut PerOutputWindow> {
|
pub fn active_surface_mut(&mut self) -> Option<&mut PerOutputSurface> {
|
||||||
let key = self.active_surface_key.clone()?;
|
let key = self.active_surface_key.clone()?;
|
||||||
self.surfaces.get_mut(&key)
|
self.surfaces.get_mut(&key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn primary_output(&self) -> Option<&PerOutputWindow> {
|
pub fn primary_output(&self) -> Option<&PerOutputSurface> {
|
||||||
self.output_registry
|
self.output_registry
|
||||||
.primary_handle()
|
.primary_handle()
|
||||||
.and_then(|handle| self.get_first_window_for_output(handle))
|
.and_then(|handle| self.get_first_surface_for_output(handle))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn primary_output_handle(&self) -> Option<OutputHandle> {
|
pub fn primary_output_handle(&self) -> Option<OutputHandle> {
|
||||||
self.output_registry.primary_handle()
|
self.output_registry.primary_handle()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn active_output(&self) -> Option<&PerOutputWindow> {
|
pub fn active_output(&self) -> Option<&PerOutputSurface> {
|
||||||
self.output_registry
|
self.output_registry
|
||||||
.active_handle()
|
.active_handle()
|
||||||
.and_then(|handle| self.get_first_window_for_output(handle))
|
.and_then(|handle| self.get_first_surface_for_output(handle))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all_outputs(&self) -> impl Iterator<Item = &PerOutputWindow> {
|
pub fn all_outputs(&self) -> impl Iterator<Item = &PerOutputSurface> {
|
||||||
self.surfaces.values()
|
self.surfaces.values()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all_outputs_mut(&mut self) -> impl Iterator<Item = &mut PerOutputWindow> {
|
pub fn all_outputs_mut(&mut self) -> impl Iterator<Item = &mut PerOutputSurface> {
|
||||||
self.surfaces.values_mut()
|
self.surfaces.values_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn windows_for_output(
|
pub fn surfaces_for_output(
|
||||||
&self,
|
&self,
|
||||||
handle: OutputHandle,
|
handle: OutputHandle,
|
||||||
) -> impl Iterator<Item = (&str, &PerOutputWindow)> {
|
) -> impl Iterator<Item = (&str, &PerOutputSurface)> {
|
||||||
self.surfaces
|
self.surfaces
|
||||||
.iter()
|
.iter()
|
||||||
.filter(move |(k, _)| k.output_handle == handle)
|
.filter(move |(k, _)| k.output_handle == handle)
|
||||||
.map(|(k, v)| (k.surface_name.as_str(), v))
|
.map(|(k, v)| (k.surface_name.as_str(), v))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn windows_with_keys(&self) -> impl Iterator<Item = (&ShellSurfaceKey, &PerOutputWindow)> {
|
pub fn surfaces_with_keys(
|
||||||
|
&self,
|
||||||
|
) -> impl Iterator<Item = (&ShellSurfaceKey, &PerOutputSurface)> {
|
||||||
self.surfaces.iter()
|
self.surfaces.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -292,9 +297,9 @@ impl AppState {
|
||||||
&self.shared_pointer_serial
|
&self.shared_pointer_serial
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_output_by_popup(&self, popup_surface_id: &ObjectId) -> Option<&PerOutputWindow> {
|
pub fn find_output_by_popup(&self, popup_surface_id: &ObjectId) -> Option<&PerOutputSurface> {
|
||||||
self.surfaces.values().find(|window| {
|
self.surfaces.values().find(|surface| {
|
||||||
window
|
surface
|
||||||
.popup_manager()
|
.popup_manager()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|pm| pm.find_by_surface(popup_surface_id))
|
.and_then(|pm| pm.find_by_surface(popup_surface_id))
|
||||||
|
|
@ -305,9 +310,9 @@ impl AppState {
|
||||||
pub fn find_output_by_popup_mut(
|
pub fn find_output_by_popup_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
popup_surface_id: &ObjectId,
|
popup_surface_id: &ObjectId,
|
||||||
) -> Option<&mut PerOutputWindow> {
|
) -> Option<&mut PerOutputSurface> {
|
||||||
self.surfaces.values_mut().find(|window| {
|
self.surfaces.values_mut().find(|surface| {
|
||||||
window
|
surface
|
||||||
.popup_manager()
|
.popup_manager()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|pm| pm.find_by_surface(popup_surface_id))
|
.and_then(|pm| pm.find_by_surface(popup_surface_id))
|
||||||
|
|
@ -316,8 +321,8 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_key_by_popup(&self, popup_surface_id: &ObjectId) -> Option<&ShellSurfaceKey> {
|
pub fn get_key_by_popup(&self, popup_surface_id: &ObjectId) -> Option<&ShellSurfaceKey> {
|
||||||
self.surfaces.iter().find_map(|(key, window)| {
|
self.surfaces.iter().find_map(|(key, surface)| {
|
||||||
window
|
surface
|
||||||
.popup_manager()
|
.popup_manager()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|pm| pm.find_by_surface(popup_surface_id))
|
.and_then(|pm| pm.find_by_surface(popup_surface_id))
|
||||||
|
|
@ -333,8 +338,8 @@ impl AppState {
|
||||||
pub fn get_output_by_handle_mut(
|
pub fn get_output_by_handle_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
handle: OutputHandle,
|
handle: OutputHandle,
|
||||||
) -> Option<&mut PerOutputWindow> {
|
) -> Option<&mut PerOutputSurface> {
|
||||||
self.get_first_window_for_output_mut(handle)
|
self.get_first_surface_for_output_mut(handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_info(&self, handle: OutputHandle) -> Option<&OutputInfo> {
|
pub fn get_output_info(&self, handle: OutputHandle) -> Option<&OutputInfo> {
|
||||||
|
|
@ -364,35 +369,35 @@ impl AppState {
|
||||||
names
|
names
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn surfaces_by_name(&self, surface_name: &str) -> impl Iterator<Item = &PerOutputWindow> {
|
pub fn surfaces_by_name(&self, surface_name: &str) -> impl Iterator<Item = &PerOutputSurface> {
|
||||||
self.surfaces
|
self.surfaces
|
||||||
.iter()
|
.iter()
|
||||||
.filter(move |(k, _)| k.surface_name == surface_name)
|
.filter(move |(k, _)| k.surface_name == surface_name)
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_by_handle(&self, handle: OutputHandle) -> Option<&PerOutputWindow> {
|
pub fn get_output_by_handle(&self, handle: OutputHandle) -> Option<&PerOutputSurface> {
|
||||||
self.get_first_window_for_output(handle)
|
self.get_first_surface_for_output(handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outputs_with_handles(&self) -> impl Iterator<Item = (OutputHandle, &PerOutputWindow)> {
|
pub fn outputs_with_handles(&self) -> impl Iterator<Item = (OutputHandle, &PerOutputSurface)> {
|
||||||
self.surfaces
|
self.surfaces
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(key, window)| (key.output_handle, window))
|
.map(|(key, surface)| (key.output_handle, surface))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outputs_with_info(&self) -> impl Iterator<Item = (&OutputInfo, &PerOutputWindow)> {
|
pub fn outputs_with_info(&self) -> impl Iterator<Item = (&OutputInfo, &PerOutputSurface)> {
|
||||||
self.output_registry.all_info().filter_map(|info| {
|
self.output_registry.all_info().filter_map(|info| {
|
||||||
let handle = info.handle();
|
let handle = info.handle();
|
||||||
self.get_first_window_for_output(handle)
|
self.get_first_surface_for_output(handle)
|
||||||
.map(|window| (info, window))
|
.map(|surface| (info, surface))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all_windows_for_output_mut(
|
pub fn all_surfaces_for_output_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
output_id: &ObjectId,
|
output_id: &ObjectId,
|
||||||
) -> Vec<&mut PerOutputWindow> {
|
) -> Vec<&mut PerOutputSurface> {
|
||||||
let Some(handle) = self.output_mapping.get(output_id) else {
|
let Some(handle) = self.output_mapping.get(output_id) else {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ pub struct EventContext {
|
||||||
current_pointer_position: LogicalPosition,
|
current_pointer_position: LogicalPosition,
|
||||||
last_pointer_serial: u32,
|
last_pointer_serial: u32,
|
||||||
shared_pointer_serial: Option<Rc<SharedPointerSerial>>,
|
shared_pointer_serial: Option<Rc<SharedPointerSerial>>,
|
||||||
active_window: ActiveWindow,
|
active_surface: ActiveWindow,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventContext {
|
impl EventContext {
|
||||||
|
|
@ -60,7 +60,7 @@ impl EventContext {
|
||||||
current_pointer_position: LogicalPosition::new(0.0, 0.0),
|
current_pointer_position: LogicalPosition::new(0.0, 0.0),
|
||||||
last_pointer_serial: 0,
|
last_pointer_serial: 0,
|
||||||
shared_pointer_serial: None,
|
shared_pointer_serial: None,
|
||||||
active_window: ActiveWindow::None,
|
active_surface: ActiveWindow::None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,7 +126,7 @@ impl EventContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_entered_surface(&mut self, surface: &WlSurface) {
|
pub fn set_entered_surface(&mut self, surface: &WlSurface) {
|
||||||
self.active_window = if let Some(popup_manager) = &self.popup_manager {
|
self.active_surface = if let Some(popup_manager) = &self.popup_manager {
|
||||||
popup_manager.get_active_window(surface, &self.main_surface_id)
|
popup_manager.get_active_window(surface, &self.main_surface_id)
|
||||||
} else {
|
} else {
|
||||||
let surface_id = surface.id();
|
let surface_id = surface.id();
|
||||||
|
|
@ -139,18 +139,18 @@ impl EventContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear_entered_surface(&mut self) {
|
pub fn clear_entered_surface(&mut self) {
|
||||||
self.active_window = ActiveWindow::None;
|
self.active_surface = ActiveWindow::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dispatch_to_active_window(&self, event: WindowEvent) {
|
pub fn dispatch_to_active_window(&self, event: WindowEvent) {
|
||||||
match self.active_window {
|
match self.active_surface {
|
||||||
ActiveWindow::Main => {
|
ActiveWindow::Main => {
|
||||||
self.main_window.window().dispatch_event(event);
|
self.main_window.window().dispatch_event(event);
|
||||||
}
|
}
|
||||||
ActiveWindow::Popup(handle) => {
|
ActiveWindow::Popup(handle) => {
|
||||||
if let Some(popup_manager) = &self.popup_manager {
|
if let Some(popup_manager) = &self.popup_manager {
|
||||||
if let Some(popup_window) = popup_manager.get_popup_window(handle.key()) {
|
if let Some(popup_surface) = popup_manager.get_popup_window(handle.key()) {
|
||||||
popup_window.dispatch_event(event);
|
popup_surface.dispatch_event(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,5 @@ pub mod popup_manager;
|
||||||
pub mod popup_surface;
|
pub mod popup_surface;
|
||||||
pub mod rendering_state;
|
pub mod rendering_state;
|
||||||
pub mod surface_builder;
|
pub mod surface_builder;
|
||||||
|
pub mod surface_renderer;
|
||||||
pub mod surface_state;
|
pub mod surface_state;
|
||||||
pub mod window_renderer;
|
|
||||||
|
|
|
||||||
|
|
@ -310,29 +310,30 @@ impl PopupManager {
|
||||||
|
|
||||||
info!("Popup physical size: {popup_size:?}");
|
info!("Popup physical size: {popup_size:?}");
|
||||||
|
|
||||||
let popup_surface = PopupSurface::create(&super::popup_surface::PopupSurfaceParams {
|
let wayland_popup_surface =
|
||||||
compositor: &self.context.compositor,
|
PopupSurface::create(&super::popup_surface::PopupSurfaceParams {
|
||||||
xdg_wm_base,
|
compositor: &self.context.compositor,
|
||||||
parent_layer_surface,
|
xdg_wm_base,
|
||||||
fractional_scale_manager: self.context.fractional_scale_manager.as_ref(),
|
parent_layer_surface,
|
||||||
viewporter: self.context.viewporter.as_ref(),
|
fractional_scale_manager: self.context.fractional_scale_manager.as_ref(),
|
||||||
queue_handle,
|
viewporter: self.context.viewporter.as_ref(),
|
||||||
popup_config,
|
queue_handle,
|
||||||
physical_size: popup_size,
|
popup_config,
|
||||||
scale_factor,
|
physical_size: popup_size,
|
||||||
});
|
scale_factor,
|
||||||
|
});
|
||||||
|
|
||||||
if params.grab {
|
if params.grab {
|
||||||
popup_surface.grab(&self.context.seat, params.last_pointer_serial);
|
wayland_popup_surface.grab(&self.context.seat, params.last_pointer_serial);
|
||||||
} else {
|
} else {
|
||||||
info!("Skipping popup grab (grab disabled in request)");
|
info!("Skipping popup grab (grab disabled in request)");
|
||||||
popup_surface.surface.commit();
|
wayland_popup_surface.surface.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
let context = self
|
let context = self
|
||||||
.context
|
.context
|
||||||
.render_factory
|
.render_factory
|
||||||
.create_context(&popup_surface.surface.id(), popup_size)?;
|
.create_context(&wayland_popup_surface.surface.id(), popup_size)?;
|
||||||
|
|
||||||
let renderer = FemtoVGRenderer::new(context)
|
let renderer = FemtoVGRenderer::new(context)
|
||||||
.map_err(|e| LayerShikaError::FemtoVGRendererCreation { source: e })?;
|
.map_err(|e| LayerShikaError::FemtoVGRendererCreation { source: e })?;
|
||||||
|
|
@ -359,7 +360,7 @@ impl PopupManager {
|
||||||
state.popups.insert(
|
state.popups.insert(
|
||||||
popup_id,
|
popup_id,
|
||||||
ActivePopup {
|
ActivePopup {
|
||||||
surface: popup_surface,
|
surface: wayland_popup_surface,
|
||||||
window: Rc::clone(&popup_window),
|
window: Rc::clone(&popup_window),
|
||||||
request,
|
request,
|
||||||
last_serial: params.last_pointer_serial,
|
last_serial: params.last_pointer_serial,
|
||||||
|
|
@ -542,11 +543,11 @@ impl PopupManager {
|
||||||
let fractional_scale_id = fractional_scale_proxy.id();
|
let fractional_scale_id = fractional_scale_proxy.id();
|
||||||
|
|
||||||
if let Some(popup_key) = self.find_popup_key_by_fractional_scale_id(&fractional_scale_id) {
|
if let Some(popup_key) = self.find_popup_key_by_fractional_scale_id(&fractional_scale_id) {
|
||||||
if let Some(popup_window) = self.get_popup_window(popup_key) {
|
if let Some(popup_surface) = self.get_popup_window(popup_key) {
|
||||||
let new_scale_factor = DisplayMetrics::scale_factor_from_120ths(scale_120ths);
|
let new_scale_factor = DisplayMetrics::scale_factor_from_120ths(scale_120ths);
|
||||||
info!("Updating popup scale factor to {new_scale_factor} ({scale_120ths}x)");
|
info!("Updating popup scale factor to {new_scale_factor} ({scale_120ths}x)");
|
||||||
popup_window.set_scale_factor(new_scale_factor);
|
popup_surface.set_scale_factor(new_scale_factor);
|
||||||
popup_window.request_redraw();
|
popup_surface.request_redraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use crate::errors::Result;
|
use crate::errors::Result;
|
||||||
use crate::rendering::femtovg::renderable_window::RenderableWindow;
|
use crate::rendering::femtovg::renderable_window::RenderableWindow;
|
||||||
use crate::wayland::surfaces::window_renderer::{WindowRenderer, WindowRendererParams};
|
use crate::wayland::surfaces::surface_renderer::{SurfaceRenderer, SurfaceRendererParams};
|
||||||
use slint::PhysicalSize;
|
use slint::PhysicalSize;
|
||||||
use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1;
|
use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1;
|
||||||
use crate::wayland::managed_proxies::ManagedWpFractionalScaleV1;
|
use crate::wayland::managed_proxies::ManagedWpFractionalScaleV1;
|
||||||
|
|
||||||
pub struct RenderingState<W: RenderableWindow> {
|
pub struct RenderingState<W: RenderableWindow> {
|
||||||
renderer: WindowRenderer<W>,
|
renderer: SurfaceRenderer<W>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: RenderableWindow> RenderingState<W> {
|
impl<W: RenderableWindow> RenderingState<W> {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(params: WindowRendererParams<W>) -> Self {
|
pub fn new(params: SurfaceRendererParams<W>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
renderer: WindowRenderer::new(params),
|
renderer: SurfaceRenderer::new(params),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use crate::errors::{LayerShikaError, Result};
|
||||||
use crate::rendering::femtovg::main_window::FemtoVGWindow;
|
use crate::rendering::femtovg::main_window::FemtoVGWindow;
|
||||||
use crate::rendering::slint_integration::platform::CustomSlintPlatform;
|
use crate::rendering::slint_integration::platform::CustomSlintPlatform;
|
||||||
|
|
||||||
use super::surface_state::WindowState;
|
use super::surface_state::SurfaceState;
|
||||||
|
|
||||||
pub struct PlatformWrapper(pub Rc<CustomSlintPlatform>);
|
pub struct PlatformWrapper(pub Rc<CustomSlintPlatform>);
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ impl Platform for PlatformWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WindowStateBuilder {
|
pub struct SurfaceStateBuilder {
|
||||||
pub component_definition: Option<ComponentDefinition>,
|
pub component_definition: Option<ComponentDefinition>,
|
||||||
pub compilation_result: Option<Rc<CompilationResult>>,
|
pub compilation_result: Option<Rc<CompilationResult>>,
|
||||||
pub surface: Option<Rc<WlSurface>>,
|
pub surface: Option<Rc<WlSurface>>,
|
||||||
|
|
@ -41,7 +41,7 @@ pub struct WindowStateBuilder {
|
||||||
pub exclusive_zone: i32,
|
pub exclusive_zone: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowStateBuilder {
|
impl SurfaceStateBuilder {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
|
|
@ -140,7 +140,7 @@ impl WindowStateBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(self) -> Result<(WindowState, Rc<CustomSlintPlatform>)> {
|
pub fn build(self) -> Result<(SurfaceState, Rc<CustomSlintPlatform>)> {
|
||||||
let platform = CustomSlintPlatform::new(self.window.as_ref().ok_or_else(|| {
|
let platform = CustomSlintPlatform::new(self.window.as_ref().ok_or_else(|| {
|
||||||
LayerShikaError::InvalidInput {
|
LayerShikaError::InvalidInput {
|
||||||
message: "Window is required".into(),
|
message: "Window is required".into(),
|
||||||
|
|
@ -149,12 +149,12 @@ impl WindowStateBuilder {
|
||||||
set_platform(Box::new(PlatformWrapper(Rc::clone(&platform))))
|
set_platform(Box::new(PlatformWrapper(Rc::clone(&platform))))
|
||||||
.map_err(|e| LayerShikaError::PlatformSetup { source: e })?;
|
.map_err(|e| LayerShikaError::PlatformSetup { source: e })?;
|
||||||
|
|
||||||
let state = WindowState::new(self)?;
|
let state = SurfaceState::new(self)?;
|
||||||
Ok((state, platform))
|
Ok((state, platform))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WindowStateBuilder {
|
impl Default for SurfaceStateBuilder {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
component_definition: None,
|
component_definition: None,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ enum ScalingMode {
|
||||||
Integer,
|
Integer,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WindowRendererParams<W: RenderableWindow> {
|
pub struct SurfaceRendererParams<W: RenderableWindow> {
|
||||||
pub window: Rc<W>,
|
pub window: Rc<W>,
|
||||||
pub surface: ManagedWlSurface,
|
pub surface: ManagedWlSurface,
|
||||||
pub layer_surface: ManagedZwlrLayerSurfaceV1,
|
pub layer_surface: ManagedZwlrLayerSurfaceV1,
|
||||||
|
|
@ -27,7 +27,7 @@ pub struct WindowRendererParams<W: RenderableWindow> {
|
||||||
pub size: PhysicalSize,
|
pub size: PhysicalSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WindowRenderer<W: RenderableWindow> {
|
pub struct SurfaceRenderer<W: RenderableWindow> {
|
||||||
window: Rc<W>,
|
window: Rc<W>,
|
||||||
surface: ManagedWlSurface,
|
surface: ManagedWlSurface,
|
||||||
layer_surface: ManagedZwlrLayerSurfaceV1,
|
layer_surface: ManagedZwlrLayerSurfaceV1,
|
||||||
|
|
@ -38,9 +38,9 @@ pub struct WindowRenderer<W: RenderableWindow> {
|
||||||
logical_size: PhysicalSize,
|
logical_size: PhysicalSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: RenderableWindow> WindowRenderer<W> {
|
impl<W: RenderableWindow> SurfaceRenderer<W> {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(params: WindowRendererParams<W>) -> Self {
|
pub fn new(params: SurfaceRendererParams<W>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
window: params.window,
|
window: params.window,
|
||||||
surface: params.surface,
|
surface: params.surface,
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use super::surface_builder::WindowStateBuilder;
|
use super::surface_builder::SurfaceStateBuilder;
|
||||||
use super::component_state::ComponentState;
|
use super::component_state::ComponentState;
|
||||||
use super::rendering_state::RenderingState;
|
use super::rendering_state::RenderingState;
|
||||||
use super::event_context::{EventContext, SharedPointerSerial};
|
use super::event_context::{EventContext, SharedPointerSerial};
|
||||||
use super::popup_manager::PopupManager;
|
use super::popup_manager::PopupManager;
|
||||||
use super::window_renderer::WindowRendererParams;
|
use super::surface_renderer::SurfaceRendererParams;
|
||||||
use super::display_metrics::{DisplayMetrics, SharedDisplayMetrics};
|
use super::display_metrics::{DisplayMetrics, SharedDisplayMetrics};
|
||||||
use crate::wayland::managed_proxies::{
|
use crate::wayland::managed_proxies::{
|
||||||
ManagedWlPointer, ManagedWlSurface, ManagedZwlrLayerSurfaceV1,
|
ManagedWlPointer, ManagedWlSurface, ManagedZwlrLayerSurfaceV1,
|
||||||
|
|
@ -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::ShellContextPort;
|
use layer_shika_domain::ports::shell::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};
|
||||||
|
|
@ -23,7 +23,7 @@ use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::z
|
||||||
use wayland_client::{protocol::wl_surface::WlSurface, Proxy};
|
use wayland_client::{protocol::wl_surface::WlSurface, Proxy};
|
||||||
use wayland_protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::WpFractionalScaleV1;
|
use wayland_protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::WpFractionalScaleV1;
|
||||||
|
|
||||||
pub struct WindowState {
|
pub struct SurfaceState {
|
||||||
component: ComponentState,
|
component: ComponentState,
|
||||||
rendering: RenderingState<FemtoVGWindow>,
|
rendering: RenderingState<FemtoVGWindow>,
|
||||||
event_context: RefCell<EventContext>,
|
event_context: RefCell<EventContext>,
|
||||||
|
|
@ -32,8 +32,8 @@ pub struct WindowState {
|
||||||
pointer: ManagedWlPointer,
|
pointer: ManagedWlPointer,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowState {
|
impl SurfaceState {
|
||||||
pub fn new(builder: WindowStateBuilder) -> Result<Self> {
|
pub fn new(builder: SurfaceStateBuilder) -> Result<Self> {
|
||||||
let component_definition =
|
let component_definition =
|
||||||
builder
|
builder
|
||||||
.component_definition
|
.component_definition
|
||||||
|
|
@ -99,7 +99,7 @@ impl WindowState {
|
||||||
Rc::clone(&display_metrics),
|
Rc::clone(&display_metrics),
|
||||||
);
|
);
|
||||||
|
|
||||||
let rendering = RenderingState::new(WindowRendererParams {
|
let rendering = RenderingState::new(SurfaceRendererParams {
|
||||||
window: Rc::clone(&window),
|
window: Rc::clone(&window),
|
||||||
surface,
|
surface,
|
||||||
layer_surface,
|
layer_surface,
|
||||||
|
|
@ -257,9 +257,9 @@ impl WindowState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShellContextPort for WindowState {
|
impl ShellContextPort for SurfaceState {
|
||||||
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 {
|
SurfaceState::render_frame_if_dirty(self).map_err(|e| DomainError::Adapter {
|
||||||
source: Box::new(e),
|
source: Box::new(e),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use layer_shika_adapters::platform::calloop::{
|
||||||
EventSource, Generic, Interest, Mode, PostAction, RegistrationToken, TimeoutAction, Timer,
|
EventSource, Generic, Interest, Mode, PostAction, RegistrationToken, TimeoutAction, Timer,
|
||||||
channel,
|
channel,
|
||||||
};
|
};
|
||||||
use layer_shika_adapters::{AppState, WindowingSystemFacade};
|
use layer_shika_adapters::{AppState, ShellSystemFacade};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::os::unix::io::AsFd;
|
use std::os::unix::io::AsFd;
|
||||||
use std::rc::Weak;
|
use std::rc::Weak;
|
||||||
|
|
@ -15,11 +15,11 @@ pub trait FromAppState<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EventLoopHandleBase {
|
pub struct EventLoopHandleBase {
|
||||||
system: Weak<RefCell<WindowingSystemFacade>>,
|
system: Weak<RefCell<ShellSystemFacade>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventLoopHandleBase {
|
impl EventLoopHandleBase {
|
||||||
pub fn new(system: Weak<RefCell<WindowingSystemFacade>>) -> Self {
|
pub fn new(system: Weak<RefCell<ShellSystemFacade>>) -> Self {
|
||||||
Self { system }
|
Self { system }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use layer_shika_adapters::platform::slint_interpreter::{
|
||||||
CompilationResult, Compiler, ComponentInstance, Value,
|
CompilationResult, Compiler, ComponentInstance, Value,
|
||||||
};
|
};
|
||||||
use layer_shika_adapters::{
|
use layer_shika_adapters::{
|
||||||
AppState, ShellWindowConfig, WaylandWindowConfig, WindowState, WindowingSystemFacade,
|
AppState, ShellWindowConfig, WaylandWindowConfig, SurfaceState, ShellSystemFacade,
|
||||||
};
|
};
|
||||||
use layer_shika_domain::config::WindowConfig;
|
use layer_shika_domain::config::WindowConfig;
|
||||||
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
||||||
|
|
@ -30,7 +30,7 @@ use std::rc::Rc;
|
||||||
pub const DEFAULT_COMPONENT_NAME: &str = "Main";
|
pub const DEFAULT_COMPONENT_NAME: &str = "Main";
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct WindowDefinition {
|
pub struct SurfaceDefinition {
|
||||||
pub component: String,
|
pub component: String,
|
||||||
pub config: WindowConfig,
|
pub config: WindowConfig,
|
||||||
}
|
}
|
||||||
|
|
@ -43,12 +43,12 @@ enum CompilationSource {
|
||||||
|
|
||||||
pub struct ShellBuilder {
|
pub struct ShellBuilder {
|
||||||
compilation: CompilationSource,
|
compilation: CompilationSource,
|
||||||
windows: Vec<WindowDefinition>,
|
windows: Vec<SurfaceDefinition>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShellBuilder {
|
impl ShellBuilder {
|
||||||
pub fn window(self, component: impl Into<String>) -> WindowConfigBuilder {
|
pub fn window(self, component: impl Into<String>) -> SurfaceConfigBuilder {
|
||||||
WindowConfigBuilder {
|
SurfaceConfigBuilder {
|
||||||
shell_builder: self,
|
shell_builder: self,
|
||||||
component: component.into(),
|
component: component.into(),
|
||||||
config: WindowConfig::default(),
|
config: WindowConfig::default(),
|
||||||
|
|
@ -56,12 +56,12 @@ impl ShellBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn discover_windows(
|
pub fn discover_surfaces(
|
||||||
mut self,
|
mut self,
|
||||||
components: impl IntoIterator<Item = impl Into<String>>,
|
components: impl IntoIterator<Item = impl Into<String>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
for component in components {
|
for component in components {
|
||||||
self.windows.push(WindowDefinition {
|
self.surfaces.push(SurfaceDefinition {
|
||||||
component: component.into(),
|
component: component.into(),
|
||||||
config: WindowConfig::default(),
|
config: WindowConfig::default(),
|
||||||
});
|
});
|
||||||
|
|
@ -70,13 +70,13 @@ impl ShellBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(self) -> Result<Runtime> {
|
pub fn build(self) -> Result<Runtime> {
|
||||||
let windows = if self.windows.is_empty() {
|
let windows = if self.surfaces.is_empty() {
|
||||||
vec![WindowDefinition {
|
vec![SurfaceDefinition {
|
||||||
component: DEFAULT_COMPONENT_NAME.to_string(),
|
component: DEFAULT_COMPONENT_NAME.to_string(),
|
||||||
config: WindowConfig::default(),
|
config: WindowConfig::default(),
|
||||||
}]
|
}]
|
||||||
} else {
|
} else {
|
||||||
self.windows
|
self.surfaces
|
||||||
};
|
};
|
||||||
|
|
||||||
let compilation_result = match self.compilation {
|
let compilation_result = match self.compilation {
|
||||||
|
|
@ -120,13 +120,13 @@ impl ShellBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WindowConfigBuilder {
|
pub struct SurfaceConfigBuilder {
|
||||||
shell_builder: ShellBuilder,
|
shell_builder: ShellBuilder,
|
||||||
component: String,
|
component: String,
|
||||||
config: WindowConfig,
|
config: WindowConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowConfigBuilder {
|
impl SurfaceConfigBuilder {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn size(mut self, width: u32, height: u32) -> Self {
|
pub fn size(mut self, width: u32, height: u32) -> Self {
|
||||||
self.config.dimensions = WindowDimension::new(width, height);
|
self.config.dimensions = WindowDimension::new(width, height);
|
||||||
|
|
@ -194,7 +194,7 @@ impl WindowConfigBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn window(self, component: impl Into<String>) -> WindowConfigBuilder {
|
pub fn window(self, component: impl Into<String>) -> SurfaceConfigBuilder {
|
||||||
let shell_builder = self.complete();
|
let shell_builder = self.complete();
|
||||||
shell_builder.window(component)
|
shell_builder.window(component)
|
||||||
}
|
}
|
||||||
|
|
@ -209,7 +209,7 @@ impl WindowConfigBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn complete(mut self) -> ShellBuilder {
|
fn complete(mut self) -> ShellBuilder {
|
||||||
self.shell_builder.windows.push(WindowDefinition {
|
self.shell_builder.surfaces.push(SurfaceDefinition {
|
||||||
component: self.component,
|
component: self.component,
|
||||||
config: self.config,
|
config: self.config,
|
||||||
});
|
});
|
||||||
|
|
@ -301,8 +301,8 @@ impl LayerShika {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Runtime {
|
pub struct Runtime {
|
||||||
inner: Rc<RefCell<WindowingSystemFacade>>,
|
inner: Rc<RefCell<ShellSystemFacade>>,
|
||||||
windows: HashMap<String, WindowDefinition>,
|
windows: HashMap<String, SurfaceDefinition>,
|
||||||
compilation_result: Rc<CompilationResult>,
|
compilation_result: Rc<CompilationResult>,
|
||||||
popup_command_sender: channel::Sender<PopupCommand>,
|
popup_command_sender: channel::Sender<PopupCommand>,
|
||||||
}
|
}
|
||||||
|
|
@ -310,7 +310,7 @@ pub struct Runtime {
|
||||||
impl Runtime {
|
impl Runtime {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
compilation_result: Rc<CompilationResult>,
|
compilation_result: Rc<CompilationResult>,
|
||||||
definitions: Vec<WindowDefinition>,
|
definitions: Vec<SurfaceDefinition>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
log::info!(
|
log::info!(
|
||||||
"Creating LayerShika runtime with {} windows",
|
"Creating LayerShika runtime with {} windows",
|
||||||
|
|
@ -339,7 +339,7 @@ impl Runtime {
|
||||||
|
|
||||||
fn new_single_window(
|
fn new_single_window(
|
||||||
compilation_result: Rc<CompilationResult>,
|
compilation_result: Rc<CompilationResult>,
|
||||||
definition: WindowDefinition,
|
definition: SurfaceDefinition,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let component_definition = compilation_result
|
let component_definition = compilation_result
|
||||||
.component(&definition.component)
|
.component(&definition.component)
|
||||||
|
|
@ -358,8 +358,8 @@ impl Runtime {
|
||||||
definition.config.clone(),
|
definition.config.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let inner = layer_shika_adapters::WaylandWindowingSystem::new(&wayland_config)?;
|
let inner = layer_shika_adapters::WaylandShellSystem::new(&wayland_config)?;
|
||||||
let facade = WindowingSystemFacade::new(inner);
|
let facade = ShellSystemFacade::new(inner);
|
||||||
let inner_rc = Rc::new(RefCell::new(facade));
|
let inner_rc = Rc::new(RefCell::new(facade));
|
||||||
|
|
||||||
let (sender, receiver) = channel::channel();
|
let (sender, receiver) = channel::channel();
|
||||||
|
|
@ -383,7 +383,7 @@ impl Runtime {
|
||||||
|
|
||||||
fn new_multi_window(
|
fn new_multi_window(
|
||||||
compilation_result: Rc<CompilationResult>,
|
compilation_result: Rc<CompilationResult>,
|
||||||
definitions: Vec<WindowDefinition>,
|
definitions: Vec<SurfaceDefinition>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let shell_configs: Vec<ShellWindowConfig> = definitions
|
let shell_configs: Vec<ShellWindowConfig> = definitions
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -412,8 +412,8 @@ impl Runtime {
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>>>()?;
|
.collect::<Result<Vec<_>>>()?;
|
||||||
|
|
||||||
let inner = layer_shika_adapters::WaylandWindowingSystem::new_multi(&shell_configs)?;
|
let inner = layer_shika_adapters::WaylandShellSystem::new_multi(&shell_configs)?;
|
||||||
let facade = WindowingSystemFacade::new(inner);
|
let facade = ShellSystemFacade::new(inner);
|
||||||
let inner_rc = Rc::new(RefCell::new(facade));
|
let inner_rc = Rc::new(RefCell::new(facade));
|
||||||
|
|
||||||
let (sender, receiver) = channel::channel();
|
let (sender, receiver) = channel::channel();
|
||||||
|
|
@ -434,7 +434,7 @@ impl Runtime {
|
||||||
|
|
||||||
log::info!(
|
log::info!(
|
||||||
"LayerShika runtime created (multi-window mode) with windows: {:?}",
|
"LayerShika runtime created (multi-window mode) with windows: {:?}",
|
||||||
shell.window_names()
|
shell.surface_names()
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(shell)
|
Ok(shell)
|
||||||
|
|
@ -489,12 +489,12 @@ impl Runtime {
|
||||||
ShellControl::new(self.popup_command_sender.clone())
|
ShellControl::new(self.popup_command_sender.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_names(&self) -> Vec<&str> {
|
pub fn surface_names(&self) -> Vec<&str> {
|
||||||
self.windows.keys().map(String::as_str).collect()
|
self.surfaces.keys().map(String::as_str).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_window(&self, name: &str) -> bool {
|
pub fn has_surface(&self, name: &str) -> bool {
|
||||||
self.windows.contains_key(name)
|
self.surfaces.contains_key(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn event_loop_handle(&self) -> EventLoopHandle {
|
pub fn event_loop_handle(&self) -> EventLoopHandle {
|
||||||
|
|
@ -504,17 +504,17 @@ impl Runtime {
|
||||||
pub fn run(&mut self) -> Result<()> {
|
pub fn run(&mut self) -> Result<()> {
|
||||||
log::info!(
|
log::info!(
|
||||||
"Starting LayerShika event loop with {} windows",
|
"Starting LayerShika event loop with {} windows",
|
||||||
self.windows.len()
|
self.surfaces.len()
|
||||||
);
|
);
|
||||||
self.inner.borrow_mut().run()?;
|
self.inner.borrow_mut().run()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_window<F, R>(&self, name: &str, f: F) -> Result<R>
|
pub fn with_surface<F, R>(&self, name: &str, f: F) -> Result<R>
|
||||||
where
|
where
|
||||||
F: FnOnce(&ComponentInstance) -> R,
|
F: FnOnce(&ComponentInstance) -> R,
|
||||||
{
|
{
|
||||||
if !self.windows.contains_key(name) {
|
if !self.surfaces.contains_key(name) {
|
||||||
return Err(Error::Domain(DomainError::Configuration {
|
return Err(Error::Domain(DomainError::Configuration {
|
||||||
message: format!("Window '{}' not found", name),
|
message: format!("Window '{}' not found", name),
|
||||||
}));
|
}));
|
||||||
|
|
@ -527,7 +527,7 @@ impl Runtime {
|
||||||
.app_state()
|
.app_state()
|
||||||
.windows_by_shell_name(name)
|
.windows_by_shell_name(name)
|
||||||
.next()
|
.next()
|
||||||
.map(|window| f(window.component_instance()))
|
.map(|surface| f(surface.component_instance()))
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
Error::Domain(DomainError::Configuration {
|
Error::Domain(DomainError::Configuration {
|
||||||
message: format!("No instance found for window '{}'", name),
|
message: format!("No instance found for window '{}'", name),
|
||||||
|
|
@ -535,16 +535,16 @@ impl Runtime {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_all_windows<F>(&self, mut f: F)
|
pub fn with_all_surfaces<F>(&self, mut f: F)
|
||||||
where
|
where
|
||||||
F: FnMut(&str, &ComponentInstance),
|
F: FnMut(&str, &ComponentInstance),
|
||||||
{
|
{
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for name in self.windows.keys() {
|
for name in self.surfaces.keys() {
|
||||||
for window in system.app_state().windows_by_shell_name(name) {
|
for surface in system.app_state().windows_by_shell_name(name) {
|
||||||
f(name, window.component_instance());
|
f(name, surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -563,7 +563,7 @@ impl Runtime {
|
||||||
message: format!("Output with handle {:?} not found", handle),
|
message: format!("Output with handle {:?} not found", handle),
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
Ok(f(window.component_instance()))
|
Ok(f(surface.component_instance()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_all_outputs<F>(&self, mut f: F)
|
pub fn with_all_outputs<F>(&self, mut f: F)
|
||||||
|
|
@ -572,8 +572,8 @@ impl Runtime {
|
||||||
{
|
{
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
for (handle, window) in system.app_state().outputs_with_handles() {
|
for (handle, surface) in system.app_state().outputs_with_handles() {
|
||||||
f(handle, window.component_instance());
|
f(handle, surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -587,14 +587,14 @@ impl Runtime {
|
||||||
PopupBuilder::new(self, component_name.into())
|
PopupBuilder::new(self, component_name.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on<F, R>(&self, window_name: &str, callback_name: &str, handler: F) -> Result<()>
|
pub fn on<F, R>(&self, surface_name: &str, callback_name: &str, handler: F) -> Result<()>
|
||||||
where
|
where
|
||||||
F: Fn(ShellControl) -> R + 'static,
|
F: Fn(ShellControl) -> R + 'static,
|
||||||
R: IntoValue,
|
R: IntoValue,
|
||||||
{
|
{
|
||||||
if !self.windows.contains_key(window_name) {
|
if !self.surfaces.contains_key(surface_name) {
|
||||||
return Err(Error::Domain(DomainError::Configuration {
|
return Err(Error::Domain(DomainError::Configuration {
|
||||||
message: format!("Window '{}' not found", window_name),
|
message: format!("Window '{}' not found", surface_name),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -603,7 +603,7 @@ impl Runtime {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for window in system.app_state().windows_by_shell_name(window_name) {
|
for surface in system.app_state().windows_by_shell_name(surface_name) {
|
||||||
let handler_rc = Rc::clone(&handler);
|
let handler_rc = Rc::clone(&handler);
|
||||||
let control_clone = control.clone();
|
let control_clone = control.clone();
|
||||||
if let Err(e) = window
|
if let Err(e) = window
|
||||||
|
|
@ -615,7 +615,7 @@ impl Runtime {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Failed to register callback '{}' on window '{}': {}",
|
"Failed to register callback '{}' on window '{}': {}",
|
||||||
callback_name,
|
callback_name,
|
||||||
window_name,
|
surface_name,
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -626,7 +626,7 @@ impl Runtime {
|
||||||
|
|
||||||
pub fn on_with_args<F, R>(
|
pub fn on_with_args<F, R>(
|
||||||
&self,
|
&self,
|
||||||
window_name: &str,
|
surface_name: &str,
|
||||||
callback_name: &str,
|
callback_name: &str,
|
||||||
handler: F,
|
handler: F,
|
||||||
) -> Result<()>
|
) -> Result<()>
|
||||||
|
|
@ -634,9 +634,9 @@ impl Runtime {
|
||||||
F: Fn(&[Value], ShellControl) -> R + 'static,
|
F: Fn(&[Value], ShellControl) -> R + 'static,
|
||||||
R: IntoValue,
|
R: IntoValue,
|
||||||
{
|
{
|
||||||
if !self.windows.contains_key(window_name) {
|
if !self.surfaces.contains_key(surface_name) {
|
||||||
return Err(Error::Domain(DomainError::Configuration {
|
return Err(Error::Domain(DomainError::Configuration {
|
||||||
message: format!("Window '{}' not found", window_name),
|
message: format!("Window '{}' not found", surface_name),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -645,7 +645,7 @@ impl Runtime {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for window in system.app_state().windows_by_shell_name(window_name) {
|
for surface in system.app_state().windows_by_shell_name(surface_name) {
|
||||||
let handler_rc = Rc::clone(&handler);
|
let handler_rc = Rc::clone(&handler);
|
||||||
let control_clone = control.clone();
|
let control_clone = control.clone();
|
||||||
if let Err(e) = window
|
if let Err(e) = window
|
||||||
|
|
@ -657,7 +657,7 @@ impl Runtime {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Failed to register callback '{}' on window '{}': {}",
|
"Failed to register callback '{}' on window '{}': {}",
|
||||||
callback_name,
|
callback_name,
|
||||||
window_name,
|
surface_name,
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -676,7 +676,7 @@ impl Runtime {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for window in system.app_state().all_outputs() {
|
for surface in system.app_state().all_outputs() {
|
||||||
let handler_rc = Rc::clone(&handler);
|
let handler_rc = Rc::clone(&handler);
|
||||||
let control_clone = control.clone();
|
let control_clone = control.clone();
|
||||||
if let Err(e) = window
|
if let Err(e) = window
|
||||||
|
|
@ -706,7 +706,7 @@ impl Runtime {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for window in system.app_state().all_outputs() {
|
for surface in system.app_state().all_outputs() {
|
||||||
let handler_rc = Rc::clone(&handler);
|
let handler_rc = Rc::clone(&handler);
|
||||||
let control_clone = control.clone();
|
let control_clone = control.clone();
|
||||||
if let Err(e) = window
|
if let Err(e) = window
|
||||||
|
|
@ -726,17 +726,17 @@ impl Runtime {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_window_config<F>(&self, window_name: &str, f: F)
|
pub fn apply_surface_config<F>(&self, surface_name: &str, f: F)
|
||||||
where
|
where
|
||||||
F: Fn(&ComponentInstance, LayerSurfaceHandle<'_>),
|
F: Fn(&ComponentInstance, LayerSurfaceHandle<'_>),
|
||||||
{
|
{
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
if self.windows.contains_key(window_name) {
|
if self.surfaces.contains_key(surface_name) {
|
||||||
for window in system.app_state().windows_by_shell_name(window_name) {
|
for surface in system.app_state().windows_by_shell_name(surface_name) {
|
||||||
let surface_handle = LayerSurfaceHandle::from_window_state(window);
|
let surface_handle = LayerSurfaceHandle::from_window_state(surface);
|
||||||
f(window.component_instance(), surface_handle);
|
f(surface.component_instance(), surface_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -748,9 +748,9 @@ impl Runtime {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for window in system.app_state().all_outputs() {
|
for surface in system.app_state().all_outputs() {
|
||||||
let surface_handle = LayerSurfaceHandle::from_window_state(window);
|
let surface_handle = LayerSurfaceHandle::from_window_state(surface);
|
||||||
f(window.component_instance(), surface_handle);
|
f(surface.component_instance(), surface_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -788,9 +788,9 @@ impl ShellRuntime for Runtime {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
if self.windows.contains_key(name) {
|
if self.surfaces.contains_key(name) {
|
||||||
for window in system.app_state().windows_by_shell_name(name) {
|
for surface in system.app_state().windows_by_shell_name(name) {
|
||||||
f(window.component_instance());
|
f(surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -802,9 +802,9 @@ impl ShellRuntime for Runtime {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for name in self.windows.keys() {
|
for name in self.surfaces.keys() {
|
||||||
for window in system.app_state().windows_by_shell_name(name) {
|
for surface in system.app_state().windows_by_shell_name(name) {
|
||||||
f(name, window.component_instance());
|
f(name, surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -828,22 +828,22 @@ impl<'a> FromAppState<'a> for EventContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventContext<'_> {
|
impl EventContext<'_> {
|
||||||
pub fn get_window_component(&self, name: &str) -> Option<&ComponentInstance> {
|
pub fn get_surface_component(&self, name: &str) -> Option<&ComponentInstance> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.windows_by_shell_name(name)
|
.windows_by_shell_name(name)
|
||||||
.next()
|
.next()
|
||||||
.map(WindowState::component_instance)
|
.map(SurfaceState::component_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all_window_components(&self) -> impl Iterator<Item = &ComponentInstance> {
|
pub fn all_surface_components(&self) -> impl Iterator<Item = &ComponentInstance> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.all_outputs()
|
.all_outputs()
|
||||||
.map(WindowState::component_instance)
|
.map(SurfaceState::component_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_frame_if_dirty(&mut self) -> Result<()> {
|
pub fn render_frame_if_dirty(&mut self) -> Result<()> {
|
||||||
for window in self.app_state.all_outputs() {
|
for surface in self.app_state.all_outputs() {
|
||||||
window.render_frame_if_dirty()?;
|
surface.render_frame_if_dirty()?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -865,13 +865,13 @@ impl EventContext<'_> {
|
||||||
pub fn outputs(&self) -> impl Iterator<Item = (OutputHandle, &ComponentInstance)> {
|
pub fn outputs(&self) -> impl Iterator<Item = (OutputHandle, &ComponentInstance)> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.outputs_with_handles()
|
.outputs_with_handles()
|
||||||
.map(|(handle, window)| (handle, window.component_instance()))
|
.map(|(handle, surface)| (handle, surface.component_instance()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_component(&self, handle: OutputHandle) -> Option<&ComponentInstance> {
|
pub fn get_output_component(&self, handle: OutputHandle) -> Option<&ComponentInstance> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.get_output_by_handle(handle)
|
.get_output_by_handle(handle)
|
||||||
.map(WindowState::component_instance)
|
.map(SurfaceState::component_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_info(&self, handle: OutputHandle) -> Option<&OutputInfo> {
|
pub fn get_output_info(&self, handle: OutputHandle) -> Option<&OutputInfo> {
|
||||||
|
|
@ -885,13 +885,13 @@ impl EventContext<'_> {
|
||||||
pub fn outputs_with_info(&self) -> impl Iterator<Item = (&OutputInfo, &ComponentInstance)> {
|
pub fn outputs_with_info(&self) -> impl Iterator<Item = (&OutputInfo, &ComponentInstance)> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.outputs_with_info()
|
.outputs_with_info()
|
||||||
.map(|(info, window)| (info, window.component_instance()))
|
.map(|(info, surface)| (info, surface.component_instance()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn compilation_result(&self) -> Option<Rc<CompilationResult>> {
|
pub fn compilation_result(&self) -> Option<Rc<CompilationResult>> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.primary_output()
|
.primary_output()
|
||||||
.and_then(WindowState::compilation_result)
|
.and_then(SurfaceState::compilation_result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use layer_shika_adapters::WindowState;
|
use layer_shika_adapters::SurfaceState;
|
||||||
use layer_shika_adapters::platform::slint_interpreter::ComponentInstance;
|
use layer_shika_adapters::platform::slint_interpreter::ComponentInstance;
|
||||||
use layer_shika_adapters::platform::wayland::{Anchor, WaylandKeyboardInteractivity, WaylandLayer};
|
use layer_shika_adapters::platform::wayland::{Anchor, WaylandKeyboardInteractivity, WaylandLayer};
|
||||||
use layer_shika_domain::value_objects::keyboard_interactivity::KeyboardInteractivity;
|
use layer_shika_domain::value_objects::keyboard_interactivity::KeyboardInteractivity;
|
||||||
|
|
@ -6,11 +6,11 @@ use layer_shika_domain::value_objects::layer::Layer;
|
||||||
use layer_shika_domain::value_objects::margins::Margins;
|
use layer_shika_domain::value_objects::margins::Margins;
|
||||||
|
|
||||||
pub struct LayerSurfaceHandle<'a> {
|
pub struct LayerSurfaceHandle<'a> {
|
||||||
window_state: &'a WindowState,
|
window_state: &'a SurfaceState,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> LayerSurfaceHandle<'a> {
|
impl<'a> LayerSurfaceHandle<'a> {
|
||||||
pub(crate) fn from_window_state(window_state: &'a WindowState) -> Self {
|
pub(crate) fn from_window_state(window_state: &'a SurfaceState) -> Self {
|
||||||
Self { window_state }
|
Self { window_state }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ pub use layer_shika_domain::value_objects::popup_request::{
|
||||||
};
|
};
|
||||||
pub use popup_builder::PopupBuilder;
|
pub use popup_builder::PopupBuilder;
|
||||||
pub use shell_runtime::{DEFAULT_SURFACE_NAME, ShellRuntime};
|
pub use shell_runtime::{DEFAULT_SURFACE_NAME, ShellRuntime};
|
||||||
pub use system::{EventContext, EventLoopHandle, ShellControl, SingleWindowShell};
|
pub use system::{EventContext, EventLoopHandle, ShellControl, SingleSurfaceShell};
|
||||||
pub use value_conversion::IntoValue;
|
pub use value_conversion::IntoValue;
|
||||||
|
|
||||||
pub use layer_surface::{LayerSurfaceHandle, ShellSurfaceConfigHandler, ShellSurfaceHandle};
|
pub use layer_surface::{LayerSurfaceHandle, ShellSurfaceConfigHandler, ShellSurfaceHandle};
|
||||||
|
|
@ -69,7 +69,7 @@ pub mod prelude {
|
||||||
OutputRegistry, PopupBuilder, PopupHandle, PopupPlacement, PopupPositioningMode,
|
OutputRegistry, PopupBuilder, PopupHandle, PopupPlacement, PopupPositioningMode,
|
||||||
PopupRequest, PopupSize, PopupWindow, Result, Shell, ShellBuilder, ShellConfig,
|
PopupRequest, PopupSize, PopupWindow, Result, Shell, ShellBuilder, ShellConfig,
|
||||||
ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime,
|
ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime,
|
||||||
ShellSurfaceConfigHandler, ShellSurfaceHandle, SingleWindowShell, SurfaceComponentConfig,
|
ShellSurfaceConfigHandler, ShellSurfaceHandle, SingleSurfaceShell, SurfaceComponentConfig,
|
||||||
SurfaceConfigBuilder, SurfaceDefinition,
|
SurfaceConfigBuilder, SurfaceDefinition,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ use layer_shika_adapters::platform::slint_interpreter::{
|
||||||
CompilationResult, Compiler, ComponentInstance, Value,
|
CompilationResult, Compiler, ComponentInstance, Value,
|
||||||
};
|
};
|
||||||
use layer_shika_adapters::{
|
use layer_shika_adapters::{
|
||||||
AppState, ShellSurfaceConfig, WaylandSurfaceConfig, WindowState, WindowingSystemFacade,
|
AppState, ShellSurfaceConfig, ShellSystemFacade, SurfaceState, WaylandSurfaceConfig,
|
||||||
};
|
};
|
||||||
use layer_shika_domain::config::SurfaceConfig;
|
use layer_shika_domain::config::SurfaceConfig;
|
||||||
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
||||||
|
|
@ -219,7 +219,7 @@ impl SurfaceConfigBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Shell {
|
pub struct Shell {
|
||||||
inner: Rc<RefCell<WindowingSystemFacade>>,
|
inner: Rc<RefCell<ShellSystemFacade>>,
|
||||||
surfaces: HashMap<String, SurfaceDefinition>,
|
surfaces: HashMap<String, SurfaceDefinition>,
|
||||||
compilation_result: Rc<CompilationResult>,
|
compilation_result: Rc<CompilationResult>,
|
||||||
popup_command_sender: channel::Sender<PopupCommand>,
|
popup_command_sender: channel::Sender<PopupCommand>,
|
||||||
|
|
@ -389,8 +389,8 @@ impl Shell {
|
||||||
definition.config.clone(),
|
definition.config.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let inner = layer_shika_adapters::WaylandWindowingSystem::new(&wayland_config)?;
|
let inner = layer_shika_adapters::WaylandShellSystem::new(&wayland_config)?;
|
||||||
let facade = WindowingSystemFacade::new(inner);
|
let facade = ShellSystemFacade::new(inner);
|
||||||
let inner_rc = Rc::new(RefCell::new(facade));
|
let inner_rc = Rc::new(RefCell::new(facade));
|
||||||
|
|
||||||
let (sender, receiver) = channel::channel();
|
let (sender, receiver) = channel::channel();
|
||||||
|
|
@ -444,8 +444,8 @@ impl Shell {
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>>>()?;
|
.collect::<Result<Vec<_>>>()?;
|
||||||
|
|
||||||
let inner = layer_shika_adapters::WaylandWindowingSystem::new_multi(&shell_configs)?;
|
let inner = layer_shika_adapters::WaylandShellSystem::new_multi(&shell_configs)?;
|
||||||
let facade = WindowingSystemFacade::new(inner);
|
let facade = ShellSystemFacade::new(inner);
|
||||||
let inner_rc = Rc::new(RefCell::new(facade));
|
let inner_rc = Rc::new(RefCell::new(facade));
|
||||||
|
|
||||||
let (sender, receiver) = channel::channel();
|
let (sender, receiver) = channel::channel();
|
||||||
|
|
@ -559,7 +559,7 @@ impl Shell {
|
||||||
.app_state()
|
.app_state()
|
||||||
.surfaces_by_name(name)
|
.surfaces_by_name(name)
|
||||||
.next()
|
.next()
|
||||||
.map(|window| f(window.component_instance()))
|
.map(|surface| f(surface.component_instance()))
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
Error::Domain(DomainError::Configuration {
|
Error::Domain(DomainError::Configuration {
|
||||||
message: format!("No instance found for window '{}'", name),
|
message: format!("No instance found for window '{}'", name),
|
||||||
|
|
@ -575,8 +575,8 @@ impl Shell {
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for name in self.surfaces.keys() {
|
for name in self.surfaces.keys() {
|
||||||
for window in system.app_state().surfaces_by_name(name) {
|
for surface in system.app_state().surfaces_by_name(name) {
|
||||||
f(name, window.component_instance());
|
f(name, surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -604,8 +604,8 @@ impl Shell {
|
||||||
{
|
{
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
for (handle, window) in system.app_state().outputs_with_handles() {
|
for (handle, surface) in system.app_state().outputs_with_handles() {
|
||||||
f(handle, window.component_instance());
|
f(handle, surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -619,14 +619,14 @@ impl Shell {
|
||||||
PopupBuilder::new(self, component_name.into())
|
PopupBuilder::new(self, component_name.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on<F, R>(&self, window_name: &str, callback_name: &str, handler: F) -> Result<()>
|
pub fn on<F, R>(&self, surface_name: &str, callback_name: &str, handler: F) -> Result<()>
|
||||||
where
|
where
|
||||||
F: Fn(ShellControl) -> R + 'static,
|
F: Fn(ShellControl) -> R + 'static,
|
||||||
R: IntoValue,
|
R: IntoValue,
|
||||||
{
|
{
|
||||||
if !self.surfaces.contains_key(window_name) {
|
if !self.surfaces.contains_key(surface_name) {
|
||||||
return Err(Error::Domain(DomainError::Configuration {
|
return Err(Error::Domain(DomainError::Configuration {
|
||||||
message: format!("Window '{}' not found", window_name),
|
message: format!("Window '{}' not found", surface_name),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -635,19 +635,19 @@ impl Shell {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for window in system.app_state().surfaces_by_name(window_name) {
|
for surface in system.app_state().surfaces_by_name(surface_name) {
|
||||||
let handler_rc = Rc::clone(&handler);
|
let handler_rc = Rc::clone(&handler);
|
||||||
let control_clone = control.clone();
|
let control_clone = control.clone();
|
||||||
if let Err(e) = window
|
if let Err(e) = surface
|
||||||
.component_instance()
|
.component_instance()
|
||||||
.set_callback(callback_name, move |_args| {
|
.set_callback(callback_name, move |_args| {
|
||||||
handler_rc(control_clone.clone()).into_value()
|
handler_rc(control_clone.clone()).into_value()
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
log::error!(
|
log::error!(
|
||||||
"Failed to register callback '{}' on window '{}': {}",
|
"Failed to register callback '{}' on surface '{}': {}",
|
||||||
callback_name,
|
callback_name,
|
||||||
window_name,
|
surface_name,
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -658,7 +658,7 @@ impl Shell {
|
||||||
|
|
||||||
pub fn on_with_args<F, R>(
|
pub fn on_with_args<F, R>(
|
||||||
&self,
|
&self,
|
||||||
window_name: &str,
|
surface_name: &str,
|
||||||
callback_name: &str,
|
callback_name: &str,
|
||||||
handler: F,
|
handler: F,
|
||||||
) -> Result<()>
|
) -> Result<()>
|
||||||
|
|
@ -666,9 +666,9 @@ impl Shell {
|
||||||
F: Fn(&[Value], ShellControl) -> R + 'static,
|
F: Fn(&[Value], ShellControl) -> R + 'static,
|
||||||
R: IntoValue,
|
R: IntoValue,
|
||||||
{
|
{
|
||||||
if !self.surfaces.contains_key(window_name) {
|
if !self.surfaces.contains_key(surface_name) {
|
||||||
return Err(Error::Domain(DomainError::Configuration {
|
return Err(Error::Domain(DomainError::Configuration {
|
||||||
message: format!("Window '{}' not found", window_name),
|
message: format!("Window '{}' not found", surface_name),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -677,19 +677,19 @@ impl Shell {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for window in system.app_state().surfaces_by_name(window_name) {
|
for surface in system.app_state().surfaces_by_name(surface_name) {
|
||||||
let handler_rc = Rc::clone(&handler);
|
let handler_rc = Rc::clone(&handler);
|
||||||
let control_clone = control.clone();
|
let control_clone = control.clone();
|
||||||
if let Err(e) = window
|
if let Err(e) = surface
|
||||||
.component_instance()
|
.component_instance()
|
||||||
.set_callback(callback_name, move |args| {
|
.set_callback(callback_name, move |args| {
|
||||||
handler_rc(args, control_clone.clone()).into_value()
|
handler_rc(args, control_clone.clone()).into_value()
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
log::error!(
|
log::error!(
|
||||||
"Failed to register callback '{}' on window '{}': {}",
|
"Failed to register callback '{}' on surface '{}': {}",
|
||||||
callback_name,
|
callback_name,
|
||||||
window_name,
|
surface_name,
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -708,10 +708,10 @@ impl Shell {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for window in system.app_state().all_outputs() {
|
for surface in system.app_state().all_outputs() {
|
||||||
let handler_rc = Rc::clone(&handler);
|
let handler_rc = Rc::clone(&handler);
|
||||||
let control_clone = control.clone();
|
let control_clone = control.clone();
|
||||||
if let Err(e) = window
|
if let Err(e) = surface
|
||||||
.component_instance()
|
.component_instance()
|
||||||
.set_callback(callback_name, move |_args| {
|
.set_callback(callback_name, move |_args| {
|
||||||
handler_rc(control_clone.clone()).into_value()
|
handler_rc(control_clone.clone()).into_value()
|
||||||
|
|
@ -738,10 +738,10 @@ impl Shell {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for window in system.app_state().all_outputs() {
|
for surface in system.app_state().all_outputs() {
|
||||||
let handler_rc = Rc::clone(&handler);
|
let handler_rc = Rc::clone(&handler);
|
||||||
let control_clone = control.clone();
|
let control_clone = control.clone();
|
||||||
if let Err(e) = window
|
if let Err(e) = surface
|
||||||
.component_instance()
|
.component_instance()
|
||||||
.set_callback(callback_name, move |args| {
|
.set_callback(callback_name, move |args| {
|
||||||
handler_rc(args, control_clone.clone()).into_value()
|
handler_rc(args, control_clone.clone()).into_value()
|
||||||
|
|
@ -758,17 +758,17 @@ impl Shell {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_surface_config<F>(&self, window_name: &str, f: F)
|
pub fn apply_surface_config<F>(&self, surface_name: &str, f: F)
|
||||||
where
|
where
|
||||||
F: Fn(&ComponentInstance, LayerSurfaceHandle<'_>),
|
F: Fn(&ComponentInstance, LayerSurfaceHandle<'_>),
|
||||||
{
|
{
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
if self.surfaces.contains_key(window_name) {
|
if self.surfaces.contains_key(surface_name) {
|
||||||
for window in system.app_state().surfaces_by_name(window_name) {
|
for surface in system.app_state().surfaces_by_name(surface_name) {
|
||||||
let surface_handle = LayerSurfaceHandle::from_window_state(window);
|
let surface_handle = LayerSurfaceHandle::from_window_state(surface);
|
||||||
f(window.component_instance(), surface_handle);
|
f(surface.component_instance(), surface_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -780,9 +780,9 @@ impl Shell {
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for window in system.app_state().all_outputs() {
|
for surface in system.app_state().all_outputs() {
|
||||||
let surface_handle = LayerSurfaceHandle::from_window_state(window);
|
let surface_handle = LayerSurfaceHandle::from_window_state(surface);
|
||||||
f(window.component_instance(), surface_handle);
|
f(surface.component_instance(), surface_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -821,8 +821,8 @@ impl ShellRuntime for Shell {
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
if self.surfaces.contains_key(name) {
|
if self.surfaces.contains_key(name) {
|
||||||
for window in system.app_state().surfaces_by_name(name) {
|
for surface in system.app_state().surfaces_by_name(name) {
|
||||||
f(window.component_instance());
|
f(surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -835,8 +835,8 @@ impl ShellRuntime for Shell {
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
|
|
||||||
for name in self.surfaces.keys() {
|
for name in self.surfaces.keys() {
|
||||||
for window in system.app_state().surfaces_by_name(name) {
|
for surface in system.app_state().surfaces_by_name(name) {
|
||||||
f(name, window.component_instance());
|
f(name, surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -860,22 +860,22 @@ impl<'a> FromAppState<'a> for ShellEventContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShellEventContext<'_> {
|
impl ShellEventContext<'_> {
|
||||||
pub fn get_window_component(&self, name: &str) -> Option<&ComponentInstance> {
|
pub fn get_surface_component(&self, name: &str) -> Option<&ComponentInstance> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.surfaces_by_name(name)
|
.surfaces_by_name(name)
|
||||||
.next()
|
.next()
|
||||||
.map(WindowState::component_instance)
|
.map(SurfaceState::component_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all_window_components(&self) -> impl Iterator<Item = &ComponentInstance> {
|
pub fn all_surface_components(&self) -> impl Iterator<Item = &ComponentInstance> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.all_outputs()
|
.all_outputs()
|
||||||
.map(WindowState::component_instance)
|
.map(SurfaceState::component_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_frame_if_dirty(&mut self) -> Result<()> {
|
pub fn render_frame_if_dirty(&mut self) -> Result<()> {
|
||||||
for window in self.app_state.all_outputs() {
|
for surface in self.app_state.all_outputs() {
|
||||||
window.render_frame_if_dirty()?;
|
surface.render_frame_if_dirty()?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -897,13 +897,13 @@ impl ShellEventContext<'_> {
|
||||||
pub fn outputs(&self) -> impl Iterator<Item = (OutputHandle, &ComponentInstance)> {
|
pub fn outputs(&self) -> impl Iterator<Item = (OutputHandle, &ComponentInstance)> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.outputs_with_handles()
|
.outputs_with_handles()
|
||||||
.map(|(handle, window)| (handle, window.component_instance()))
|
.map(|(handle, surface)| (handle, surface.component_instance()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_component(&self, handle: OutputHandle) -> Option<&ComponentInstance> {
|
pub fn get_output_component(&self, handle: OutputHandle) -> Option<&ComponentInstance> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.get_output_by_handle(handle)
|
.get_output_by_handle(handle)
|
||||||
.map(WindowState::component_instance)
|
.map(SurfaceState::component_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_info(&self, handle: OutputHandle) -> Option<&OutputInfo> {
|
pub fn get_output_info(&self, handle: OutputHandle) -> Option<&OutputInfo> {
|
||||||
|
|
@ -917,13 +917,13 @@ impl ShellEventContext<'_> {
|
||||||
pub fn outputs_with_info(&self) -> impl Iterator<Item = (&OutputInfo, &ComponentInstance)> {
|
pub fn outputs_with_info(&self) -> impl Iterator<Item = (&OutputInfo, &ComponentInstance)> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.outputs_with_info()
|
.outputs_with_info()
|
||||||
.map(|(info, window)| (info, window.component_instance()))
|
.map(|(info, surface)| (info, surface.component_instance()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn compilation_result(&self) -> Option<Rc<CompilationResult>> {
|
pub fn compilation_result(&self) -> Option<Rc<CompilationResult>> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.primary_output()
|
.primary_output()
|
||||||
.and_then(WindowState::compilation_result)
|
.and_then(SurfaceState::compilation_result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use layer_shika_adapters::platform::slint_interpreter::{
|
||||||
CompilationResult, ComponentDefinition, ComponentInstance, Value,
|
CompilationResult, ComponentDefinition, ComponentInstance, Value,
|
||||||
};
|
};
|
||||||
use layer_shika_adapters::{
|
use layer_shika_adapters::{
|
||||||
AppState, PopupManager, WaylandSurfaceConfig, WindowState, WindowingSystemFacade,
|
AppState, PopupManager, ShellSystemFacade, SurfaceState, WaylandSurfaceConfig,
|
||||||
};
|
};
|
||||||
use layer_shika_domain::config::SurfaceConfig;
|
use layer_shika_domain::config::SurfaceConfig;
|
||||||
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
||||||
|
|
@ -134,13 +134,13 @@ impl EventContext<'_> {
|
||||||
pub fn component_instance(&self) -> Option<&ComponentInstance> {
|
pub fn component_instance(&self) -> Option<&ComponentInstance> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.primary_output()
|
.primary_output()
|
||||||
.map(WindowState::component_instance)
|
.map(SurfaceState::component_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all_component_instances(&self) -> impl Iterator<Item = &ComponentInstance> {
|
pub fn all_component_instances(&self) -> impl Iterator<Item = &ComponentInstance> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.all_outputs()
|
.all_outputs()
|
||||||
.map(WindowState::component_instance)
|
.map(SurfaceState::component_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn output_registry(&self) -> &OutputRegistry {
|
pub const fn output_registry(&self) -> &OutputRegistry {
|
||||||
|
|
@ -160,13 +160,13 @@ impl EventContext<'_> {
|
||||||
pub fn outputs(&self) -> impl Iterator<Item = (OutputHandle, &ComponentInstance)> {
|
pub fn outputs(&self) -> impl Iterator<Item = (OutputHandle, &ComponentInstance)> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.outputs_with_handles()
|
.outputs_with_handles()
|
||||||
.map(|(handle, window)| (handle, window.component_instance()))
|
.map(|(handle, surface)| (handle, surface.component_instance()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_component(&self, handle: OutputHandle) -> Option<&ComponentInstance> {
|
pub fn get_output_component(&self, handle: OutputHandle) -> Option<&ComponentInstance> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.get_output_by_handle(handle)
|
.get_output_by_handle(handle)
|
||||||
.map(WindowState::component_instance)
|
.map(SurfaceState::component_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_info(&self, handle: OutputHandle) -> Option<&OutputInfo> {
|
pub fn get_output_info(&self, handle: OutputHandle) -> Option<&OutputInfo> {
|
||||||
|
|
@ -180,18 +180,18 @@ impl EventContext<'_> {
|
||||||
pub fn outputs_with_info(&self) -> impl Iterator<Item = (&OutputInfo, &ComponentInstance)> {
|
pub fn outputs_with_info(&self) -> impl Iterator<Item = (&OutputInfo, &ComponentInstance)> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.outputs_with_info()
|
.outputs_with_info()
|
||||||
.map(|(info, window)| (info, window.component_instance()))
|
.map(|(info, surface)| (info, surface.component_instance()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn active_or_primary_output(&self) -> Option<&WindowState> {
|
fn active_or_primary_output(&self) -> Option<&SurfaceState> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.active_output()
|
.active_output()
|
||||||
.or_else(|| self.app_state.primary_output())
|
.or_else(|| self.app_state.primary_output())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_frame_if_dirty(&mut self) -> Result<()> {
|
pub fn render_frame_if_dirty(&mut self) -> Result<()> {
|
||||||
for window in self.app_state.all_outputs() {
|
for surface in self.app_state.all_outputs() {
|
||||||
window.render_frame_if_dirty()?;
|
surface.render_frame_if_dirty()?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -200,7 +200,7 @@ impl EventContext<'_> {
|
||||||
pub fn compilation_result(&self) -> Option<Rc<CompilationResult>> {
|
pub fn compilation_result(&self) -> Option<Rc<CompilationResult>> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.primary_output()
|
.primary_output()
|
||||||
.and_then(WindowState::compilation_result)
|
.and_then(SurfaceState::compilation_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show_popup(
|
pub fn show_popup(
|
||||||
|
|
@ -242,7 +242,7 @@ impl EventContext<'_> {
|
||||||
self.close_current_popup()?;
|
self.close_current_popup()?;
|
||||||
|
|
||||||
let is_using_active = self.app_state.active_output().is_some();
|
let is_using_active = self.app_state.active_output().is_some();
|
||||||
let active_window = self.active_or_primary_output().ok_or_else(|| {
|
let active_surface = self.active_or_primary_output().ok_or_else(|| {
|
||||||
log::error!("No active or primary output available");
|
log::error!("No active or primary output available");
|
||||||
Error::Domain(DomainError::Configuration {
|
Error::Domain(DomainError::Configuration {
|
||||||
message: "No active or primary output available".to_string(),
|
message: "No active or primary output available".to_string(),
|
||||||
|
|
@ -254,7 +254,7 @@ impl EventContext<'_> {
|
||||||
if is_using_active { "active" } else { "primary" }
|
if is_using_active { "active" } else { "primary" }
|
||||||
);
|
);
|
||||||
|
|
||||||
let popup_manager = active_window.popup_manager().ok_or_else(|| {
|
let popup_manager = active_surface.popup_manager().ok_or_else(|| {
|
||||||
Error::Domain(DomainError::Configuration {
|
Error::Domain(DomainError::Configuration {
|
||||||
message: "No popup manager available".to_string(),
|
message: "No popup manager available".to_string(),
|
||||||
})
|
})
|
||||||
|
|
@ -289,8 +289,8 @@ impl EventContext<'_> {
|
||||||
|
|
||||||
popup_key_cell.set(popup_handle.key());
|
popup_key_cell.set(popup_handle.key());
|
||||||
|
|
||||||
if let Some(popup_window) = popup_manager.get_popup_window(popup_handle.key()) {
|
if let Some(popup_surface) = popup_manager.get_popup_window(popup_handle.key()) {
|
||||||
popup_window.set_component_instance(instance);
|
popup_surface.set_component_instance(instance);
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::Domain(DomainError::Configuration {
|
return Err(Error::Domain(DomainError::Configuration {
|
||||||
message: "Popup window not found after creation".to_string(),
|
message: "Popup window not found after creation".to_string(),
|
||||||
|
|
@ -301,8 +301,8 @@ impl EventContext<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn close_popup(&mut self, handle: PopupHandle) -> Result<()> {
|
pub fn close_popup(&mut self, handle: PopupHandle) -> Result<()> {
|
||||||
if let Some(active_window) = self.active_or_primary_output() {
|
if let Some(active_surface) = self.active_or_primary_output() {
|
||||||
if let Some(popup_manager) = active_window.popup_manager() {
|
if let Some(popup_manager) = active_surface.popup_manager() {
|
||||||
popup_manager.close(handle)?;
|
popup_manager.close(handle)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -310,8 +310,8 @@ impl EventContext<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn close_current_popup(&mut self) -> Result<()> {
|
pub fn close_current_popup(&mut self) -> Result<()> {
|
||||||
if let Some(active_window) = self.active_or_primary_output() {
|
if let Some(active_surface) = self.active_or_primary_output() {
|
||||||
if let Some(popup_manager) = active_window.popup_manager() {
|
if let Some(popup_manager) = active_surface.popup_manager() {
|
||||||
popup_manager.close_current_popup();
|
popup_manager.close_current_popup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -319,13 +319,13 @@ impl EventContext<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resize_popup(&mut self, handle: PopupHandle, width: f32, height: f32) -> Result<()> {
|
pub fn resize_popup(&mut self, handle: PopupHandle, width: f32, height: f32) -> Result<()> {
|
||||||
let active_window = self.active_or_primary_output().ok_or_else(|| {
|
let active_surface = self.active_or_primary_output().ok_or_else(|| {
|
||||||
Error::Domain(DomainError::Configuration {
|
Error::Domain(DomainError::Configuration {
|
||||||
message: "No active or primary output available".to_string(),
|
message: "No active or primary output available".to_string(),
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let popup_manager = active_window.popup_manager().ok_or_else(|| {
|
let popup_manager = active_surface.popup_manager().ok_or_else(|| {
|
||||||
Error::Domain(DomainError::Configuration {
|
Error::Domain(DomainError::Configuration {
|
||||||
message: "No popup manager available".to_string(),
|
message: "No popup manager available".to_string(),
|
||||||
})
|
})
|
||||||
|
|
@ -344,8 +344,8 @@ impl EventContext<'_> {
|
||||||
current_size.is_none_or(|(w, h)| (w - width).abs() > 0.01 || (h - height).abs() > 0.01);
|
current_size.is_none_or(|(w, h)| (w - width).abs() > 0.01 || (h - height).abs() > 0.01);
|
||||||
|
|
||||||
if size_changed {
|
if size_changed {
|
||||||
if let Some(popup_window) = popup_manager.get_popup_window(handle.key()) {
|
if let Some(popup_surface) = popup_manager.get_popup_window(handle.key()) {
|
||||||
popup_window.request_resize(width, height);
|
popup_surface.request_resize(width, height);
|
||||||
|
|
||||||
#[allow(clippy::cast_possible_truncation)]
|
#[allow(clippy::cast_possible_truncation)]
|
||||||
#[allow(clippy::cast_possible_wrap)]
|
#[allow(clippy::cast_possible_wrap)]
|
||||||
|
|
@ -518,8 +518,8 @@ impl EventContext<'_> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(popup_manager) = popup_manager_weak.upgrade() {
|
if let Some(popup_manager) = popup_manager_weak.upgrade() {
|
||||||
if let Some(popup_window) = popup_manager.get_popup_window(popup_key) {
|
if let Some(popup_surface) = popup_manager.get_popup_window(popup_key) {
|
||||||
popup_window.request_resize(dimensions.width, dimensions.height);
|
popup_surface.request_resize(dimensions.width, dimensions.height);
|
||||||
|
|
||||||
#[allow(clippy::cast_possible_truncation)]
|
#[allow(clippy::cast_possible_truncation)]
|
||||||
#[allow(clippy::cast_possible_wrap)]
|
#[allow(clippy::cast_possible_wrap)]
|
||||||
|
|
@ -552,14 +552,14 @@ impl EventContext<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SingleWindowShell {
|
pub struct SingleSurfaceShell {
|
||||||
inner: Rc<RefCell<WindowingSystemFacade>>,
|
inner: Rc<RefCell<ShellSystemFacade>>,
|
||||||
popup_command_sender: channel::Sender<PopupCommand>,
|
popup_command_sender: channel::Sender<PopupCommand>,
|
||||||
window_name: String,
|
surface_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
impl SingleWindowShell {
|
impl SingleSurfaceShell {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
component_definition: ComponentDefinition,
|
component_definition: ComponentDefinition,
|
||||||
compilation_result: Option<Rc<CompilationResult>>,
|
compilation_result: Option<Rc<CompilationResult>>,
|
||||||
|
|
@ -571,8 +571,8 @@ impl SingleWindowShell {
|
||||||
compilation_result,
|
compilation_result,
|
||||||
config,
|
config,
|
||||||
);
|
);
|
||||||
let inner = layer_shika_adapters::WaylandWindowingSystem::new(&wayland_config)?;
|
let inner = layer_shika_adapters::WaylandShellSystem::new(&wayland_config)?;
|
||||||
let facade = WindowingSystemFacade::new(inner);
|
let facade = ShellSystemFacade::new(inner);
|
||||||
let inner_rc = Rc::new(RefCell::new(facade));
|
let inner_rc = Rc::new(RefCell::new(facade));
|
||||||
|
|
||||||
let (sender, receiver) = channel::channel();
|
let (sender, receiver) = channel::channel();
|
||||||
|
|
@ -580,7 +580,7 @@ impl SingleWindowShell {
|
||||||
let shell = Self {
|
let shell = Self {
|
||||||
inner: Rc::clone(&inner_rc),
|
inner: Rc::clone(&inner_rc),
|
||||||
popup_command_sender: sender,
|
popup_command_sender: sender,
|
||||||
window_name: DEFAULT_SURFACE_NAME.to_string(),
|
surface_name: DEFAULT_SURFACE_NAME.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
shell.setup_popup_command_handler(receiver)?;
|
shell.setup_popup_command_handler(receiver)?;
|
||||||
|
|
@ -589,14 +589,14 @@ impl SingleWindowShell {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_window_name(mut self, name: impl Into<String>) -> Self {
|
pub fn with_surface_name(mut self, name: impl Into<String>) -> Self {
|
||||||
self.window_name = name.into();
|
self.surface_name = name.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn window_name(&self) -> &str {
|
pub fn surface_name(&self) -> &str {
|
||||||
&self.window_name
|
&self.surface_name
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_popup_command_handler(&self, receiver: channel::Channel<PopupCommand>) -> Result<()> {
|
fn setup_popup_command_handler(&self, receiver: channel::Channel<PopupCommand>) -> Result<()> {
|
||||||
|
|
@ -777,8 +777,8 @@ impl SingleWindowShell {
|
||||||
{
|
{
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
for window in system.app_state().all_outputs() {
|
for surface in system.app_state().all_outputs() {
|
||||||
f(window.component_instance());
|
f(surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -805,8 +805,8 @@ impl SingleWindowShell {
|
||||||
{
|
{
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
for (handle, window) in system.app_state().outputs_with_handles() {
|
for (handle, surface) in system.app_state().outputs_with_handles() {
|
||||||
f(handle, window.component_instance());
|
f(handle, surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -829,7 +829,7 @@ impl SingleWindowShell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShellRuntime for SingleWindowShell {
|
impl ShellRuntime for SingleSurfaceShell {
|
||||||
type LoopHandle = EventLoopHandle;
|
type LoopHandle = EventLoopHandle;
|
||||||
type Context<'a> = EventContext<'a>;
|
type Context<'a> = EventContext<'a>;
|
||||||
|
|
||||||
|
|
@ -843,8 +843,8 @@ impl ShellRuntime for SingleWindowShell {
|
||||||
{
|
{
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
for window in system.app_state().all_outputs() {
|
for surface in system.app_state().all_outputs() {
|
||||||
f(window.component_instance());
|
f(surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -854,8 +854,8 @@ impl ShellRuntime for SingleWindowShell {
|
||||||
{
|
{
|
||||||
let facade = self.inner.borrow();
|
let facade = self.inner.borrow();
|
||||||
let system = facade.inner_ref();
|
let system = facade.inner_ref();
|
||||||
for window in system.app_state().all_outputs() {
|
for surface in system.app_state().all_outputs() {
|
||||||
f(&self.window_name, window.component_instance());
|
f(&self.surface_name, surface.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
pub mod windowing;
|
pub mod shell;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::errors::DomainError;
|
use crate::errors::DomainError;
|
||||||
|
|
||||||
pub trait WindowingSystemPort {
|
pub trait ShellSystemPort {
|
||||||
fn run(&mut self) -> Result<(), DomainError>;
|
fn run(&mut self) -> Result<(), DomainError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,8 +33,8 @@ fn main() -> Result<()> {
|
||||||
let handle = shell.event_loop_handle();
|
let handle = shell.event_loop_handle();
|
||||||
|
|
||||||
let (_token, sender) = handle.add_channel(|message: UiMessage, app_state| {
|
let (_token, sender) = handle.add_channel(|message: UiMessage, app_state| {
|
||||||
for window in app_state.all_outputs() {
|
for surface in app_state.all_outputs() {
|
||||||
let component = window.component_instance();
|
let component = surface.component_instance();
|
||||||
|
|
||||||
match &message {
|
match &message {
|
||||||
UiMessage::UpdateStatus(status) => {
|
UiMessage::UpdateStatus(status) => {
|
||||||
|
|
@ -72,8 +72,8 @@ fn main() -> Result<()> {
|
||||||
handle.add_timer(Duration::from_secs(1), |_instant, app_state| {
|
handle.add_timer(Duration::from_secs(1), |_instant, app_state| {
|
||||||
let time_str = current_time_string();
|
let time_str = current_time_string();
|
||||||
|
|
||||||
for window in app_state.all_outputs() {
|
for surface in app_state.all_outputs() {
|
||||||
if let Err(e) = window
|
if let Err(e) = surface
|
||||||
.component_instance()
|
.component_instance()
|
||||||
.set_property("time", Value::String(time_str.clone().into()))
|
.set_property("time", Value::String(time_str.clone().into()))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ fn main() -> Result<()> {
|
||||||
|
|
||||||
let status_text = format!("Events received: {count}");
|
let status_text = format!("Events received: {count}");
|
||||||
|
|
||||||
for window in app_state.all_outputs() {
|
for surface in app_state.all_outputs() {
|
||||||
let component = window.component_instance();
|
let component = surface.component_instance();
|
||||||
if let Err(e) = component.set_property("counter", Value::Number(f64::from(count))) {
|
if let Err(e) = component.set_property("counter", Value::Number(f64::from(count))) {
|
||||||
log::error!("Failed to set counter: {e}");
|
log::error!("Failed to set counter: {e}");
|
||||||
}
|
}
|
||||||
|
|
@ -88,8 +88,8 @@ fn main() -> Result<()> {
|
||||||
handle.add_timer(Duration::from_secs(1), |_instant, app_state| {
|
handle.add_timer(Duration::from_secs(1), |_instant, app_state| {
|
||||||
let time_str = current_time_string();
|
let time_str = current_time_string();
|
||||||
|
|
||||||
for window in app_state.all_outputs() {
|
for surface in app_state.all_outputs() {
|
||||||
if let Err(e) = window
|
if let Err(e) = surface
|
||||||
.component_instance()
|
.component_instance()
|
||||||
.set_property("time", Value::String(time_str.clone().into()))
|
.set_property("time", Value::String(time_str.clone().into()))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ fn main() -> Result<()> {
|
||||||
handle.add_timer(Duration::ZERO, |_instant, app_state| {
|
handle.add_timer(Duration::ZERO, |_instant, app_state| {
|
||||||
let time_str = current_time_string();
|
let time_str = current_time_string();
|
||||||
|
|
||||||
for window in app_state.all_outputs() {
|
for surface in app_state.all_outputs() {
|
||||||
if let Err(e) = window
|
if let Err(e) = surface
|
||||||
.component_instance()
|
.component_instance()
|
||||||
.set_property("time", Value::String(time_str.clone().into()))
|
.set_property("time", Value::String(time_str.clone().into()))
|
||||||
{
|
{
|
||||||
|
|
@ -47,8 +47,8 @@ fn main() -> Result<()> {
|
||||||
let count = counter.get() + 1;
|
let count = counter.get() + 1;
|
||||||
counter.set(count);
|
counter.set(count);
|
||||||
|
|
||||||
for window in app_state.all_outputs() {
|
for surface in app_state.all_outputs() {
|
||||||
if let Err(e) = window
|
if let Err(e) = surface
|
||||||
.component_instance()
|
.component_instance()
|
||||||
.set_property("counter", Value::Number(f64::from(count)))
|
.set_property("counter", Value::Number(f64::from(count)))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ pub use layer_shika_composition::{Error, Result};
|
||||||
pub use shell::{
|
pub use shell::{
|
||||||
CompiledUiSource, DEFAULT_COMPONENT_NAME, DEFAULT_SURFACE_NAME, LayerSurfaceHandle, Shell,
|
CompiledUiSource, DEFAULT_COMPONENT_NAME, DEFAULT_SURFACE_NAME, LayerSurfaceHandle, Shell,
|
||||||
ShellBuilder, ShellConfig, ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime,
|
ShellBuilder, ShellConfig, ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime,
|
||||||
ShellSurfaceConfigHandler, ShellSurfaceHandle, SingleWindowShell, SurfaceComponentConfig,
|
ShellSurfaceConfigHandler, ShellSurfaceHandle, SingleSurfaceShell, SurfaceComponentConfig,
|
||||||
SurfaceConfigBuilder, SurfaceDefinition,
|
SurfaceConfigBuilder, SurfaceDefinition,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
pub use crate::shell::{
|
pub use crate::shell::{
|
||||||
CompiledUiSource, DEFAULT_COMPONENT_NAME, DEFAULT_SURFACE_NAME, LayerSurfaceHandle, Shell,
|
CompiledUiSource, DEFAULT_COMPONENT_NAME, DEFAULT_SURFACE_NAME, LayerSurfaceHandle, Shell,
|
||||||
ShellBuilder, ShellConfig, ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime,
|
ShellBuilder, ShellConfig, ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime,
|
||||||
ShellSurfaceConfigHandler, ShellSurfaceHandle, SingleWindowShell, SurfaceComponentConfig,
|
ShellSurfaceConfigHandler, ShellSurfaceHandle, SingleSurfaceShell, SurfaceComponentConfig,
|
||||||
SurfaceConfigBuilder, SurfaceDefinition,
|
SurfaceConfigBuilder, SurfaceDefinition,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
pub use layer_shika_composition::{
|
pub use layer_shika_composition::{
|
||||||
CompiledUiSource, DEFAULT_COMPONENT_NAME, DEFAULT_SURFACE_NAME, LayerSurfaceHandle, Shell,
|
CompiledUiSource, DEFAULT_COMPONENT_NAME, DEFAULT_SURFACE_NAME, LayerSurfaceHandle, Shell,
|
||||||
ShellBuilder, ShellConfig, ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime,
|
ShellBuilder, ShellConfig, ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime,
|
||||||
ShellSurfaceConfigHandler, ShellSurfaceHandle, SingleWindowShell, SurfaceComponentConfig,
|
ShellSurfaceConfigHandler, ShellSurfaceHandle, SingleSurfaceShell, SurfaceComponentConfig,
|
||||||
SurfaceConfigBuilder, SurfaceDefinition,
|
SurfaceConfigBuilder, SurfaceDefinition,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue