@@ -160,7 +160,7 @@ pub struct Window {
160
160
decorations : bool ,
161
161
cursor_icon : CursorIcon ,
162
162
cursor_visible : bool ,
163
- cursor_locked : bool ,
163
+ cursor_grab_mode : CursorGrabMode ,
164
164
physical_cursor_position : Option < DVec2 > ,
165
165
raw_window_handle : RawWindowHandleWrapper ,
166
166
focused : bool ,
@@ -195,8 +195,8 @@ pub enum WindowCommand {
195
195
SetDecorations {
196
196
decorations : bool ,
197
197
} ,
198
- SetCursorLockMode {
199
- locked : bool ,
198
+ SetCursorGrabMode {
199
+ mode : CursorGrabMode ,
200
200
} ,
201
201
SetCursorIcon {
202
202
icon : CursorIcon ,
@@ -222,6 +222,17 @@ pub enum WindowCommand {
222
222
Close ,
223
223
}
224
224
225
+ /// Defines how the cursor is grabbed.
226
+ #[ derive( Debug , Clone , Copy , PartialEq ) ]
227
+ pub enum CursorGrabMode {
228
+ /// No grabbing of the cursor is performed
229
+ None ,
230
+ /// The cursor is confined to the window area.
231
+ Confined ,
232
+ /// The cursor is locked inside the window area to a certain position.
233
+ Locked ,
234
+ }
235
+
225
236
/// Defines the way a window is displayed
226
237
#[ derive( Debug , Clone , Copy , PartialEq ) ]
227
238
pub enum WindowMode {
@@ -261,7 +272,7 @@ impl Window {
261
272
resizable : window_descriptor. resizable ,
262
273
decorations : window_descriptor. decorations ,
263
274
cursor_visible : window_descriptor. cursor_visible ,
264
- cursor_locked : window_descriptor. cursor_locked ,
275
+ cursor_grab_mode : window_descriptor. cursor_grab_mode ,
265
276
cursor_icon : CursorIcon :: Default ,
266
277
physical_cursor_position : None ,
267
278
raw_window_handle : RawWindowHandleWrapper :: new ( raw_window_handle) ,
@@ -496,25 +507,25 @@ impl Window {
496
507
}
497
508
498
509
#[ inline]
499
- pub fn cursor_locked ( & self ) -> bool {
500
- self . cursor_locked
510
+ pub fn cursor_grab_mode ( & self ) -> CursorGrabMode {
511
+ self . cursor_grab_mode
501
512
}
502
513
503
- pub fn set_cursor_lock_mode ( & mut self , lock_mode : bool ) {
504
- self . cursor_locked = lock_mode ;
514
+ pub fn set_cursor_grab_mode ( & mut self , grab_mode : CursorGrabMode ) {
515
+ self . cursor_grab_mode = grab_mode ;
505
516
self . command_queue
506
- . push ( WindowCommand :: SetCursorLockMode { locked : lock_mode } ) ;
517
+ . push ( WindowCommand :: SetCursorGrabMode { mode : grab_mode } ) ;
507
518
}
508
519
509
520
#[ inline]
510
521
pub fn cursor_visible ( & self ) -> bool {
511
522
self . cursor_visible
512
523
}
513
524
514
- pub fn set_cursor_visibility ( & mut self , visibile_mode : bool ) {
515
- self . cursor_visible = visibile_mode ;
525
+ pub fn set_cursor_visibility ( & mut self , visible_mode : bool ) {
526
+ self . cursor_visible = visible_mode ;
516
527
self . command_queue . push ( WindowCommand :: SetCursorVisibility {
517
- visible : visibile_mode ,
528
+ visible : visible_mode ,
518
529
} ) ;
519
530
}
520
531
@@ -663,8 +674,8 @@ pub struct WindowDescriptor {
663
674
pub decorations : bool ,
664
675
/// Sets whether the cursor is visible when the window has focus.
665
676
pub cursor_visible : bool ,
666
- /// Sets whether the window locks the cursor inside its borders when the window has focus .
667
- pub cursor_locked : bool ,
677
+ /// Sets the [`CursorGrabMode`](crate::CursorGrabMode) for whether it is confined/won't move to the window area .
678
+ pub cursor_grab_mode : CursorGrabMode ,
668
679
/// Sets the [`WindowMode`](crate::WindowMode).
669
680
pub mode : WindowMode ,
670
681
/// Sets whether the background of the window should be transparent.
@@ -703,7 +714,7 @@ impl Default for WindowDescriptor {
703
714
present_mode : PresentMode :: Fifo ,
704
715
resizable : true ,
705
716
decorations : true ,
706
- cursor_locked : false ,
717
+ cursor_grab_mode : CursorGrabMode :: None ,
707
718
cursor_visible : true ,
708
719
mode : WindowMode :: Windowed ,
709
720
transparent : false ,
0 commit comments