@@ -702,6 +702,35 @@ static uint32_t wl_axis_to_button(struct wlr_pointer_axis_event *event) {
702
702
}
703
703
}
704
704
705
+ static int calc_scroll_steps (struct sway_seat * seat ,
706
+ struct wlr_pointer_axis_event * event , float scroll_factor ) {
707
+ if (event -> delta_discrete ) {
708
+ return roundf (scroll_factor * event -> delta_discrete /
709
+ WLR_POINTER_AXIS_DISCRETE_STEP );
710
+ }
711
+ if (!sway_assert (event -> orientation < 2 , "axis out of range" )) {
712
+ return 0 ;
713
+ }
714
+
715
+ struct sway_scroll_axis * axis = & seat -> axis [event -> orientation ];
716
+ if (event -> time_msec - axis -> time_msec > SWAY_CONTINUOUS_SCROLL_TIMEOUT ) {
717
+ axis -> value = 0 ;
718
+ }
719
+
720
+ axis -> value += event -> delta ;
721
+ axis -> time_msec = event -> time_msec ;
722
+ if (axis -> value > WLR_POINTER_AXIS_DISCRETE_STEP ) {
723
+ axis -> value -= WLR_POINTER_AXIS_DISCRETE_STEP ;
724
+ return 1 ;
725
+ }
726
+ if (axis -> value < - WLR_POINTER_AXIS_DISCRETE_STEP ) {
727
+ axis -> value += WLR_POINTER_AXIS_DISCRETE_STEP ;
728
+ return -1 ;
729
+ }
730
+
731
+ return 0 ;
732
+ }
733
+
705
734
static void handle_pointer_axis (struct sway_seat * seat ,
706
735
struct wlr_pointer_axis_event * event ) {
707
736
struct sway_input_device * input_device =
@@ -758,8 +787,9 @@ static void handle_pointer_axis(struct sway_seat *seat,
758
787
struct sway_node * active =
759
788
seat_get_active_tiling_child (seat , tabcontainer );
760
789
list_t * siblings = container_get_siblings (cont );
790
+
761
791
int desired = list_find (siblings , active -> sway_container ) +
762
- roundf ( scroll_factor * event -> delta_discrete / WLR_POINTER_AXIS_DISCRETE_STEP );
792
+ calc_scroll_steps ( seat , event , scroll_factor );
763
793
if (desired < 0 ) {
764
794
desired = 0 ;
765
795
} else if (desired >= siblings -> length ) {
0 commit comments