Skip to main content

reovim_driver_layout/
floating.rs

1//! Floating layer trait for free-positioned windows.
2//!
3//! The floating layer manages windows that can be freely positioned
4//! and sized on screen, independent of the tiled split tree.
5//!
6//! # Future Work
7//!
8//! This trait will be implemented in Phase 2 (#398).
9
10use {
11    super::layer::{WindowPlacement, ZOrder},
12    crate::{Rect, WindowId},
13};
14
15/// Floating window state.
16#[derive(Debug, Clone)]
17pub struct FloatingWindow {
18    /// Window identifier.
19    pub id: WindowId,
20    /// Window bounds (position and size).
21    pub bounds: Rect,
22    /// Z-order within float zone.
23    pub z_order: ZOrder,
24}
25
26/// Floating layer manages freely-positioned windows.
27///
28/// Floating windows exist above the tiled zone but below overlays.
29/// They can be moved and resized freely within the layer bounds.
30///
31/// # Thread Safety
32///
33/// Implementations must be `Send + Sync` to allow the floating layer
34/// to be shared across async tasks.
35pub trait FloatingLayer: Send + Sync {
36    /// Get all floating windows in z-order.
37    ///
38    /// Returns window placements sorted by z-order (lowest first).
39    fn arrange(&self) -> Vec<WindowPlacement>;
40
41    /// Create a new floating window.
42    ///
43    /// # Arguments
44    ///
45    /// * `id` - Window identifier
46    /// * `bounds` - Initial position and size
47    ///
48    /// # Returns
49    ///
50    /// The window ID (same as input for consistency).
51    fn create(&mut self, id: WindowId, bounds: Rect) -> WindowId;
52
53    /// Close a floating window.
54    ///
55    /// # Returns
56    ///
57    /// `true` if the window existed and was closed.
58    fn close(&mut self, window: WindowId) -> bool;
59
60    /// Move window to position.
61    fn move_to(&mut self, window: WindowId, x: u16, y: u16);
62
63    /// Resize window.
64    fn resize(&mut self, window: WindowId, width: u16, height: u16);
65
66    /// Bring to front (highest z-order).
67    fn raise(&mut self, window: WindowId);
68
69    /// Send to back (lowest z-order in floating layer).
70    fn lower(&mut self, window: WindowId);
71
72    /// Get all floating window IDs.
73    fn windows(&self) -> Vec<WindowId>;
74
75    /// Check if window is in floating layer.
76    fn contains(&self, window: WindowId) -> bool;
77}
78
79#[cfg(test)]
80#[path = "floating_tests.rs"]
81mod tests;