mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-12-12 16:35:56 +00:00
refactor: rename window to surface to avoid mislead
This commit is contained in:
parent
c88644ab15
commit
983056abfc
19 changed files with 225 additions and 230 deletions
|
|
@ -6,7 +6,7 @@ pub(crate) mod wayland;
|
||||||
|
|
||||||
pub use rendering::femtovg::popup_window::PopupWindow;
|
pub use rendering::femtovg::popup_window::PopupWindow;
|
||||||
|
|
||||||
pub use wayland::config::{MultiWindowConfig, ShellWindowConfig, WaylandWindowConfig};
|
pub use wayland::config::{MultiSurfaceConfig, ShellSurfaceConfig, WaylandSurfaceConfig};
|
||||||
pub use wayland::facade::WindowingSystemFacade;
|
pub use wayland::facade::WindowingSystemFacade;
|
||||||
pub use wayland::shell_adapter::WaylandWindowingSystem;
|
pub use wayland::shell_adapter::WaylandWindowingSystem;
|
||||||
pub use wayland::surfaces::app_state::AppState;
|
pub use wayland::surfaces::app_state::AppState;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use layer_shika_domain::config::WindowConfig as DomainWindowConfig;
|
use layer_shika_domain::config::SurfaceConfig as DomainSurfaceConfig;
|
||||||
use layer_shika_domain::value_objects::anchor::AnchorEdges;
|
use layer_shika_domain::value_objects::anchor::AnchorEdges;
|
||||||
use layer_shika_domain::value_objects::keyboard_interactivity::KeyboardInteractivity as DomainKeyboardInteractivity;
|
use layer_shika_domain::value_objects::keyboard_interactivity::KeyboardInteractivity as DomainKeyboardInteractivity;
|
||||||
use layer_shika_domain::value_objects::layer::Layer;
|
use layer_shika_domain::value_objects::layer::Layer;
|
||||||
|
|
@ -22,7 +22,7 @@ pub(crate) struct LayerSurfaceConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct WaylandWindowConfig {
|
pub struct WaylandSurfaceConfig {
|
||||||
pub height: u32,
|
pub height: u32,
|
||||||
pub width: u32,
|
pub width: u32,
|
||||||
pub layer: zwlr_layer_shell_v1::Layer,
|
pub layer: zwlr_layer_shell_v1::Layer,
|
||||||
|
|
@ -37,12 +37,12 @@ pub struct WaylandWindowConfig {
|
||||||
pub output_policy: OutputPolicy,
|
pub output_policy: OutputPolicy,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaylandWindowConfig {
|
impl WaylandSurfaceConfig {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn from_domain_config(
|
pub fn from_domain_config(
|
||||||
component_definition: ComponentDefinition,
|
component_definition: ComponentDefinition,
|
||||||
compilation_result: Option<Rc<CompilationResult>>,
|
compilation_result: Option<Rc<CompilationResult>>,
|
||||||
domain_config: DomainWindowConfig,
|
domain_config: DomainSurfaceConfig,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
height: domain_config.dimensions.height(),
|
height: domain_config.dimensions.height(),
|
||||||
|
|
@ -102,35 +102,35 @@ const fn convert_keyboard_interactivity(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ShellWindowConfig {
|
pub struct ShellSurfaceConfig {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub config: WaylandWindowConfig,
|
pub config: WaylandSurfaceConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MultiWindowConfig {
|
pub struct MultiSurfaceConfig {
|
||||||
pub windows: Vec<ShellWindowConfig>,
|
pub surfaces: Vec<ShellSurfaceConfig>,
|
||||||
pub compilation_result: Rc<CompilationResult>,
|
pub compilation_result: Rc<CompilationResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MultiWindowConfig {
|
impl MultiSurfaceConfig {
|
||||||
pub fn new(compilation_result: Rc<CompilationResult>) -> Self {
|
pub fn new(compilation_result: Rc<CompilationResult>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
windows: Vec::new(),
|
surfaces: Vec::new(),
|
||||||
compilation_result,
|
compilation_result,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn add_window(mut self, name: impl Into<String>, config: WaylandWindowConfig) -> Self {
|
pub fn add_surface(mut self, name: impl Into<String>, config: WaylandSurfaceConfig) -> Self {
|
||||||
self.windows.push(ShellWindowConfig {
|
self.surfaces.push(ShellSurfaceConfig {
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
config,
|
config,
|
||||||
});
|
});
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn primary_config(&self) -> Option<&WaylandWindowConfig> {
|
pub fn primary_config(&self) -> Option<&WaylandSurfaceConfig> {
|
||||||
self.windows.first().map(|w| &w.config)
|
self.surfaces.first().map(|s| &s.config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,12 +206,12 @@ impl Dispatch<WlPointer, ()> for AppState {
|
||||||
if let Some(window) = state.get_window_by_key_mut(&key) {
|
if let Some(window) = state.get_window_by_key_mut(&key) {
|
||||||
window.handle_pointer_enter(serial, &surface, surface_x, surface_y);
|
window.handle_pointer_enter(serial, &surface, surface_x, surface_y);
|
||||||
}
|
}
|
||||||
state.set_active_window_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(window) = state.get_window_by_key_mut(&key) {
|
||||||
window.handle_pointer_enter(serial, &surface, surface_x, surface_y);
|
window.handle_pointer_enter(serial, &surface, surface_x, surface_y);
|
||||||
}
|
}
|
||||||
state.set_active_window_key(Some(key));
|
state.set_active_surface_key(Some(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -220,16 +220,16 @@ impl Dispatch<WlPointer, ()> for AppState {
|
||||||
surface_y,
|
surface_y,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if let Some(window) = state.active_window_mut() {
|
if let Some(window) = state.active_surface_mut() {
|
||||||
window.handle_pointer_motion(surface_x, surface_y);
|
window.handle_pointer_motion(surface_x, surface_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_pointer::Event::Leave { .. } => {
|
wl_pointer::Event::Leave { .. } => {
|
||||||
if let Some(window) = state.active_window_mut() {
|
if let Some(window) = state.active_surface_mut() {
|
||||||
window.handle_pointer_leave();
|
window.handle_pointer_leave();
|
||||||
}
|
}
|
||||||
state.set_active_window_key(None);
|
state.set_active_surface_key(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_pointer::Event::Button {
|
wl_pointer::Event::Button {
|
||||||
|
|
@ -237,7 +237,7 @@ impl Dispatch<WlPointer, ()> for AppState {
|
||||||
state: button_state,
|
state: button_state,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if let Some(window) = state.active_window_mut() {
|
if let Some(window) = state.active_surface_mut() {
|
||||||
window.handle_pointer_button(serial, button_state);
|
window.handle_pointer_button(serial, button_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
errors::{LayerShikaError, Result},
|
errors::{LayerShikaError, Result},
|
||||||
rendering::egl::context_factory::RenderContextFactory,
|
rendering::egl::context_factory::RenderContextFactory,
|
||||||
wayland::{
|
wayland::{
|
||||||
config::{LayerSurfaceConfig, WaylandWindowConfig},
|
config::{LayerSurfaceConfig, WaylandSurfaceConfig},
|
||||||
shell_adapter::WaylandWindowingSystem,
|
shell_adapter::WaylandWindowingSystem,
|
||||||
surfaces::{
|
surfaces::{
|
||||||
app_state::AppState,
|
app_state::AppState,
|
||||||
|
|
@ -60,7 +60,7 @@ struct PendingOutput {
|
||||||
|
|
||||||
pub struct OutputManager {
|
pub struct OutputManager {
|
||||||
context: OutputManagerContext,
|
context: OutputManagerContext,
|
||||||
config: WaylandWindowConfig,
|
config: WaylandSurfaceConfig,
|
||||||
pub(crate) layer_surface_config: LayerSurfaceConfig,
|
pub(crate) layer_surface_config: LayerSurfaceConfig,
|
||||||
output_mapping: OutputMapping,
|
output_mapping: OutputMapping,
|
||||||
pending_outputs: RefCell<HashMap<ObjectId, PendingOutput>>,
|
pending_outputs: RefCell<HashMap<ObjectId, PendingOutput>>,
|
||||||
|
|
@ -69,7 +69,7 @@ pub struct OutputManager {
|
||||||
impl OutputManager {
|
impl OutputManager {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
context: OutputManagerContext,
|
context: OutputManagerContext,
|
||||||
config: WaylandWindowConfig,
|
config: WaylandSurfaceConfig,
|
||||||
layer_surface_config: LayerSurfaceConfig,
|
layer_surface_config: LayerSurfaceConfig,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::wayland::{
|
use crate::wayland::{
|
||||||
config::{LayerSurfaceConfig, ShellWindowConfig, WaylandWindowConfig},
|
config::{LayerSurfaceConfig, ShellSurfaceConfig, WaylandSurfaceConfig},
|
||||||
globals::context::GlobalContext,
|
globals::context::GlobalContext,
|
||||||
managed_proxies::ManagedWlPointer,
|
managed_proxies::ManagedWlPointer,
|
||||||
outputs::{OutputManager, OutputManagerContext},
|
outputs::{OutputManager, OutputManagerContext},
|
||||||
|
|
@ -50,11 +50,11 @@ struct OutputSetup {
|
||||||
main_surface_id: ObjectId,
|
main_surface_id: ObjectId,
|
||||||
window: Rc<FemtoVGWindow>,
|
window: Rc<FemtoVGWindow>,
|
||||||
builder: WindowStateBuilder,
|
builder: WindowStateBuilder,
|
||||||
shell_window_name: String,
|
shell_surface_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct OutputManagerParams<'a> {
|
struct OutputManagerParams<'a> {
|
||||||
config: &'a WaylandWindowConfig,
|
config: &'a WaylandSurfaceConfig,
|
||||||
global_ctx: &'a GlobalContext,
|
global_ctx: &'a GlobalContext,
|
||||||
connection: &'a Connection,
|
connection: &'a Connection,
|
||||||
layer_surface_config: LayerSurfaceConfig,
|
layer_surface_config: LayerSurfaceConfig,
|
||||||
|
|
@ -72,7 +72,7 @@ pub struct WaylandWindowingSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaylandWindowingSystem {
|
impl WaylandWindowingSystem {
|
||||||
pub fn new(config: &WaylandWindowConfig) -> 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()?;
|
||||||
let event_loop =
|
let event_loop =
|
||||||
|
|
@ -88,15 +88,15 @@ impl WaylandWindowingSystem {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_multi(configs: &[ShellWindowConfig]) -> Result<Self> {
|
pub fn new_multi(configs: &[ShellSurfaceConfig]) -> Result<Self> {
|
||||||
if configs.is_empty() {
|
if configs.is_empty() {
|
||||||
return Err(LayerShikaError::InvalidInput {
|
return Err(LayerShikaError::InvalidInput {
|
||||||
message: "At least one window config is required".into(),
|
message: "At least one surface config is required".into(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"Initializing WindowingSystem with {} window configs",
|
"Initializing WindowingSystem with {} surface configs",
|
||||||
configs.len()
|
configs.len()
|
||||||
);
|
);
|
||||||
let (connection, mut event_queue) = Self::init_wayland_connection()?;
|
let (connection, mut event_queue) = Self::init_wayland_connection()?;
|
||||||
|
|
@ -119,7 +119,7 @@ impl WaylandWindowingSystem {
|
||||||
Ok((connection, event_queue))
|
Ok((connection, event_queue))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_layer_surface_config(config: &WaylandWindowConfig) -> LayerSurfaceConfig {
|
fn create_layer_surface_config(config: &WaylandSurfaceConfig) -> LayerSurfaceConfig {
|
||||||
LayerSurfaceConfig {
|
LayerSurfaceConfig {
|
||||||
anchor: config.anchor,
|
anchor: config.anchor,
|
||||||
margin: config.margin,
|
margin: config.margin,
|
||||||
|
|
@ -131,7 +131,7 @@ impl WaylandWindowingSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_output_setups(
|
fn create_output_setups(
|
||||||
config: &WaylandWindowConfig,
|
config: &WaylandSurfaceConfig,
|
||||||
global_ctx: &GlobalContext,
|
global_ctx: &GlobalContext,
|
||||||
connection: &Connection,
|
connection: &Connection,
|
||||||
event_queue: &mut EventQueue<AppState>,
|
event_queue: &mut EventQueue<AppState>,
|
||||||
|
|
@ -198,7 +198,7 @@ impl WaylandWindowingSystem {
|
||||||
main_surface_id,
|
main_surface_id,
|
||||||
window,
|
window,
|
||||||
builder,
|
builder,
|
||||||
shell_window_name: "default".to_string(),
|
shell_surface_name: "default".to_string(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -251,9 +251,9 @@ impl WaylandWindowingSystem {
|
||||||
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_window.layer_surface());
|
||||||
|
|
||||||
app_state.add_shell_window(
|
app_state.add_shell_surface(
|
||||||
&setup.output_id,
|
&setup.output_id,
|
||||||
&setup.shell_window_name,
|
&setup.shell_surface_name,
|
||||||
setup.main_surface_id,
|
setup.main_surface_id,
|
||||||
per_output_window,
|
per_output_window,
|
||||||
);
|
);
|
||||||
|
|
@ -263,7 +263,7 @@ impl WaylandWindowingSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_state(
|
fn init_state(
|
||||||
config: &WaylandWindowConfig,
|
config: &WaylandSurfaceConfig,
|
||||||
connection: &Connection,
|
connection: &Connection,
|
||||||
event_queue: &mut EventQueue<AppState>,
|
event_queue: &mut EventQueue<AppState>,
|
||||||
) -> Result<AppState> {
|
) -> Result<AppState> {
|
||||||
|
|
@ -330,7 +330,7 @@ impl WaylandWindowingSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_state_multi(
|
fn init_state_multi(
|
||||||
configs: &[ShellWindowConfig],
|
configs: &[ShellSurfaceConfig],
|
||||||
connection: &Connection,
|
connection: &Connection,
|
||||||
event_queue: &mut EventQueue<AppState>,
|
event_queue: &mut EventQueue<AppState>,
|
||||||
) -> Result<AppState> {
|
) -> Result<AppState> {
|
||||||
|
|
@ -399,7 +399,7 @@ impl WaylandWindowingSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_output_setups_multi(
|
fn create_output_setups_multi(
|
||||||
configs: &[ShellWindowConfig],
|
configs: &[ShellSurfaceConfig],
|
||||||
global_ctx: &GlobalContext,
|
global_ctx: &GlobalContext,
|
||||||
connection: &Connection,
|
connection: &Connection,
|
||||||
event_queue: &mut EventQueue<AppState>,
|
event_queue: &mut EventQueue<AppState>,
|
||||||
|
|
@ -419,7 +419,7 @@ impl WaylandWindowingSystem {
|
||||||
|
|
||||||
if !config.output_policy.should_render(&temp_info) {
|
if !config.output_policy.should_render(&temp_info) {
|
||||||
info!(
|
info!(
|
||||||
"Skipping shell window '{}' on output {} due to output policy",
|
"Skipping shell surface '{}' on output {} due to output policy",
|
||||||
shell_config.name, output_index
|
shell_config.name, output_index
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -469,7 +469,7 @@ impl WaylandWindowingSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"Created setup for shell window '{}' on output {}",
|
"Created setup for shell surface '{}' on output {}",
|
||||||
shell_config.name, output_index
|
shell_config.name, output_index
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -478,7 +478,7 @@ impl WaylandWindowingSystem {
|
||||||
main_surface_id,
|
main_surface_id,
|
||||||
window,
|
window,
|
||||||
builder,
|
builder,
|
||||||
shell_window_name: shell_config.name.clone(),
|
shell_surface_name: shell_config.name.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -561,7 +561,7 @@ impl WaylandWindowingSystem {
|
||||||
|
|
||||||
pub(crate) fn initialize_renderer(
|
pub(crate) fn initialize_renderer(
|
||||||
surface: &Rc<WlSurface>,
|
surface: &Rc<WlSurface>,
|
||||||
config: &WaylandWindowConfig,
|
config: &WaylandSurfaceConfig,
|
||||||
render_factory: &Rc<RenderContextFactory>,
|
render_factory: &Rc<RenderContextFactory>,
|
||||||
) -> Result<Rc<FemtoVGWindow>> {
|
) -> Result<Rc<FemtoVGWindow>> {
|
||||||
let init_size = PhysicalSize::new(1, 1);
|
let init_size = PhysicalSize::new(1, 1);
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,16 @@ use wayland_client::backend::ObjectId;
|
||||||
pub type PerOutputWindow = WindowState;
|
pub type PerOutputWindow = WindowState;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct ShellWindowKey {
|
pub struct ShellSurfaceKey {
|
||||||
pub output_handle: OutputHandle,
|
pub output_handle: OutputHandle,
|
||||||
pub shell_window_name: String,
|
pub surface_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShellWindowKey {
|
impl ShellSurfaceKey {
|
||||||
pub fn new(output_handle: OutputHandle, shell_window_name: impl Into<String>) -> Self {
|
pub fn new(output_handle: OutputHandle, surface_name: impl Into<String>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
output_handle,
|
output_handle,
|
||||||
shell_window_name: shell_window_name.into(),
|
surface_name: surface_name.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,13 +31,13 @@ impl ShellWindowKey {
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
output_registry: OutputRegistry,
|
output_registry: OutputRegistry,
|
||||||
output_mapping: OutputMapping,
|
output_mapping: OutputMapping,
|
||||||
windows: HashMap<ShellWindowKey, PerOutputWindow>,
|
surfaces: HashMap<ShellSurfaceKey, PerOutputWindow>,
|
||||||
surface_to_key: HashMap<ObjectId, ShellWindowKey>,
|
surface_to_key: HashMap<ObjectId, ShellSurfaceKey>,
|
||||||
_pointer: ManagedWlPointer,
|
_pointer: ManagedWlPointer,
|
||||||
shared_pointer_serial: Rc<SharedPointerSerial>,
|
shared_pointer_serial: Rc<SharedPointerSerial>,
|
||||||
output_manager: Option<Rc<RefCell<OutputManager>>>,
|
output_manager: Option<Rc<RefCell<OutputManager>>>,
|
||||||
registry_name_to_output_id: HashMap<u32, ObjectId>,
|
registry_name_to_output_id: HashMap<u32, ObjectId>,
|
||||||
active_window_key: Option<ShellWindowKey>,
|
active_surface_key: Option<ShellSurfaceKey>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppState {
|
impl AppState {
|
||||||
|
|
@ -45,13 +45,13 @@ impl AppState {
|
||||||
Self {
|
Self {
|
||||||
output_registry: OutputRegistry::new(),
|
output_registry: OutputRegistry::new(),
|
||||||
output_mapping: OutputMapping::new(),
|
output_mapping: OutputMapping::new(),
|
||||||
windows: HashMap::new(),
|
surfaces: HashMap::new(),
|
||||||
surface_to_key: HashMap::new(),
|
surface_to_key: HashMap::new(),
|
||||||
_pointer: pointer,
|
_pointer: pointer,
|
||||||
shared_pointer_serial: shared_serial,
|
shared_pointer_serial: shared_serial,
|
||||||
output_manager: None,
|
output_manager: None,
|
||||||
registry_name_to_output_id: HashMap::new(),
|
registry_name_to_output_id: HashMap::new(),
|
||||||
active_window_key: None,
|
active_surface_key: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,12 +75,12 @@ impl AppState {
|
||||||
self.registry_name_to_output_id.remove(&name)
|
self.registry_name_to_output_id.remove(&name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_shell_window(
|
pub fn add_shell_surface(
|
||||||
&mut self,
|
&mut self,
|
||||||
output_id: &ObjectId,
|
output_id: &ObjectId,
|
||||||
shell_window_name: &str,
|
surface_name: &str,
|
||||||
main_surface_id: ObjectId,
|
main_surface_id: ObjectId,
|
||||||
window: PerOutputWindow,
|
surface_state: PerOutputWindow,
|
||||||
) {
|
) {
|
||||||
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());
|
||||||
|
|
@ -91,25 +91,25 @@ impl AppState {
|
||||||
h
|
h
|
||||||
});
|
});
|
||||||
|
|
||||||
let key = ShellWindowKey::new(handle, shell_window_name);
|
let key = ShellSurfaceKey::new(handle, surface_name);
|
||||||
self.surface_to_key.insert(main_surface_id, key.clone());
|
self.surface_to_key.insert(main_surface_id, key.clone());
|
||||||
self.windows.insert(key, window);
|
self.surfaces.insert(key, surface_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_output(
|
pub fn add_output(
|
||||||
&mut self,
|
&mut self,
|
||||||
output_id: &ObjectId,
|
output_id: &ObjectId,
|
||||||
main_surface_id: ObjectId,
|
main_surface_id: ObjectId,
|
||||||
window: PerOutputWindow,
|
surface_state: PerOutputWindow,
|
||||||
) {
|
) {
|
||||||
self.add_shell_window(output_id, "default", main_surface_id, window);
|
self.add_shell_surface(output_id, "default", main_surface_id, surface_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_output(&mut self, handle: OutputHandle) -> Vec<PerOutputWindow> {
|
pub fn remove_output(&mut self, handle: OutputHandle) -> Vec<PerOutputWindow> {
|
||||||
self.output_registry.remove(handle);
|
self.output_registry.remove(handle);
|
||||||
|
|
||||||
let keys_to_remove: Vec<_> = self
|
let keys_to_remove: Vec<_> = self
|
||||||
.windows
|
.surfaces
|
||||||
.keys()
|
.keys()
|
||||||
.filter(|k| k.output_handle == handle)
|
.filter(|k| k.output_handle == handle)
|
||||||
.cloned()
|
.cloned()
|
||||||
|
|
@ -117,7 +117,7 @@ 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.windows.remove(&key) {
|
if let Some(window) = self.surfaces.remove(&key) {
|
||||||
removed.push(window);
|
removed.push(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -127,12 +127,12 @@ impl AppState {
|
||||||
removed
|
removed
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_window_by_key(&self, key: &ShellWindowKey) -> Option<&PerOutputWindow> {
|
pub fn get_window_by_key(&self, key: &ShellSurfaceKey) -> Option<&PerOutputWindow> {
|
||||||
self.windows.get(key)
|
self.surfaces.get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_window_by_key_mut(&mut self, key: &ShellWindowKey) -> Option<&mut PerOutputWindow> {
|
pub fn get_window_by_key_mut(&mut self, key: &ShellSurfaceKey) -> Option<&mut PerOutputWindow> {
|
||||||
self.windows.get_mut(key)
|
self.surfaces.get_mut(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_window_by_name(
|
pub fn get_window_by_name(
|
||||||
|
|
@ -140,8 +140,8 @@ impl AppState {
|
||||||
output_handle: OutputHandle,
|
output_handle: OutputHandle,
|
||||||
shell_window_name: &str,
|
shell_window_name: &str,
|
||||||
) -> Option<&PerOutputWindow> {
|
) -> Option<&PerOutputWindow> {
|
||||||
let key = ShellWindowKey::new(output_handle, shell_window_name);
|
let key = ShellSurfaceKey::new(output_handle, shell_window_name);
|
||||||
self.windows.get(&key)
|
self.surfaces.get(&key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_window_by_name_mut(
|
pub fn get_window_by_name_mut(
|
||||||
|
|
@ -149,8 +149,8 @@ impl AppState {
|
||||||
output_handle: OutputHandle,
|
output_handle: OutputHandle,
|
||||||
shell_window_name: &str,
|
shell_window_name: &str,
|
||||||
) -> Option<&mut PerOutputWindow> {
|
) -> Option<&mut PerOutputWindow> {
|
||||||
let key = ShellWindowKey::new(output_handle, shell_window_name);
|
let key = ShellSurfaceKey::new(output_handle, shell_window_name);
|
||||||
self.windows.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<&PerOutputWindow> {
|
||||||
|
|
@ -169,7 +169,7 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_first_window_for_output(&self, handle: OutputHandle) -> Option<&PerOutputWindow> {
|
fn get_first_window_for_output(&self, handle: OutputHandle) -> Option<&PerOutputWindow> {
|
||||||
self.windows
|
self.surfaces
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(k, _)| k.output_handle == handle)
|
.find(|(k, _)| k.output_handle == handle)
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
|
|
@ -179,7 +179,7 @@ impl AppState {
|
||||||
&mut self,
|
&mut self,
|
||||||
handle: OutputHandle,
|
handle: OutputHandle,
|
||||||
) -> Option<&mut PerOutputWindow> {
|
) -> Option<&mut PerOutputWindow> {
|
||||||
self.windows
|
self.surfaces
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|(k, _)| k.output_handle == handle)
|
.find(|(k, _)| k.output_handle == handle)
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
|
|
@ -188,7 +188,7 @@ impl AppState {
|
||||||
pub fn get_output_by_surface(&self, surface_id: &ObjectId) -> Option<&PerOutputWindow> {
|
pub fn get_output_by_surface(&self, surface_id: &ObjectId) -> Option<&PerOutputWindow> {
|
||||||
self.surface_to_key
|
self.surface_to_key
|
||||||
.get(surface_id)
|
.get(surface_id)
|
||||||
.and_then(|key| self.windows.get(key))
|
.and_then(|key| self.surfaces.get(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output_by_surface_mut(
|
pub fn get_output_by_surface_mut(
|
||||||
|
|
@ -197,19 +197,19 @@ impl AppState {
|
||||||
) -> Option<&mut PerOutputWindow> {
|
) -> Option<&mut PerOutputWindow> {
|
||||||
self.surface_to_key
|
self.surface_to_key
|
||||||
.get(surface_id)
|
.get(surface_id)
|
||||||
.and_then(|key| self.windows.get_mut(key))
|
.and_then(|key| self.surfaces.get_mut(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
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 PerOutputWindow> {
|
||||||
self.windows
|
self.surfaces
|
||||||
.values_mut()
|
.values_mut()
|
||||||
.find(|window| window.layer_surface().as_ref().id() == *layer_surface_id)
|
.find(|window| window.layer_surface().as_ref().id() == *layer_surface_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_key_by_surface(&self, surface_id: &ObjectId) -> Option<&ShellWindowKey> {
|
pub fn get_key_by_surface(&self, surface_id: &ObjectId) -> Option<&ShellSurfaceKey> {
|
||||||
self.surface_to_key.get(surface_id)
|
self.surface_to_key.get(surface_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -231,22 +231,22 @@ impl AppState {
|
||||||
self.output_registry.active_handle()
|
self.output_registry.active_handle()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_active_window_key(&mut self, key: Option<ShellWindowKey>) {
|
pub fn set_active_surface_key(&mut self, key: Option<ShellSurfaceKey>) {
|
||||||
if let Some(ref k) = key {
|
if let Some(ref k) = key {
|
||||||
self.output_registry.set_active(Some(k.output_handle));
|
self.output_registry.set_active(Some(k.output_handle));
|
||||||
} else {
|
} else {
|
||||||
self.output_registry.set_active(None);
|
self.output_registry.set_active(None);
|
||||||
}
|
}
|
||||||
self.active_window_key = key;
|
self.active_surface_key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn active_window_key(&self) -> Option<&ShellWindowKey> {
|
pub fn active_surface_key(&self) -> Option<&ShellSurfaceKey> {
|
||||||
self.active_window_key.as_ref()
|
self.active_surface_key.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn active_window_mut(&mut self) -> Option<&mut PerOutputWindow> {
|
pub fn active_surface_mut(&mut self) -> Option<&mut PerOutputWindow> {
|
||||||
let key = self.active_window_key.clone()?;
|
let key = self.active_surface_key.clone()?;
|
||||||
self.windows.get_mut(&key)
|
self.surfaces.get_mut(&key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn primary_output(&self) -> Option<&PerOutputWindow> {
|
pub fn primary_output(&self) -> Option<&PerOutputWindow> {
|
||||||
|
|
@ -266,25 +266,25 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all_outputs(&self) -> impl Iterator<Item = &PerOutputWindow> {
|
pub fn all_outputs(&self) -> impl Iterator<Item = &PerOutputWindow> {
|
||||||
self.windows.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 PerOutputWindow> {
|
||||||
self.windows.values_mut()
|
self.surfaces.values_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn windows_for_output(
|
pub fn windows_for_output(
|
||||||
&self,
|
&self,
|
||||||
handle: OutputHandle,
|
handle: OutputHandle,
|
||||||
) -> impl Iterator<Item = (&str, &PerOutputWindow)> {
|
) -> impl Iterator<Item = (&str, &PerOutputWindow)> {
|
||||||
self.windows
|
self.surfaces
|
||||||
.iter()
|
.iter()
|
||||||
.filter(move |(k, _)| k.output_handle == handle)
|
.filter(move |(k, _)| k.output_handle == handle)
|
||||||
.map(|(k, v)| (k.shell_window_name.as_str(), v))
|
.map(|(k, v)| (k.surface_name.as_str(), v))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn windows_with_keys(&self) -> impl Iterator<Item = (&ShellWindowKey, &PerOutputWindow)> {
|
pub fn windows_with_keys(&self) -> impl Iterator<Item = (&ShellSurfaceKey, &PerOutputWindow)> {
|
||||||
self.windows.iter()
|
self.surfaces.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn shared_pointer_serial(&self) -> &Rc<SharedPointerSerial> {
|
pub const fn shared_pointer_serial(&self) -> &Rc<SharedPointerSerial> {
|
||||||
|
|
@ -292,7 +292,7 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
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<&PerOutputWindow> {
|
||||||
self.windows.values().find(|window| {
|
self.surfaces.values().find(|window| {
|
||||||
window
|
window
|
||||||
.popup_manager()
|
.popup_manager()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
@ -305,7 +305,7 @@ impl AppState {
|
||||||
&mut self,
|
&mut self,
|
||||||
popup_surface_id: &ObjectId,
|
popup_surface_id: &ObjectId,
|
||||||
) -> Option<&mut PerOutputWindow> {
|
) -> Option<&mut PerOutputWindow> {
|
||||||
self.windows.values_mut().find(|window| {
|
self.surfaces.values_mut().find(|window| {
|
||||||
window
|
window
|
||||||
.popup_manager()
|
.popup_manager()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
@ -314,8 +314,8 @@ impl AppState {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_key_by_popup(&self, popup_surface_id: &ObjectId) -> Option<&ShellWindowKey> {
|
pub fn get_key_by_popup(&self, popup_surface_id: &ObjectId) -> Option<&ShellSurfaceKey> {
|
||||||
self.windows.iter().find_map(|(key, window)| {
|
self.surfaces.iter().find_map(|(key, window)| {
|
||||||
window
|
window
|
||||||
.popup_manager()
|
.popup_manager()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
@ -352,24 +352,21 @@ impl AppState {
|
||||||
&self.output_registry
|
&self.output_registry
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shell_window_names(&self) -> Vec<&str> {
|
pub fn shell_surface_names(&self) -> Vec<&str> {
|
||||||
let mut names: Vec<_> = self
|
let mut names: Vec<_> = self
|
||||||
.windows
|
.surfaces
|
||||||
.keys()
|
.keys()
|
||||||
.map(|k| k.shell_window_name.as_str())
|
.map(|k| k.surface_name.as_str())
|
||||||
.collect();
|
.collect();
|
||||||
names.sort_unstable();
|
names.sort_unstable();
|
||||||
names.dedup();
|
names.dedup();
|
||||||
names
|
names
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn windows_by_shell_name(
|
pub fn surfaces_by_name(&self, surface_name: &str) -> impl Iterator<Item = &PerOutputWindow> {
|
||||||
&self,
|
self.surfaces
|
||||||
shell_window_name: &str,
|
|
||||||
) -> impl Iterator<Item = &PerOutputWindow> {
|
|
||||||
self.windows
|
|
||||||
.iter()
|
.iter()
|
||||||
.filter(move |(k, _)| k.shell_window_name == shell_window_name)
|
.filter(move |(k, _)| k.surface_name == surface_name)
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -378,7 +375,7 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outputs_with_handles(&self) -> impl Iterator<Item = (OutputHandle, &PerOutputWindow)> {
|
pub fn outputs_with_handles(&self) -> impl Iterator<Item = (OutputHandle, &PerOutputWindow)> {
|
||||||
self.windows
|
self.surfaces
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(key, window)| (key.output_handle, window))
|
.map(|(key, window)| (key.output_handle, window))
|
||||||
}
|
}
|
||||||
|
|
@ -399,7 +396,7 @@ impl AppState {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
};
|
};
|
||||||
|
|
||||||
self.windows
|
self.surfaces
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|(k, _)| k.output_handle == handle)
|
.filter(|(k, _)| k.output_handle == handle)
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
|
|
|
||||||
|
|
@ -61,20 +61,20 @@ impl<'a> LayerSurfaceHandle<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ShellWindowConfigHandler {
|
pub trait ShellSurfaceConfigHandler {
|
||||||
fn configure_window(&self, instance: &ComponentInstance, surface: LayerSurfaceHandle<'_>);
|
fn configure_surface(&self, instance: &ComponentInstance, surface: LayerSurfaceHandle<'_>);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> ShellWindowConfigHandler for F
|
impl<F> ShellSurfaceConfigHandler for F
|
||||||
where
|
where
|
||||||
F: Fn(&ComponentInstance, LayerSurfaceHandle<'_>),
|
F: Fn(&ComponentInstance, LayerSurfaceHandle<'_>),
|
||||||
{
|
{
|
||||||
fn configure_window(&self, instance: &ComponentInstance, surface: LayerSurfaceHandle<'_>) {
|
fn configure_surface(&self, instance: &ComponentInstance, surface: LayerSurfaceHandle<'_>) {
|
||||||
self(instance, surface);
|
self(instance, surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ShellWindowHandle {
|
pub struct ShellSurfaceHandle {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,15 @@ pub use layer_shika_domain::value_objects::popup_request::{
|
||||||
PopupHandle, PopupPlacement, PopupRequest, PopupSize,
|
PopupHandle, PopupPlacement, PopupRequest, PopupSize,
|
||||||
};
|
};
|
||||||
pub use popup_builder::PopupBuilder;
|
pub use popup_builder::PopupBuilder;
|
||||||
pub use shell_runtime::{DEFAULT_WINDOW_NAME, ShellRuntime};
|
pub use shell_runtime::{DEFAULT_SURFACE_NAME, ShellRuntime};
|
||||||
pub use system::{EventContext, EventLoopHandle, ShellControl, SingleWindowShell};
|
pub use system::{EventContext, EventLoopHandle, ShellControl, SingleWindowShell};
|
||||||
pub use value_conversion::IntoValue;
|
pub use value_conversion::IntoValue;
|
||||||
|
|
||||||
pub use layer_surface::{LayerSurfaceHandle, ShellWindowConfigHandler, ShellWindowHandle};
|
pub use layer_surface::{LayerSurfaceHandle, ShellSurfaceConfigHandler, ShellSurfaceHandle};
|
||||||
|
|
||||||
pub use shell::{
|
pub use shell::{
|
||||||
DEFAULT_COMPONENT_NAME, Shell, ShellBuilder, ShellEventContext, ShellEventLoopHandle,
|
DEFAULT_COMPONENT_NAME, Shell, ShellBuilder, ShellEventContext, ShellEventLoopHandle,
|
||||||
WindowConfigBuilder, WindowDefinition,
|
SurfaceConfigBuilder, SurfaceDefinition,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod calloop {
|
pub mod calloop {
|
||||||
|
|
@ -60,13 +60,13 @@ pub enum Error {
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
AnchorEdges, AnchorStrategy, DEFAULT_COMPONENT_NAME, DEFAULT_WINDOW_NAME, EventContext,
|
AnchorEdges, AnchorStrategy, DEFAULT_COMPONENT_NAME, DEFAULT_SURFACE_NAME, EventContext,
|
||||||
EventLoopHandle, IntoValue, KeyboardInteractivity, Layer, LayerSurfaceHandle,
|
EventLoopHandle, IntoValue, KeyboardInteractivity, Layer, LayerSurfaceHandle,
|
||||||
OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupBuilder,
|
OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupBuilder,
|
||||||
PopupHandle, PopupPlacement, PopupPositioningMode, PopupRequest, PopupSize, PopupWindow,
|
PopupHandle, PopupPlacement, PopupPositioningMode, PopupRequest, PopupSize, PopupWindow,
|
||||||
Result, Shell, ShellBuilder, ShellControl, ShellEventContext, ShellEventLoopHandle,
|
Result, Shell, ShellBuilder, ShellControl, ShellEventContext, ShellEventLoopHandle,
|
||||||
ShellRuntime, ShellWindowConfigHandler, ShellWindowHandle, SingleWindowShell,
|
ShellRuntime, ShellSurfaceConfigHandler, ShellSurfaceHandle, SingleWindowShell,
|
||||||
WindowConfigBuilder, WindowDefinition,
|
SurfaceConfigBuilder, SurfaceDefinition,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use crate::calloop::{Generic, Interest, Mode, PostAction, RegistrationToken, Timer};
|
pub use crate::calloop::{Generic, Interest, Mode, PostAction, RegistrationToken, Timer};
|
||||||
|
|
@ -74,7 +74,7 @@ pub mod prelude {
|
||||||
pub use crate::{slint, slint_interpreter};
|
pub use crate::{slint, slint_interpreter};
|
||||||
|
|
||||||
pub use layer_shika_domain::prelude::{
|
pub use layer_shika_domain::prelude::{
|
||||||
LogicalSize, Margins, PhysicalSize, ScaleFactor, WindowConfig, WindowDimension,
|
LogicalSize, Margins, PhysicalSize, ScaleFactor, SurfaceConfig, SurfaceDimension,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use layer_shika_adapters::platform::wayland::Anchor;
|
pub use layer_shika_adapters::platform::wayland::Anchor;
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ impl<'a> PopupBuilder<'a> {
|
||||||
let request = self.build_request();
|
let request = self.build_request();
|
||||||
let control = self.shell.control();
|
let control = self.shell.control();
|
||||||
|
|
||||||
self.shell.with_all_windows(|_name, instance| {
|
self.shell.with_all_surfaces(|_name, instance| {
|
||||||
let request_clone = request.clone();
|
let request_clone = request.clone();
|
||||||
let control_clone = control.clone();
|
let control_clone = control.clone();
|
||||||
|
|
||||||
|
|
@ -174,7 +174,7 @@ impl<'a> PopupBuilder<'a> {
|
||||||
let control = self.shell.control();
|
let control = self.shell.control();
|
||||||
let component_name = request.component.clone();
|
let component_name = request.component.clone();
|
||||||
|
|
||||||
self.shell.with_all_windows(|_name, instance| {
|
self.shell.with_all_surfaces(|_name, instance| {
|
||||||
let request_clone = request.clone();
|
let request_clone = request.clone();
|
||||||
let control_clone = control.clone();
|
let control_clone = control.clone();
|
||||||
let component_clone = component_name.clone();
|
let component_clone = component_name.clone();
|
||||||
|
|
@ -205,7 +205,7 @@ impl<'a> PopupBuilder<'a> {
|
||||||
let resize_callback = self.resize_callback.clone();
|
let resize_callback = self.resize_callback.clone();
|
||||||
let control = self.shell.control();
|
let control = self.shell.control();
|
||||||
|
|
||||||
self.shell.with_all_windows(|_name, instance| {
|
self.shell.with_all_surfaces(|_name, instance| {
|
||||||
let component_clone = component_name.clone();
|
let component_clone = component_name.clone();
|
||||||
let control_clone = control.clone();
|
let control_clone = control.clone();
|
||||||
let close_cb = close_callback.clone();
|
let close_cb = close_callback.clone();
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,13 @@ 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, ShellSurfaceConfig, WaylandSurfaceConfig, WindowState, WindowingSystemFacade,
|
||||||
};
|
};
|
||||||
use layer_shika_domain::config::WindowConfig;
|
use layer_shika_domain::config::SurfaceConfig;
|
||||||
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
||||||
use layer_shika_domain::errors::DomainError;
|
use layer_shika_domain::errors::DomainError;
|
||||||
use layer_shika_domain::prelude::{
|
use layer_shika_domain::prelude::{
|
||||||
AnchorEdges, KeyboardInteractivity, Layer, Margins, OutputPolicy, ScaleFactor, WindowDimension,
|
AnchorEdges, KeyboardInteractivity, Layer, Margins, OutputPolicy, ScaleFactor, SurfaceDimension,
|
||||||
};
|
};
|
||||||
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;
|
||||||
|
|
@ -30,9 +30,9 @@ 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: SurfaceConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CompilationSource {
|
enum CompilationSource {
|
||||||
|
|
@ -43,40 +43,40 @@ enum CompilationSource {
|
||||||
|
|
||||||
pub struct ShellBuilder {
|
pub struct ShellBuilder {
|
||||||
compilation: CompilationSource,
|
compilation: CompilationSource,
|
||||||
windows: Vec<WindowDefinition>,
|
surfaces: Vec<SurfaceDefinition>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShellBuilder {
|
impl ShellBuilder {
|
||||||
pub fn window(self, component: impl Into<String>) -> WindowConfigBuilder {
|
pub fn surface(self, component: impl Into<String>) -> SurfaceConfigBuilder {
|
||||||
WindowConfigBuilder {
|
SurfaceConfigBuilder {
|
||||||
shell_builder: self,
|
shell_builder: self,
|
||||||
component: component.into(),
|
component: component.into(),
|
||||||
config: WindowConfig::default(),
|
config: SurfaceConfig::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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: SurfaceConfig::default(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(self) -> Result<Shell> {
|
pub fn build(self) -> Result<Shell> {
|
||||||
let windows = if self.windows.is_empty() {
|
let surfaces = 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: SurfaceConfig::default(),
|
||||||
}]
|
}]
|
||||||
} else {
|
} else {
|
||||||
self.windows
|
self.surfaces
|
||||||
};
|
};
|
||||||
|
|
||||||
let compilation_result = match self.compilation {
|
let compilation_result = match self.compilation {
|
||||||
|
|
@ -116,32 +116,32 @@ impl ShellBuilder {
|
||||||
CompilationSource::Compiled(result) => result,
|
CompilationSource::Compiled(result) => result,
|
||||||
};
|
};
|
||||||
|
|
||||||
Shell::new(compilation_result, windows)
|
Shell::new(compilation_result, surfaces)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WindowConfigBuilder {
|
pub struct SurfaceConfigBuilder {
|
||||||
shell_builder: ShellBuilder,
|
shell_builder: ShellBuilder,
|
||||||
component: String,
|
component: String,
|
||||||
config: WindowConfig,
|
config: SurfaceConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = SurfaceDimension::new(width, height);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn height(mut self, height: u32) -> Self {
|
pub fn height(mut self, height: u32) -> Self {
|
||||||
self.config.dimensions = WindowDimension::new(self.config.dimensions.width(), height);
|
self.config.dimensions = SurfaceDimension::new(self.config.dimensions.width(), height);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn width(mut self, width: u32) -> Self {
|
pub fn width(mut self, width: u32) -> Self {
|
||||||
self.config.dimensions = WindowDimension::new(width, self.config.dimensions.height());
|
self.config.dimensions = SurfaceDimension::new(width, self.config.dimensions.height());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,9 +194,9 @@ impl WindowConfigBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn window(self, component: impl Into<String>) -> WindowConfigBuilder {
|
pub fn surface(self, component: impl Into<String>) -> SurfaceConfigBuilder {
|
||||||
let shell_builder = self.complete();
|
let shell_builder = self.complete();
|
||||||
shell_builder.window(component)
|
shell_builder.surface(component)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(self) -> Result<Shell> {
|
pub fn build(self) -> Result<Shell> {
|
||||||
|
|
@ -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,
|
||||||
});
|
});
|
||||||
|
|
@ -219,7 +219,7 @@ impl WindowConfigBuilder {
|
||||||
|
|
||||||
pub struct Shell {
|
pub struct Shell {
|
||||||
inner: Rc<RefCell<WindowingSystemFacade>>,
|
inner: Rc<RefCell<WindowingSystemFacade>>,
|
||||||
windows: HashMap<String, WindowDefinition>,
|
surfaces: HashMap<String, SurfaceDefinition>,
|
||||||
compilation_result: Rc<CompilationResult>,
|
compilation_result: Rc<CompilationResult>,
|
||||||
popup_command_sender: channel::Sender<PopupCommand>,
|
popup_command_sender: channel::Sender<PopupCommand>,
|
||||||
}
|
}
|
||||||
|
|
@ -231,7 +231,7 @@ impl Shell {
|
||||||
path: path.as_ref().to_path_buf(),
|
path: path.as_ref().to_path_buf(),
|
||||||
compiler: Compiler::default(),
|
compiler: Compiler::default(),
|
||||||
},
|
},
|
||||||
windows: Vec::new(),
|
surfaces: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,7 +241,7 @@ impl Shell {
|
||||||
path: path.as_ref().to_path_buf(),
|
path: path.as_ref().to_path_buf(),
|
||||||
compiler,
|
compiler,
|
||||||
},
|
},
|
||||||
windows: Vec::new(),
|
surfaces: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -251,7 +251,7 @@ impl Shell {
|
||||||
code: code.into(),
|
code: code.into(),
|
||||||
compiler: Compiler::default(),
|
compiler: Compiler::default(),
|
||||||
},
|
},
|
||||||
windows: Vec::new(),
|
surfaces: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -261,14 +261,14 @@ impl Shell {
|
||||||
code: code.into(),
|
code: code.into(),
|
||||||
compiler,
|
compiler,
|
||||||
},
|
},
|
||||||
windows: Vec::new(),
|
surfaces: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_compilation(result: Rc<CompilationResult>) -> ShellBuilder {
|
pub fn from_compilation(result: Rc<CompilationResult>) -> ShellBuilder {
|
||||||
ShellBuilder {
|
ShellBuilder {
|
||||||
compilation: CompilationSource::Compiled(result),
|
compilation: CompilationSource::Compiled(result),
|
||||||
windows: Vec::new(),
|
surfaces: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,7 +278,7 @@ impl Shell {
|
||||||
code: String::new(),
|
code: String::new(),
|
||||||
compiler: Compiler::default(),
|
compiler: Compiler::default(),
|
||||||
},
|
},
|
||||||
windows: Vec::new(),
|
surfaces: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -316,7 +316,7 @@ impl Shell {
|
||||||
|
|
||||||
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!("Creating Shell with {} windows", definitions.len());
|
log::info!("Creating Shell with {} windows", definitions.len());
|
||||||
|
|
||||||
|
|
@ -342,7 +342,7 @@ impl Shell {
|
||||||
|
|
||||||
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)
|
||||||
|
|
@ -355,7 +355,7 @@ impl Shell {
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let wayland_config = WaylandWindowConfig::from_domain_config(
|
let wayland_config = WaylandSurfaceConfig::from_domain_config(
|
||||||
component_definition,
|
component_definition,
|
||||||
Some(Rc::clone(&compilation_result)),
|
Some(Rc::clone(&compilation_result)),
|
||||||
definition.config.clone(),
|
definition.config.clone(),
|
||||||
|
|
@ -367,12 +367,12 @@ impl Shell {
|
||||||
|
|
||||||
let (sender, receiver) = channel::channel();
|
let (sender, receiver) = channel::channel();
|
||||||
|
|
||||||
let mut windows = HashMap::new();
|
let mut surfaces = HashMap::new();
|
||||||
windows.insert(definition.component.clone(), definition);
|
surfaces.insert(definition.component.clone(), definition);
|
||||||
|
|
||||||
let shell = Self {
|
let shell = Self {
|
||||||
inner: Rc::clone(&inner_rc),
|
inner: Rc::clone(&inner_rc),
|
||||||
windows,
|
surfaces,
|
||||||
compilation_result,
|
compilation_result,
|
||||||
popup_command_sender: sender,
|
popup_command_sender: sender,
|
||||||
};
|
};
|
||||||
|
|
@ -386,9 +386,9 @@ impl Shell {
|
||||||
|
|
||||||
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<ShellSurfaceConfig> = definitions
|
||||||
.iter()
|
.iter()
|
||||||
.map(|def| {
|
.map(|def| {
|
||||||
let component_definition = compilation_result
|
let component_definition = compilation_result
|
||||||
|
|
@ -402,13 +402,13 @@ impl Shell {
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let wayland_config = WaylandWindowConfig::from_domain_config(
|
let wayland_config = WaylandSurfaceConfig::from_domain_config(
|
||||||
component_definition,
|
component_definition,
|
||||||
Some(Rc::clone(&compilation_result)),
|
Some(Rc::clone(&compilation_result)),
|
||||||
def.config.clone(),
|
def.config.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(ShellWindowConfig {
|
Ok(ShellSurfaceConfig {
|
||||||
name: def.component.clone(),
|
name: def.component.clone(),
|
||||||
config: wayland_config,
|
config: wayland_config,
|
||||||
})
|
})
|
||||||
|
|
@ -421,14 +421,14 @@ impl Shell {
|
||||||
|
|
||||||
let (sender, receiver) = channel::channel();
|
let (sender, receiver) = channel::channel();
|
||||||
|
|
||||||
let mut windows = HashMap::new();
|
let mut surfaces = HashMap::new();
|
||||||
for definition in definitions {
|
for definition in definitions {
|
||||||
windows.insert(definition.component.clone(), definition);
|
surfaces.insert(definition.component.clone(), definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
let shell = Self {
|
let shell = Self {
|
||||||
inner: Rc::clone(&inner_rc),
|
inner: Rc::clone(&inner_rc),
|
||||||
windows,
|
surfaces,
|
||||||
compilation_result,
|
compilation_result,
|
||||||
popup_command_sender: sender,
|
popup_command_sender: sender,
|
||||||
};
|
};
|
||||||
|
|
@ -436,8 +436,8 @@ impl Shell {
|
||||||
shell.setup_popup_command_handler(receiver)?;
|
shell.setup_popup_command_handler(receiver)?;
|
||||||
|
|
||||||
log::info!(
|
log::info!(
|
||||||
"Shell created (multi-window mode) with windows: {:?}",
|
"Shell created (multi-surface mode) with surfaces: {:?}",
|
||||||
shell.window_names()
|
shell.surface_names()
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(shell)
|
Ok(shell)
|
||||||
|
|
@ -492,12 +492,12 @@ impl Shell {
|
||||||
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) -> ShellEventLoopHandle {
|
pub fn event_loop_handle(&self) -> ShellEventLoopHandle {
|
||||||
|
|
@ -507,17 +507,17 @@ impl Shell {
|
||||||
pub fn run(&mut self) -> Result<()> {
|
pub fn run(&mut self) -> Result<()> {
|
||||||
log::info!(
|
log::info!(
|
||||||
"Starting Shell event loop with {} windows",
|
"Starting Shell 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),
|
||||||
}));
|
}));
|
||||||
|
|
@ -528,7 +528,7 @@ impl Shell {
|
||||||
|
|
||||||
system
|
system
|
||||||
.app_state()
|
.app_state()
|
||||||
.windows_by_shell_name(name)
|
.surfaces_by_name(name)
|
||||||
.next()
|
.next()
|
||||||
.map(|window| f(window.component_instance()))
|
.map(|window| f(window.component_instance()))
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
|
|
@ -538,15 +538,15 @@ impl Shell {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
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 window in system.app_state().surfaces_by_name(name) {
|
||||||
f(name, window.component_instance());
|
f(name, window.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -595,7 +595,7 @@ impl Shell {
|
||||||
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(window_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", window_name),
|
||||||
}));
|
}));
|
||||||
|
|
@ -606,7 +606,7 @@ 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().windows_by_shell_name(window_name) {
|
for window in system.app_state().surfaces_by_name(window_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
|
||||||
|
|
@ -637,7 +637,7 @@ impl Shell {
|
||||||
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(window_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", window_name),
|
||||||
}));
|
}));
|
||||||
|
|
@ -648,7 +648,7 @@ 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().windows_by_shell_name(window_name) {
|
for window in system.app_state().surfaces_by_name(window_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
|
||||||
|
|
@ -729,15 +729,15 @@ impl Shell {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_window_config<F>(&self, window_name: &str, f: F)
|
pub fn apply_surface_config<F>(&self, window_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(window_name) {
|
||||||
for window in system.app_state().windows_by_shell_name(window_name) {
|
for window in system.app_state().surfaces_by_name(window_name) {
|
||||||
let surface_handle = LayerSurfaceHandle::from_window_state(window);
|
let surface_handle = LayerSurfaceHandle::from_window_state(window);
|
||||||
f(window.component_instance(), surface_handle);
|
f(window.component_instance(), surface_handle);
|
||||||
}
|
}
|
||||||
|
|
@ -791,8 +791,8 @@ impl ShellRuntime for Shell {
|
||||||
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 window in system.app_state().surfaces_by_name(name) {
|
||||||
f(window.component_instance());
|
f(window.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -805,8 +805,8 @@ impl ShellRuntime for Shell {
|
||||||
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 window in system.app_state().surfaces_by_name(name) {
|
||||||
f(name, window.component_instance());
|
f(name, window.component_instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -833,7 +833,7 @@ impl<'a> FromAppState<'a> for ShellEventContext<'a> {
|
||||||
impl ShellEventContext<'_> {
|
impl ShellEventContext<'_> {
|
||||||
pub fn get_window_component(&self, name: &str) -> Option<&ComponentInstance> {
|
pub fn get_window_component(&self, name: &str) -> Option<&ComponentInstance> {
|
||||||
self.app_state
|
self.app_state
|
||||||
.windows_by_shell_name(name)
|
.surfaces_by_name(name)
|
||||||
.next()
|
.next()
|
||||||
.map(WindowState::component_instance)
|
.map(WindowState::component_instance)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use layer_shika_adapters::platform::slint_interpreter::ComponentInstance;
|
use layer_shika_adapters::platform::slint_interpreter::ComponentInstance;
|
||||||
|
|
||||||
pub const DEFAULT_WINDOW_NAME: &str = "main";
|
pub const DEFAULT_SURFACE_NAME: &str = "main";
|
||||||
|
|
||||||
pub trait ShellRuntime {
|
pub trait ShellRuntime {
|
||||||
type LoopHandle;
|
type LoopHandle;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::event_loop::{EventLoopHandleBase, FromAppState};
|
use crate::event_loop::{EventLoopHandleBase, FromAppState};
|
||||||
use crate::shell_runtime::{DEFAULT_WINDOW_NAME, ShellRuntime};
|
use crate::shell_runtime::{DEFAULT_SURFACE_NAME, ShellRuntime};
|
||||||
use crate::value_conversion::IntoValue;
|
use crate::value_conversion::IntoValue;
|
||||||
use crate::{Error, Result};
|
use crate::{Error, Result};
|
||||||
use layer_shika_adapters::errors::EventLoopError;
|
use layer_shika_adapters::errors::EventLoopError;
|
||||||
|
|
@ -9,9 +9,9 @@ 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, WaylandWindowConfig, WindowState, WindowingSystemFacade,
|
AppState, PopupManager, WaylandSurfaceConfig, WindowState, WindowingSystemFacade,
|
||||||
};
|
};
|
||||||
use layer_shika_domain::config::WindowConfig;
|
use layer_shika_domain::config::SurfaceConfig;
|
||||||
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
use layer_shika_domain::entities::output_registry::OutputRegistry;
|
||||||
use layer_shika_domain::errors::DomainError;
|
use layer_shika_domain::errors::DomainError;
|
||||||
use layer_shika_domain::value_objects::dimensions::PopupDimensions;
|
use layer_shika_domain::value_objects::dimensions::PopupDimensions;
|
||||||
|
|
@ -563,9 +563,9 @@ impl SingleWindowShell {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
component_definition: ComponentDefinition,
|
component_definition: ComponentDefinition,
|
||||||
compilation_result: Option<Rc<CompilationResult>>,
|
compilation_result: Option<Rc<CompilationResult>>,
|
||||||
config: WindowConfig,
|
config: SurfaceConfig,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let wayland_config = WaylandWindowConfig::from_domain_config(
|
let wayland_config = WaylandSurfaceConfig::from_domain_config(
|
||||||
component_definition,
|
component_definition,
|
||||||
compilation_result,
|
compilation_result,
|
||||||
config,
|
config,
|
||||||
|
|
@ -579,7 +579,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_WINDOW_NAME.to_string(),
|
window_name: DEFAULT_SURFACE_NAME.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
shell.setup_popup_command_handler(receiver)?;
|
shell.setup_popup_command_handler(receiver)?;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
use crate::dimensions::ScaleFactor;
|
use crate::dimensions::ScaleFactor;
|
||||||
use crate::value_objects::anchor::AnchorEdges;
|
use crate::value_objects::anchor::AnchorEdges;
|
||||||
use crate::value_objects::dimensions::WindowDimension;
|
use crate::value_objects::dimensions::SurfaceDimension;
|
||||||
use crate::value_objects::keyboard_interactivity::KeyboardInteractivity;
|
use crate::value_objects::keyboard_interactivity::KeyboardInteractivity;
|
||||||
use crate::value_objects::layer::Layer;
|
use crate::value_objects::layer::Layer;
|
||||||
use crate::value_objects::margins::Margins;
|
use crate::value_objects::margins::Margins;
|
||||||
use crate::value_objects::output_policy::OutputPolicy;
|
use crate::value_objects::output_policy::OutputPolicy;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct WindowConfig {
|
pub struct SurfaceConfig {
|
||||||
pub dimensions: WindowDimension,
|
pub dimensions: SurfaceDimension,
|
||||||
pub margin: Margins,
|
pub margin: Margins,
|
||||||
pub exclusive_zone: i32,
|
pub exclusive_zone: i32,
|
||||||
pub scale_factor: ScaleFactor,
|
pub scale_factor: ScaleFactor,
|
||||||
|
|
@ -19,11 +19,11 @@ pub struct WindowConfig {
|
||||||
pub output_policy: OutputPolicy,
|
pub output_policy: OutputPolicy,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowConfig {
|
impl SurfaceConfig {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
dimensions: WindowDimension::default(),
|
dimensions: SurfaceDimension::default(),
|
||||||
margin: Margins::default(),
|
margin: Margins::default(),
|
||||||
exclusive_zone: -1,
|
exclusive_zone: -1,
|
||||||
namespace: "layer-shika".to_owned(),
|
namespace: "layer-shika".to_owned(),
|
||||||
|
|
@ -36,7 +36,7 @@ impl WindowConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WindowConfig {
|
impl Default for SurfaceConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new()
|
Self::new()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#![allow(clippy::pub_use)]
|
#![allow(clippy::pub_use)]
|
||||||
|
|
||||||
pub use crate::config::WindowConfig;
|
pub use crate::config::SurfaceConfig;
|
||||||
pub use crate::dimensions::{
|
pub use crate::dimensions::{
|
||||||
LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, ScaleFactor,
|
LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, ScaleFactor,
|
||||||
};
|
};
|
||||||
|
|
@ -9,7 +9,7 @@ pub use crate::errors::{DomainError, Result};
|
||||||
pub use crate::surface_dimensions::SurfaceDimensions;
|
pub use crate::surface_dimensions::SurfaceDimensions;
|
||||||
pub use crate::value_objects::anchor::AnchorEdges;
|
pub use crate::value_objects::anchor::AnchorEdges;
|
||||||
pub use crate::value_objects::anchor_strategy::AnchorStrategy;
|
pub use crate::value_objects::anchor_strategy::AnchorStrategy;
|
||||||
pub use crate::value_objects::dimensions::{PopupDimensions, WindowDimension};
|
pub use crate::value_objects::dimensions::{PopupDimensions, SurfaceDimension};
|
||||||
pub use crate::value_objects::keyboard_interactivity::KeyboardInteractivity;
|
pub use crate::value_objects::keyboard_interactivity::KeyboardInteractivity;
|
||||||
pub use crate::value_objects::layer::Layer;
|
pub use crate::value_objects::layer::Layer;
|
||||||
pub use crate::value_objects::margins::Margins;
|
pub use crate::value_objects::margins::Margins;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct WindowDimension {
|
pub struct SurfaceDimension {
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowDimension {
|
impl SurfaceDimension {
|
||||||
pub fn new(width: u32, height: u32) -> Self {
|
pub fn new(width: u32, height: u32) -> Self {
|
||||||
Self {
|
Self {
|
||||||
width: if width == 0 {
|
width: if width == 0 {
|
||||||
|
|
@ -33,7 +33,7 @@ impl WindowDimension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WindowDimension {
|
impl Default for SurfaceDimension {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
width: 20,
|
width: 20,
|
||||||
|
|
|
||||||
26
src/lib.rs
26
src/lib.rs
|
|
@ -1,6 +1,6 @@
|
||||||
//! layer-shika: A Wayland layer shell library with Slint UI integration
|
//! layer-shika: A Wayland layer shell library with Slint UI integration
|
||||||
//!
|
//!
|
||||||
//! This crate provides a high-level API for creating Wayland layer shell windows
|
//! This crate provides a high-level API for creating Wayland layer shell surfaces
|
||||||
//! with Slint-based user interfaces. It's built on a clean architecture with three
|
//! with Slint-based user interfaces. It's built on a clean architecture with three
|
||||||
//! internal layers (domain, adapters, composition), but users should only depend on
|
//! internal layers (domain, adapters, composition), but users should only depend on
|
||||||
//! this root crate.
|
//! this root crate.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
//! The API is organized into conceptual facets:
|
//! The API is organized into conceptual facets:
|
||||||
//!
|
//!
|
||||||
//! - [`shell`] – Main runtime and shell composition types
|
//! - [`shell`] – Main runtime and shell composition types
|
||||||
//! - [`window`] – Window configuration, layers, anchors, and popup types
|
//! - [`window`] – Surface configuration, layers, anchors, and popup types
|
||||||
//! - [`output`] – Output (monitor) info, geometry, and policies
|
//! - [`output`] – Output (monitor) info, geometry, and policies
|
||||||
//! - [`event`] – Event loop handles and contexts
|
//! - [`event`] – Event loop handles and contexts
|
||||||
//! - [`slint_integration`] – Slint framework re-exports and wrappers
|
//! - [`slint_integration`] – Slint framework re-exports and wrappers
|
||||||
|
|
@ -30,13 +30,13 @@
|
||||||
//!
|
//!
|
||||||
//! # Quick Start
|
//! # Quick Start
|
||||||
//!
|
//!
|
||||||
//! Single-window use case:
|
//! Single-surface use case:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use layer_shika::prelude::*;
|
//! use layer_shika::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! Shell::from_file("ui/bar.slint")
|
//! Shell::from_file("ui/bar.slint")
|
||||||
//! .window("Main")
|
//! .surface("Main")
|
||||||
//! .height(42)
|
//! .height(42)
|
||||||
//! .anchor(AnchorEdges::top_bar())
|
//! .anchor(AnchorEdges::top_bar())
|
||||||
//! .exclusive_zone(42)
|
//! .exclusive_zone(42)
|
||||||
|
|
@ -45,18 +45,18 @@
|
||||||
//! # Ok::<(), layer_shika::Error>(())
|
//! # Ok::<(), layer_shika::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! # Multi-Window Shell
|
//! # Multi-Surface Shell
|
||||||
//!
|
//!
|
||||||
//! Same API naturally extends to multiple windows:
|
//! Same API naturally extends to multiple surfaces:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use layer_shika::prelude::*;
|
//! use layer_shika::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! Shell::from_file("ui/shell.slint")
|
//! Shell::from_file("ui/shell.slint")
|
||||||
//! .window("TopBar")
|
//! .surface("TopBar")
|
||||||
//! .height(42)
|
//! .height(42)
|
||||||
//! .anchor(AnchorEdges::top_bar())
|
//! .anchor(AnchorEdges::top_bar())
|
||||||
//! .window("Dock")
|
//! .surface("Dock")
|
||||||
//! .height(64)
|
//! .height(64)
|
||||||
//! .anchor(AnchorEdges::bottom_bar())
|
//! .anchor(AnchorEdges::bottom_bar())
|
||||||
//! .build()?
|
//! .build()?
|
||||||
|
|
@ -74,10 +74,10 @@
|
||||||
//! let compilation = Shell::compile_file("ui/shell.slint")?;
|
//! let compilation = Shell::compile_file("ui/shell.slint")?;
|
||||||
//!
|
//!
|
||||||
//! Shell::from_compilation(compilation)
|
//! Shell::from_compilation(compilation)
|
||||||
//! .window("TopBar")
|
//! .surface("TopBar")
|
||||||
//! .output_policy(OutputPolicy::AllOutputs)
|
//! .output_policy(OutputPolicy::AllOutputs)
|
||||||
//! .height(42)
|
//! .height(42)
|
||||||
//! .window("Dock")
|
//! .surface("Dock")
|
||||||
//! .output_policy(OutputPolicy::PrimaryOnly)
|
//! .output_policy(OutputPolicy::PrimaryOnly)
|
||||||
//! .height(64)
|
//! .height(64)
|
||||||
//! .build()?
|
//! .build()?
|
||||||
|
|
@ -98,9 +98,9 @@ pub mod window;
|
||||||
pub use layer_shika_composition::{Error, Result};
|
pub use layer_shika_composition::{Error, Result};
|
||||||
|
|
||||||
pub use shell::{
|
pub use shell::{
|
||||||
DEFAULT_COMPONENT_NAME, DEFAULT_WINDOW_NAME, LayerSurfaceHandle, Shell, ShellBuilder,
|
DEFAULT_COMPONENT_NAME, DEFAULT_SURFACE_NAME, LayerSurfaceHandle, Shell, ShellBuilder,
|
||||||
ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime, ShellWindowConfigHandler,
|
ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime, ShellSurfaceConfigHandler,
|
||||||
ShellWindowHandle, SingleWindowShell, WindowConfigBuilder, WindowDefinition,
|
ShellSurfaceHandle, SingleWindowShell, SurfaceConfigBuilder, SurfaceDefinition,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use window::{
|
pub use window::{
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
#![allow(clippy::pub_use)]
|
#![allow(clippy::pub_use)]
|
||||||
|
|
||||||
pub use crate::shell::{
|
pub use crate::shell::{
|
||||||
DEFAULT_COMPONENT_NAME, DEFAULT_WINDOW_NAME, LayerSurfaceHandle, Shell, ShellBuilder,
|
DEFAULT_COMPONENT_NAME, DEFAULT_SURFACE_NAME, LayerSurfaceHandle, Shell, ShellBuilder,
|
||||||
ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime, ShellWindowConfigHandler,
|
ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime, ShellSurfaceConfigHandler,
|
||||||
ShellWindowHandle, SingleWindowShell, WindowConfigBuilder, WindowDefinition,
|
ShellSurfaceHandle, SingleWindowShell, SurfaceConfigBuilder, SurfaceDefinition,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use crate::window::{
|
pub use crate::window::{
|
||||||
|
|
@ -28,7 +28,7 @@ pub use crate::slint_integration::{PopupWindow, slint, slint_interpreter};
|
||||||
pub use crate::{Error, Result};
|
pub use crate::{Error, Result};
|
||||||
|
|
||||||
pub use layer_shika_composition::prelude::{
|
pub use layer_shika_composition::prelude::{
|
||||||
Anchor, LogicalSize, Margins, PhysicalSize, ScaleFactor, WindowConfig, WindowDimension,
|
Anchor, LogicalSize, Margins, PhysicalSize, ScaleFactor, SurfaceConfig, SurfaceDimension,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use crate::calloop;
|
pub use crate::calloop;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
pub use layer_shika_composition::{
|
pub use layer_shika_composition::{
|
||||||
DEFAULT_COMPONENT_NAME, DEFAULT_WINDOW_NAME, LayerSurfaceHandle, Shell, ShellBuilder,
|
DEFAULT_COMPONENT_NAME, DEFAULT_SURFACE_NAME, LayerSurfaceHandle, Shell, ShellBuilder,
|
||||||
ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime, ShellWindowConfigHandler,
|
ShellControl, ShellEventContext, ShellEventLoopHandle, ShellRuntime, ShellSurfaceConfigHandler,
|
||||||
ShellWindowHandle, SingleWindowShell, WindowConfigBuilder, WindowDefinition,
|
ShellSurfaceHandle, SingleWindowShell, SurfaceConfigBuilder, SurfaceDefinition,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,3 @@ pub use layer_shika_composition::{
|
||||||
AnchorEdges, AnchorStrategy, KeyboardInteractivity, Layer, PopupHandle, PopupPlacement,
|
AnchorEdges, AnchorStrategy, KeyboardInteractivity, Layer, PopupHandle, PopupPlacement,
|
||||||
PopupPositioningMode, PopupRequest, PopupSize,
|
PopupPositioningMode, PopupRequest, PopupSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use layer_shika_composition::DEFAULT_WINDOW_NAME;
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue