diff --git a/src/backend/graphics/cursor.rs b/src/backend/graphics/cursor.rs new file mode 100644 index 0000000..fe2ab8c --- /dev/null +++ b/src/backend/graphics/cursor.rs @@ -0,0 +1,33 @@ +/// Functions to render cursors on any graphics backend independently from it's rendering techique. +pub trait CursorBackend<'a> { + /// Format representing the image drawn for the cursor. + type CursorFormat: 'a; + + /// Error the underlying backend throws if operations fail + type Error; + + /// Sets the cursor position and therefor updates the drawn cursors position. + /// Useful as well for e.g. pointer wrapping. + /// + /// Not guaranteed to be supported on every backend. The result usually + /// depends on the backend, the cursor might be "owned" by another more priviledged + /// compositor (running nested). + /// + /// In these cases setting the position is actually not required, as movement is done + /// by the higher compositor and not by the backend. It is still good practice to update + /// the position after every recieved event, but don't rely on pointer wrapping working. + /// + fn set_cursor_position(&self, x: u32, y: u32) -> Result<(), Self::Error>; + + /// Set the cursor drawn on the `CursorBackend`. + /// + /// The format is entirely dictated by the concrete implementation and might range + /// from raw image buffers over a fixed list of possible cursor types to simply the + /// void type () to represent no possible customization of the cursor itself. + fn set_cursor_representation<'b>( + &'b self, + cursor: Self::CursorFormat, + hotspot: (u32, u32), + ) -> Result<(), Self::Error> + where 'a: 'b; +} \ No newline at end of file diff --git a/src/backend/graphics/mod.rs b/src/backend/graphics/mod.rs index 323cc39..00bcc32 100644 --- a/src/backend/graphics/mod.rs +++ b/src/backend/graphics/mod.rs @@ -2,38 +2,9 @@ //! //! Note: Not every API may be supported by every backend -/// General functions any graphics backend should support independently from it's rendering -/// technique. -pub trait GraphicsBackend { - /// Format representing the image drawn for the cursor. - type CursorFormat; - /// Error the underlying backend throws if operations fail - type Error; - - /// Sets the cursor position and therefor updates the drawn cursors position. - /// Useful as well for e.g. pointer wrapping. - /// - /// Not guaranteed to be supported on every backend. The result usually - /// depends on the backend, the cursor might be "owned" by another more privileged - /// compositor (running nested). - /// - /// In these cases setting the position is actually not required, as movement is done - /// by the higher compositor and not by the backend. It is still good practice to update - /// the position after every received event, but don't rely on pointer wrapping working. - fn set_cursor_position(&self, x: u32, y: u32) -> Result<(), Self::Error>; - - /// Set the cursor drawn on the `GraphicsBackend`. - /// - /// The format is entirely dictated by the concrete implementation and might range - /// from raw image buffers over a fixed list of possible cursor types to simply the - /// void type `()` to represent no possible customization of the cursor itself. - fn set_cursor_representation( - &self, - cursor: &Self::CursorFormat, - hotspot: (u32, u32), - ) -> Result<(), Self::Error>; -} +mod cursor; +pub use self::cursor::*; #[cfg(feature = "renderer_gl")] pub mod gl;