diff options
| author | JosJuice <josjuice@gmail.com> | 2019-01-25 22:45:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-25 22:45:31 +0100 |
| commit | b14e540671a37c69b392085f3bc458bc5ea6154f (patch) | |
| tree | 7d08362f03a58e269dbbc4bbbfae097d938fa5a3 /Source/Core | |
| parent | f0ac74d1b05a124023c37db202c6fa73a3ee3aad (diff) | |
| parent | 3d8145af65afd0445ae9416906cffad0750007de (diff) | |
Merge pull request #7736 from stenzek/imgui-hidpi
RenderWidget: Fix mouse position for imgui on hidpi screens
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/DolphinQt/RenderWidget.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Source/Core/DolphinQt/RenderWidget.cpp b/Source/Core/DolphinQt/RenderWidget.cpp index f75882b55b..460a983da4 100644 --- a/Source/Core/DolphinQt/RenderWidget.cpp +++ b/Source/Core/DolphinQt/RenderWidget.cpp @@ -284,8 +284,13 @@ void RenderWidget::PassEventToImGui(const QEvent* event) case QEvent::MouseMove: { auto lock = g_renderer->GetImGuiLock(); - ImGui::GetIO().MousePos.x = static_cast<const QMouseEvent*>(event)->x(); - ImGui::GetIO().MousePos.y = static_cast<const QMouseEvent*>(event)->y(); + + // Qt multiplies all coordinates by the scaling factor in highdpi mode, giving us "scaled" mouse + // coordinates (as if the screen was standard dpi). We need to update the mouse position in + // native coordinates, as the UI (and game) is rendered at native resolution. + const float scale = devicePixelRatio(); + ImGui::GetIO().MousePos.x = static_cast<const QMouseEvent*>(event)->x() * scale; + ImGui::GetIO().MousePos.y = static_cast<const QMouseEvent*>(event)->y() * scale; } break; |
