mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-11-03 09:04:24 +00:00
feat: add missing kb interactivity
This commit is contained in:
parent
9252b93196
commit
7e2aa6dd3e
7 changed files with 45 additions and 6 deletions
|
|
@ -1,10 +1,11 @@
|
|||
use layer_shika_domain::prelude::{
|
||||
AnchorEdges, Layer, Margins, WindowConfig as DomainWindowConfig,
|
||||
AnchorEdges, KeyboardInteractivity as DomainKeyboardInteractivity, Layer, Margins,
|
||||
WindowConfig as DomainWindowConfig,
|
||||
};
|
||||
use slint_interpreter::ComponentDefinition;
|
||||
use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::{
|
||||
zwlr_layer_shell_v1::{self},
|
||||
zwlr_layer_surface_v1::{Anchor, KeyboardInteractivity},
|
||||
zwlr_layer_surface_v1::{Anchor, KeyboardInteractivity as WaylandKeyboardInteractivity},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -12,7 +13,7 @@ pub(crate) struct LayerSurfaceParams {
|
|||
pub anchor: Anchor,
|
||||
pub margin: Margins,
|
||||
pub exclusive_zone: i32,
|
||||
pub keyboard_interactivity: KeyboardInteractivity,
|
||||
pub keyboard_interactivity: WaylandKeyboardInteractivity,
|
||||
pub height: u32,
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ pub struct WaylandWindowConfig {
|
|||
pub layer: zwlr_layer_shell_v1::Layer,
|
||||
pub margin: Margins,
|
||||
pub anchor: Anchor,
|
||||
pub keyboard_interactivity: KeyboardInteractivity,
|
||||
pub keyboard_interactivity: WaylandKeyboardInteractivity,
|
||||
pub exclusive_zone: i32,
|
||||
pub scale_factor: f32,
|
||||
pub namespace: String,
|
||||
|
|
@ -40,7 +41,9 @@ impl WaylandWindowConfig {
|
|||
layer: convert_layer(domain_config.layer),
|
||||
margin: domain_config.margin,
|
||||
anchor: convert_anchor(domain_config.anchor),
|
||||
keyboard_interactivity: KeyboardInteractivity::OnDemand,
|
||||
keyboard_interactivity: convert_keyboard_interactivity(
|
||||
domain_config.keyboard_interactivity,
|
||||
),
|
||||
exclusive_zone: domain_config.exclusive_zone,
|
||||
scale_factor: domain_config.scale_factor,
|
||||
namespace: domain_config.namespace,
|
||||
|
|
@ -76,3 +79,13 @@ const fn convert_anchor(anchor: AnchorEdges) -> Anchor {
|
|||
|
||||
result
|
||||
}
|
||||
|
||||
const fn convert_keyboard_interactivity(
|
||||
mode: DomainKeyboardInteractivity,
|
||||
) -> WaylandKeyboardInteractivity {
|
||||
match mode {
|
||||
DomainKeyboardInteractivity::None => WaylandKeyboardInteractivity::None,
|
||||
DomainKeyboardInteractivity::Exclusive => WaylandKeyboardInteractivity::Exclusive,
|
||||
DomainKeyboardInteractivity::OnDemand => WaylandKeyboardInteractivity::OnDemand,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
use crate::Result;
|
||||
use crate::system::WindowingSystem;
|
||||
use layer_shika_adapters::platform::slint_interpreter::ComponentDefinition;
|
||||
use layer_shika_domain::prelude::{AnchorEdges, Layer, Margins, WindowConfig};
|
||||
use layer_shika_domain::prelude::{
|
||||
AnchorEdges, KeyboardInteractivity, Layer, Margins, WindowConfig,
|
||||
};
|
||||
|
||||
pub struct NeedsComponent;
|
||||
pub struct HasComponent {
|
||||
|
|
@ -73,6 +75,12 @@ impl LayerShika<HasComponent> {
|
|||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn with_keyboard_interactivity(mut self, mode: KeyboardInteractivity) -> Self {
|
||||
self.config.keyboard_interactivity = mode;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> Result<WindowingSystem> {
|
||||
WindowingSystem::new(self.state.component_definition, self.config)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ pub use layer_shika_adapters::close_current_popup;
|
|||
pub use layer_shika_adapters::platform::{slint, slint_interpreter};
|
||||
pub use layer_shika_adapters::{clear_popup_config, get_popup_config, set_popup_config};
|
||||
pub use layer_shika_domain::value_objects::anchor::AnchorEdges;
|
||||
pub use layer_shika_domain::value_objects::keyboard_interactivity::KeyboardInteractivity;
|
||||
pub use layer_shika_domain::value_objects::popup_positioning_mode::PopupPositioningMode;
|
||||
|
||||
pub mod calloop {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::value_objects::anchor::AnchorEdges;
|
||||
use crate::value_objects::keyboard_interactivity::KeyboardInteractivity;
|
||||
use crate::value_objects::layer::Layer;
|
||||
use crate::value_objects::margins::Margins;
|
||||
|
||||
|
|
@ -11,6 +12,7 @@ pub struct WindowConfig {
|
|||
pub namespace: String,
|
||||
pub layer: Layer,
|
||||
pub anchor: AnchorEdges,
|
||||
pub keyboard_interactivity: KeyboardInteractivity,
|
||||
}
|
||||
|
||||
impl WindowConfig {
|
||||
|
|
@ -24,6 +26,7 @@ impl WindowConfig {
|
|||
scale_factor: 1.0,
|
||||
layer: Layer::default(),
|
||||
anchor: AnchorEdges::default(),
|
||||
keyboard_interactivity: KeyboardInteractivity::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,5 +8,6 @@ pub use crate::errors::{DomainError, Result};
|
|||
pub use crate::surface_dimensions::SurfaceDimensions;
|
||||
pub use crate::value_objects::anchor::AnchorEdges;
|
||||
pub use crate::value_objects::dimensions::WindowHeight;
|
||||
pub use crate::value_objects::keyboard_interactivity::KeyboardInteractivity;
|
||||
pub use crate::value_objects::layer::Layer;
|
||||
pub use crate::value_objects::margins::Margins;
|
||||
|
|
|
|||
12
domain/src/value_objects/keyboard_interactivity.rs
Normal file
12
domain/src/value_objects/keyboard_interactivity.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum KeyboardInteractivity {
|
||||
None,
|
||||
Exclusive,
|
||||
OnDemand,
|
||||
}
|
||||
|
||||
impl Default for KeyboardInteractivity {
|
||||
fn default() -> Self {
|
||||
Self::OnDemand
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
pub mod anchor;
|
||||
pub mod dimensions;
|
||||
pub mod keyboard_interactivity;
|
||||
pub mod layer;
|
||||
pub mod margins;
|
||||
pub mod popup_config;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue