on 06f42e7 help sign in
unity8/tests/mocks/WindowManager/WindowManagerPlugin.cpp
89 lines 3.3 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 "AvailableDesktopArea.h"
20#include "MockScreens.h"
21#include "MockScreenWindow.h"
22#include "Screen.h"
23#include "ScreenAttached.h"
24#include "Screens.h"
25#include "ScreensConfiguration.h"
26#include "TopLevelWindowModel.h"
27#include "Window.h"
28#include "WindowMargins.h"
29#include "WindowManagementPolicy.h"
30#include "WindowManagerObjects.h"
31#include "WorkspaceManager.h"
32#include "Workspace.h"
33#include "WorkspaceModel.h"
35#include <QtQml>
37static const QString notInstantiatable = QStringLiteral("Not instantiatable");
39static QObject *workspace_manager(QQmlEngine *engine, QJSEngine *scriptEngine)
41 Q_UNUSED(engine)
42 Q_UNUSED(scriptEngine)
43 return WorkspaceManager::instance();
45QObject* screensSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
46 Q_UNUSED(engine);
47 Q_UNUSED(scriptEngine);
48 return ConcreteScreens::self();
50QObject* objectsSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
51 Q_UNUSED(engine);
52 Q_UNUSED(scriptEngine);
53 return WindowManagerObjects::instance();
56void WindowManagerPlugin::registerTypes(const char *uri)
58 qmlRegisterType<AvailableDesktopArea>(uri, 1, 0, "AvailableDesktopArea");
59 qmlRegisterType<WindowMargins>(uri, 1, 0, "WindowMargins");
60 qmlRegisterSingletonType<WorkspaceManager>(uri, 1, 0, "WorkspaceManager", workspace_manager);
61 qmlRegisterSingletonType<ConcreteScreens>(uri, 1, 0, "Screens", screensSingleton);
62 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", notInstantiatable);
63 qmlRegisterSingletonType<WindowManagerObjects>(uri, 1, 0, "WindowManagerObjects", objectsSingleton);
65 qRegisterMetaType<ConcreteScreen*>("ConcreteScreen*");
66 qRegisterMetaType<ProxyScreens*>("ProxyScreens*");
67 qRegisterMetaType<Workspace*>("Workspace*");
68 qRegisterMetaType<TopLevelWindowModel*>("TopLevelWindowModel*");
69 qRegisterMetaType<ScreenConfig*>("ScreenConfig*");
70 qRegisterMetaType<WorkspaceModel*>("WorkspaceModel*");
72 qRegisterMetaType<Window*>("Window*");
73 qRegisterMetaType<QAbstractListModel*>("QAbstractListModel*");
75 qmlRegisterType<MockScreenWindow>(uri, 1, 0, "ScreenWindow");
76 qmlRegisterRevision<QWindow,1>(uri, 1, 0);
78 qmlRegisterUncreatableType<WMScreen>(uri, 1, 0, "WMScreen", notInstantiatable);
81void WindowManagerPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
83 QQmlExtensionPlugin::initializeEngine(engine, uri);
85 // Make sure we've initialized the wm policy.
86 WindowManagementPolicy::instance();
87 // Create Screens
88 new ConcreteScreens(MockScreens::instance(), new ScreensConfiguration());