From d74623faf963d41e19074126b177b37d9ef929d0 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Thu, 26 May 2022 22:21:56 -0500 Subject: [PATCH] Qt: Support DPI change events --- pcsx2-qt/DisplayWidget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pcsx2-qt/DisplayWidget.cpp b/pcsx2-qt/DisplayWidget.cpp index c517e8a033..e2e06731cb 100644 --- a/pcsx2-qt/DisplayWidget.cpp +++ b/pcsx2-qt/DisplayWidget.cpp @@ -230,16 +230,17 @@ bool DisplayWidget::event(QEvent* event) return true; } + // According to https://bugreports.qt.io/browse/QTBUG-95925 the recommended practice for handling DPI change is responding to paint events + case QEvent::Paint: case QEvent::Resize: { QWidget::event(event); const qreal dpr = devicePixelRatioFromScreen(); - const QSize size = static_cast(event)->size(); - const int width = static_cast(std::ceil(static_cast(size.width()) * devicePixelRatioFromScreen())); - const int height = static_cast(std::ceil(static_cast(size.height()) * devicePixelRatioFromScreen())); + const int scaled_width = static_cast(std::ceil(static_cast(width()) * devicePixelRatioFromScreen())); + const int scaled_height = static_cast(std::ceil(static_cast(height()) * devicePixelRatioFromScreen())); - emit windowResizedEvent(width, height, dpr); + emit windowResizedEvent(scaled_width, scaled_height, dpr); return true; }