@@ -12,7 +12,10 @@ use num_enum::FromPrimitive;
1212use ui_events:: {
1313 ScrollDelta ,
1414 keyboard:: { KeyboardEvent , Modifiers } ,
15- pointer:: { ContactGeometry , PointerEvent , PointerId , PointerState , PointerUpdate } ,
15+ pointer:: {
16+ ContactGeometry , PointerButtonEvent , PointerEvent , PointerId , PointerScrollEvent ,
17+ PointerState , PointerUpdate ,
18+ } ,
1619} ;
1720
1821use crate :: ViewConfiguration ;
@@ -467,16 +470,18 @@ impl<'local> MotionEvent<'local> {
467470 } ;
468471
469472 Some ( match action {
470- MotionAction :: Down | MotionAction :: PointerDown => PointerEvent :: Down {
471- pointer,
472- state,
473- button,
474- } ,
475- MotionAction :: Up | MotionAction :: PointerUp => PointerEvent :: Up {
473+ MotionAction :: Down | MotionAction :: PointerDown => {
474+ PointerEvent :: Down ( PointerButtonEvent {
475+ pointer,
476+ state,
477+ button,
478+ } )
479+ }
480+ MotionAction :: Up | MotionAction :: PointerUp => PointerEvent :: Up ( PointerButtonEvent {
476481 pointer,
477482 state,
478483 button,
479- } ,
484+ } ) ,
480485 MotionAction :: Move | MotionAction :: HoverMove => {
481486 let hsz = self . history_size ( env) ;
482487 let mut coalesced: Vec < PointerState > = vec ! [ state. clone( ) ; hsz as usize ] ;
@@ -527,7 +532,7 @@ impl<'local> MotionEvent<'local> {
527532 MotionAction :: Cancel => PointerEvent :: Cancel ( pointer) ,
528533 MotionAction :: HoverEnter => PointerEvent :: Enter ( pointer) ,
529534 MotionAction :: HoverExit => PointerEvent :: Leave ( pointer) ,
530- MotionAction :: Scroll => PointerEvent :: Scroll {
535+ MotionAction :: Scroll => PointerEvent :: Scroll ( PointerScrollEvent {
531536 pointer,
532537 delta : ScrollDelta :: PixelDelta ( PhysicalPosition :: < f64 > {
533538 x : ( self . axis ( env, Axis :: Hscroll , action_index)
@@ -536,7 +541,7 @@ impl<'local> MotionEvent<'local> {
536541 * vc. scaled_vertical_scroll_factor ) as f64 ,
537542 } ) ,
538543 state,
539- } ,
544+ } ) ,
540545 _ => {
541546 // Other current `MotionAction` values relate to gamepad/joystick buttons;
542547 // ui-events doesn't currently have types for these, so consider them unhandled.
@@ -620,11 +625,11 @@ impl TapCounter {
620625 ///
621626 pub fn attach_count ( & mut self , e : PointerEvent ) -> PointerEvent {
622627 match e {
623- PointerEvent :: Down {
628+ PointerEvent :: Down ( PointerButtonEvent {
624629 button,
625630 pointer,
626631 state,
627- } => {
632+ } ) => {
628633 let e = if let Some ( i) =
629634 self . taps . iter ( ) . position ( |TapState { x, y, up_time, .. } | {
630635 let dx = ( x - state. position . x ) . abs ( ) ;
@@ -641,11 +646,11 @@ impl TapCounter {
641646 self . taps [ i] . x = state. position . x ;
642647 self . taps [ i] . y = state. position . y ;
643648
644- PointerEvent :: Down {
649+ PointerEvent :: Down ( PointerButtonEvent {
645650 button,
646651 pointer,
647652 state : PointerState { count, ..state } ,
648- }
653+ } )
649654 } else {
650655 let s = TapState {
651656 pointer_id : pointer. pointer_id ,
@@ -656,34 +661,34 @@ impl TapCounter {
656661 y : state. position . y ,
657662 } ;
658663 self . taps . push ( s) ;
659- PointerEvent :: Down {
664+ PointerEvent :: Down ( PointerButtonEvent {
660665 button,
661666 pointer,
662667 state : PointerState { count : 1 , ..state } ,
663- }
668+ } )
664669 } ;
665670 self . clear_expired ( state. time ) ;
666671 e
667672 }
668- PointerEvent :: Up {
673+ PointerEvent :: Up ( PointerButtonEvent {
669674 button,
670675 pointer,
671676 ref state,
672- } => {
677+ } ) => {
673678 if let Some ( i) = self
674679 . taps
675680 . iter ( )
676681 . position ( |TapState { pointer_id, .. } | * pointer_id == pointer. pointer_id )
677682 {
678683 self . taps [ i] . up_time = state. time ;
679- PointerEvent :: Up {
684+ PointerEvent :: Up ( PointerButtonEvent {
680685 button,
681686 pointer,
682687 state : PointerState {
683688 count : self . taps [ i] . count ,
684689 ..state. clone ( )
685690 } ,
686- }
691+ } )
687692 } else {
688693 e. clone ( )
689694 }
@@ -735,7 +740,9 @@ impl TapCounter {
735740 . retain ( |TapState { pointer_id, .. } | * pointer_id != p. pointer_id ) ;
736741 e. clone ( )
737742 }
738- PointerEvent :: Enter ( ..) | PointerEvent :: Scroll { .. } => e. clone ( ) ,
743+ PointerEvent :: Enter ( ..) | PointerEvent :: Scroll ( ..) | PointerEvent :: Gesture ( ..) => {
744+ e. clone ( )
745+ }
739746 }
740747 }
741748
0 commit comments