Skip to main content

cbf_compositor/core/
commands.rs

1use crate::model::{
2    CompositionItemId, CompositorWindowId, HitTestCoordinateSpace, HitTestRegion,
3    HitTestRegionMode, Rect, WindowCompositionSpec,
4};
5
6/// Declarative scene updates applied to a compositor-managed window.
7#[derive(Debug, Clone)]
8pub enum CompositionCommand {
9    /// Replace the entire scene contents for a window.
10    SetWindowComposition {
11        /// Window to update.
12        window_id: CompositorWindowId,
13        /// New composition snapshot for the window.
14        composition: WindowCompositionSpec,
15    },
16    /// Update only the bounds of one existing scene item.
17    UpdateItemBounds {
18        /// Window that owns the item.
19        window_id: CompositorWindowId,
20        /// Item to move or resize.
21        item_id: CompositionItemId,
22        /// New bounds in window coordinates.
23        bounds: Rect,
24    },
25    /// Update only the visibility of one existing scene item.
26    SetItemVisibility {
27        /// Window that owns the item.
28        window_id: CompositorWindowId,
29        /// Item to show or hide.
30        item_id: CompositionItemId,
31        /// New visibility state.
32        visible: bool,
33    },
34    /// Replace the cached hit-test snapshot for one item.
35    SetItemHitTestRegions {
36        /// Window that owns the item.
37        window_id: CompositorWindowId,
38        /// Item that should receive the snapshot.
39        item_id: CompositionItemId,
40        /// Monotonic snapshot identifier used to ignore stale updates.
41        snapshot_id: u64,
42        /// Coordinate space used by the provided regions.
43        coordinate_space: HitTestCoordinateSpace,
44        /// How the listed regions should participate in hit-testing.
45        mode: HitTestRegionMode,
46        /// Regions interpreted according to `mode`.
47        regions: Vec<HitTestRegion>,
48    },
49    /// Remove one scene item from a window.
50    RemoveItem {
51        /// Window that owns the item.
52        window_id: CompositorWindowId,
53        /// Item to remove.
54        item_id: CompositionItemId,
55    },
56}