浏览代码

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

Michael Ragazzon 7 月之前
父节点
当前提交
cdff6ad9dc
共有 1 个文件被更改,包括 6 次插入1 次删除
  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: