summaryrefslogtreecommitdiffstats
path: root/src/window-lib
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2023-12-02 18:15:14 +0100
committerRobert Griebl <robert.griebl@qt.io>2023-12-05 23:22:37 +0100
commita92e05eee958cb8408d1a999e951b2faba8b28f6 (patch)
tree6612615b5f4a53ac330e39ec8bc981a4d36eeb1c /src/window-lib
parent44f985a53c6102a30b5bd9270bbaa28fadb2e0b2 (diff)
Make FrameTimer work again
This got broken in the big declarative registration patch. In addition this gets rid of the unnecessary unique connections that don't work in conjunction with lambdas. Change-Id: I5d7cbc684da544aaf08380a5cf7583e036fa2be6 Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Diffstat (limited to 'src/window-lib')
-rw-r--r--src/window-lib/systemframetimerimpl.cpp66
-rw-r--r--src/window-lib/systemframetimerimpl.h8
2 files changed, 35 insertions, 39 deletions
diff --git a/src/window-lib/systemframetimerimpl.cpp b/src/window-lib/systemframetimerimpl.cpp
index c7d4db96..a042c678 100644
--- a/src/window-lib/systemframetimerimpl.cpp
+++ b/src/window-lib/systemframetimerimpl.cpp
@@ -19,53 +19,49 @@ SystemFrameTimerImpl::SystemFrameTimerImpl(FrameTimer *frameTimer)
: FrameTimerImpl(frameTimer)
{ }
-bool SystemFrameTimerImpl::connectToAppManWindow(QObject *window)
+bool SystemFrameTimerImpl::connectToSystemWindow(QObject *window)
{
- if (!window)
- return false;
-
- if (auto amwin = qobject_cast<ApplicationManagerWindow *>(window)) {
- if (amwin->isInProcess()) {
- qmlWarning(frameTimer()) << "It makes no sense to measure the FPS of an application's window in single-process mode."
- " FrameTimer won't operate with the given window.";
- return true;
- }
+ if (qobject_cast<InProcessWindow *>(window)) {
+ qmlWarning(frameTimer()) << "It makes no sense to measure the FPS of a WindowObject in single-process mode."
+ " FrameTimer won't operate with the given window.";
+ return true;
}
-
- if (auto *winobj = qobject_cast<Window *>(window)) {
- if (qobject_cast<InProcessWindow *>(winobj)) {
- qmlWarning(frameTimer()) << "It makes no sense to measure the FPS of a WindowObject in single-process mode."
- " FrameTimer won't operate with the given window.";
- }
#if defined(AM_MULTI_PROCESS)
- else if (auto *wlwin = qobject_cast<WaylandWindow *>(winobj)) {
- QObject::connect(wlwin, &WaylandWindow::waylandSurfaceChanged,
- frameTimer(), [this, wlwin]() {
- disconnectFromAppManWindow(nullptr);
+ if (auto *wlwin = qobject_cast<WaylandWindow *>(window)) {
+ auto connectToWaylandSurface = [this](WaylandWindow *waylandWindow) {
+ if (m_redrawConnection) {
+ QObject::disconnect(m_redrawConnection);
+ m_redrawConnection = { };
+ }
- m_waylandSurface = wlwin->waylandSurface();
- if (m_waylandSurface) {
- QObject::connect(m_waylandSurface, &QWaylandQuickSurface::redraw,
- frameTimer(), &FrameTimer::reportFrameSwap, Qt::UniqueConnection);
- }
- }, Qt::UniqueConnection);
- }
-#endif
+ if (auto surface = waylandWindow ? waylandWindow->waylandSurface() : nullptr) {
+ m_redrawConnection = QObject::connect(surface, &QWaylandQuickSurface::redraw,
+ frameTimer(), &FrameTimer::reportFrameSwap);
+ }
+ };
+
+ m_surfaceChangeConnection = QObject::connect(wlwin, &WaylandWindow::waylandSurfaceChanged,
+ frameTimer(), [=]() {
+ connectToWaylandSurface(wlwin);
+ });
+ connectToWaylandSurface(wlwin);
return true;
}
+#endif
return false;
}
-void SystemFrameTimerImpl::disconnectFromAppManWindow(QObject *window)
+void SystemFrameTimerImpl::disconnectFromSystemWindow(QObject *window)
{
Q_UNUSED(window)
-
#if defined(AM_MULTI_PROCESS)
- if (m_waylandSurface) {
- QObject::disconnect(m_waylandSurface, &QWaylandQuickSurface::redraw,
- frameTimer(), &FrameTimer::reportFrameSwap);
-
- m_waylandSurface = nullptr;
+ if (m_redrawConnection) {
+ QObject::disconnect(m_redrawConnection);
+ m_redrawConnection = { };
+ }
+ if (m_surfaceChangeConnection) {
+ QObject::disconnect(m_surfaceChangeConnection);
+ m_surfaceChangeConnection = { };
}
#endif
}
diff --git a/src/window-lib/systemframetimerimpl.h b/src/window-lib/systemframetimerimpl.h
index 64d647b6..a4c36041 100644
--- a/src/window-lib/systemframetimerimpl.h
+++ b/src/window-lib/systemframetimerimpl.h
@@ -19,13 +19,13 @@ class SystemFrameTimerImpl : public FrameTimerImpl
public:
SystemFrameTimerImpl(FrameTimer *frameTimer);
- bool connectToAppManWindow(QObject *window) override;
- void disconnectFromAppManWindow(QObject *window) override;
+ bool connectToSystemWindow(QObject *window) override;
+ void disconnectFromSystemWindow(QObject *window) override;
private:
- void disconnectFromWaylandSurface();
#if defined(AM_MULTI_PROCESS)
- QPointer<QWaylandQuickSurface> m_waylandSurface;
+ QMetaObject::Connection m_surfaceChangeConnection;
+ QMetaObject::Connection m_redrawConnection;
#endif
};