Skip to content

Commit 3c00c4d

Browse files
committed
Qt: Remove main window surfaceless hackery
1 parent 33b532d commit 3c00c4d

File tree

6 files changed

+104
-137
lines changed

6 files changed

+104
-137
lines changed

src/duckstation-qt/displaywidget.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,22 @@ bool DisplayWidget::isActuallyFullscreen() const
163163
return container ? container->isFullScreen() : isFullScreen();
164164
}
165165

166+
void DisplayWidget::checkForSizeChange()
167+
{
168+
const qreal dpr = QtUtils::GetDevicePixelRatioForWidget(this);
169+
const QSize size = QtUtils::GetPixelSizeForWidget(this, dpr);
170+
171+
// avoid spamming resize events for paint events (sent on move on windows)
172+
if (m_last_window_size != size || m_last_window_scale != dpr)
173+
{
174+
m_last_window_size = size;
175+
m_last_window_scale = dpr;
176+
emit windowResizedEvent(size.width(), size.height(), static_cast<float>(dpr));
177+
}
178+
179+
updateCenterPos();
180+
}
181+
166182
void DisplayWidget::updateCenterPos()
167183
{
168184
#ifdef _WIN32
@@ -349,23 +365,14 @@ bool DisplayWidget::event(QEvent* event)
349365
{
350366
QWidget::event(event);
351367

352-
const qreal dpr = QtUtils::GetDevicePixelRatioForWidget(this);
353-
const QSize size = QtUtils::GetPixelSizeForWidget(this, dpr);
354-
355-
// avoid spamming resize events for paint events (sent on move on windows)
356-
if (m_last_window_size != size || m_last_window_scale != dpr)
357-
{
358-
m_last_window_size = size;
359-
m_last_window_scale = dpr;
360-
emit windowResizedEvent(size.width(), size.height(), static_cast<float>(dpr));
361-
}
362-
363-
updateCenterPos();
368+
checkForSizeChange();
364369
return true;
365370
}
366371

367372
case QEvent::Move:
368373
{
374+
QWidget::event(event);
375+
369376
updateCenterPos();
370377
return true;
371378
}

src/duckstation-qt/displaywidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class DisplayWidget final : public QWidget
3535
void updateRelativeMode(bool enabled);
3636
void updateCursor(bool hidden);
3737

38+
void checkForSizeChange();
3839
void handleCloseEvent(QCloseEvent* event);
3940
void destroy();
4041

0 commit comments

Comments
 (0)