Skip to content

Commit

Permalink
Merge pull request #7736 from stenzek/imgui-hidpi
Browse files Browse the repository at this point in the history
RenderWidget: Fix mouse position for imgui on hidpi screens
  • Loading branch information
JosJuice committed Jan 25, 2019
2 parents f0ac74d + 3d8145a commit b14e540
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Source/Core/DolphinQt/RenderWidget.cpp
Expand Up @@ -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;

Expand Down

0 comments on commit b14e540

Please sign in to comment.