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 <QtQml/qqml.h>
26#include <qpa/qplatformnativeinterface.h>
35#include "MouseTouchAdaptor.h"
36#include "ApplicationArguments.h"
38#include <unity-mir/qmirserver.h>
41int startShell(int argc, const char** argv, void* server)
43 const bool isUbuntuMirServer = qgetenv("QT_QPA_PLATFORM") == "ubuntumirserver";
45 QGuiApplication::setApplicationName("Unity 8");
46 QGuiApplication *application;
47 if (isUbuntuMirServer) {
48 QLibrary unityMir("unity-mir", 1);
51 typedef QGuiApplication* (*createServerApplication_t)(int&, const char **, void*);
52 createServerApplication_t createQMirServerApplication = (createServerApplication_t) unityMir.resolve("createQMirServerApplication");
53 if (!createQMirServerApplication) {
54 qDebug() << "unable to resolve symbol: createQMirServerApplication";
58 application = createQMirServerApplication(argc, argv, server);
60 application = new QGuiApplication(argc, (char**)argv);
63 QString indicatorProfile = qgetenv("UNITY_INDICATOR_PROFILE");
64 if (indicatorProfile.isEmpty()) {
65 indicatorProfile = "phone";
70 QStringList args = application->arguments();
71 ApplicationArguments qmlArgs(args);
73 // The testability driver is only loaded by QApplication but not by QGuiApplication.
74 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
75 if (args.contains(QLatin1String("-testability")) || getenv("QT_LOAD_TESTABILITY")) {
76 QLibrary testLib(QLatin1String("qttestability"));
78 typedef void (*TasInitialize)(void);
79 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
83 qCritical("Library qttestability resolve failed!");
86 qCritical("Library qttestability load failed!");
90 bindtextdomain("unity8", translationDirectory().toUtf8().data());
92 QQuickView* view = new QQuickView();
93 view->setResizeMode(QQuickView::SizeRootObjectToView);
94 view->setTitle("Qml Phone Shell");
95 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
96 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
97 view->rootContext()->setContextProperty("indicatorProfile", indicatorProfile);
98 if (args.contains(QLatin1String("-frameless"))) {
99 view->setFlags(Qt::FramelessWindowHint);
102 // You will need this if you want to interact with touch-only components using a mouse
103 // Needed only when manually testing on a desktop.
104 MouseTouchAdaptor *mouseTouchAdaptor = 0;
105 if (args.contains(QLatin1String("-mousetouch"))) {
106 mouseTouchAdaptor = new MouseTouchAdaptor;
107 application->installNativeEventFilter(mouseTouchAdaptor);
110 qmlRegisterSingletonType(QUrl("file://" + qmlDirectory() + "Dash/CardCreatorCache.qml"), "Unity.Dash", 1, 0, "CardCreatorCache");
112 QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
113 /* Shell is declared as a system session so that it always receives all
115 FIXME: use the enum value corresponding to SYSTEM_SESSION_TYPE (= 1)
116 when it becomes available.
118 nativeInterface->setProperty("ubuntuSessionType", 1);
119 view->setProperty("role", 2); // INDICATOR_ACTOR_ROLE
121 QUrl source(::qmlDirectory()+"Shell.qml");
122 prependImportPaths(view->engine(), ::overrideImportPaths());
123 if (!isUbuntuMirServer) {
124 prependImportPaths(view->engine(), ::nonMirImportPaths());
126 appendImportPaths(view->engine(), ::fallbackImportPaths());
128 view->setSource(source);
129 view->setColor("transparent");
131 if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || isUbuntuMirServer || args.contains(QLatin1String("-fullscreen"))) {
132 view->showFullScreen();
137 int result = application->exec();
140 delete mouseTouchAdaptor;
146int main(int argc, const char *argv[])
148 /* Workaround Qt platform integration plugin not advertising itself
149 as having the following capabilities:
150 - QPlatformIntegration::ThreadedOpenGL
151 - QPlatformIntegration::BufferQueueingOpenGL
153 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
154 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
156 // For ubuntumirserver/ubuntumirclient
157 if (qgetenv("QT_QPA_PLATFORM").startsWith("ubuntumir")) {
158 setenv("QT_QPA_PLATFORM", "ubuntumirserver", 1);
160 // If we use unity-mir directly, we automatically link to the Mir-server
161 // platform-api bindings, which result in unexpected behaviour when
162 // running the non-Mir scenario.
163 QLibrary unityMir("unity-mir", 1);
165 if (!unityMir.isLoaded()) {
166 qDebug() << "Library unity-mir not found/loaded";
170 typedef QMirServer* (*createServer_t)(int, const char **);
171 createServer_t createQMirServer = (createServer_t) unityMir.resolve("createQMirServer");
172 if (!createQMirServer) {
173 qDebug() << "unable to resolve symbol: createQMirServer";
177 QMirServer* mirServer = createQMirServer(argc, argv);
179 typedef int (*runWithClient_t)(QMirServer*, std::function<int(int, const char**, void*)>);
180 runWithClient_t runWithClient = (runWithClient_t) unityMir.resolve("runQMirServerWithClient");
181 if (!runWithClient) {
182 qDebug() << "unable to resolve symbol: runWithClient";
186 return runWithClient(mirServer, startShell);
188 if (qgetenv("UPSTART_JOB") == "unity8") {
189 // Emit SIGSTOP as expected by upstart, under Mir it's unity-mir that will raise it.
190 // see http://upstart.ubuntu.com/cookbook/#expect-stop
193 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