@@ -17,7 +17,6 @@ use std::time::{Duration, Instant};
17
17
18
18
const TIMER_SELECT : TimerHandle = TimerHandle :: new ( 1 << 60 , true ) ;
19
19
const TIMER_GLIDE : TimerHandle = TimerHandle :: new ( ( 1 << 60 ) + 1 , true ) ;
20
- const GLIDE_POLL_MS : u64 = 3 ;
21
20
const GLIDE_MAX_SAMPLES : usize = 8 ;
22
21
23
22
#[ derive( Clone , Debug ) ]
@@ -318,7 +317,7 @@ impl ScrollComponent {
318
317
if self . max_offset != Offset :: ZERO && cx. config_enable_pan ( * press) =>
319
318
{
320
319
let _ = press
321
- . grab ( id. clone ( ) )
320
+ . grab ( id. clone ( ) , GrabMode :: Grab )
322
321
. with_icon ( CursorIcon :: Grabbing )
323
322
. with_cx ( cx) ;
324
323
self . glide . press_start ( ) ;
@@ -336,21 +335,20 @@ impl ScrollComponent {
336
335
let timeout = cx. config ( ) . event ( ) . scroll_flick_timeout ( ) ;
337
336
let pan_dist_thresh = cx. config ( ) . event ( ) . pan_dist_thresh ( ) ;
338
337
if self . glide . press_end ( timeout, pan_dist_thresh) {
339
- cx. request_timer ( id. clone ( ) , TIMER_GLIDE , Duration :: ZERO ) ;
338
+ cx. request_frame_timer ( id. clone ( ) , TIMER_GLIDE ) ;
340
339
}
341
340
}
342
- Event :: Timer ( pl ) if pl == TIMER_GLIDE => {
341
+ Event :: Timer ( TIMER_GLIDE ) => {
343
342
// Momentum/glide scrolling: update per arbitrary step time until movment stops.
344
343
let timeout = cx. config ( ) . event ( ) . scroll_flick_timeout ( ) ;
345
344
let decay = cx. config ( ) . event ( ) . scroll_flick_decay ( ) ;
346
345
if let Some ( delta) = self . glide . step ( timeout, decay) {
347
346
action = self . scroll_by_delta ( cx, delta) ;
347
+ cx. set_scroll ( Scroll :: Scrolled ) ;
348
+ }
348
349
349
- if self . glide . vel != Vec2 :: ZERO {
350
- let dur = Duration :: from_millis ( GLIDE_POLL_MS ) ;
351
- cx. request_timer ( id. clone ( ) , TIMER_GLIDE , dur) ;
352
- cx. set_scroll ( Scroll :: Scrolled ) ;
353
- }
350
+ if self . glide . vel != Vec2 :: ZERO {
351
+ cx. request_frame_timer ( id. clone ( ) , TIMER_GLIDE ) ;
354
352
}
355
353
}
356
354
_ => return ( false , Unused ) ,
@@ -444,7 +442,10 @@ impl TextInput {
444
442
None
445
443
}
446
444
} ;
447
- press. grab ( w_id) . with_opt_icon ( icon) . with_cx ( cx) ;
445
+ press
446
+ . grab ( w_id, GrabMode :: Grab )
447
+ . with_opt_icon ( icon)
448
+ . with_cx ( cx) ;
448
449
self . glide . press_start ( ) ;
449
450
action
450
451
}
@@ -484,11 +485,11 @@ impl TextInput {
484
485
|| matches ! ( press. source, PressSource :: Mouse ( ..) if cx. config_enable_mouse_text_pan( ) ) )
485
486
{
486
487
self . touch_phase = TouchPhase :: None ;
487
- cx. request_timer ( w_id, TIMER_GLIDE , Duration :: ZERO ) ;
488
+ cx. request_frame_timer ( w_id, TIMER_GLIDE ) ;
488
489
}
489
490
Action :: None
490
491
}
491
- Event :: Timer ( pl ) if pl == TIMER_SELECT => match self . touch_phase {
492
+ Event :: Timer ( TIMER_SELECT ) => match self . touch_phase {
492
493
TouchPhase :: Start ( touch_id, coord) => {
493
494
self . touch_phase = TouchPhase :: Cursor ( touch_id) ;
494
495
Action :: Focus {
@@ -498,13 +499,12 @@ impl TextInput {
498
499
}
499
500
_ => Action :: None ,
500
501
} ,
501
- Event :: Timer ( pl ) if pl == TIMER_GLIDE => {
502
+ Event :: Timer ( TIMER_GLIDE ) => {
502
503
// Momentum/glide scrolling: update per arbitrary step time until movment stops.
503
504
let timeout = cx. config ( ) . event ( ) . scroll_flick_timeout ( ) ;
504
505
let decay = cx. config ( ) . event ( ) . scroll_flick_decay ( ) ;
505
506
if let Some ( delta) = self . glide . step ( timeout, decay) {
506
- let dur = Duration :: from_millis ( GLIDE_POLL_MS ) ;
507
- cx. request_timer ( w_id, TIMER_GLIDE , dur) ;
507
+ cx. request_frame_timer ( w_id, TIMER_GLIDE ) ;
508
508
Action :: Pan ( delta)
509
509
} else {
510
510
Action :: None
0 commit comments