summaryrefslogtreecommitdiffstats
path: root/src/window-lib
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2023-09-26 11:25:34 +0200
committerRobert Griebl <robert.griebl@qt.io>2023-09-26 17:19:13 +0200
commit2cfa6be185b3aa32a96a15d012739135faaadb2a (patch)
tree6c2207267fc4c5d200aa9a79b726f27406d8148b /src/window-lib
parent6042485fe360d8611d3d6f123540a55af170d3bb (diff)
DBus cleanup, part 2 and shared QML API
Rewrote the NativeRuntime <-> Launcher communication using auto- generated interfaces and adaptors. Also made the shared QML classes (Notification and ApplicationInterface) simple QObjects, so the QMetaObject is always the same: both on the AM and the launcher side. This is necessary for qmlsc, as the compiler doesn't know how to deal with different MOC data for the same class name in different processes. Along the same lines, ApplicationManagerWindow is now a QObject, both for in-process (this was already the case) and out-of process use. The out-of-process/Wayland implementation will now implicitly allocate a QQuickWindow and re-parent it accordingly to have the same visibility behavior as if you would be using normal Windows. Also FrameTimer got an Impl backend, although in this case a special implementation is only needed for the System-UI. And additional unrelated change was rolled into this: launcher-lib was renamed to application-main-lib and the class LauncherMain to ApplicationMain to better reflect their purpose (the lib started as the basis for launcher-qml, but evolved into a generic app/launcher helper) The reason for including these changes here is that we are touching all the files in there anyway and having a rename after these big changes would make git blame far less useful. Change-Id: Iff915c1b2209f8104051dc131b9add5498df277c Task-number: QTBUG-103266 Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Diffstat (limited to 'src/window-lib')
-rw-r--r--src/window-lib/CMakeLists.txt4
-rw-r--r--src/window-lib/configure.cmake23
-rw-r--r--src/window-lib/systemframetimerimpl.cpp73
-rw-r--r--src/window-lib/systemframetimerimpl.h32
-rw-r--r--src/window-lib/windowmanager.cpp9
5 files changed, 116 insertions, 25 deletions
diff --git a/src/window-lib/CMakeLists.txt b/src/window-lib/CMakeLists.txt
index 2bf391f2..5492e08d 100644
--- a/src/window-lib/CMakeLists.txt
+++ b/src/window-lib/CMakeLists.txt
@@ -9,14 +9,14 @@ qt_internal_add_module(AppManWindowPrivate
INTERNAL_MODULE
SOURCES
inprocesswindow.cpp inprocesswindow.h
+ systemframetimerimpl.cpp systemframetimerimpl.h
window.cpp window.h
windowitem.cpp windowitem.h
windowmanager.cpp windowmanager.h windowmanager_p.h
LIBRARIES
- Qt::AppManApplicationPrivate
Qt::AppManCommonPrivate
Qt::AppManManagerPrivate
- Qt::AppManMonitorPrivate
+ Qt::AppManSharedMainPrivate
PUBLIC_LIBRARIES
Qt::Core
Qt::CorePrivate
diff --git a/src/window-lib/configure.cmake b/src/window-lib/configure.cmake
deleted file mode 100644
index e51ef2ee..00000000
--- a/src/window-lib/configure.cmake
+++ /dev/null
@@ -1,23 +0,0 @@
-#### Inputs
-
-#### Libraries
-
-qt_find_package(X11)
-
-#### Tests
-
-#### Features
-
-qt_feature("am-widgets-support" PRIVATE PUBLIC
- LABEL "Enable support for Qt widgets"
- CONDITION TARGET Qt::Widgets
- ENABLE INPUT_widgets_support STREQUAL 'yes'
- DISABLE INPUT_widgets_support STREQUAL 'no'
-)
-qt_feature_definition("am-widgets-support" "AM_WIDGETS_SUPPORT")
-
-qt_configure_add_summary_section(NAME "Qt Application Manager [Window module]")
-qt_configure_add_summary_entry(ARGS "am-widgets-support")
-qt_configure_end_summary_section() # end of "Qt ApplicationManger" section
-
-qt_extra_definition("AM_VERSION" "\"${PROJECT_VERSION}\"" PUBLIC)
diff --git a/src/window-lib/systemframetimerimpl.cpp b/src/window-lib/systemframetimerimpl.cpp
new file mode 100644
index 00000000..c7d4db96
--- /dev/null
+++ b/src/window-lib/systemframetimerimpl.cpp
@@ -0,0 +1,73 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// Copyright (C) 2019 Luxoft Sweden AB
+// Copyright (C) 2018 Pelagicore AG
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <qqmlinfo.h>
+#include "systemframetimerimpl.h"
+#include "applicationmanagerwindow.h"
+#include "frametimer.h"
+#include "inprocesswindow.h"
+#if defined(AM_MULTI_PROCESS)
+# include "waylandwindow.h"
+#endif
+
+
+QT_BEGIN_NAMESPACE_AM
+
+SystemFrameTimerImpl::SystemFrameTimerImpl(FrameTimer *frameTimer)
+ : FrameTimerImpl(frameTimer)
+{ }
+
+bool SystemFrameTimerImpl::connectToAppManWindow(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 (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);
+
+ m_waylandSurface = wlwin->waylandSurface();
+ if (m_waylandSurface) {
+ QObject::connect(m_waylandSurface, &QWaylandQuickSurface::redraw,
+ frameTimer(), &FrameTimer::reportFrameSwap, Qt::UniqueConnection);
+ }
+ }, Qt::UniqueConnection);
+ }
+#endif
+ return true;
+ }
+ return false;
+}
+
+void SystemFrameTimerImpl::disconnectFromAppManWindow(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;
+ }
+#endif
+}
+
+QT_END_NAMESPACE_AM
diff --git a/src/window-lib/systemframetimerimpl.h b/src/window-lib/systemframetimerimpl.h
new file mode 100644
index 00000000..64d647b6
--- /dev/null
+++ b/src/window-lib/systemframetimerimpl.h
@@ -0,0 +1,32 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// Copyright (C) 2019 Luxoft Sweden AB
+// Copyright (C) 2018 Pelagicore AG
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#pragma once
+
+#include <QtCore/QPointer>
+#include <QtAppManSharedMain/frametimerimpl.h>
+#include <QtAppManCommon/global.h>
+
+
+QT_FORWARD_DECLARE_CLASS(QWaylandQuickSurface)
+
+QT_BEGIN_NAMESPACE_AM
+
+class SystemFrameTimerImpl : public FrameTimerImpl
+{
+public:
+ SystemFrameTimerImpl(FrameTimer *frameTimer);
+
+ bool connectToAppManWindow(QObject *window) override;
+ void disconnectFromAppManWindow(QObject *window) override;
+
+private:
+ void disconnectFromWaylandSurface();
+#if defined(AM_MULTI_PROCESS)
+ QPointer<QWaylandQuickSurface> m_waylandSurface;
+#endif
+};
+
+QT_END_NAMESPACE_AM
diff --git a/src/window-lib/windowmanager.cpp b/src/window-lib/windowmanager.cpp
index 1068f5a9..299b2369 100644
--- a/src/window-lib/windowmanager.cpp
+++ b/src/window-lib/windowmanager.cpp
@@ -34,6 +34,8 @@
#include "waylandwindow.h"
#include "inprocesswindow.h"
#include "qml-utilities.h"
+#include "qmlinprocapplicationmanagerwindowimpl.h"
+#include "systemframetimerimpl.h"
/*!
@@ -224,6 +226,13 @@ WindowManager *WindowManager::createInstance(QQmlEngine *qmlEngine, const QStrin
if (s_instance)
qFatal("WindowManager::createInstance() was called a second time.");
+ ApplicationManagerWindowImpl::setFactory([](ApplicationManagerWindow *window) {
+ return new QmlInProcApplicationManagerWindowImpl(window);
+ });
+ SystemFrameTimerImpl::setFactory([](FrameTimer *frameTimer) {
+ return new SystemFrameTimerImpl(frameTimer);
+ });
+
qmlRegisterSingletonType<WindowManager>("QtApplicationManager.SystemUI", 2, 0, "WindowManager",
&WindowManager::instanceForQml);