mirror of
https://github.com/PCSX2/pcsx2.git
synced 2025-12-16 04:08:48 +00:00
Qt: delay resize events using a timer (#13614)
Some checks are pending
🐧 Linux Builds / AppImage (push) Waiting to run
🐧 Linux Builds / Flatpak (push) Waiting to run
🍎 MacOS Builds / Defaults (push) Waiting to run
🖥️ Windows Builds / Lint VS Project Files (push) Waiting to run
🖥️ Windows Builds / SSE4 (push) Blocked by required conditions
🖥️ Windows Builds / AVX2 (push) Blocked by required conditions
🖥️ Windows Builds / CMake (push) Waiting to run
Some checks are pending
🐧 Linux Builds / AppImage (push) Waiting to run
🐧 Linux Builds / Flatpak (push) Waiting to run
🍎 MacOS Builds / Defaults (push) Waiting to run
🖥️ Windows Builds / Lint VS Project Files (push) Waiting to run
🖥️ Windows Builds / SSE4 (push) Blocked by required conditions
🖥️ Windows Builds / AVX2 (push) Blocked by required conditions
🖥️ Windows Builds / CMake (push) Waiting to run
This commit is contained in:
parent
3e8327e934
commit
0cbd884234
@ -13,6 +13,7 @@
|
|||||||
#include "common/Console.h"
|
#include "common/Console.h"
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
#include <QtCore/QTimer>
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include <QtGui/QKeyEvent>
|
#include <QtGui/QKeyEvent>
|
||||||
#include <QtGui/QResizeEvent>
|
#include <QtGui/QResizeEvent>
|
||||||
@ -32,6 +33,10 @@
|
|||||||
DisplaySurface::DisplaySurface()
|
DisplaySurface::DisplaySurface()
|
||||||
: QWindow()
|
: QWindow()
|
||||||
{
|
{
|
||||||
|
m_resize_debounce_timer = new QTimer(this);
|
||||||
|
m_resize_debounce_timer->setSingleShot(true);
|
||||||
|
m_resize_debounce_timer->setTimerType(Qt::PreciseTimer);
|
||||||
|
connect(m_resize_debounce_timer, &QTimer::timeout, this, &DisplaySurface::onResizeDebounceTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplaySurface::~DisplaySurface()
|
DisplaySurface::~DisplaySurface()
|
||||||
@ -245,6 +250,11 @@ void DisplaySurface::handleKeyInputEvent(QEvent* event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisplaySurface::onResizeDebounceTimer()
|
||||||
|
{
|
||||||
|
emit windowResizedEvent(m_pending_window_width, m_pending_window_height, m_pending_window_scale);
|
||||||
|
}
|
||||||
|
|
||||||
bool DisplaySurface::event(QEvent* event)
|
bool DisplaySurface::event(QEvent* event)
|
||||||
{
|
{
|
||||||
switch (event->type())
|
switch (event->type())
|
||||||
@ -355,10 +365,17 @@ bool DisplaySurface::event(QEvent* event)
|
|||||||
// avoid spamming resize events for paint events (sent on move on windows)
|
// avoid spamming resize events for paint events (sent on move on windows)
|
||||||
if (m_last_window_width != scaled_width || m_last_window_height != scaled_height || m_last_window_scale != dpr)
|
if (m_last_window_width != scaled_width || m_last_window_height != scaled_height || m_last_window_scale != dpr)
|
||||||
{
|
{
|
||||||
|
m_pending_window_width = scaled_width;
|
||||||
|
m_pending_window_height = scaled_height;
|
||||||
|
m_pending_window_scale = dpr;
|
||||||
|
|
||||||
m_last_window_width = scaled_width;
|
m_last_window_width = scaled_width;
|
||||||
m_last_window_height = scaled_height;
|
m_last_window_height = scaled_height;
|
||||||
m_last_window_scale = dpr;
|
m_last_window_scale = dpr;
|
||||||
emit windowResizedEvent(scaled_width, scaled_height, dpr);
|
// qt spams resize events, sometimes several time per ms.
|
||||||
|
// since a vulkan resize swap chain event takes between 15 to 25ms this is,
|
||||||
|
// need less to say, unwanted.
|
||||||
|
m_resize_debounce_timer->start(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCenterPos();
|
updateCenterPos();
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "common/WindowInfo.h"
|
#include "common/WindowInfo.h"
|
||||||
|
#include <QtCore/QTimer>
|
||||||
#include <QtGui/QDragMoveEvent>
|
#include <QtGui/QDragMoveEvent>
|
||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@ -42,6 +43,9 @@ protected:
|
|||||||
bool event(QEvent* event) override;
|
bool event(QEvent* event) override;
|
||||||
bool eventFilter(QObject* object, QEvent* event) override;
|
bool eventFilter(QObject* object, QEvent* event) override;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void onResizeDebounceTimer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isActuallyFullscreen() const;
|
bool isActuallyFullscreen() const;
|
||||||
void updateCenterPos();
|
void updateCenterPos();
|
||||||
@ -60,5 +64,10 @@ private:
|
|||||||
u32 m_last_window_height = 0;
|
u32 m_last_window_height = 0;
|
||||||
float m_last_window_scale = 1.0f;
|
float m_last_window_scale = 1.0f;
|
||||||
|
|
||||||
|
QTimer* m_resize_debounce_timer = nullptr;
|
||||||
|
u32 m_pending_window_width = 0;
|
||||||
|
u32 m_pending_window_height = 0;
|
||||||
|
float m_pending_window_scale = 1.0f;
|
||||||
|
|
||||||
QWidget* m_container = nullptr;
|
QWidget* m_container = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user