feat: subsurfaces

This commit is contained in:
Ashley Wulber 2025-03-14 11:16:25 -04:00 committed by Ashley Wulber
parent 0f37c9922d
commit 93bc4bbd88
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
33 changed files with 1898 additions and 2651 deletions

View file

@ -1,10 +1,10 @@
use std::fmt;
use iced_core::layout::Limits;
use cctk::sctk::{
reexports::client::protocol::wl_output::WlOutput,
shell::wlr_layer::{Anchor, KeyboardInteractivity, Layer},
};
use iced_core::layout::Limits;
use iced_core::window::Id;

View file

@ -14,6 +14,9 @@ pub mod popup;
/// session locks
pub mod session_lock;
// subsurfaces
pub mod subsurface;
/// Platform specific actions defined for wayland
pub enum Action {
/// LayerSurface Actions
@ -26,6 +29,8 @@ pub enum Action {
SessionLock(session_lock::Action),
/// Overlap Notify
OverlapNotify(Id, bool),
/// Subsurfaces
Subsurface(subsurface::Action),
}
impl Debug for Action {
@ -44,6 +49,9 @@ impl Debug for Action {
Action::OverlapNotify(id, _) => {
f.debug_tuple("OverlapNotify").field(id).finish()
}
Action::Subsurface(action) => {
f.debug_tuple("Subsurface").field(action).finish()
}
}
}
}

View file

@ -1,12 +1,15 @@
use std::any::Any;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::sync::Arc;
use iced_core::layout::Limits;
use iced_core::window::Id;
use iced_core::Rectangle;
use cctk::sctk::reexports::protocols::xdg::shell::client::xdg_positioner::{
Anchor, Gravity,
};
use iced_core::layout::Limits;
use iced_core::window::Id;
use iced_core::{Element, Rectangle};
/// Popup creation details
#[derive(Debug, Clone)]
pub struct SctkPopupSettings {
@ -20,6 +23,11 @@ pub struct SctkPopupSettings {
pub parent_size: Option<(u32, u32)>,
/// whether a grab should be requested for the popup after creation
pub grab: bool,
/// whether a popup should close when its child popups close
pub close_with_children: bool,
/// input zone
/// None results in accepting all input
pub input_zone: Option<Rectangle>,
}
impl Hash for SctkPopupSettings {

View file

@ -0,0 +1,77 @@
use std::any::Any;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::sync::Arc;
use cctk::sctk::reexports::protocols::xdg::shell::client::xdg_positioner::{
Anchor, Gravity,
};
use iced_core::layout::Limits;
use iced_core::window::Id;
use iced_core::{Element, Point, Rectangle, Size};
/// Subsurface creation details
#[derive(Debug, Clone)]
pub struct SctkSubsurfaceSettings {
/// XXX must be unique, id of the parent
pub parent: Id,
/// XXX must be unique, id of the subsurface
pub id: Id,
/// anchor position of the subsurface
pub loc: Point,
/// size of the subsurface
pub size: Option<Size>,
// pub subsurface_view: Option<Arc<dyn Any + Send + Sync>>,
/// Z
pub z: u32,
/// Steal Keyboard focus from parent while open.
/// Will not work on a regular window.
pub steal_keyboard_focus: bool,
/// offset of the subsurface from the anchor
pub offset: (i32, i32),
/// the gravity of the popup
pub gravity: Gravity,
/// input zone
/// None results in accepting all input
pub input_zone: Option<Rectangle>,
}
impl Hash for SctkSubsurfaceSettings {
fn hash<H: Hasher>(&self, state: &mut H) {
self.id.hash(state);
}
}
#[derive(Clone)]
/// Window Action
pub enum Action {
/// create a window and receive a message with its Id
Subsurface {
/// subsurface
subsurface: SctkSubsurfaceSettings,
},
/// destroy the subsurface
Destroy {
/// id of the subsurface
id: Id,
},
}
impl fmt::Debug for Action {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Action::Subsurface { subsurface, .. } => write!(
f,
"Action::SubsurfaceAction::Subsurface {{ subsurface: {:?} }}",
subsurface
),
Action::Destroy { id } => write!(
f,
"Action::SubsurfaceAction::Destroy {{ id: {:?} }}",
id
),
}
}
}