Browse Source

SDL3 backend: Fix wrong mouse position on Mac with high DPI, see #770

Michael Ragazzon 7 months ago
parent
commit
cdff6ad9dc
1 changed files with 6 additions and 1 deletions
  1. 6 1
      Backends/RmlUi_Platform_SDL.cpp

+ 6 - 1
Backends/RmlUi_Platform_SDL.cpp

@@ -195,7 +195,12 @@ bool RmlSDL::InputEventHandler(Rml::Context* context, SDL_Window* window, SDL_Ev
 	{
 	case event_mouse_motion:
 	{
-		result = context->ProcessMouseMove(int(ev.motion.x), int(ev.motion.y), GetKeyModifierState());
+#if SDL_MAJOR_VERSION >= 3
+		const float pixel_density = SDL_GetWindowPixelDensity(window);
+#else
+		constexpr float pixel_density = 1.f;
+#endif
+		result = context->ProcessMouseMove(int(ev.motion.x * pixel_density), int(ev.motion.y * pixel_density), GetKeyModifierState());
 	}
 	break;
 	case event_mouse_down: