Add set_cursor_representation
This commit is contained in:
parent
9b6273f297
commit
056ce6312c
|
@ -6,7 +6,7 @@ use backend::graphics::GraphicsBackend;
|
|||
use backend::graphics::opengl::{Api, OpenglGraphicsBackend, PixelFormat, SwapBuffersError};
|
||||
use backend::input::{Axis, AxisSource, InputBackend, InputHandler, KeyState, MouseButton, MouseButtonState,
|
||||
Seat, SeatCapabilities, TouchEvent, TouchSlot, Output};
|
||||
use glutin::{Api as GlutinApi, MouseButton as GlutinMouseButton, PixelFormat as GlutinPixelFormat};
|
||||
use glutin::{Api as GlutinApi, MouseButton as GlutinMouseButton, PixelFormat as GlutinPixelFormat, MouseCursor};
|
||||
use glutin::{ContextError, CreationError, ElementState, Event, GlContext, HeadlessContext,
|
||||
HeadlessRendererBuilder, MouseScrollDelta, Touch, TouchPhase, Window, WindowBuilder};
|
||||
use nix::c_void;
|
||||
|
@ -81,10 +81,14 @@ impl GlutinHeadlessRenderer {
|
|||
}
|
||||
|
||||
impl GraphicsBackend for GlutinHeadlessRenderer {
|
||||
type CursorFormat = ();
|
||||
|
||||
fn set_cursor_position(&mut self, _x: u32, _y: u32) -> Result<(), ()> {
|
||||
//FIXME: Maybe save position? Is it of any use?
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_cursor_representation(&mut self, cursor: ()) {}
|
||||
}
|
||||
|
||||
impl OpenglGraphicsBackend for GlutinHeadlessRenderer {
|
||||
|
@ -139,6 +143,8 @@ impl GlutinWindowedRenderer {
|
|||
}
|
||||
|
||||
impl GraphicsBackend for GlutinWindowedRenderer {
|
||||
type CursorFormat = MouseCursor;
|
||||
|
||||
fn set_cursor_position(&mut self, x: u32, y: u32) -> Result<(), ()> {
|
||||
if let Some((win_x, win_y)) = self.window.get_position() {
|
||||
self.window
|
||||
|
@ -147,6 +153,10 @@ impl GraphicsBackend for GlutinWindowedRenderer {
|
|||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
fn set_cursor_representation(&mut self, cursor: MouseCursor) {
|
||||
self.window.set_cursor(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
impl OpenglGraphicsBackend for GlutinWindowedRenderer {
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
/// General functions any graphics backend should support independently from it's rendering
|
||||
/// techique.
|
||||
pub trait GraphicsBackend {
|
||||
/// Format representing the image drawn for the cursor.
|
||||
type CursorFormat;
|
||||
|
||||
/// Sets the cursor position and therefor updates the drawn cursors position.
|
||||
/// Useful as well for e.g. pointer wrapping.
|
||||
///
|
||||
|
@ -17,6 +20,13 @@ pub trait GraphicsBackend {
|
|||
/// the position after every recieved event, but don't rely on pointer wrapping working.
|
||||
///
|
||||
fn set_cursor_position(&mut self, x: u32, y: u32) -> Result<(), ()>;
|
||||
|
||||
/// 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(&mut self, cursor: Self::CursorFormat);
|
||||
}
|
||||
|
||||
pub mod software;
|
||||
|
|
Loading…
Reference in New Issue