@@ -68,6 +68,13 @@ use runner::{EventLoopRunner, EventLoopRunnerShared};
6868
6969use super :: { dpi:: hwnd_dpi, util:: get_system_metrics_for_dpi} ;
7070
71+ // This is defined in `winuser.h` as a macro that expands to `UINT_MAX`
72+ const WHEEL_PAGESCROLL : u32 = u32:: MAX ;
73+ // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa#:~:text=SPI_GETWHEELSCROLLLINES
74+ const DEFAULT_SCROLL_LINES_PER_WHEEL_DELTA : isize = 3 ;
75+ // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa#:~:text=SPI_GETWHEELSCROLLCHARS
76+ const DEFAULT_SCROLL_CHARACTERS_PER_WHEEL_DELTA : isize = 3 ;
77+
7178type GetPointerFrameInfoHistory = unsafe extern "system" fn (
7279 pointerId : u32 ,
7380 entriesCount : * mut u32 ,
@@ -1378,11 +1385,25 @@ unsafe fn public_window_callback_inner<T: 'static>(
13781385
13791386 let modifiers = update_modifiers ( window, subclass_input) ;
13801387
1388+ let mut scroll_lines = DEFAULT_SCROLL_LINES_PER_WHEEL_DELTA ;
1389+
1390+ let _ = SystemParametersInfoW (
1391+ SPI_GETWHEELSCROLLLINES ,
1392+ 0 ,
1393+ Some ( & mut scroll_lines as * mut isize as * mut c_void ) ,
1394+ SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS ( 0 ) ,
1395+ ) ;
1396+
1397+ if scroll_lines as u32 == WHEEL_PAGESCROLL {
1398+ // TODO: figure out how to handle page scrolls
1399+ scroll_lines = DEFAULT_SCROLL_LINES_PER_WHEEL_DELTA ;
1400+ }
1401+
13811402 subclass_input. send_event ( Event :: WindowEvent {
13821403 window_id : RootWindowId ( WindowId ( window. 0 as _ ) ) ,
13831404 event : WindowEvent :: MouseWheel {
13841405 device_id : DEVICE_ID ,
1385- delta : LineDelta ( 0.0 , value) ,
1406+ delta : LineDelta ( 0.0 , value * scroll_lines as f32 ) ,
13861407 phase : TouchPhase :: Moved ,
13871408 modifiers,
13881409 } ,
@@ -1399,11 +1420,20 @@ unsafe fn public_window_callback_inner<T: 'static>(
13991420
14001421 let modifiers = update_modifiers ( window, subclass_input) ;
14011422
1423+ let mut scroll_characters = DEFAULT_SCROLL_CHARACTERS_PER_WHEEL_DELTA ;
1424+
1425+ let _ = SystemParametersInfoW (
1426+ SPI_GETWHEELSCROLLCHARS ,
1427+ 0 ,
1428+ Some ( & mut scroll_characters as * mut isize as * mut c_void ) ,
1429+ SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS ( 0 ) ,
1430+ ) ;
1431+
14021432 subclass_input. send_event ( Event :: WindowEvent {
14031433 window_id : RootWindowId ( WindowId ( window. 0 as _ ) ) ,
14041434 event : WindowEvent :: MouseWheel {
14051435 device_id : DEVICE_ID ,
1406- delta : LineDelta ( value, 0.0 ) ,
1436+ delta : LineDelta ( value * scroll_characters as f32 , 0.0 ) ,
14071437 phase : TouchPhase :: Moved ,
14081438 modifiers,
14091439 } ,
0 commit comments