mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-13 15:59:23 +01:00
Qt: Send SizeChanged on DPI changes
This commit is contained in:
parent
d3110b9521
commit
fc53dca7bd
@ -437,6 +437,10 @@ bool RenderWidget::event(QEvent* event)
|
||||
case QEvent::Move:
|
||||
SetCursorLocked(m_cursor_locked);
|
||||
break;
|
||||
|
||||
// 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:
|
||||
{
|
||||
SetCursorLocked(m_cursor_locked);
|
||||
@ -446,9 +450,18 @@ bool RenderWidget::event(QEvent* event)
|
||||
|
||||
QScreen* screen = window()->windowHandle()->screen();
|
||||
|
||||
const auto dpr = screen->devicePixelRatio();
|
||||
const float dpr = screen->devicePixelRatio();
|
||||
const int width = new_size.width() * dpr;
|
||||
const int height = new_size.height() * dpr;
|
||||
|
||||
emit SizeChanged(new_size.width() * dpr, new_size.height() * dpr);
|
||||
if (m_last_window_width != width || m_last_window_height != height ||
|
||||
m_last_window_scale != dpr)
|
||||
{
|
||||
m_last_window_width = width;
|
||||
m_last_window_height = height;
|
||||
m_last_window_scale = dpr;
|
||||
emit SizeChanged(width, height);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Happens when we add/remove the widget from the main window instead of the dedicated one
|
||||
|
@ -47,6 +47,9 @@ private:
|
||||
static constexpr int MOUSE_HIDE_DELAY = 3000;
|
||||
QTimer* m_mouse_timer;
|
||||
QPoint m_last_mouse{};
|
||||
int m_last_window_width = 0;
|
||||
int m_last_window_height = 0;
|
||||
float m_last_window_scale = 0;
|
||||
bool m_cursor_locked = false;
|
||||
bool m_lock_cursor_on_next_activation = false;
|
||||
bool m_dont_lock_cursor_on_show = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user