File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -80,8 +80,7 @@ pub enum WindowCommand {
8080 visible : bool ,
8181 } ,
8282 SetCursorPosition {
83- x : i32 ,
84- y : i32 ,
83+ position : Vec2 ,
8584 } ,
8685}
8786
@@ -237,9 +236,9 @@ impl Window {
237236 self . cursor_position
238237 }
239238
240- pub fn set_cursor_position ( & mut self , x : i32 , y : i32 ) {
239+ pub fn set_cursor_position ( & mut self , position : Vec2 ) {
241240 self . command_queue
242- . push ( WindowCommand :: SetCursorPosition { x , y } ) ;
241+ . push ( WindowCommand :: SetCursorPosition { position } ) ;
243242 }
244243
245244 #[ allow( missing_docs) ]
Original file line number Diff line number Diff line change @@ -94,10 +94,14 @@ fn change_window(_: &mut World, resources: &mut Resources) {
9494 let window = winit_windows. get_window ( id) . unwrap ( ) ;
9595 window. set_cursor_visible ( visible) ;
9696 }
97- bevy_window:: WindowCommand :: SetCursorPosition { x , y } => {
97+ bevy_window:: WindowCommand :: SetCursorPosition { position } => {
9898 let window = winit_windows. get_window ( id) . unwrap ( ) ;
99+ let inner_size = window. inner_size ( ) . to_logical :: < f32 > ( window. scale_factor ( ) ) ;
99100 window
100- . set_cursor_position ( winit:: dpi:: LogicalPosition :: new ( x, y) )
101+ . set_cursor_position ( winit:: dpi:: LogicalPosition :: new (
102+ position. x ,
103+ inner_size. height - position. y ,
104+ ) )
101105 . unwrap_or_else ( |e| error ! ( "Unable to set cursor position: {}" , e) ) ;
102106 }
103107 }
You can’t perform that action at this time.
0 commit comments