on xenial help sign in
Select the backend to use dynamically on runtime according to the QPA selected by the system.
6b8b30bRicardo Mendoza
CMakeLists.txt+4
@@ -62,10 +62,13 @@ set(SHELL_PRIVATE_LIBDIR ${CMAKE_INSTALL_LIBDIR}/unity8)
62
62
63configure_file(paths.h.in ${CMAKE_CURRENT_BINARY_DIR}/paths.h @ONLY)
63configure_file(paths.h.in ${CMAKE_CURRENT_BINARY_DIR}/paths.h @ONLY)
64
64
65+pkg_check_modules(UNITY-MIR REQUIRED unity-mir)
66+
65include_directories(
67include_directories(
66 ${CMAKE_CURRENT_BINARY_DIR}
68 ${CMAKE_CURRENT_BINARY_DIR}
67 ${CMAKE_CURRENT_SOURCE_DIR}
69 ${CMAKE_CURRENT_SOURCE_DIR}
68 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
70 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
71+ ${UNITY-MIR_INCLUDE_DIRS}
69 )
72 )
70
73
71set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
74set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
@@ -118,6 +121,7 @@ target_link_libraries(${SHELL_APP}
118 ${Qt5Qml_LIBRARIES}
121 ${Qt5Qml_LIBRARIES}
119 ${Qt5Quick_LIBRARIES}
122 ${Qt5Quick_LIBRARIES}
120 ${XCB_LDFLAGS}
123 ${XCB_LDFLAGS}
124+ ${CMAKE_DL_LIBS}
121 )
125 )
122
126
123# install binaries
127# install binaries
debian/control+2
@@ -23,6 +23,7 @@ Build-Depends: cmake,
23 libunity-api-dev (>= 7.80.3),
23 libunity-api-dev (>= 7.80.3),
24 libunity-core-6.0-dev (<< 7.80),
24 libunity-core-6.0-dev (<< 7.80),
25 libunity-dev (>= 7.0.12),
25 libunity-dev (>= 7.0.12),
26+ libunity-mir-dev,
26 libunity-scopes-json-def-phone,
27 libunity-scopes-json-def-phone,
27 libupstart-dev,
28 libupstart-dev,
28 libusermetricsoutput1-dev,
29 libusermetricsoutput1-dev,
@@ -65,6 +66,7 @@ Package: unity8
65Architecture: any
66Architecture: any
66Provides: indicator-renderer,
67Provides: indicator-renderer,
67Depends: gsettings-desktop-schemas,
68Depends: gsettings-desktop-schemas,
69+ libunity-mir1,
68 qmenumodel-qml (>= 0.2.7),
70 qmenumodel-qml (>= 0.2.7),
69 qtdeclarative5-dee-plugin,
71 qtdeclarative5-dee-plugin,
70 qtdeclarative5-gsettings1.0,
72 qtdeclarative5-gsettings1.0,
main.cpp+73−6
@@ -25,13 +25,17 @@
25#include <QtQml/QQmlContext>
25#include <QtQml/QQmlContext>
26#include <qpa/qplatformnativeinterface.h>
26#include <qpa/qplatformnativeinterface.h>
27#include <QLibrary>
27#include <QLibrary>
28+#include <QDebug>
28#include <libintl.h>
29#include <libintl.h>
30+#include <dlfcn.h>
29
31
30// local
32// local
31#include "paths.h"
33#include "paths.h"
32#include "MouseTouchAdaptor.h"
34#include "MouseTouchAdaptor.h"
33#include "ApplicationArguments.h"
35#include "ApplicationArguments.h"
34
36
37+#include <unity-mir/qmirserver.h>
38+
35namespace {
39namespace {
36
40
37void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
41void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
@@ -72,7 +76,7 @@ void resolveIconTheme() {
72}
76}
73} // namespace {
77} // namespace {
74
78
75−int main(int argc, char** argv)
79+int startShell(int argc, const char** argv, void* server)
76{
80{
77 /* Workaround Qt platform integration plugin not advertising itself
81 /* Workaround Qt platform integration plugin not advertising itself
78 as having the following capabilities:
82 as having the following capabilities:
@@ -82,12 +86,29 @@ int main(int argc, char** argv)
82 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
86 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
83 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
87 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
84
88
89+ const bool isUbuntuMirServer = qgetenv("QT_QPA_PLATFORM") == "ubuntumirserver";
90+
85 QGuiApplication::setApplicationName("Unity 8");
91 QGuiApplication::setApplicationName("Unity 8");
86− QGuiApplication application(argc, argv);
92+ QGuiApplication *application;
93+ if (isUbuntuMirServer) {
94+ QLibrary unityMir("unity-mir");
95+ unityMir.load();
96+
97+ typedef QGuiApplication* (*createServerApplication_t)(int&, const char **, void*);
98+ createServerApplication_t createQMirServerApplication = (createServerApplication_t) unityMir.resolve("createQMirServerApplication");
99+ if (!createQMirServerApplication) {
100+ qDebug() << "unable to resolve symbol: createQMirServerApplication";
101+ return 4;
102+ }
103+
104+ application = createQMirServerApplication(argc, argv, server);
105+ } else {
106+ application = new QGuiApplication(argc, (char**)argv);
107+ }
87
108
88 resolveIconTheme();
109 resolveIconTheme();
89
110
90− QStringList args = application.arguments();
111+ QStringList args = application->arguments();
91 ApplicationArguments qmlArgs(args);
112 ApplicationArguments qmlArgs(args);
92
113
93 // The testability driver is only loaded by QApplication but not by QGuiApplication.
114 // The testability driver is only loaded by QApplication but not by QGuiApplication.
@@ -124,7 +145,7 @@ int main(int argc, char** argv)
124 if (args.contains(QLatin1String("-mousetouch"))) {
145 if (args.contains(QLatin1String("-mousetouch"))) {
125 mouseTouchAdaptor = new MouseTouchAdaptor;
146 mouseTouchAdaptor = new MouseTouchAdaptor;
126 mouseTouchAdaptor->setTargetWindow(view);
147 mouseTouchAdaptor->setTargetWindow(view);
127− application.installNativeEventFilter(mouseTouchAdaptor);
148+ application->installNativeEventFilter(mouseTouchAdaptor);
128 }
149 }
129
150
130 QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
151 QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
@@ -139,18 +160,64 @@ int main(int argc, char** argv)
139 QUrl source("Shell.qml");
160 QUrl source("Shell.qml");
140 prependImportPaths(view->engine(), ::overrideImportPaths());
161 prependImportPaths(view->engine(), ::overrideImportPaths());
141 appendImportPaths(view->engine(), ::fallbackImportPaths());
162 appendImportPaths(view->engine(), ::fallbackImportPaths());
163+
164+ QStringList importPath = view->engine()->importPathList().filter("qt5/imports");
165+ if (isUbuntuMirServer) {
166+ importPath.first().append("/Unity-Mir");
167+ view->engine()->addImportPath(importPath.first());
168+ }
169+
142 view->setSource(source);
170 view->setSource(source);
143 view->setColor("transparent");
171 view->setColor("transparent");
144
172
145− if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || args.contains(QLatin1String("-fullscreen"))) {
173+ if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || isUbuntuMirServer || args.contains(QLatin1String("-fullscreen"))) {
146 view->showFullScreen();
174 view->showFullScreen();
147 } else {
175 } else {
148 view->show();
176 view->show();
149 }
177 }
150
178
151− int result = application.exec();
179+ int result = application->exec();
152
180
153 delete mouseTouchAdaptor;
181 delete mouseTouchAdaptor;
182+ delete application;
154
183
155 return result;
184 return result;
156}
185}
186+
187+int main(int argc, const char *argv[])
188+{
189+ // For ubuntumirserver/ubuntumirclient
190+ if (qgetenv("QT_QPA_PLATFORM").startsWith("ubuntumir")) {
191+ setenv("QT_QPA_PLATFORM", "ubuntumirserver", 1);
192+
193+ // If we use unity-mir directly, we automatically link to the Mir-server
194+ // platform-api bindings, which result in unexpected behaviour when
195+ // running the non-Mir scenario.
196+ QLibrary unityMir("unity-mir");
197+ unityMir.load();
198+ if (!unityMir.isLoaded()) {
199+ qDebug() << "Library unity-mir not found/loaded";
200+ return 1;
201+ }
202+
203+ typedef QMirServer* (*createServer_t)(int, const char **);
204+ createServer_t createQMirServer = (createServer_t) unityMir.resolve("createQMirServer");
205+ if (!createQMirServer) {
206+ qDebug() << "unable to resolve symbol: createQMirServer";
207+ return 2;
208+ }
209+
210+ QMirServer* mirServer = createQMirServer(argc, argv);
211+
212+ typedef int (*runWithClient_t)(QMirServer*, std::function<int(int, const char**, void*)>);
213+ runWithClient_t runWithClient = (runWithClient_t) unityMir.resolve("runQMirServerWithClient");
214+ if (!runWithClient) {
215+ qDebug() << "unable to resolve symbol: runWithClient";
216+ return 3;
217+ }
218+
219+ return runWithClient(mirServer, startShell);
220+ } else {
221+ return startShell(argc, argv, nullptr);
222+ }
223+}