| 1 | use bitflags::bitflags; |
| 2 | use thiserror::Error; |
| 3 | |
| 4 | use crate::Pixels; |
| 5 | |
| 6 | /// The layer the surface is rendered on. Multiple surfaces can share a layer, and ordering within |
| 7 | /// a single layer is undefined. |
| 8 | #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] |
| 9 | pub enum Layer { |
| 10 | /// The background layer, typically used for wallpapers. |
| 11 | Background, |
| 12 | |
| 13 | /// The bottom layer. |
| 14 | Bottom, |
| 15 | |
| 16 | /// The top layer, typically used for fullscreen windows. |
| 17 | Top, |
| 18 | |
| 19 | /// The overlay layer, used for surfaces that should always be on top. |
| 20 | #[default] |
| 21 | Overlay, |
| 22 | } |
| 23 | |
| 24 | bitflags! { |
| 25 | /// Screen anchor point for layer_shell surfaces. These can be used in any combination, e.g. |
| 26 | /// specifying `Anchor::LEFT | Anchor::RIGHT` will stretch the surface across the width of the |
| 27 | /// screen. |
| 28 | #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] |
| 29 | pub struct Anchor: u32 { |
| 30 | /// Anchor to the top edge of the screen. |
| 31 | const TOP = 1; |
| 32 | /// Anchor to the bottom edge of the screen. |
| 33 | const BOTTOM = 2; |
| 34 | /// Anchor to the left edge of the screen. |
| 35 | const LEFT = 4; |
| 36 | /// Anchor to the right edge of the screen. |
| 37 | const RIGHT = 8; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | /// Keyboard interactivity mode for the layer_shell surfaces. |
| 42 | #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] |
| 43 | pub enum KeyboardInteractivity { |
| 44 | /// No keyboard inputs will be delivered to the surface and it won't be able to receive |
| 45 | /// keyboard focus. |
| 46 | None, |
| 47 | |
| 48 | /// The surface will receive exclusive keyboard focus as long as it is above the shell surface |
| 49 | /// layer, and no other layer_shell surfaces are above it. |
| 50 | Exclusive, |
| 51 | |
| 52 | /// The surface can be focused similarly to a normal window. |
| 53 | #[default] |
| 54 | OnDemand, |
| 55 | } |
| 56 | |
| 57 | /// Options for creating a layer_shell window. |
| 58 | #[derive(Clone, Debug, Default, PartialEq, Eq)] |
| 59 | pub struct LayerShellOptions { |
| 60 | /// The namespace for the surface, mostly used by compositors to apply rules, can not be |
| 61 | /// changed after the surface is created. |
| 62 | pub namespace: String, |
| 63 | /// The layer the surface is rendered on. |
| 64 | pub layer: Layer, |
| 65 | /// The anchor point of the surface. |
| 66 | pub anchor: Anchor, |
| 67 | /// Requests that the compositor avoids occluding an area with other surfaces. |
| 68 | pub exclusive_zone: Option<Pixels>, |
| 69 | /// The anchor point of the exclusive zone, will be determined using the anchor if left |
| 70 | /// unspecified. |
| 71 | pub exclusive_edge: Option<Anchor>, |
| 72 | /// Margins between the surface and its anchor point(s). |
| 73 | /// Specified in CSS order: top, right, bottom, left. |
| 74 | pub margin: Option<(Pixels, Pixels, Pixels, Pixels)>, |
| 75 | /// How keyboard events should be delivered to the surface. |
| 76 | pub keyboard_interactivity: KeyboardInteractivity, |
| 77 | } |
| 78 | |
| 79 | /// An error indicating that an action failed because the compositor doesn't support the required |
| 80 | /// layer_shell protocol. |
| 81 | #[derive(Debug, Error)] |
| 82 | #[error("Compositor doesn't support zwlr_layer_shell_v1")] |
| 83 | pub struct LayerShellNotSupportedError; |