Merge pull request '[win32] Use wheel scroll lines system setting to determine how much to scroll' (#7) from ilidemi/milepost:win32-scroll-lines into main
Reviewed-on: MartinFouilleul/milepost#7
This commit is contained in:
commit
b6462ca5f8
|
@ -163,6 +163,10 @@ void mp_init()
|
|||
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), mode);
|
||||
|
||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
|
||||
u32 wheelScrollLines = 3;
|
||||
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &wheelScrollLines, 0);
|
||||
__mpApp.win32.wheelScrollLines = wheelScrollLines;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,8 +245,10 @@ static void process_wheel_event(mp_window_data* window, f32 x, f32 y)
|
|||
mp_event event = {0};
|
||||
event.window = mp_window_handle_from_ptr(window);
|
||||
event.type = MP_EVENT_MOUSE_WHEEL;
|
||||
event.mouse.deltaX = x/30.0f;
|
||||
event.mouse.deltaY = -y/30.0f;
|
||||
// Borrowed from https://source.chromium.org/chromium/chromium/src/+/3e1a26c44c024d97dc9a4c09bbc6a2365398ca2c:ui/events/blink/web_input_event_builders_win.cc;l=318-330
|
||||
f32 scrollMultiplier = __mpApp.win32.wheelScrollLines * 100.0 / 3.0;
|
||||
event.mouse.deltaX = x / WHEEL_DELTA * scrollMultiplier;
|
||||
event.mouse.deltaY = -y / WHEEL_DELTA * scrollMultiplier;
|
||||
event.mouse.mods = mp_get_mod_keys();
|
||||
|
||||
mp_queue_event(&event);
|
||||
|
@ -500,6 +506,17 @@ LRESULT WinProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
} break;
|
||||
|
||||
case WM_SETTINGCHANGE:
|
||||
{
|
||||
if((u32)wParam == SPI_SETWHEELSCROLLLINES)
|
||||
{
|
||||
u32 wheelScrollLines;
|
||||
if(SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &wheelScrollLines, 0) != 0) {
|
||||
__mpApp.win32.wheelScrollLines = wheelScrollLines;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
case WM_DROPFILES:
|
||||
{
|
||||
//TODO
|
||||
|
|
|
@ -40,6 +40,7 @@ typedef struct win32_app_data
|
|||
int mouseCaptureMask;
|
||||
bool mouseTracked;
|
||||
vec2 lastMousePos;
|
||||
u32 wheelScrollLines;
|
||||
|
||||
} win32_app_data;
|
||||
|
||||
|
|
Loading…
Reference in New Issue