on ccd07fa help sign in
unity8/tests/mocks/WindowManager/WindowManagerPlugin.cpp
75 lines 2.7 kB history raw
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "WindowManagerPlugin.h"
19#include "MockScreens.h"
20#include "MockScreenWindow.h"
21#include "Screen.h"
22#include "ScreenAttached.h"
23#include "Screens.h"
24#include "TopLevelWindowModel.h"
25#include "Window.h"
26#include "WorkspaceManager.h"
27#include "Workspace.h"
28#include "WorkspaceModel.h"
29#include "WindowManagementPolicy.h"
31#include <QtQml>
33static const QString notInstantiatable = QStringLiteral("Not instantiatable");
35static QObject *workspace_manager(QQmlEngine *engine, QJSEngine *scriptEngine)
37 Q_UNUSED(engine)
38 Q_UNUSED(scriptEngine)
39 return WorkspaceManager::instance();
41QObject* screensSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
42 Q_UNUSED(engine);
43 Q_UNUSED(scriptEngine);
44 return new Screens(MockScreens::instance());
47void WindowManagerPlugin::registerTypes(const char *uri)
49 qmlRegisterType<TopLevelWindowModel>(uri, 1, 0, "TopLevelWindowModel");
50 qmlRegisterSingletonType<WorkspaceManager>(uri, 1, 0, "WorkspaceManager", workspace_manager);
51 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", notInstantiatable);
52 qmlRegisterSingletonType<Screens>(uri, 1, 0, "Screens", screensSingleton);
53 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", notInstantiatable);
54 qmlRegisterUncreatableType<Workspace>(uri, 1, 0, "Workspace", notInstantiatable);
56 qRegisterMetaType<Screen*>("Screen*");
57 qRegisterMetaType<ScreensProxy*>("ScreensProxy*");
58 qRegisterMetaType<Workspace*>("Workspace*");
60 qRegisterMetaType<Window*>("Window*");
61 qRegisterMetaType<QAbstractListModel*>("QAbstractListModel*");
63 qmlRegisterType<MockScreenWindow>(uri, 1, 0, "ScreenWindow");
64 qmlRegisterRevision<QWindow,1>(uri, 1, 0);
66 qmlRegisterUncreatableType<WMScreen>(uri, 1, 0, "WMScreen", notInstantiatable);
69void WindowManagerPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
71 QQmlExtensionPlugin::initializeEngine(engine, uri);
73 // Make sure we've initialized the wm policy.
74 WindowManagementPolicy::instance();