diff options
author | Ben Bridle <ben@derelict.engineering> | 2024-12-16 14:22:33 +1300 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2024-12-16 14:22:33 +1300 |
commit | 393d4f309ba238f81d100aae409a784f82d88c15 (patch) | |
tree | a6ce747bde68b5ac93efaf308cb63442e5e87604 /src/window.rs | |
parent | 598e503f9898580b40c7a63b343eb2b1d168c2c3 (diff) | |
download | phosphor-393d4f309ba238f81d100aae409a784f82d88c15.zip |
Only send Event::CursorExit when all mouse buttons are released
This is to allow a user to drag an element inside the program window
and for the mouse cursor to move in and out of the window during the
drag operation. This is the intuitive and expected behaviour.
Diffstat (limited to 'src/window.rs')
-rw-r--r-- | src/window.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/window.rs b/src/window.rs index 70c9c02..f031af5 100644 --- a/src/window.rs +++ b/src/window.rs @@ -18,11 +18,21 @@ fn to_physical_size(dimensions: Dimensions, scale: u32) -> PhysicalSize<u32> { } +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum PointerState { + In, + Out, + PendingOut, +} + + pub(crate) struct PhosphorWindow { pub winit: Rc<Window>, pub program: Box<dyn WindowProgram>, pub requests: EventQueue<Request>, pub pointer: Option<Position>, + pub pointer_state: PointerState, + pub mouse_buttons: [bool; 5], pub marked_for_destruction: bool, pub size_bounds: SizeBounds, // logical dimensions @@ -79,6 +89,8 @@ impl PhosphorWindow { program: builder.program, requests: EventQueue::new(), pointer: None, + pointer_state: PointerState::Out, + mouse_buttons: [false; 5], marked_for_destruction: false, size_bounds, |