summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@pelagicore.com>2017-11-03 15:16:21 +0100
committerDominik Holland <dominik.holland@pelagicore.com>2017-11-03 14:22:31 +0000
commit57ff870b0790e1e1feb3421cdfb46dff82878825 (patch)
tree023d444240c43d7346adfb176c75446f9cd419d9
parent1766188e3c490f040cf491b140b85dda62c8d478 (diff)
downloadqtapplicationmanager-57ff870b0790e1e1feb3421cdfb46dff82878825.tar.gz
Fix headless build
Change-Id: I415450e454707a0074fbdc32024d3bf1df6a0d79 Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r--examples/examples.pro3
-rw-r--r--src/launchers/qml/main.cpp6
-rw-r--r--src/main-lib/main-lib.pro2
-rw-r--r--src/main-lib/main.cpp25
-rw-r--r--src/main-lib/main.h2
-rw-r--r--src/manager-lib/fakeapplicationmanagerwindow.h9
-rw-r--r--src/monitor-lib/processmonitor_p.cpp26
-rw-r--r--src/monitor-lib/processmonitor_p.h12
-rw-r--r--src/monitor-lib/systemmonitor.cpp10
-rw-r--r--src/tools/dumpqmltypes/dumpqmltypes.pro2
10 files changed, 67 insertions, 30 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
index 58c3f3a0..d91b42ec 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -4,6 +4,9 @@ SUBDIRS = \
minidesk \
monitor \
startup-plugin \
+
+# remove the !headless and handle this in the example when we switch to the new configure system
+!headless:SUBDIRS += \
custom-appman \
linux:!android:SUBDIRS += \
diff --git a/src/launchers/qml/main.cpp b/src/launchers/qml/main.cpp
index e92ce4a3..c996436d 100644
--- a/src/launchers/qml/main.cpp
+++ b/src/launchers/qml/main.cpp
@@ -493,9 +493,10 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile
for (StartupInterface *iface : qAsConst(startupPlugins))
iface->afterQmlEngineLoad(&m_engine);
- QObject *topLevel = topLevels.at(0);
+ bool createStartupReportNow = true;
#if !defined(AM_HEADLESS)
+ QObject *topLevel = topLevels.at(0);
m_window = qobject_cast<QQuickWindow *>(topLevel);
if (!m_window) {
QQuickItem *contentItem = qobject_cast<QQuickItem *>(topLevel);
@@ -511,6 +512,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile
} else {
if (!m_engine.incubationController())
m_engine.setIncubationController(m_window->incubationController());
+ createStartupReportNow = false; // create the startup report later, since we have a window
}
StartupTimer::instance()->checkpoint("after creating and setting application window");
@@ -557,7 +559,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile
qCDebug(LogQmlRuntime) << "component loading and creating complete.";
StartupTimer::instance()->checkpoint("component loading and creating complete.");
- if (!m_window) // create the startup report now, since we have no window
+ if (createStartupReportNow)
StartupTimer::instance()->createReport(applicationId);
if (!document.isEmpty() && m_applicationInterface)
diff --git a/src/main-lib/main-lib.pro b/src/main-lib/main-lib.pro
index c201992d..1227d630 100644
--- a/src/main-lib/main-lib.pro
+++ b/src/main-lib/main-lib.pro
@@ -16,9 +16,9 @@ QT *= \
appman_package-private \
appman_installer-private \
appman_notification-private \
- appman_window-private \
appman_monitor-private \
+!headless:QT *= appman_window-private
!disable-external-dbus-interfaces:qtHaveModule(dbus):QT *= dbus appman_dbus-private
CONFIG *= static internal_module
diff --git a/src/main-lib/main.cpp b/src/main-lib/main.cpp
index 29c511f4..5e7bed41 100644
--- a/src/main-lib/main.cpp
+++ b/src/main-lib/main.cpp
@@ -159,7 +159,9 @@ Main::~Main()
m_applicationInstaller,
m_applicationIPCManager,
m_notificationManager,
+#if !defined(AM_HEADLESS)
m_windowManager,
+#endif
m_systemMonitor
};
for (const auto &singleton : singletons)
@@ -262,11 +264,13 @@ void Main::shutDown(int exitCode)
this, []() { checkShutDownFinished(QuickLauncherDown); });
m_quickLauncher->shutDown();
}
+#if !defined(AM_HEADLESS)
if (m_windowManager) {
connect(m_windowManager, &WindowManager::shutDownFinished,
this, []() { checkShutDownFinished(WindowManagerDown); });
m_windowManager->shutDown();
}
+#endif
}
QQmlApplicationEngine *Main::qmlEngine() const
@@ -577,7 +581,10 @@ void Main::setupQmlEngine(const QStringList &importPaths, const QString &quickCo
void Main::setupWindowTitle(const QString &title, const QString &iconPath)
{
-#if !defined(AM_HEADLESS)
+#if defined(AM_HEADLESS)
+ Q_UNUSED(title)
+ Q_UNUSED(iconPath)
+#else
// For development only: set an icon, so you know which window is the AM
bool setTitle =
# if defined(Q_OS_LINUX)
@@ -596,7 +603,11 @@ void Main::setupWindowTitle(const QString &title, const QString &iconPath)
void Main::setupWindowManager(const QString &waylandSocketName, bool slowAnimations, bool uiWatchdog)
{
-#if !defined(AM_HEADLESS)
+#if defined(AM_HEADLESS)
+ Q_UNUSED(waylandSocketName)
+ Q_UNUSED(slowAnimations)
+ Q_UNUSED(uiWatchdog)
+#else
QUnifiedTimer::instance()->setSlowModeEnabled(slowAnimations);
m_windowManager = WindowManager::createInstance(m_engine, waylandSocketName);
@@ -636,7 +647,9 @@ void Main::loadQml(bool loadDummyData) Q_DECL_NOEXCEPT_EXPR(false)
void Main::showWindow(bool showFullscreen)
{
-#if !defined(AM_HEADLESS)
+#if defined(AM_HEADLESS)
+ Q_UNUSED(showFullscreen)
+#else
setQuitOnLastWindowClosed(false);
connect(this, &QGuiApplication::lastWindowClosed, this, [this]() { shutDown(); });
@@ -658,11 +671,11 @@ void Main::showWindow(bool showFullscreen)
static QMetaObject::Connection conn = QObject::connect(window, &QQuickWindow::frameSwapped, this, []() {
// this is a queued signal, so there may be still one in the queue after calling disconnect()
if (conn) {
-#if defined(Q_CC_MSVC)
+# if defined(Q_CC_MSVC)
qApp->disconnect(conn); // MSVC2013 cannot call static member functions without capturing this
-#else
+# else
QObject::disconnect(conn);
-#endif
+# endif
StartupTimer::instance()->checkFirstFrame();
StartupTimer::instance()->createReport(qSL("System UI"));
}
diff --git a/src/main-lib/main.h b/src/main-lib/main.h
index b621b471..985905eb 100644
--- a/src/main-lib/main.h
+++ b/src/main-lib/main.h
@@ -49,7 +49,7 @@
# include <QCoreApplication>
typedef QCoreApplication MainBase;
#elif defined(AM_ENABLE_WIDGETS)
-#include <QApplication>
+# include <QApplication>
typedef QApplication MainBase;
#else
# include <QGuiApplication>
diff --git a/src/manager-lib/fakeapplicationmanagerwindow.h b/src/manager-lib/fakeapplicationmanagerwindow.h
index a526109b..eed6112b 100644
--- a/src/manager-lib/fakeapplicationmanagerwindow.h
+++ b/src/manager-lib/fakeapplicationmanagerwindow.h
@@ -41,9 +41,10 @@
#pragma once
-#include <QColor>
-#include <QQuickItem>
-#include <QtAppManCommon/global.h>
+#if !defined(AM_HEADLESS)
+# include <QColor>
+# include <QQuickItem>
+# include <QtAppManCommon/global.h>
QT_FORWARD_DECLARE_CLASS(QQmlComponentAttached)
@@ -129,3 +130,5 @@ private:
};
QT_END_NAMESPACE_AM
+
+#endif // !AM_HEADLESS
diff --git a/src/monitor-lib/processmonitor_p.cpp b/src/monitor-lib/processmonitor_p.cpp
index 36f0e07e..205b5cb9 100644
--- a/src/monitor-lib/processmonitor_p.cpp
+++ b/src/monitor-lib/processmonitor_p.cpp
@@ -568,6 +568,7 @@ void ProcessMonitorPrivate::readingUpdate()
void ProcessMonitorPrivate::setupFrameRateMonitoring()
{
resetFrameRateMonitoring();
+#if !defined(AM_HEADLESS)
if (reportFps) {
if (ApplicationManager::instance()->isSingleProcess() || appId.isEmpty()) {
@@ -579,7 +580,7 @@ void ProcessMonitorPrivate::setupFrameRateMonitoring()
}
}
} else {
-#if defined(AM_MULTI_PROCESS)
+# if defined(AM_MULTI_PROCESS)
for (auto it = frameCounters.begin(); it != frameCounters.end(); ++it) {
WaylandWindow *win = qobject_cast<WaylandWindow *>(it.key());
@@ -597,18 +598,20 @@ void ProcessMonitorPrivate::setupFrameRateMonitoring()
connect(WindowManager::instance(), &WindowManager::windowClosing,
this, &ProcessMonitorPrivate::applicationWindowClosing);
-#endif
+# endif
}
} else {
-#if defined(AM_MULTI_PROCESS)
+# if defined(AM_MULTI_PROCESS)
disconnect(WindowManager::instance(), &WindowManager::windowClosing,
this, &ProcessMonitorPrivate::applicationWindowClosing);
-#endif
+# endif
}
+#endif // !AM_HEADLESS
}
void ProcessMonitorPrivate::updateMonitoredWindows(const QList<QObject *> &windows)
{
+#if !defined(AM_HEADLESS)
Q_Q(ProcessMonitor);
clearMonitoredWindows();
@@ -628,7 +631,7 @@ void ProcessMonitorPrivate::updateMonitoredWindows(const QList<QObject *> &windo
} else
qCWarning(LogSystem) << "In single process only QQuickWindow can be monitored";
} else {
-#if defined(AM_MULTI_PROCESS)
+# if defined(AM_MULTI_PROCESS)
for (int i = 0; i < applicationWindows.size(); i++) {
WaylandWindow *win = qobject_cast<WaylandWindow *>(applicationWindows.at(i));
@@ -638,18 +641,22 @@ void ProcessMonitorPrivate::updateMonitoredWindows(const QList<QObject *> &windo
break;
}
}
-#endif
+# endif
}
}
emit q->monitoredWindowsChanged();
setupFrameRateMonitoring();
+#else
+ Q_UNUSED(windows)
+#endif
}
QList<QObject *> ProcessMonitorPrivate::monitoredWindows() const
{
QList<QObject *> list;
+#if !defined(AM_HEADLESS)
if (ApplicationManager::instance()->isSingleProcess() || appId.isEmpty()) {
for (auto it = frameCounters.begin(); it != frameCounters.end(); ++it) {
list.append(it.key());
@@ -658,25 +665,24 @@ QList<QObject *> ProcessMonitorPrivate::monitoredWindows() const
return list;
}
-#if defined(AM_MULTI_PROCESS)
+# if defined(AM_MULTI_PROCESS)
// Return window items
for (auto it = frameCounters.begin(); it != frameCounters.end(); ++it) {
WaylandWindow *win = qobject_cast<WaylandWindow *>(it.key());
if (win)
list.append(win->windowItem());
}
+# endif
#endif
-
return list;
}
-#if defined(AM_MULTI_PROCESS)
+#if defined(AM_MULTI_PROCESS) && !defined(AM_HEADLESS)
void ProcessMonitorPrivate::applicationWindowClosing(int index, QQuickItem *window)
{
Q_UNUSED(index)
-
for (auto it = frameCounters.cbegin(); it != frameCounters.cend(); ++it) {
WaylandWindow *win = qobject_cast<WaylandWindow *>(it.key());
diff --git a/src/monitor-lib/processmonitor_p.h b/src/monitor-lib/processmonitor_p.h
index 7908312c..ccdb10ca 100644
--- a/src/monitor-lib/processmonitor_p.h
+++ b/src/monitor-lib/processmonitor_p.h
@@ -59,13 +59,15 @@
#include <QString>
#include <QHash>
#include <QVector>
-#include <QQuickWindow>
#if defined(Q_OS_LINUX)
-# include <QScopedPointer>
-# include "sysfsreader.h"
+# include <QScopedPointer>
+# include "sysfsreader.h"
#endif
-#if defined(AM_MULTI_PROCESS)
+#if !defined(AM_HEADLESS)
+# include <QQuickWindow>
+# if defined(AM_MULTI_PROCESS)
# include <QtAppManWindow/waylandwindow.h>
+# endif
#endif
#include "processmonitor.h"
#include "frametimer.h"
@@ -222,7 +224,7 @@ signals:
public slots:
void readingUpdate();
void appRuntimeChanged(const QString &id, ApplicationManager::RunState state);
-#if defined(AM_MULTI_PROCESS)
+#if defined(AM_MULTI_PROCESS) && !defined(AM_HEADLESS)
void applicationWindowClosing(int index, QQuickItem *window);
#endif
void frameUpdated();
diff --git a/src/monitor-lib/systemmonitor.cpp b/src/monitor-lib/systemmonitor.cpp
index d82bd9fd..fef6e28e 100644
--- a/src/monitor-lib/systemmonitor.cpp
+++ b/src/monitor-lib/systemmonitor.cpp
@@ -46,8 +46,10 @@
#include <QTimerEvent>
#include <QElapsedTimer>
#include <vector>
-#include <QGuiApplication>
-#include <QQuickView>
+#if !defined(AM_HEADLESS)
+# include <QGuiApplication>
+# include <QQuickView>
+#endif
#include "global.h"
#include "logging.h"
@@ -363,15 +365,18 @@ public:
return processMonitors.last();
}
+#if !defined(AM_HEADLESS)
void registerNewView(QQuickWindow *view)
{
Q_Q(SystemMonitor);
if (reportFps)
connect(view, &QQuickWindow::frameSwapped, q, &SystemMonitor::reportFrameSwap);
}
+#endif
void setupFpsReporting()
{
+#if !defined(AM_HEADLESS)
Q_Q(SystemMonitor);
if (!windowManagerConnectionCreated) {
connect(WindowManager::instance(), &WindowManager::compositorViewRegistered, this, &SystemMonitorPrivate::registerNewView);
@@ -384,6 +389,7 @@ public:
else
disconnect(view, &QQuickWindow::frameSwapped, q, &SystemMonitor::reportFrameSwap);
}
+#endif
}
void setupTimer(int newInterval = -1)
diff --git a/src/tools/dumpqmltypes/dumpqmltypes.pro b/src/tools/dumpqmltypes/dumpqmltypes.pro
index 823626b9..91f5cc14 100644
--- a/src/tools/dumpqmltypes/dumpqmltypes.pro
+++ b/src/tools/dumpqmltypes/dumpqmltypes.pro
@@ -1,3 +1,5 @@
+requires(!headless)
+
TEMPLATE = app
TARGET = appman-dumpqmltypes