File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,13 +10,11 @@ pub struct RawCursorPosition {
1010
1111impl RawCursorPosition {
1212 pub fn get ( ) -> Self {
13- let device_state = DeviceState :: new ( ) ;
14- let position = device_state . get_mouse ( ) . coords ;
13+ Self :: from_coords ( DeviceState :: new ( ) . get_mouse ( ) . coords )
14+ }
1515
16- Self {
17- x : position. 0 ,
18- y : position. 1 ,
19- }
16+ pub fn from_coords ( ( x, y) : ( i32 , i32 ) ) -> Self {
17+ Self { x, y }
2018 }
2119
2220 pub fn relative_to_display ( & self , display : Display ) -> Option < RelativeCursorPosition > {
Original file line number Diff line number Diff line change @@ -509,7 +509,8 @@ pub fn spawn_cursor_recorder(
509509 let mut last_mouse_state = device_state. get_mouse ( ) ;
510510 let mut last_keys: Vec < device_query:: Keycode > = device_state. get_keys ( ) ;
511511
512- let mut last_position = cap_cursor_capture:: RawCursorPosition :: get ( ) ;
512+ let mut last_position =
513+ cap_cursor_capture:: RawCursorPosition :: from_coords ( last_mouse_state. coords ) ;
513514
514515 std:: fs:: create_dir_all ( & cursors_dir) . unwrap ( ) ;
515516
@@ -544,15 +545,16 @@ pub fn spawn_cursor_recorder(
544545 }
545546
546547 let Some ( epoch) = input_epoch ( start_gate. as_ref ( ) , start_time) else {
547- last_position = cap_cursor_capture:: RawCursorPosition :: get ( ) ;
548548 last_mouse_state = device_state. get_mouse ( ) ;
549+ last_position =
550+ cap_cursor_capture:: RawCursorPosition :: from_coords ( last_mouse_state. coords ) ;
549551 last_keys = device_state. get_keys ( ) ;
550552 continue ;
551553 } ;
552554 let elapsed = epoch. elapsed ( ) . as_secs_f64 ( ) * 1000.0 ;
553555 let mouse_state = device_state. get_mouse ( ) ;
554556
555- let position = cap_cursor_capture:: RawCursorPosition :: get ( ) ;
557+ let position = cap_cursor_capture:: RawCursorPosition :: from_coords ( mouse_state . coords ) ;
556558 // The first sample after the gate opens is always recorded so the
557559 // cursor has a known position at the recording's time zero.
558560 let position_changed = position != last_position || std:: mem:: take ( & mut awaiting_start) ;
You can’t perform that action at this time.
0 commit comments