2025-03-14 11:16:25 -04:00
|
|
|
use std::fmt;
|
|
|
|
|
use std::hash::{Hash, Hasher};
|
|
|
|
|
|
2026-05-05 16:45:37 +02:00
|
|
|
use cctk::sctk::reexports::protocols::xdg::shell::client::xdg_positioner::Gravity;
|
2025-03-14 11:16:25 -04:00
|
|
|
use iced_core::window::Id;
|
2026-05-05 16:45:37 +02:00
|
|
|
use iced_core::{Point, Rectangle, Size};
|
2025-03-14 11:16:25 -04:00
|
|
|
|
|
|
|
|
/// 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
|
2025-03-27 12:35:25 -07:00
|
|
|
pub z: i32,
|
2025-03-14 11:16:25 -04:00
|
|
|
/// 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
|
2025-09-18 13:05:18 -07:00
|
|
|
pub input_zone: Option<Vec<Rectangle>>,
|
2025-03-14 11:16:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
},
|
2025-08-25 00:16:31 -04:00
|
|
|
/// reposition the subsurface
|
|
|
|
|
Reposition {
|
|
|
|
|
/// id of the subsurface
|
|
|
|
|
id: Id,
|
|
|
|
|
x: i32,
|
|
|
|
|
y: i32,
|
|
|
|
|
},
|
2025-03-14 11:16:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
),
|
2025-08-25 00:16:31 -04:00
|
|
|
Action::Reposition { id, x, y } => write!(
|
|
|
|
|
f,
|
|
|
|
|
"Action::SubsurfaceAction::Reposition {{ id: {:?}, x: {:?}, y: {:?} }}",
|
|
|
|
|
id, x, y
|
|
|
|
|
),
|
2025-03-14 11:16:25 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|