on xenial help sign in
merge prereq
commit364028b1241673da9e594c31bfc8fb06184dcf05 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 7 Mar 2017, 11:10 (10 years ago) parent3a0ec61f820352
6 files changed+30−4
debian/control+1 plugins/WindowManager/Screen.cpp+6 plugins/WindowManager/Screens.cpp+9−2 plugins/WindowManager/WorkspaceManager.cpp+6 plugins/WindowManager/WorkspaceManager.h+3−1 plugins/WindowManager/WorkspaceModel.cpp+5−1
debian/control+1
@@ -46,6 +46,7 @@ Build-Depends: cmake,
4646 libxcb1-dev[!arm64 !armhf],
4747 libxi-dev[!arm64 !armhf],
4848# End of X11 libs
49+ mirtest-dev,
4950 pkg-config,
5051 python3-all:any,
5152 python3-setuptools,
plugins/WindowManager/Screen.cpp+6
@@ -18,10 +18,14 @@
1818#include "WorkspaceManager.h"
1919#include "Workspace.h"
2020
21+#include <QQmlEngine>
22+
2123Screen::Screen(qtmir::Screen* screen)
2224 : m_wrapped(screen)
2325 , m_workspaces(new WorkspaceModel)
2426{
27+ QQmlEngine::setObjectOwnership(m_workspaces.data(), QQmlEngine::CppOwnership);
28+
2529 connect(m_wrapped, &qtmir::Screen::usedChanged, this, &Screen::usedChanged);
2630 connect(m_wrapped, &qtmir::Screen::nameChanged, this, &Screen::nameChanged);
2731 connect(m_wrapped, &qtmir::Screen::outputTypeChanged, this, &Screen::outputTypeChanged);
@@ -53,6 +57,8 @@ Screen::Screen(const Screen &other)
5357 , m_wrapped(other.m_wrapped)
5458 , m_workspaces(new WorkspaceModelProxy(other.m_workspaces.data()))
5559{
60+ QQmlEngine::setObjectOwnership(m_workspaces.data(), QQmlEngine::CppOwnership);
61+
5662 connect(m_wrapped, &qtmir::Screen::usedChanged, this, &Screen::usedChanged);
5763 connect(m_wrapped, &qtmir::Screen::nameChanged, this, &Screen::nameChanged);
5864 connect(m_wrapped, &qtmir::Screen::outputTypeChanged, this, &Screen::outputTypeChanged);
plugins/WindowManager/Screens.cpp+9−2
@@ -21,6 +21,7 @@
2121// qtmirserver
2222#include <qtmir/screens.h>
2323#include <QGuiApplication>
24+#include <QQmlEngine>
2425
2526// Qt
2627#include <QScreen>
@@ -34,7 +35,9 @@ Screens::Screens(const QSharedPointer<qtmir::Screens>& model)
3435 connect(m_wrapped.data(), &qtmir::Screens::activeScreenChanged, this, &Screens::activeScreenChanged);
3536
3637 Q_FOREACH(qtmir::Screen* screen, m_wrapped->screens()) {
37− m_screens.push_back(new Screen(screen));
38+ auto screenWrapper(new Screen(screen));
39+ QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
40+ m_screens.push_back(screenWrapper);
3841 }
3942}
4043
@@ -125,6 +128,7 @@ void Screens::onScreenAdded(qtmir::Screen *added)
125128
126129 beginInsertRows(QModelIndex(), count(), count());
127130 auto screenWrapper(new Screen(added));
131+ QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
128132 m_screens.push_back(screenWrapper);
129133 endInsertRows();
130134 Q_EMIT screenAdded(screenWrapper);
@@ -165,13 +169,14 @@ ScreensProxy::ScreensProxy(Screens * const screens)
165169
166170 beginInsertRows(QModelIndex(), count(), count());
167171 auto screenWrapper(new ScreenProxy(added));
172+ QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
168173 m_screens.push_back(screenWrapper);
169174 endInsertRows();
170175 Q_EMIT screenAdded(screenWrapper);
171176 Q_EMIT countChanged();
172177 });
173178
174− connect(screens, &Screens::screenAdded, this, [this](Screen *removed) {
179+ connect(screens, &Screens::screenRemoved, this, [this](Screen *removed) {
175180 int index = 0;
176181 QMutableVectorIterator<Screen*> iter(m_screens);
177182 while(iter.hasNext()) {
@@ -193,6 +198,8 @@ ScreensProxy::ScreensProxy(Screens * const screens)
193198 });
194199
195200 Q_FOREACH(Screen* screen, screens->list()) {
201+ auto screenWrapper(new ScreenProxy(screen));
202+ QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
196203 m_screens.push_back(new ScreenProxy(screen));
197204 }
198205}
plugins/WindowManager/WorkspaceManager.cpp+6
@@ -109,3 +109,9 @@ void WorkspaceManager::setActiveWorkspace(Workspace *workspace)
109109 Q_EMIT activeWorkspaceChanged();
110110 }
111111}
112+
113+void WorkspaceManager::setActiveWorkspace2(Workspace *workspace)
114+{
115+ if (!workspace) return;
116+ workspace->activate();
117+}
plugins/WindowManager/WorkspaceManager.h+3−1
@@ -26,7 +26,7 @@ class ScreensProxy;
2626class WorkspaceManager : public QObject
2727{
2828 Q_OBJECT
29− Q_PROPERTY(Workspace* activeWorkspace READ activeWorkspace WRITE setActiveWorkspace NOTIFY activeWorkspaceChanged)
29+ Q_PROPERTY(Workspace* activeWorkspace READ activeWorkspace WRITE setActiveWorkspace2 NOTIFY activeWorkspaceChanged)
3030 Q_PROPERTY(QQmlListProperty<Workspace> floatingWorkspaces READ floatingWorkspaces NOTIFY floatingWorkspacesChanged)
3131
3232public:
@@ -48,6 +48,8 @@ Q_SIGNALS:
4848private:
4949 WorkspaceManager();
5050
51+ void setActiveWorkspace2(Workspace* workspace);
52+
5153 QSet<Workspace*> m_allWorkspaces;
5254 QList<Workspace*> m_floatingWorkspaces;
5355 Workspace* m_activeWorkspace;
plugins/WindowManager/WorkspaceModel.cpp+5−1
@@ -18,6 +18,8 @@
1818#include "WorkspaceManager.h"
1919#include "Workspace.h"
2020
21+#include <QQmlEngine>
22+
2123Q_LOGGING_CATEGORY(WORKSPACES, "Workspaces", QtInfoMsg)
2224
2325#define DEBUG_MSG qCDebug(WORKSPACES).nospace().noquote() << __func__
@@ -171,7 +173,9 @@ WorkspaceModelProxy::WorkspaceModelProxy(WorkspaceModel * const model)
171173 : m_original(model)
172174{
173175 Q_FOREACH(auto workspace, model->list()) {
174− (new WorkspaceProxy(workspace))->assign(this);
176+ auto proxy = new WorkspaceProxy(workspace);
177+ QQmlEngine::setObjectOwnership(proxy, QQmlEngine::CppOwnership);
178+ proxy->assign(this);
175179 }
176180}
177181