diff --git a/aurora/lib/aurora.cpp b/aurora/lib/aurora.cpp index fd3b07877..80422a4ce 100644 --- a/aurora/lib/aurora.cpp +++ b/aurora/lib/aurora.cpp @@ -352,12 +352,20 @@ WindowSize get_window_size() noexcept { int width, height, fb_w, fb_h; SDL_GetWindowSize(g_window, &width, &height); SDL_GL_GetDrawableSize(g_window, &fb_w, &fb_h); + float scale = fb_w / width; + +#ifndef __APPLE__ + if (SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(g_window), nullptr, &scale, nullptr) == 0) { + scale /= 96.f; + } +#endif + return { .width = static_cast(width), .height = static_cast(height), .fb_width = static_cast(fb_w), .fb_height = static_cast(fb_h), - .scale = static_cast(fb_w) / static_cast(width), + .scale = scale, }; } diff --git a/aurora/lib/imgui.cpp b/aurora/lib/imgui.cpp index 940f646f8..4fe8ac4b7 100644 --- a/aurora/lib/imgui.cpp +++ b/aurora/lib/imgui.cpp @@ -40,9 +40,15 @@ void process_event(const SDL_Event& event) noexcept { auto newEvent = event; if (newEvent.type == SDL_MOUSEMOTION) { auto& io = ImGui::GetIO(); + float mouseX = newEvent.motion.x; + float mouseY = newEvent.motion.y; +#ifdef __APPLE__ + mouseX *= g_scale; + mouseY *= g_scale; +#endif // Scale up mouse coordinates - io.AddMousePosEvent(static_cast(newEvent.motion.x) * g_scale, - static_cast(newEvent.motion.y) * g_scale); + io.AddMousePosEvent(mouseX, mouseY); + return; } ImGui_ImplSDL2_ProcessEvent(&newEvent);