@@ -387,6 +387,14 @@ BOOL InitInstance(HINSTANCE, int);
387
387
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
388
388
INT_PTR CALLBACK About (HWND, UINT, WPARAM, LPARAM);
389
389
390
+ void SetCursorWindowPos (HWND hwnd, int x, int y) {
391
+ POINT pos;
392
+ pos.x = x;
393
+ pos.y = y;
394
+ ClientToScreen (hwnd, &pos);
395
+ SetCursorPos (pos.x , pos.y );
396
+ }
397
+
390
398
[[noreturn]] void winapi_failure () {
391
399
DWORD errCode = GetLastError ();
392
400
LPWSTR buffer = nullptr ;
@@ -806,7 +814,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
806
814
if (mode == Mode::Clicked) {
807
815
mode = Mode::PressedAgain;
808
816
} else {
809
- mode = Mode::Pressed;
810
817
center_point.x = GET_X_LPARAM (lparam);
811
818
center_point.y = GET_Y_LPARAM (lparam);
812
819
RECT client_rect;
@@ -826,6 +833,11 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
826
833
center_point.y = cy - params.min_window_margin ;
827
834
}
828
835
menu_state.reset ();
836
+
837
+ SetCursorWindowPos (hwnd, center_point.x , center_point.y );
838
+
839
+ mode = Mode::Pressed;
840
+
829
841
InvalidateRect (hwnd, nullptr , FALSE );
830
842
}
831
843
return 0 ;
@@ -878,21 +890,22 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
878
890
}
879
891
return 0 ;
880
892
}
881
- case WM_INPUT :
893
+ case WM_MOUSEMOVE :
882
894
{
883
- UINT dwSize;
884
- RAWINPUT raw ;
885
- GetRawInputData ((HRAWINPUT)lparam, RID_INPUT, NULL , &dwSize, sizeof (RAWINPUTHEADER)) ;
886
- if (dwSize > sizeof (raw)) {
887
- printf ( " Raw input data is too large \n " );
888
- return 0 ;
889
- }
890
- GetRawInputData ((HRAWINPUT)lparam, RID_INPUT, &raw, &dwSize, sizeof (RAWINPUTHEADER));
891
- if (raw. header . dwType == RIM_TYPEMOUSE) {
892
- RAWMOUSE& mouse = raw. data . mouse ;
893
- menu_state. apply_delta (vec2{( float )mouse. lLastX , ( float )mouse. lLastY } );
894
- InvalidateRect (hwnd, nullptr , FALSE );
895
+ if (mode != Mode::Disabled) {
896
+ int dx = GET_X_LPARAM (lparam) - center_point. x ;
897
+ int dy = GET_Y_LPARAM (lparam) - center_point. y ;
898
+
899
+ if (dx != 0 || dy != 0 ) {
900
+ menu_state. apply_delta (vec2{dx / display_scale, dy / display_scale}) ;
901
+ // menu_state.apply_delta(vec2{(float)dx, (float)dy});
902
+
903
+ SetCursorWindowPos (hwnd, center_point. x , center_point. y );
904
+
905
+ InvalidateRect (hwnd, nullptr , FALSE );
906
+ }
895
907
}
908
+
896
909
return 0 ;
897
910
}
898
911
default :
0 commit comments