2 * Copyright (C) 2012 Canonical, Ltd.
5 * Gerry Boland <gerry.boland@canonical.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include <QtQuick/QQuickView>
22#include <QtGui/QGuiApplication>
23#include <QtQml/QQmlEngine>
24#include <QtQml/QQmlContext>
25#include <qpa/qplatformnativeinterface.h>
34#include "MouseTouchAdaptor.h"
35#include "ApplicationArguments.h"
37#include <unity-mir/qmirserver.h>
40int startShell(int argc, const char** argv, void* server)
42 const bool isUbuntuMirServer = qgetenv("QT_QPA_PLATFORM") == "ubuntumirserver";
44 QGuiApplication::setApplicationName("Unity 8");
45 QGuiApplication *application;
46 if (isUbuntuMirServer) {
47 QLibrary unityMir("unity-mir", 1);
50 typedef QGuiApplication* (*createServerApplication_t)(int&, const char **, void*);
51 createServerApplication_t createQMirServerApplication = (createServerApplication_t) unityMir.resolve("createQMirServerApplication");
52 if (!createQMirServerApplication) {
53 qDebug() << "unable to resolve symbol: createQMirServerApplication";
57 application = createQMirServerApplication(argc, argv, server);
59 application = new QGuiApplication(argc, (char**)argv);
64 QStringList args = application->arguments();
65 ApplicationArguments qmlArgs(args);
67 // The testability driver is only loaded by QApplication but not by QGuiApplication.
68 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
69 if (args.contains(QLatin1String("-testability")) || getenv("QT_LOAD_TESTABILITY")) {
70 QLibrary testLib(QLatin1String("qttestability"));
72 typedef void (*TasInitialize)(void);
73 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
77 qCritical("Library qttestability resolve failed!");
80 qCritical("Library qttestability load failed!");
84 bindtextdomain("unity8", translationDirectory().toUtf8().data());
86 QQuickView* view = new QQuickView();
87 view->setResizeMode(QQuickView::SizeRootObjectToView);
88 view->setTitle("Qml Phone Shell");
89 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
90 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
91 if (args.contains(QLatin1String("-frameless"))) {
92 view->setFlags(Qt::FramelessWindowHint);
95 // You will need this if you want to interact with touch-only components using a mouse
96 // Needed only when manually testing on a desktop.
97 MouseTouchAdaptor *mouseTouchAdaptor = 0;
98 if (args.contains(QLatin1String("-mousetouch"))) {
99 mouseTouchAdaptor = new MouseTouchAdaptor;
100 application->installNativeEventFilter(mouseTouchAdaptor);
103 QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
104 /* Shell is declared as a system session so that it always receives all
106 FIXME: use the enum value corresponding to SYSTEM_SESSION_TYPE (= 1)
107 when it becomes available.
109 nativeInterface->setProperty("ubuntuSessionType", 1);
110 view->setProperty("role", 2); // INDICATOR_ACTOR_ROLE
112 QUrl source(::qmlDirectory()+"Shell.qml");
113 prependImportPaths(view->engine(), ::overrideImportPaths());
114 appendImportPaths(view->engine(), ::fallbackImportPaths());
116 if (isUbuntuMirServer) {
117 QStringList importPaths = view->engine()->importPathList();
118 importPaths.replaceInStrings(QRegExp("qt5/imports$"), "qt5/imports/Unity-Mir");
119 view->engine()->setImportPathList(importPaths);
122 view->setSource(source);
123 view->setColor("transparent");
125 if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || isUbuntuMirServer || args.contains(QLatin1String("-fullscreen"))) {
126 view->showFullScreen();
131 int result = application->exec();
134 delete mouseTouchAdaptor;
140int main(int argc, const char *argv[])
142 /* Workaround Qt platform integration plugin not advertising itself
143 as having the following capabilities:
144 - QPlatformIntegration::ThreadedOpenGL
145 - QPlatformIntegration::BufferQueueingOpenGL
147 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
148 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
150 // For ubuntumirserver/ubuntumirclient
151 if (qgetenv("QT_QPA_PLATFORM").startsWith("ubuntumir")) {
152 setenv("QT_QPA_PLATFORM", "ubuntumirserver", 1);
154 // If we use unity-mir directly, we automatically link to the Mir-server
155 // platform-api bindings, which result in unexpected behaviour when
156 // running the non-Mir scenario.
157 QLibrary unityMir("unity-mir", 1);
159 if (!unityMir.isLoaded()) {
160 qDebug() << "Library unity-mir not found/loaded";
164 typedef QMirServer* (*createServer_t)(int, const char **);
165 createServer_t createQMirServer = (createServer_t) unityMir.resolve("createQMirServer");
166 if (!createQMirServer) {
167 qDebug() << "unable to resolve symbol: createQMirServer";
171 QMirServer* mirServer = createQMirServer(argc, argv);
173 typedef int (*runWithClient_t)(QMirServer*, std::function<int(int, const char**, void*)>);
174 runWithClient_t runWithClient = (runWithClient_t) unityMir.resolve("runQMirServerWithClient");
175 if (!runWithClient) {
176 qDebug() << "unable to resolve symbol: runWithClient";
180 return runWithClient(mirServer, startShell);
182 if (qgetenv("UPSTART_JOB") == "unity8") {
183 // Emit SIGSTOP as expected by upstart, under Mir it's unity-mir that will raise it.
184 // see http://upstart.ubuntu.com/cookbook/#expect-stop
187 return startShell(argc, argv, nullptr);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list