Skip to content

Commit 84b2756

Browse files
committed
Debounce geometry update in prefs panel
1 parent 843c984 commit 84b2756

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/projectionwindow.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <QtGui/QCursor>
2121
#include <QtGui/QPainter>
2222
#include <QGuiApplication>
23+
#include <QTimer>
2324

2425
#include "subtitlestyle.h"
2526
#include "projectionwindow.h"
@@ -42,6 +43,12 @@ ProjectionWindow::ProjectionWindow(QWidget *parent)
4243
makeWindowCoverMenuBar(this, true);
4344
m_drawBounds = false;
4445
m_fixedScale = true;
46+
47+
m_geometryChangedDebounceTimer = new QTimer(this);
48+
m_geometryChangedDebounceTimer->setSingleShot(true);
49+
connect(m_geometryChangedDebounceTimer, &QTimer::timeout, this, [this]() {
50+
emit geometryChanged(m_monitor, m_subtitlesGeomBottomScreenRelative);
51+
});
4552
}
4653

4754
ProjectionWindow::~ProjectionWindow() {}
@@ -177,5 +184,7 @@ void ProjectionWindow::applyGeometry(const QRect &r) {
177184
r.x() - m_screenGeom.x(),
178185
m_screenGeom.y() + m_screenGeom.height() - r.height() - r.y());
179186

180-
emit geometryChanged(m_monitor, m_subtitlesGeomBottomScreenRelative);
187+
// Start/restart timer to emit geometryChanged later
188+
// Store params for debounce emit
189+
m_geometryChangedDebounceTimer->start(100); // debounce delay (e.g., 100ms)
181190
}

src/projectionwindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public slots:
5656
bool m_hideDesktop;
5757
int m_monitor;
5858
bool m_resizable;
59+
60+
QTimer *m_geometryChangedDebounceTimer;
5961
};
6062

6163
#endif // PROJECTION_WINDOW_H

0 commit comments

Comments
 (0)