From 270560f8e631b12ead215cb6cc287a0d45a3ed69 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Wed, 7 Oct 2026 21:11:30 -0500 Subject: [PATCH] Qt: Avoid using casting to wrong type of event --- Source/Core/DolphinQt/RenderWidget.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Source/Core/DolphinQt/RenderWidget.cpp b/Source/Core/DolphinQt/RenderWidget.cpp index 49680b8482..660df4eef7 100644 --- a/Source/Core/DolphinQt/RenderWidget.cpp +++ b/Source/Core/DolphinQt/RenderWidget.cpp @@ -467,21 +467,29 @@ bool RenderWidget::event(QEvent* event) SetCursorLocked(m_cursor_locked); break; +#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) + case QEvent::DevicePixelRatioChange: +#else // According to https://bugreports.qt.io/browse/QTBUG-95925 the recommended practice for // handling DPI change is responding to paint events case QEvent::Paint: +#endif case QEvent::Resize: { SetCursorLocked(m_cursor_locked); - const QResizeEvent* se = static_cast(event); - QSize new_size = se->size(); - QScreen* screen = window()->windowHandle()->screen(); const float dpr = screen->devicePixelRatio(); - const int width = new_size.width() * dpr; - const int height = new_size.height() * dpr; + int width = m_last_window_width; + int height = m_last_window_height; + + if (event->type() == QEvent::Resize) + { + QSize new_size = static_cast(event)->size(); + width = new_size.width(); + height = new_size.height(); + } if (m_last_window_width != width || m_last_window_height != height || m_last_window_scale != dpr)