on xenial help sign in
Fixed issues with syncing
ac93886Nick Dedekind
plugins/WindowManager/Screen.cpp+87−49
@@ -19,146 +19,184 @@
19#include "WorkspaceManager.h"
19#include "WorkspaceManager.h"
20#include "Workspace.h"
20#include "Workspace.h"
21
21
22−ScreenInterface::ScreenInterface(QObject *parent)
22+Screen::Screen(QObject *parent)
23 : QObject(parent)
23 : QObject(parent)
24{
24{
25}
25}
26
26
27−void ScreenInterface::connectToScreen(qtmir::Screen *screen)
27+void Screen::connectToScreen(qtmir::Screen *screen)
28{
28{
29 m_wrapped = screen;
29 m_wrapped = screen;
30− connect(screen, &qtmir::Screen::usedChanged, this, &ScreenInterface::usedChanged);
30+ connect(screen, &qtmir::Screen::usedChanged, this, &Screen::usedChanged);
31− connect(screen, &qtmir::Screen::nameChanged, this, &ScreenInterface::nameChanged);
31+ connect(screen, &qtmir::Screen::nameChanged, this, &Screen::nameChanged);
32− connect(screen, &qtmir::Screen::outputTypeChanged, this, &ScreenInterface::outputTypeChanged);
32+ connect(screen, &qtmir::Screen::outputTypeChanged, this, &Screen::outputTypeChanged);
33+ connect(screen, &qtmir::Screen::outputTypeChanged, this, &Screen::outputTypeNameChanged);
33− connect(screen, &qtmir::Screen::scaleChanged, this, &ScreenInterface::scaleChanged);
34+ connect(screen, &qtmir::Screen::scaleChanged, this, &Screen::scaleChanged);
34− connect(screen, &qtmir::Screen::formFactorChanged, this, &ScreenInterface::formFactorChanged);
35+ connect(screen, &qtmir::Screen::formFactorChanged, this, &Screen::formFactorChanged);
35− connect(screen, &qtmir::Screen::physicalSizeChanged, this, &ScreenInterface::physicalSizeChanged);
36+ connect(screen, &qtmir::Screen::physicalSizeChanged, this, &Screen::physicalSizeChanged);
36− connect(screen, &qtmir::Screen::positionChanged, this, &ScreenInterface::positionChanged);
37+ connect(screen, &qtmir::Screen::positionChanged, this, &Screen::positionChanged);
37− connect(screen, &qtmir::Screen::activeChanged, this, &ScreenInterface::activeChanged);
38+ connect(screen, &qtmir::Screen::activeChanged, this, &Screen::activeChanged);
38− connect(screen, &qtmir::Screen::currentModeIndexChanged, this, &ScreenInterface::currentModeIndexChanged);
39+ connect(screen, &qtmir::Screen::currentModeIndexChanged, this, &Screen::currentModeIndexChanged);
39− connect(screen, &qtmir::Screen::availableModesChanged, this, &ScreenInterface::availableModesChanged);
40+ connect(screen, &qtmir::Screen::availableModesChanged, this, &Screen::availableModesChanged);
40}
41}
41
42
42−void ScreenInterface::connectToScreen(ScreenInterface *screen)
43+void Screen::connectToScreen(Screen *screen)
43{
44{
44 connectToScreen(screen->wrapped());
45 connectToScreen(screen->wrapped());
45− connect(screen, &ScreenInterface::currentWorkspaceChanged, this, &ScreenInterface::currentWorkspaceChanged);
46+ connect(screen, &Screen::currentWorkspaceChanged, this, &Screen::currentWorkspaceChanged);
46}
47}
47
48
48−qtmir::OutputId ScreenInterface::outputId() const
49+qtmir::OutputId Screen::outputId() const
49{
50{
50 if (!m_wrapped) return qtmir::OutputId(-1);
51 if (!m_wrapped) return qtmir::OutputId(-1);
51 return m_wrapped->outputId();
52 return m_wrapped->outputId();
52}
53}
53
54
54−bool ScreenInterface::used() const
55+bool Screen::used() const
55{
56{
56 if (!m_wrapped) return false;
57 if (!m_wrapped) return false;
57 return m_wrapped->used();
58 return m_wrapped->used();
58}
59}
59
60
60−QString ScreenInterface::name() const
61+QString Screen::name() const
61{
62{
62 if (!m_wrapped) return QString();
63 if (!m_wrapped) return QString();
63 return m_wrapped->name();
64 return m_wrapped->name();
64}
65}
65
66
66−float ScreenInterface::scale() const
67+float Screen::scale() const
67{
68{
68 if (!m_wrapped) return 1.0;
69 if (!m_wrapped) return 1.0;
69 return m_wrapped->scale();
70 return m_wrapped->scale();
70}
71}
71
72
72−QSizeF ScreenInterface::physicalSize() const
73+QSizeF Screen::physicalSize() const
73{
74{
74 if (!m_wrapped) return QSizeF();
75 if (!m_wrapped) return QSizeF();
75 return m_wrapped->physicalSize();
76 return m_wrapped->physicalSize();
76}
77}
77
78
78−qtmir::FormFactor ScreenInterface::formFactor() const
79+qtmir::FormFactor Screen::formFactor() const
79{
80{
80 if (!m_wrapped) return qtmir::FormFactorUnknown;
81 if (!m_wrapped) return qtmir::FormFactorUnknown;
81 return m_wrapped->formFactor();
82 return m_wrapped->formFactor();
82}
83}
83
84
84−qtmir::OutputTypes ScreenInterface::outputType() const
85+qtmir::OutputTypes Screen::outputType() const
85{
86{
86 if (!m_wrapped) return qtmir::Unknown;
87 if (!m_wrapped) return qtmir::Unknown;
87 return m_wrapped->outputType();
88 return m_wrapped->outputType();
88}
89}
89
90
90−MirPowerMode ScreenInterface::powerMode() const
91+MirPowerMode Screen::powerMode() const
91{
92{
92 if (!m_wrapped) return mir_power_mode_on;
93 if (!m_wrapped) return mir_power_mode_on;
93 return m_wrapped->powerMode();
94 return m_wrapped->powerMode();
94}
95}
95
96
96−Qt::ScreenOrientation ScreenInterface::orientation() const
97+Qt::ScreenOrientation Screen::orientation() const
97{
98{
98 if (!m_wrapped) return Qt::PrimaryOrientation;
99 if (!m_wrapped) return Qt::PrimaryOrientation;
99 return m_wrapped->orientation();
100 return m_wrapped->orientation();
100}
101}
101
102
102−QPoint ScreenInterface::position() const
103+QPoint Screen::position() const
103{
104{
104 if (!m_wrapped) return QPoint();
105 if (!m_wrapped) return QPoint();
105 return m_wrapped->position();
106 return m_wrapped->position();
106}
107}
107
108
108−QQmlListProperty<qtmir::ScreenMode> ScreenInterface::availableModes()
109+QQmlListProperty<qtmir::ScreenMode> Screen::availableModes()
109{
110{
110 if (!m_wrapped) return QQmlListProperty<qtmir::ScreenMode>();
111 if (!m_wrapped) return QQmlListProperty<qtmir::ScreenMode>();
111 return m_wrapped->availableModes();
112 return m_wrapped->availableModes();
112}
113}
113
114
114−uint ScreenInterface::currentModeIndex() const
115+uint Screen::currentModeIndex() const
115{
116{
116 if (!m_wrapped) return -1;
117 if (!m_wrapped) return -1;
117 return m_wrapped->currentModeIndex();
118 return m_wrapped->currentModeIndex();
118}
119}
119
120
120−bool ScreenInterface::isActive() const
121+bool Screen::isActive() const
121{
122{
122 if (!m_wrapped) return false;
123 if (!m_wrapped) return false;
123 return m_wrapped->isActive();
124 return m_wrapped->isActive();
124}
125}
125
126
126−void ScreenInterface::activate()
127+void Screen::activate()
127{
128{
128 setActive(true);
129 setActive(true);
129}
130}
130
131
131−void ScreenInterface::setActive(bool active)
132+void Screen::setActive(bool active)
132{
133{
133 if (!m_wrapped) return;
134 if (!m_wrapped) return;
134 m_wrapped->setActive(active);
135 m_wrapped->setActive(active);
135}
136}
136
137
137−QScreen *ScreenInterface::qscreen() const
138+QScreen *Screen::qscreen() const
138{
139{
139 if (!m_wrapped) return nullptr;
140 if (!m_wrapped) return nullptr;
140 return m_wrapped->qscreen();
141 return m_wrapped->qscreen();
141}
142}
142
143
143−qtmir::ScreenConfiguration *ScreenInterface::beginConfiguration() const
144+qtmir::ScreenConfiguration *Screen::beginConfiguration() const
144{
145{
145 if (!m_wrapped) return nullptr;
146 if (!m_wrapped) return nullptr;
146 return m_wrapped->beginConfiguration();
147 return m_wrapped->beginConfiguration();
147}
148}
148
149
149−bool ScreenInterface::applyConfiguration(qtmir::ScreenConfiguration *configuration)
150+bool Screen::applyConfiguration(qtmir::ScreenConfiguration *configuration)
150{
151{
151 if (!m_wrapped) return false;
152 if (!m_wrapped) return false;
152 return m_wrapped->applyConfiguration(configuration);
153 return m_wrapped->applyConfiguration(configuration);
153}
154}
154
155
155−void ScreenInterface::sync(ScreenInterface *proxy)
156+QString Screen::outputTypeName() const
157+{
158+ switch (m_wrapped->outputType()) {
159+ case qtmir::Unknown:
160+ return tr("Unknown");
161+ case qtmir::VGA:
162+ return tr("VGA");
163+ case qtmir::DVII:
164+ case qtmir::DVID:
165+ case qtmir::DVIA:
166+ return tr("DVI");
167+ case qtmir::Composite:
168+ return tr("Composite");
169+ case qtmir::SVideo:
170+ return tr("S-Video");
171+ case qtmir::LVDS:
172+ case qtmir::NinePinDIN:
173+ case qtmir::EDP:
174+ return tr("Internal");
175+ case qtmir::Component:
176+ return tr("Component");
177+ case qtmir::DisplayPort:
178+ return tr("DisplayPort");
179+ case qtmir::HDMIA:
180+ case qtmir::HDMIB:
181+ return tr("HDMI");
182+ case qtmir::TV:
183+ return tr("TV");
184+ }
185+ return QString();
186+}
187+
188+void Screen::setSyncing(bool syncing)
189+{
190+ workspaces()->setSyncing(syncing);
191+}
192+
193+void Screen::sync(Screen *proxy)
156{
194{
157 if (!proxy) return;
195 if (!proxy) return;
158 workspaces()->sync(proxy->workspaces());
196 workspaces()->sync(proxy->workspaces());
159}
197}
160
198
161−Screen::Screen(qtmir::Screen* wrapped)
199+ConcreteScreen::ConcreteScreen(qtmir::Screen* wrapped)
162 : m_workspaces(new WorkspaceModel)
200 : m_workspaces(new WorkspaceModel)
163{
201{
164 connectToScreen(wrapped);
202 connectToScreen(wrapped);
@@ -185,7 +223,7 @@ Screen::Screen(qtmir::Screen* wrapped)
185 resetCurrentWorkspace();
223 resetCurrentWorkspace();
186 }
224 }
187 });
225 });
188− connect(this, &Screen::activeChanged, this, [this](bool active) {
226+ connect(this, &ConcreteScreen::activeChanged, this, [this](bool active) {
189 if (active && m_currentWorspace) {
227 if (active && m_currentWorspace) {
190 m_currentWorspace->activate();
228 m_currentWorspace->activate();
191 }
229 }
@@ -195,7 +233,7 @@ Screen::Screen(qtmir::Screen* wrapped)
195 WorkspaceManager::instance()->createWorkspace()->assign(m_workspaces.data());
233 WorkspaceManager::instance()->createWorkspace()->assign(m_workspaces.data());
196}
234}
197
235
198−void Screen::resetCurrentWorkspace()
236+void ConcreteScreen::resetCurrentWorkspace()
199{
237{
200 auto newCurrent = m_workspaces->rowCount() > 0 ? m_workspaces->get(0) : nullptr;
238 auto newCurrent = m_workspaces->rowCount() > 0 ? m_workspaces->get(0) : nullptr;
201 if (m_currentWorspace != newCurrent) {
239 if (m_currentWorspace != newCurrent) {
@@ -205,17 +243,17 @@ void Screen::resetCurrentWorkspace()
205}
243}
206
244
207
245
208−WorkspaceModel *Screen::workspaces() const
246+WorkspaceModel *ConcreteScreen::workspaces() const
209{
247{
210 return m_workspaces.data();
248 return m_workspaces.data();
211}
249}
212
250
213−Workspace *Screen::currentWorkspace() const
251+Workspace *ConcreteScreen::currentWorkspace() const
214{
252{
215 return m_currentWorspace.data();
253 return m_currentWorspace.data();
216}
254}
217
255
218−void Screen::setCurrentWorkspace(Workspace *workspace)
256+void ConcreteScreen::setCurrentWorkspace(Workspace *workspace)
219{
257{
220 if (m_currentWorspace != workspace) {
258 if (m_currentWorspace != workspace) {
221 m_currentWorspace = workspace;
259 m_currentWorspace = workspace;
@@ -223,15 +261,15 @@ void Screen::setCurrentWorkspace(Workspace *workspace)
223 }
261 }
224}
262}
225
263
226−ScreenProxy::ScreenProxy(ScreenInterface *const screen)
264+ProxyScreen::ProxyScreen(Screen *const screen)
227− : m_workspaces(new WorkspaceModelProxy(screen->workspaces()))
265+ : m_workspaces(new ProxyWorkspaceModel(screen->workspaces()))
228 , m_original(screen)
266 , m_original(screen)
229{
267{
230 connectToScreen(screen);
268 connectToScreen(screen);
231
269
232 auto updateCurrentWorkspaceFn = [this](Workspace* realWorkspace) {
270 auto updateCurrentWorkspaceFn = [this](Workspace* realWorkspace) {
233 Q_FOREACH(Workspace* workspace, m_workspaces->list()) {
271 Q_FOREACH(Workspace* workspace, m_workspaces->list()) {
234− auto p = qobject_cast<WorkspaceProxy*>(workspace);
272+ auto p = qobject_cast<ProxyWorkspace*>(workspace);
235 if (p && p->proxyObject() == realWorkspace) {
273 if (p && p->proxyObject() == realWorkspace) {
236 if (m_currentWorspace != p) {
274 if (m_currentWorspace != p) {
237 m_currentWorspace = p;
275 m_currentWorspace = p;
@@ -240,29 +278,29 @@ ScreenProxy::ScreenProxy(ScreenInterface *const screen)
240 }
278 }
241 }
279 }
242 };
280 };
243− connect(screen, &ScreenInterface::currentWorkspaceChanged, this, updateCurrentWorkspaceFn);
281+ connect(screen, &Screen::currentWorkspaceChanged, this, updateCurrentWorkspaceFn);
244 updateCurrentWorkspaceFn(screen->currentWorkspace());
282 updateCurrentWorkspaceFn(screen->currentWorkspace());
245}
283}
246
284
247−WorkspaceModel *ScreenProxy::workspaces() const
285+WorkspaceModel *ProxyScreen::workspaces() const
248{
286{
249 return m_workspaces.data();
287 return m_workspaces.data();
250}
288}
251
289
252−Workspace *ScreenProxy::currentWorkspace() const
290+Workspace *ProxyScreen::currentWorkspace() const
253{
291{
254 return m_currentWorspace.data();
292 return m_currentWorspace.data();
255}
293}
256
294
257−void ScreenProxy::setCurrentWorkspace(Workspace *workspace)
295+void ProxyScreen::setCurrentWorkspace(Workspace *workspace)
258{
296{
259− auto p = qobject_cast<WorkspaceProxy*>(workspace);
297+ auto p = qobject_cast<ProxyWorkspace*>(workspace);
260 if (p) {
298 if (p) {
261 m_original->setCurrentWorkspace(p->proxyObject());
299 m_original->setCurrentWorkspace(p->proxyObject());
262 }
300 }
263}
301}
264
302
265−void ScreenProxy::addWorkspace()
303+void ProxyScreen::addWorkspace()
266{
304{
267− (new WorkspaceProxy(WorkspaceManager::instance()->createWorkspace()))->assign(workspaces());
305+ (new ProxyWorkspace(WorkspaceManager::instance()->createWorkspace()))->assign(workspaces());
268}
306}
plugins/WindowManager/Screen.h+16−11
@@ -7,10 +7,10 @@
7
7
8#include "WorkspaceModel.h"
8#include "WorkspaceModel.h"
9
9
10−class ScreenProxy;
10+class ProxyScreen;
11class ScreenAttached;
11class ScreenAttached;
12
12
13−class ScreenInterface: public QObject
13+class Screen: public QObject
14{
14{
15 Q_OBJECT
15 Q_OBJECT
16
16
@@ -27,6 +27,7 @@ class ScreenInterface: public QObject
27 Q_PROPERTY(uint currentModeIndex READ currentModeIndex NOTIFY currentModeIndexChanged)
27 Q_PROPERTY(uint currentModeIndex READ currentModeIndex NOTIFY currentModeIndexChanged)
28 Q_PROPERTY(QQmlListProperty<qtmir::ScreenMode> availableModes READ availableModes NOTIFY availableModesChanged)
28 Q_PROPERTY(QQmlListProperty<qtmir::ScreenMode> availableModes READ availableModes NOTIFY availableModesChanged)
29 Q_PROPERTY(QSizeF physicalSize READ physicalSize NOTIFY physicalSizeChanged)
29 Q_PROPERTY(QSizeF physicalSize READ physicalSize NOTIFY physicalSizeChanged)
30+ Q_PROPERTY(QString outputTypeName READ outputTypeName NOTIFY outputTypeChanged)
30 Q_PROPERTY(WorkspaceModel* workspaces READ workspaces CONSTANT)
31 Q_PROPERTY(WorkspaceModel* workspaces READ workspaces CONSTANT)
31 Q_PROPERTY(Workspace* currentWorkspace READ currentWorkspace WRITE setCurrentWorkspace NOTIFY currentWorkspaceChanged)
32 Q_PROPERTY(Workspace* currentWorkspace READ currentWorkspace WRITE setCurrentWorkspace NOTIFY currentWorkspaceChanged)
32public:
33public:
@@ -46,6 +47,8 @@ public:
46 bool isActive() const;
47 bool isActive() const;
47 void setActive(bool active);
48 void setActive(bool active);
48 QScreen* qscreen() const;
49 QScreen* qscreen() const;
50+ QString outputTypeName() const;
51+
49 qtmir::ScreenConfiguration *beginConfiguration() const;
52 qtmir::ScreenConfiguration *beginConfiguration() const;
50 bool applyConfiguration(qtmir::ScreenConfiguration *configuration);
53 bool applyConfiguration(qtmir::ScreenConfiguration *configuration);
51
54
@@ -53,7 +56,8 @@ public:
53 virtual Workspace *currentWorkspace() const = 0;
56 virtual Workspace *currentWorkspace() const = 0;
54 virtual void setCurrentWorkspace(Workspace* workspace) = 0;
57 virtual void setCurrentWorkspace(Workspace* workspace) = 0;
55
58
56− void sync(ScreenInterface* proxy);
59+ void setSyncing(bool);
60+ void sync(Screen* proxy);
57
61
58 qtmir::Screen* wrapped() const { return m_wrapped; }
62 qtmir::Screen* wrapped() const { return m_wrapped; }
59
63
@@ -64,6 +68,7 @@ Q_SIGNALS:
64 void usedChanged();
68 void usedChanged();
65 void nameChanged();
69 void nameChanged();
66 void outputTypeChanged();
70 void outputTypeChanged();
71+ void outputTypeNameChanged();
67 void scaleChanged();
72 void scaleChanged();
68 void formFactorChanged();
73 void formFactorChanged();
69 void powerModeChanged();
74 void powerModeChanged();
@@ -76,21 +81,21 @@ Q_SIGNALS:
76 void currentWorkspaceChanged(Workspace*);
81 void currentWorkspaceChanged(Workspace*);
77
82
78protected:
83protected:
79− ScreenInterface(QObject* parent = 0);
84+ Screen(QObject* parent = 0);
80
85
81 void connectToScreen(qtmir::Screen* screen);
86 void connectToScreen(qtmir::Screen* screen);
82− void connectToScreen(ScreenInterface* screen);
87+ void connectToScreen(Screen* screen);
83
88
84protected:
89protected:
85 QPointer<qtmir::Screen> m_wrapped;
90 QPointer<qtmir::Screen> m_wrapped;
86};
91};
87
92
88
93
89−class Screen : public ScreenInterface
94+class ConcreteScreen : public Screen
90{
95{
91 Q_OBJECT
96 Q_OBJECT
92public:
97public:
93− explicit Screen(qtmir::Screen*const wrapped);
98+ explicit ConcreteScreen(qtmir::Screen*const wrapped);
94
99
95 // From qtmir::Screen
100 // From qtmir::Screen
96 WorkspaceModel* workspaces() const override;
101 WorkspaceModel* workspaces() const override;
@@ -106,25 +111,25 @@ protected:
106 QPointer<Workspace> m_currentWorspace;
111 QPointer<Workspace> m_currentWorspace;
107};
112};
108
113
109−class ScreenProxy : public ScreenInterface
114+class ProxyScreen : public Screen
110{
115{
111 Q_OBJECT
116 Q_OBJECT
112public:
117public:
113− explicit ScreenProxy(ScreenInterface*const screen);
118+ explicit ProxyScreen(Screen*const screen);
114
119
115 // From qtmir::Screen
120 // From qtmir::Screen
116 WorkspaceModel* workspaces() const override;
121 WorkspaceModel* workspaces() const override;
117 Workspace *currentWorkspace() const override;
122 Workspace *currentWorkspace() const override;
118 void setCurrentWorkspace(Workspace* workspace) override;
123 void setCurrentWorkspace(Workspace* workspace) override;
119
124
120− ScreenInterface* proxyObject() const { return m_original.data(); }
125+ Screen* proxyObject() const { return m_original.data(); }
121
126
122public Q_SLOTS:
127public Q_SLOTS:
123 void addWorkspace();
128 void addWorkspace();
124
129
125private:
130private:
126 const QScopedPointer<WorkspaceModel> m_workspaces;
131 const QScopedPointer<WorkspaceModel> m_workspaces;
127− const QPointer<ScreenInterface> m_original;
132+ const QPointer<Screen> m_original;
128 QPointer<Workspace> m_currentWorspace;
133 QPointer<Workspace> m_currentWorspace;
129};
134};
130
135
plugins/WindowManager/ScreenAttached.cpp+7−5
@@ -22,7 +22,7 @@
22#include <QScreen>
22#include <QScreen>
23
23
24ScreenAttached::ScreenAttached(QObject *owner)
24ScreenAttached::ScreenAttached(QObject *owner)
25− : ScreenInterface(owner)
25+ : Screen(owner)
26 , m_window(nullptr)
26 , m_window(nullptr)
27{
27{
28 if (auto item = qobject_cast<QQuickItem*>(owner)) {
28 if (auto item = qobject_cast<QQuickItem*>(owner)) {
@@ -75,8 +75,8 @@ void ScreenAttached::screenChanged(QScreen *qscreen)
75{
75{
76 // Find a screen that matches.
76 // Find a screen that matches.
77 // Should only get here in mocks if we don't have a ScreenWindow
77 // Should only get here in mocks if we don't have a ScreenWindow
78− ScreenInterface* screen{nullptr};
78+ Screen* screen{nullptr};
79− Q_FOREACH(auto s, Screens::self()->list()) {
79+ Q_FOREACH(auto s, ConcreteScreens::self()->list()) {
80 if (s->qscreen() == qscreen) {
80 if (s->qscreen() == qscreen) {
81 screen = s;
81 screen = s;
82 }
82 }
@@ -84,11 +84,11 @@ void ScreenAttached::screenChanged(QScreen *qscreen)
84 screenChanged2(screen);
84 screenChanged2(screen);
85}
85}
86
86
87−void ScreenAttached::screenChanged2(ScreenInterface* screen)
87+void ScreenAttached::screenChanged2(Screen* screen)
88{
88{
89 if (screen == m_screen) return;
89 if (screen == m_screen) return;
90
90
91− ScreenInterface* oldScreen = m_screen;
91+ Screen* oldScreen = m_screen;
92 m_screen = screen;
92 m_screen = screen;
93
93
94 if (oldScreen)
94 if (oldScreen)
@@ -119,6 +119,8 @@ void ScreenAttached::screenChanged2(ScreenInterface* screen)
119 Q_EMIT currentModeIndexChanged();
119 Q_EMIT currentModeIndexChanged();
120 if (!oldScreen || screen->physicalSize() != oldScreen->physicalSize())
120 if (!oldScreen || screen->physicalSize() != oldScreen->physicalSize())
121 Q_EMIT physicalSizeChanged();
121 Q_EMIT physicalSizeChanged();
122+ if (!oldScreen || screen->currentWorkspace() != oldScreen->currentWorkspace())
123+ Q_EMIT currentWorkspaceChanged(currentWorkspace());
122
124
123 if (oldScreen) {
125 if (oldScreen) {
124 QVector<qtmir::ScreenMode*> oldModes;
126 QVector<qtmir::ScreenMode*> oldModes;
plugins/WindowManager/ScreenAttached.h+3−3
@@ -23,7 +23,7 @@
23
23
24class QQuickWindow;
24class QQuickWindow;
25
25
26−class ScreenAttached : public ScreenInterface
26+class ScreenAttached : public Screen
27{
27{
28 Q_OBJECT
28 Q_OBJECT
29public:
29public:
@@ -36,10 +36,10 @@ public:
36private Q_SLOTS:
36private Q_SLOTS:
37 void windowChanged(QQuickWindow*);
37 void windowChanged(QQuickWindow*);
38 void screenChanged(QScreen*);
38 void screenChanged(QScreen*);
39− void screenChanged2(ScreenInterface* screen);
39+ void screenChanged2(Screen* screen);
40
40
41private:
41private:
42− QPointer<ScreenInterface> m_screen;
42+ QPointer<Screen> m_screen;
43 QQuickWindow* m_window;
43 QQuickWindow* m_window;
44};
44};
45
45
plugins/WindowManager/ScreenWindow.cpp+2−2
@@ -30,12 +30,12 @@ ScreenWindow::~ScreenWindow()
30{
30{
31}
31}
32
32
33−Screen *ScreenWindow::screenWrapper() const
33+ConcreteScreen *ScreenWindow::screenWrapper() const
34{
34{
35 return m_screen.data();
35 return m_screen.data();
36}
36}
37
37
38−void ScreenWindow::setScreenWrapper(Screen *screen)
38+void ScreenWindow::setScreenWrapper(ConcreteScreen *screen)
39{
39{
40 if (m_screen != screen) {
40 if (m_screen != screen) {
41 m_screen = screen;
41 m_screen = screen;
plugins/WindowManager/ScreenWindow.h+5−5
@@ -30,20 +30,20 @@ class ScreenAdapter;
30class ScreenWindow : public QQuickWindow
30class ScreenWindow : public QQuickWindow
31{
31{
32 Q_OBJECT
32 Q_OBJECT
33− Q_PROPERTY(Screen *screen READ screenWrapper WRITE setScreenWrapper NOTIFY screenWrapperChanged)
33+ Q_PROPERTY(ConcreteScreen *screen READ screenWrapper WRITE setScreenWrapper NOTIFY screenWrapperChanged)
34 Q_PROPERTY(int winId READ winId CONSTANT)
34 Q_PROPERTY(int winId READ winId CONSTANT)
35public:
35public:
36 explicit ScreenWindow(QQuickWindow *parent = 0);
36 explicit ScreenWindow(QQuickWindow *parent = 0);
37 ~ScreenWindow();
37 ~ScreenWindow();
38
38
39− Screen *screenWrapper() const;
39+ ConcreteScreen *screenWrapper() const;
40− void setScreenWrapper(Screen *screen);
40+ void setScreenWrapper(ConcreteScreen *screen);
41
41
42Q_SIGNALS:
42Q_SIGNALS:
43− void screenWrapperChanged(Screen* screen);
43+ void screenWrapperChanged(ConcreteScreen* screen);
44
44
45private:
45private:
46− QPointer<Screen> m_screen;
46+ QPointer<ConcreteScreen> m_screen;
47};
47};
48
48
49#endif // UNITY_SCREENWINDOW_H
49#endif // UNITY_SCREENWINDOW_H
plugins/WindowManager/Screens.cpp+55−49
@@ -27,21 +27,11 @@
27#include <QScreen>
27#include <QScreen>
28#include <QWindow>
28#include <QWindow>
29
29
30−Screens* Screens::m_self{nullptr};
30+ConcreteScreens* ConcreteScreens::m_self{nullptr};
31
31
32Screens::Screens(const QSharedPointer<qtmir::Screens>& model)
32Screens::Screens(const QSharedPointer<qtmir::Screens>& model)
33 : m_wrapped(model)
33 : m_wrapped(model)
34{
34{
35− m_self = this;
36− connect(m_wrapped.data(), &qtmir::Screens::screenAdded, this, &Screens::onScreenAdded);
37− connect(m_wrapped.data(), &qtmir::Screens::screenRemoved, this, &Screens::onScreenRemoved);
38− connect(m_wrapped.data(), &qtmir::Screens::activeScreenChanged, this, &Screens::activeScreenChanged);
39−
40− Q_FOREACH(qtmir::Screen* screen, m_wrapped->screens()) {
41− auto screenWrapper(new Screen(screen));
42− QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
43− m_screens.push_back(screenWrapper);
44− }
45}
35}
46
36
47Screens::~Screens()
37Screens::~Screens()
@@ -50,12 +40,6 @@ Screens::~Screens()
50 m_screens.clear();
40 m_screens.clear();
51}
41}
52
42
53−Screens::Screens(const Screens &other)
54− : QAbstractListModel(nullptr)
55− , m_wrapped(other.m_wrapped)
56−{
57−}
58−
59QHash<int, QByteArray> Screens::roleNames() const
43QHash<int, QByteArray> Screens::roleNames() const
60{
44{
61 QHash<int, QByteArray> roles;
45 QHash<int, QByteArray> roles;
@@ -95,47 +79,68 @@ QVariant Screens::activeScreen() const
95 return QVariant();
79 return QVariant();
96}
80}
97
81
98−Screens *Screens::self()
82+void Screens::activateScreen(const QVariant& vindex)
99{
83{
100− return Screens::m_self;
84+ bool ok = false;
85+ int index = vindex.toInt(&ok);
86+ if (!ok || index < 0 || m_screens.count() <= index) return;
87+
88+ auto screen = m_screens.at(index);
89+ screen->setActive(true);
101}
90}
102
91
103−ScreensProxy *Screens::createProxy()
92+
93+ConcreteScreens::ConcreteScreens(const QSharedPointer<qtmir::Screens> &model)
94+ : Screens(model)
104{
95{
105− return new ScreensProxy(this);
96+ m_self = this;
97+ connect(m_wrapped.data(), &qtmir::Screens::screenAdded, this, &ConcreteScreens::onScreenAdded);
98+ connect(m_wrapped.data(), &qtmir::Screens::screenRemoved, this, &ConcreteScreens::onScreenRemoved);
99+ connect(m_wrapped.data(), &qtmir::Screens::activeScreenChanged, this, &ConcreteScreens::activeScreenChanged);
100+
101+ Q_FOREACH(qtmir::Screen* screen, m_wrapped->screens()) {
102+ auto screenWrapper(new ConcreteScreen(screen));
103+ QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
104+ m_screens.push_back(screenWrapper);
105+ }
106+}
107+
108+ConcreteScreens *ConcreteScreens::self()
109+{
110+ return ConcreteScreens::m_self;
106}
111}
107
112
113+ProxyScreens *ConcreteScreens::createProxy()
114+{
115+ return new ProxyScreens(this);
116+}
117+
108−void Screens::sync(Screens *proxy)
118+void ConcreteScreens::sync(Screens *proxy)
109{
119{
110 if (!proxy) return;
120 if (!proxy) return;
111
121
122+ for (auto screen : m_screens) {
123+ screen->setSyncing(true);
124+ }
125+
112 const auto& proxyList = proxy->list();
126 const auto& proxyList = proxy->list();
113 for (int i = 0; i < m_screens.count() && i < proxyList.count(); ++i) {
127 for (int i = 0; i < m_screens.count() && i < proxyList.count(); ++i) {
114 m_screens[i]->sync(proxyList[i]);
128 m_screens[i]->sync(proxyList[i]);
115 }
129 }
116
130
117− // need to clean up all the workspaces we unassigned.
131+ for (auto screen : m_screens) {
118− WorkspaceManager::instance()->destroyFloatingWorkspaces();
132+ screen->setSyncing(false);
119−}
133+ }
120−
121−void Screens::activateScreen(const QVariant& vindex)
122−{
123− bool ok = false;
124− int index = vindex.toInt(&ok);
125− if (!ok || index < 0 || m_screens.count() <= index) return;
126−
127− auto screen = m_screens.at(index);
128− screen->setActive(true);
129}
134}
130
135
131−void Screens::onScreenAdded(qtmir::Screen *added)
136+void ConcreteScreens::onScreenAdded(qtmir::Screen *added)
132{
137{
133 Q_FOREACH(auto screenWrapper, m_screens) {
138 Q_FOREACH(auto screenWrapper, m_screens) {
134 if (screenWrapper->wrapped() == added) return;
139 if (screenWrapper->wrapped() == added) return;
135 }
140 }
136
141
137 beginInsertRows(QModelIndex(), count(), count());
142 beginInsertRows(QModelIndex(), count(), count());
138− auto screenWrapper(new Screen(added));
143+ auto screenWrapper(new ConcreteScreen(added));
139 QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
144 QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
140 m_screens.push_back(screenWrapper);
145 m_screens.push_back(screenWrapper);
141 endInsertRows();
146 endInsertRows();
@@ -143,10 +148,10 @@ void Screens::onScreenAdded(qtmir::Screen *added)
143 Q_EMIT countChanged();
148 Q_EMIT countChanged();
144}
149}
145
150
146−void Screens::onScreenRemoved(qtmir::Screen *removed)
151+void ConcreteScreens::onScreenRemoved(qtmir::Screen *removed)
147{
152{
148 int index = 0;
153 int index = 0;
149− QMutableVectorIterator<ScreenInterface*> iter(m_screens);
154+ QMutableVectorIterator<Screen*> iter(m_screens);
150 while(iter.hasNext()) {
155 while(iter.hasNext()) {
151 auto screenWrapper = iter.next();
156 auto screenWrapper = iter.next();
152 if (screenWrapper->wrapped() == removed) {
157 if (screenWrapper->wrapped() == removed) {
@@ -165,18 +170,19 @@ void Screens::onScreenRemoved(qtmir::Screen *removed)
165 }
170 }
166}
171}
167
172
173+
168−ScreensProxy::ScreensProxy(Screens * const screens)
174+ProxyScreens::ProxyScreens(Screens * const screens)
169− : Screens(*screens)
175+ : Screens(screens->m_wrapped)
170 , m_original(screens)
176 , m_original(screens)
171{
177{
172− connect(screens, &Screens::screenAdded, this, [this](ScreenInterface *added) {
178+ connect(screens, &Screens::screenAdded, this, [this](Screen *added) {
173 Q_FOREACH(auto screen, m_screens) {
179 Q_FOREACH(auto screen, m_screens) {
174− auto proxy = static_cast<ScreenProxy*>(screen);
180+ auto proxy = static_cast<ProxyScreen*>(screen);
175 if (proxy->proxyObject() == added) return;
181 if (proxy->proxyObject() == added) return;
176 }
182 }
177
183
178 beginInsertRows(QModelIndex(), count(), count());
184 beginInsertRows(QModelIndex(), count(), count());
179− auto screenWrapper(new ScreenProxy(added));
185+ auto screenWrapper(new ProxyScreen(added));
180 QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
186 QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
181 m_screens.push_back(screenWrapper);
187 m_screens.push_back(screenWrapper);
182 endInsertRows();
188 endInsertRows();
@@ -184,11 +190,11 @@ ScreensProxy::ScreensProxy(Screens * const screens)
184 Q_EMIT countChanged();
190 Q_EMIT countChanged();
185 });
191 });
186
192
187− connect(screens, &Screens::screenRemoved, this, [this](ScreenInterface *removed) {
193+ connect(screens, &Screens::screenRemoved, this, [this](Screen *removed) {
188 int index = 0;
194 int index = 0;
189− QMutableVectorIterator<ScreenInterface*> iter(m_screens);
195+ QMutableVectorIterator<Screen*> iter(m_screens);
190 while(iter.hasNext()) {
196 while(iter.hasNext()) {
191− auto proxy = static_cast<ScreenProxy*>(iter.next());
197+ auto proxy = static_cast<ProxyScreen*>(iter.next());
192 if (proxy->proxyObject() == removed) {
198 if (proxy->proxyObject() == removed) {
193
199
194 beginRemoveRows(QModelIndex(), index, index);
200 beginRemoveRows(QModelIndex(), index, index);
@@ -205,9 +211,9 @@ ScreensProxy::ScreensProxy(Screens * const screens)
205 }
211 }
206 });
212 });
207
213
208− Q_FOREACH(ScreenInterface* screen, screens->list()) {
214+ Q_FOREACH(Screen* screen, screens->list()) {
209− auto screenWrapper(new ScreenProxy(screen));
215+ auto screenWrapper(new ProxyScreen(screen));
210 QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
216 QQmlEngine::setObjectOwnership(screenWrapper, QQmlEngine::CppOwnership);
211− m_screens.push_back(new ScreenProxy(screen));
217+ m_screens.push_back(new ProxyScreen(screen));
212 }
218 }
213}
219}
plugins/WindowManager/Screens.h+32−19
@@ -27,8 +27,8 @@ class Screen;
27class Screens;
27class Screens;
28}
28}
29
29
30−class ScreenInterface;
30+class Screen;
31−class ScreensProxy;
31+class ProxyScreens;
32
32
33class Screens : public QAbstractListModel
33class Screens : public QAbstractListModel
34{
34{
@@ -41,12 +41,8 @@ public:
41 ScreenRole = Qt::UserRole + 1
41 ScreenRole = Qt::UserRole + 1
42 };
42 };
43
43
44− explicit Screens(const QSharedPointer<qtmir::Screens>& model);
45 ~Screens();
44 ~Screens();
46
45
47− Q_INVOKABLE ScreensProxy *createProxy();
48− Q_INVOKABLE void sync(Screens *proxy);
49−
50 /* QAbstractItemModel */
46 /* QAbstractItemModel */
51 QHash<int, QByteArray> roleNames() const override;
47 QHash<int, QByteArray> roleNames() const override;
52 QVariant data(const QModelIndex &index, int role = ScreenRole) const override;
48 QVariant data(const QModelIndex &index, int role = ScreenRole) const override;
@@ -55,9 +51,9 @@ public:
55 int count() const;
51 int count() const;
56 QVariant activeScreen() const;
52 QVariant activeScreen() const;
57
53
58− const QVector<ScreenInterface*>& list() const { return m_screens; }
54+ bool isSyncing() const { return m_syncing; }
59
55
60− static Screens *self();
56+ const QVector<Screen*>& list() const { return m_screens; }
61
57
62public Q_SLOTS:
58public Q_SLOTS:
63 void activateScreen(const QVariant& index);
59 void activateScreen(const QVariant& index);
@@ -66,25 +62,42 @@ Q_SIGNALS:
66 void countChanged();
62 void countChanged();
67 void activeScreenChanged();
63 void activeScreenChanged();
68
64
69− void screenAdded(ScreenInterface* screen);
65+ void screenAdded(Screen* screen);
70− void screenRemoved(ScreenInterface* screen);
66+ void screenRemoved(Screen* screen);
67+
68+protected:
69+ Screens(const QSharedPointer<qtmir::Screens>& model);
70+
71+ QVector<Screen*> m_screens;
72+ const QSharedPointer<qtmir::Screens> m_wrapped;
73+ bool m_syncing;
74+
75+ friend class ProxyScreens;
76+};
77+
78+class ConcreteScreens : public Screens
79+{
80+ Q_OBJECT
81+public:
82+ explicit ConcreteScreens(const QSharedPointer<qtmir::Screens>& model);
83+
84+ Q_INVOKABLE ProxyScreens *createProxy();
85+ Q_INVOKABLE void sync(Screens *proxy);
71
86
87+ static ConcreteScreens *self();
88+
72−private Q_SLOTS:
89+protected Q_SLOTS:
73 void onScreenAdded(qtmir::Screen *screen);
90 void onScreenAdded(qtmir::Screen *screen);
74 void onScreenRemoved(qtmir::Screen *screen);
91 void onScreenRemoved(qtmir::Screen *screen);
75
92
76−protected:
93+private:
77− Screens(const Screens& other);
78−
79− QVector<ScreenInterface*> m_screens;
80− QSharedPointer<qtmir::Screens> m_wrapped;
81− static Screens* m_self;
94+ static ConcreteScreens* m_self;
82};
95};
83
96
84−class ScreensProxy : public Screens
97+class ProxyScreens : public Screens
85{
98{
86public:
99public:
87− ScreensProxy(Screens*const screens);
100+ explicit ProxyScreens(Screens*const screens);
88
101
89private:
102private:
90 const QPointer<Screens> m_original;
103 const QPointer<Screens> m_original;
plugins/WindowManager/TopLevelWindowModel.cpp+5
@@ -50,6 +50,10 @@ TopLevelWindowModel::TopLevelWindowModel(Workspace* workspace)
50 setSurfaceManager(WindowManagerObjects::instance()->surfaceManager());
50 setSurfaceManager(WindowManagerObjects::instance()->surfaceManager());
51}
51}
52
52
53+TopLevelWindowModel::~TopLevelWindowModel()
54+{
55+}
56+
53void TopLevelWindowModel::setApplicationManager(unityapi::ApplicationManagerInterface* value)
57void TopLevelWindowModel::setApplicationManager(unityapi::ApplicationManagerInterface* value)
54{
58{
55 if (m_applicationManager == value) {
59 if (m_applicationManager == value) {
@@ -398,6 +402,7 @@ void TopLevelWindowModel::onSurfacesAddedToWorkspace(const std::shared_ptr<miral
398void TopLevelWindowModel::onSurfacesAboutToBeRemovedFromWorkspace(const std::shared_ptr<miral::Workspace> &workspace,
402void TopLevelWindowModel::onSurfacesAboutToBeRemovedFromWorkspace(const std::shared_ptr<miral::Workspace> &workspace,
399 const QVector<unity::shell::application::MirSurfaceInterface *> surfaces)
403 const QVector<unity::shell::application::MirSurfaceInterface *> surfaces)
400{
404{
405+ qDebug() << "SURFACE ABOUT TO BE REMOVED" << this;
401 if (!m_workspace || workspace != m_workspace->workspace()) return;
406 if (!m_workspace || workspace != m_workspace->workspace()) return;
402
407
403 int start = -1;
408 int start = -1;
plugins/WindowManager/TopLevelWindowModel.h+1
@@ -94,6 +94,7 @@ public:
94 };
94 };
95
95
96 TopLevelWindowModel(Workspace* workspace);
96 TopLevelWindowModel(Workspace* workspace);
97+ ~TopLevelWindowModel();
97
98
98 // From QAbstractItemModel
99 // From QAbstractItemModel
99 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
100 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
plugins/WindowManager/WindowManagerPlugin.cpp+16−5
@@ -30,6 +30,8 @@
30#include <QtQml>
30#include <QtQml>
31#include <qtmir/qtmir.h>
31#include <qtmir/qtmir.h>
32
32
33+namespace {
34+
33static const QString notInstantiatable = QStringLiteral("Not instantiatable");
35static const QString notInstantiatable = QStringLiteral("Not instantiatable");
34
36
35static QObject *workspace_manager(QQmlEngine *engine, QJSEngine *scriptEngine)
37static QObject *workspace_manager(QQmlEngine *engine, QJSEngine *scriptEngine)
@@ -41,7 +43,7 @@ static QObject *workspace_manager(QQmlEngine *engine, QJSEngine *scriptEngine)
41QObject* screensSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
43QObject* screensSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
42 Q_UNUSED(engine);
44 Q_UNUSED(engine);
43 Q_UNUSED(scriptEngine);
45 Q_UNUSED(scriptEngine);
44− return new Screens(qtmir::get_screen_model());
46+ return ConcreteScreens::self();
45}
47}
46QObject* objectsSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
48QObject* objectsSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
47 Q_UNUSED(engine);
49 Q_UNUSED(engine);
@@ -49,17 +51,18 @@ QObject* objectsSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
49 return WindowManagerObjects::instance();
51 return WindowManagerObjects::instance();
50}
52}
51
53
54+} // namspace
55+
52void WindowManagerPlugin::registerTypes(const char *uri)
56void WindowManagerPlugin::registerTypes(const char *uri)
53{
57{
54 qmlRegisterSingletonType<WorkspaceManager>(uri, 1, 0, "WorkspaceManager", workspace_manager);
58 qmlRegisterSingletonType<WorkspaceManager>(uri, 1, 0, "WorkspaceManager", workspace_manager);
55 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", notInstantiatable);
59 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", notInstantiatable);
56− qmlRegisterSingletonType<Screens>(uri, 1, 0, "Screens", screensSingleton);
60+ qmlRegisterSingletonType<ConcreteScreens>(uri, 1, 0, "Screens", screensSingleton);
57 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", notInstantiatable);
61 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", notInstantiatable);
58− qmlRegisterUncreatableType<Workspace>(uri, 1, 0, "Workspace", notInstantiatable);
59 qmlRegisterSingletonType<WindowManagerObjects>(uri, 1, 0, "WindowManagerObjects", objectsSingleton);
62 qmlRegisterSingletonType<WindowManagerObjects>(uri, 1, 0, "WindowManagerObjects", objectsSingleton);
60
63
61− qRegisterMetaType<Screen*>("Screen*");
64+ qRegisterMetaType<ConcreteScreen*>("ConcreteScreen*");
62− qRegisterMetaType<ScreensProxy*>("ScreensProxy*");
65+ qRegisterMetaType<ProxyScreens*>("ProxyScreens*");
63 qRegisterMetaType<Workspace*>("Workspace*");
66 qRegisterMetaType<Workspace*>("Workspace*");
64 qRegisterMetaType<TopLevelWindowModel*>("TopLevelWindowModel*");
67 qRegisterMetaType<TopLevelWindowModel*>("TopLevelWindowModel*");
65
68
@@ -71,3 +74,11 @@ void WindowManagerPlugin::registerTypes(const char *uri)
71
74
72 qmlRegisterUncreatableType<WMScreen>(uri, 1, 0, "WMScreen", notInstantiatable);
75 qmlRegisterUncreatableType<WMScreen>(uri, 1, 0, "WMScreen", notInstantiatable);
73}
76}
77+
78+void WindowManagerPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
79+{
80+ WindowManagerPlugin::initializeEngine(engine, uri);
81+
82+ // Create Screens
83+ new ConcreteScreens(qtmir::get_screen_model());
84+}
plugins/WindowManager/WindowManagerPlugin.h+1
@@ -27,6 +27,7 @@ class WindowManagerPlugin : public QQmlExtensionPlugin
27
27
28public:
28public:
29 void registerTypes(const char *uri) override;
29 void registerTypes(const char *uri) override;
30+ void initializeEngine(QQmlEngine *engine, const char *uri) override;
30};
31};
31
32
32#endif // WINDOWMANAGER_PLUGIN_H
33#endif // WINDOWMANAGER_PLUGIN_H
plugins/WindowManager/Workspace.cpp+48−35
@@ -27,37 +27,18 @@ Workspace::Workspace(QObject *parent)
27 : QObject(parent)
27 : QObject(parent)
28 , m_workspace(WMPolicyInterface::instance()->createWorkspace())
28 , m_workspace(WMPolicyInterface::instance()->createWorkspace())
29 , m_model(nullptr)
29 , m_model(nullptr)
30− , m_windowModel(new TopLevelWindowModel(this))
31− , m_active(false)
32{
30{
33 setObjectName((QString("Wks%1").arg(nextWorkspace++)));
31 setObjectName((QString("Wks%1").arg(nextWorkspace++)));
34−
35− connect(WorkspaceManager::instance(), &WorkspaceManager::activeWorkspaceChanged, this, [this]() {
36− bool newActive = WorkspaceManager::instance()->activeWorkspace() == this;
37− if (newActive != m_active) {
38− m_active = newActive;
39− Q_EMIT activeChanged(m_active);
40−
41− if (m_active) {
42− WMPolicyInterface::instance()->setActiveWorkspace(m_workspace);
43− }
44− }
45− });
46}
32}
47
33
48Workspace::Workspace(const Workspace &other)
34Workspace::Workspace(const Workspace &other)
49 : QObject(nullptr)
35 : QObject(nullptr)
50 , m_workspace(other.m_workspace)
36 , m_workspace(other.m_workspace)
51 , m_model(nullptr)
37 , m_model(nullptr)
52− , m_windowModel(other.m_windowModel)
53− , m_active(other.m_active)
54{
38{
55 setObjectName(other.objectName());
39 setObjectName(other.objectName());
56
40
57− connect(&other, &Workspace::activeChanged, this, [this](bool active) {
41+ connect(&other, &Workspace::activeChanged, this, &Workspace::activeChanged);
58− m_active = active;
59− Q_EMIT activeChanged(m_active);
60− });
61}
42}
62
43
63Workspace::~Workspace()
44Workspace::~Workspace()
@@ -67,11 +48,6 @@ Workspace::~Workspace()
67 }
48 }
68}
49}
69
50
70−void Workspace::activate()
71−{
72− WorkspaceManager::instance()->setActiveWorkspace(this);
73−}
74−
75void Workspace::assign(WorkspaceModel *model, const QVariant& vIndex)
51void Workspace::assign(WorkspaceModel *model, const QVariant& vIndex)
76{
52{
77 if (m_model == model) return;
53 if (m_model == model) return;
@@ -105,39 +81,76 @@ void Workspace::unassign()
105 assign(nullptr);
81 assign(nullptr);
106}
82}
107
83
108−void Workspace::release()
84+bool Workspace::isAssigned() const
85+{
86+ return m_model != nullptr;
87+}
88+
89+
90+ConcreteWorkspace::ConcreteWorkspace(QObject *parent)
91+ : Workspace(parent)
92+ , m_active(false)
93+ , m_windowModel(new TopLevelWindowModel(this))
94+{
95+ connect(WorkspaceManager::instance(), &WorkspaceManager::activeWorkspaceChanged, this, [this](Workspace* activeWorkspace) {
96+ bool newActive = activeWorkspace == this;
97+ if (newActive != m_active) {
98+ m_active = newActive;
99+ Q_EMIT activeChanged(m_active);
100+
101+ if (m_active) {
102+ WMPolicyInterface::instance()->setActiveWorkspace(m_workspace);
103+ }
104+ }
105+ });
106+}
107+
108+ConcreteWorkspace::~ConcreteWorkspace()
109{
109{
110+ WorkspaceManager::instance()->destroyWorkspace(this);
110 WMPolicyInterface::instance()->releaseWorkspace(m_workspace);
111 WMPolicyInterface::instance()->releaseWorkspace(m_workspace);
111− deleteLater();
112}
112}
113
113
114−bool Workspace::isAssigned() const
114+TopLevelWindowModel *ConcreteWorkspace::windowModel() const
115{
115{
116− return m_model != nullptr;
116+ return m_windowModel.data();
117+}
118+
119+void ConcreteWorkspace::activate()
120+{
121+ WorkspaceManager::instance()->setActiveWorkspace(this);
117}
122}
118
123
124+
119−WorkspaceProxy::WorkspaceProxy(Workspace * const workspace)
125+ProxyWorkspace::ProxyWorkspace(Workspace * const workspace)
120 : Workspace(*workspace)
126 : Workspace(*workspace)
121 , m_original(workspace)
127 , m_original(workspace)
122{
128{
123}
129}
124
130
125−void WorkspaceProxy::assign(WorkspaceModel *model, const QVariant &index)
131+void ProxyWorkspace::assign(WorkspaceModel *model, const QVariant &index)
126{
132{
127 Workspace::assign(model, index);
133 Workspace::assign(model, index);
128}
134}
129
135
130−void WorkspaceProxy::unassign()
136+void ProxyWorkspace::unassign()
131{
137{
132 Workspace::unassign();
138 Workspace::unassign();
133}
139}
134
140
135−bool WorkspaceProxy::isActive() const
141+bool ProxyWorkspace::isActive() const
136{
142{
137 return m_original ? m_original->isActive() : false;
143 return m_original ? m_original->isActive() : false;
138}
144}
139
145
146+TopLevelWindowModel *ProxyWorkspace::windowModel() const
147+{
148+ return m_original ? m_original->windowModel() : nullptr;
149+}
150+
140−void WorkspaceProxy::activate()
151+void ProxyWorkspace::activate()
141{
152{
153+ if (m_original) {
142− if (m_original) m_original->activate();
154+ m_original->activate();
155+ }
143}
156}
plugins/WindowManager/Workspace.h+25−13
@@ -20,6 +20,7 @@
20#include <QObject>
20#include <QObject>
21#include <QVariant>
21#include <QVariant>
22#include <QPointer>
22#include <QPointer>
23+#include <QSharedPointer>
23
24
24#include <memory>
25#include <memory>
25#include <functional>
26#include <functional>
@@ -41,51 +42,62 @@ class Workspace : public QObject
41{
42{
42 Q_OBJECT
43 Q_OBJECT
43 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
44 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
44− Q_PROPERTY(TopLevelWindowModel* windowModel READ windowModel NOTIFY windowModelChanged)
45+ Q_PROPERTY(TopLevelWindowModel* windowModel READ windowModel CONSTANT)
45public:
46public:
46− ~Workspace();
47+ virtual ~Workspace();
47
48
48 virtual void assign(WorkspaceModel* model, const QVariant& index = QVariant());
49 virtual void assign(WorkspaceModel* model, const QVariant& index = QVariant());
49 virtual void unassign();
50 virtual void unassign();
50− void release();
51
51
52− virtual bool isActive() const { return m_active; }
52+ virtual bool isActive() const = 0;
53+ virtual TopLevelWindowModel *windowModel() const = 0;
53
54
54− TopLevelWindowModel *windowModel() const { return m_windowModel; }
55 std::shared_ptr<miral::Workspace> workspace() const { return m_workspace; }
55 std::shared_ptr<miral::Workspace> workspace() const { return m_workspace; }
56 bool isAssigned() const;
56 bool isAssigned() const;
57
57
58public Q_SLOTS:
58public Q_SLOTS:
59− virtual void activate();
59+ virtual void activate() = 0;
60
60
61Q_SIGNALS:
61Q_SIGNALS:
62 void assigned();
62 void assigned();
63 void unassigned();
63 void unassigned();
64
64
65 void activeChanged(bool);
65 void activeChanged(bool);
66− void windowModelChanged();
67
66
68protected:
67protected:
69− Workspace(QObject *parent = 0);
68+ Workspace(QObject *parent = nullptr);
70 Workspace(Workspace const& other);
69 Workspace(Workspace const& other);
71
70
72 std::shared_ptr<miral::Workspace> m_workspace;
71 std::shared_ptr<miral::Workspace> m_workspace;
73 WorkspaceModel* m_model;
72 WorkspaceModel* m_model;
74− TopLevelWindowModel* m_windowModel;
73+};
75− bool m_active;
74+
75+class ConcreteWorkspace : public Workspace
76+{
77+public:
78+ explicit ConcreteWorkspace(QObject *parent = nullptr);
79+ ~ConcreteWorkspace();
76
80
77− friend class WorkspaceManager;
81+ bool isActive() const override { return m_active; }
82+ TopLevelWindowModel *windowModel() const override;
83+ void activate() override;
84+
85+private:
86+ bool m_active;
87+ const QScopedPointer<TopLevelWindowModel> m_windowModel;
78};
88};
79
89
80−class WorkspaceProxy : public Workspace
90+class ProxyWorkspace : public Workspace
81{
91{
82 Q_OBJECT
92 Q_OBJECT
83public:
93public:
84− WorkspaceProxy(Workspace*const workspace);
94+ explicit ProxyWorkspace(Workspace*const workspace);
95+ ~ProxyWorkspace() = default;
85
96
86 Q_INVOKABLE void assign(WorkspaceModel* model, const QVariant& index = QVariant()) override;
97 Q_INVOKABLE void assign(WorkspaceModel* model, const QVariant& index = QVariant()) override;
87
98
88 bool isActive() const override;
99 bool isActive() const override;
100+ TopLevelWindowModel *windowModel() const override;
89 void activate() override;
101 void activate() override;
90
102
91 Workspace* proxyObject() const { return m_original.data(); }
103 Workspace* proxyObject() const { return m_original.data(); }
plugins/WindowManager/WorkspaceManager.cpp+2−29
@@ -38,23 +38,12 @@ WorkspaceManager::WorkspaceManager()
38
38
39Workspace *WorkspaceManager::createWorkspace()
39Workspace *WorkspaceManager::createWorkspace()
40{
40{
41− auto workspace = new Workspace(this);
41+ auto workspace = new ConcreteWorkspace(this);
42 QQmlEngine::setObjectOwnership(workspace, QQmlEngine::CppOwnership);
42 QQmlEngine::setObjectOwnership(workspace, QQmlEngine::CppOwnership);
43 m_allWorkspaces.insert(workspace);
43 m_allWorkspaces.insert(workspace);
44− m_floatingWorkspaces.append(workspace);
45−
46− connect(workspace, &Workspace::assigned, this, [this, workspace]() {
47− m_floatingWorkspaces.removeOne(workspace);
48− Q_EMIT floatingWorkspacesChanged();
49− });
50− connect(workspace, &Workspace::unassigned, this, [this, workspace]() {
51− m_floatingWorkspaces.append(workspace);
52− Q_EMIT floatingWorkspacesChanged();
53− });
54
44
55 if (m_allWorkspaces.count() == 0 && m_activeWorkspace) {
45 if (m_allWorkspaces.count() == 0 && m_activeWorkspace) {
56 setActiveWorkspace(nullptr);
46 setActiveWorkspace(nullptr);
57− Q_EMIT activeWorkspaceChanged();
58 } else if (m_allWorkspaces.count() == 1) {
47 } else if (m_allWorkspaces.count() == 1) {
59 setActiveWorkspace(workspace);
48 setActiveWorkspace(workspace);
60 }
49 }
@@ -69,9 +58,7 @@ void WorkspaceManager::destroyWorkspace(Workspace *workspace)
69 if (workspace->isAssigned()) {
58 if (workspace->isAssigned()) {
70 workspace->unassign();
59 workspace->unassign();
71 }
60 }
72− m_floatingWorkspaces.removeOne(workspace);
73 m_allWorkspaces.remove(workspace);
61 m_allWorkspaces.remove(workspace);
74− Q_EMIT floatingWorkspacesChanged();
75
62
76 if (m_activeWorkspace == workspace) {
63 if (m_activeWorkspace == workspace) {
77 Q_ASSERT(false); // Shouldn't happen, should have chosen something by now.
64 Q_ASSERT(false); // Shouldn't happen, should have chosen something by now.
@@ -83,20 +70,6 @@ void WorkspaceManager::destroyWorkspace(Workspace *workspace)
83 }
70 }
84
71
85 disconnect(workspace, 0, this, 0);
72 disconnect(workspace, 0, this, 0);
86− workspace->release();
87−}
88−
89−QQmlListProperty<Workspace> WorkspaceManager::floatingWorkspaces()
90−{
91− return QQmlListProperty<Workspace>(this, m_floatingWorkspaces);
92−}
93−
94−void WorkspaceManager::destroyFloatingWorkspaces()
95−{
96− QList<Workspace*> dpCpy(m_floatingWorkspaces);
97− Q_FOREACH(auto workspace, dpCpy) {
98− destroyWorkspace(workspace);
99− }
100}
73}
101
74
102void WorkspaceManager::moveSurfaceToWorkspace(unity::shell::application::MirSurfaceInterface *surface, Workspace *workspace)
75void WorkspaceManager::moveSurfaceToWorkspace(unity::shell::application::MirSurfaceInterface *surface, Workspace *workspace)
@@ -124,7 +97,7 @@ void WorkspaceManager::setActiveWorkspace(Workspace *workspace)
124{
97{
125 if (workspace != m_activeWorkspace) {
98 if (workspace != m_activeWorkspace) {
126 m_activeWorkspace = workspace;
99 m_activeWorkspace = workspace;
127− Q_EMIT activeWorkspaceChanged();
100+ Q_EMIT activeWorkspaceChanged(workspace);
128 }
101 }
129}
102}
130
103
plugins/WindowManager/WorkspaceManager.h+1−5
@@ -21,7 +21,6 @@
21#include <QQmlListProperty>
21#include <QQmlListProperty>
22
22
23class Workspace;
23class Workspace;
24−class ScreensProxy;
25
24
26namespace unity {
25namespace unity {
27 namespace shell {
26 namespace shell {
@@ -46,7 +45,6 @@ public:
46 Workspace* createWorkspace();
45 Workspace* createWorkspace();
47 void destroyWorkspace(Workspace* workspace);
46 void destroyWorkspace(Workspace* workspace);
48
47
49− QQmlListProperty<Workspace> floatingWorkspaces();
50 void destroyFloatingWorkspaces();
48 void destroyFloatingWorkspaces();
51
49
52 Q_INVOKABLE void moveSurfaceToWorkspace(unity::shell::application::MirSurfaceInterface* surface,
50 Q_INVOKABLE void moveSurfaceToWorkspace(unity::shell::application::MirSurfaceInterface* surface,
@@ -55,8 +53,7 @@ public:
55 Q_INVOKABLE void moveWorkspaceContentToWorkspace(Workspace* to, Workspace* from);
53 Q_INVOKABLE void moveWorkspaceContentToWorkspace(Workspace* to, Workspace* from);
56
54
57Q_SIGNALS:
55Q_SIGNALS:
58− void activeWorkspaceChanged();
56+ void activeWorkspaceChanged(Workspace*);
59− void floatingWorkspacesChanged();
60
57
61private:
58private:
62 WorkspaceManager();
59 WorkspaceManager();
@@ -64,7 +61,6 @@ private:
64 void setActiveWorkspace2(Workspace* workspace);
61 void setActiveWorkspace2(Workspace* workspace);
65
62
66 QSet<Workspace*> m_allWorkspaces;
63 QSet<Workspace*> m_allWorkspaces;
67− QList<Workspace*> m_floatingWorkspaces;
68 Workspace* m_activeWorkspace;
64 Workspace* m_activeWorkspace;
69 unity::shell::application::SurfaceManagerInterface* m_surfaceManager;
65 unity::shell::application::SurfaceManagerInterface* m_surfaceManager;
70};
66};
plugins/WindowManager/WorkspaceModel.cpp+36−16
@@ -58,6 +58,15 @@ void WorkspaceModel::remove(Workspace *workspace)
58
58
59 endRemoveRows();
59 endRemoveRows();
60
60
61+ m_unassignedWorkspaces.insert(workspace);
62+ connect(workspace, &Workspace::assigned, this, [=]() {
63+ m_unassignedWorkspaces.remove(workspace);
64+ disconnect(workspace, &Workspace::assigned, this, 0);
65+ });
66+ connect(workspace, &QObject::destroyed, this, [=]() {
67+ m_unassignedWorkspaces.remove(workspace);
68+ });
69+
61 Q_EMIT workspaceRemoved(workspace);
70 Q_EMIT workspaceRemoved(workspace);
62 Q_EMIT countChanged();
71 Q_EMIT countChanged();
63}
72}
@@ -112,10 +121,15 @@ QVariant WorkspaceModel::data(const QModelIndex &index, int role) const
112 }
121 }
113}
122}
114
123
124+void WorkspaceModel::setSyncing(bool syncing)
125+{
126+ m_syncing = syncing;
127+}
128+
115void WorkspaceModel::sync(WorkspaceModel *proxy)
129void WorkspaceModel::sync(WorkspaceModel *proxy)
116{
130{
131+ qDebug() << "SYNC" << this << proxy;
117 if (!proxy) return;
132 if (!proxy) return;
118− m_syncing = proxy;
119 const auto& proxyList = proxy->list();
133 const auto& proxyList = proxy->list();
120
134
121 // check for removals
135 // check for removals
@@ -125,7 +139,7 @@ void WorkspaceModel::sync(WorkspaceModel *proxy)
125
139
126 bool found = false;
140 bool found = false;
127 Q_FOREACH(auto p, proxyList) {
141 Q_FOREACH(auto p, proxyList) {
128− auto workspaceProxy = qobject_cast<WorkspaceProxy*>(p);
142+ auto workspaceProxy = qobject_cast<ProxyWorkspace*>(p);
129 if (workspaceProxy->proxyObject() == workspace) {
143 if (workspaceProxy->proxyObject() == workspace) {
130 found = true;
144 found = true;
131 break;
145 break;
@@ -142,7 +156,7 @@ void WorkspaceModel::sync(WorkspaceModel *proxy)
142 // existing
156 // existing
143 QSet<Workspace*> newWorkspaces;
157 QSet<Workspace*> newWorkspaces;
144 for (int i = 0; i < proxyList.count(); i++) {
158 for (int i = 0; i < proxyList.count(); i++) {
145− auto workspaceProxy = qobject_cast<WorkspaceProxy*>(proxyList[i]);
159+ auto workspaceProxy = qobject_cast<ProxyWorkspace*>(proxyList[i]);
146 auto workspace = workspaceProxy->proxyObject();
160 auto workspace = workspaceProxy->proxyObject();
147
161
148 int oldIndex = this->indexOf(workspace);
162 int oldIndex = this->indexOf(workspace);
@@ -159,7 +173,7 @@ void WorkspaceModel::sync(WorkspaceModel *proxy)
159 if (rowCount() == 0) {
173 if (rowCount() == 0) {
160 Workspace* workspace = WorkspaceManager::instance()->createWorkspace();
174 Workspace* workspace = WorkspaceManager::instance()->createWorkspace();
161 workspace->assign(this);
175 workspace->assign(this);
162− (new WorkspaceProxy(workspace))->assign(proxy);
176+ (new ProxyWorkspace(workspace))->assign(proxy);
163 }
177 }
164
178
165 if (removedIndexWhichWasActive != -1) {
179 if (removedIndexWhichWasActive != -1) {
@@ -168,32 +182,38 @@ void WorkspaceModel::sync(WorkspaceModel *proxy)
168
182
169 WorkspaceManager::instance()->setActiveWorkspace(newActiveWorkspace);
183 WorkspaceManager::instance()->setActiveWorkspace(newActiveWorkspace);
170 }
184 }
171− m_syncing = nullptr;
185+
186+ proxy->finishSync();
187+ finishSync();
172}
188}
173
189
174−bool WorkspaceModel::isSyncingWith(WorkspaceModel *m)
190+void WorkspaceModel::finishSync()
175{
191{
176− return m_syncing == m;
192+ QSet<Workspace*> dpCpy(m_unassignedWorkspaces);
193+ Q_FOREACH(auto workspace, dpCpy) {
194+ delete workspace;
195+ }
196+ m_unassignedWorkspaces.clear();
177}
197}
178
198
179−WorkspaceModelProxy::WorkspaceModelProxy(WorkspaceModel * const model)
199+ProxyWorkspaceModel::ProxyWorkspaceModel(WorkspaceModel * const model)
180 : m_original(model)
200 : m_original(model)
181{
201{
182 Q_FOREACH(auto workspace, model->list()) {
202 Q_FOREACH(auto workspace, model->list()) {
183− auto proxy = new WorkspaceProxy(workspace);
203+ auto proxy = new ProxyWorkspace(workspace);
184 QQmlEngine::setObjectOwnership(proxy, QQmlEngine::CppOwnership);
204 QQmlEngine::setObjectOwnership(proxy, QQmlEngine::CppOwnership);
185 proxy->assign(this);
205 proxy->assign(this);
186 }
206 }
187 connect(m_original, &WorkspaceModel::workspaceInserted, this, [this](int index, Workspace* inserted) {
207 connect(m_original, &WorkspaceModel::workspaceInserted, this, [this](int index, Workspace* inserted) {
188− if (m_original->isSyncingWith(this)) return;
208+ if (m_original->isSyncing()) return;
189
209
190− (new WorkspaceProxy(inserted))->assign(this, index);
210+ (new ProxyWorkspace(inserted))->assign(this, index);
191 });
211 });
192 connect(m_original, &WorkspaceModel::workspaceRemoved, this, [this](Workspace* removed) {
212 connect(m_original, &WorkspaceModel::workspaceRemoved, this, [this](Workspace* removed) {
193− if (m_original->isSyncingWith(this)) return;
213+ if (m_original->isSyncing()) return;
194
214
195 for (int i = 0; i < rowCount(); i++) {
215 for (int i = 0; i < rowCount(); i++) {
196− auto workspaceProxy = qobject_cast<WorkspaceProxy*>(get(i));
216+ auto workspaceProxy = qobject_cast<ProxyWorkspace*>(get(i));
197 auto w = workspaceProxy->proxyObject();
217 auto w = workspaceProxy->proxyObject();
198 if (w == removed) {
218 if (w == removed) {
199 remove(workspaceProxy);
219 remove(workspaceProxy);
@@ -202,19 +222,19 @@ WorkspaceModelProxy::WorkspaceModelProxy(WorkspaceModel * const model)
202 }
222 }
203 });
223 });
204 connect(m_original, &WorkspaceModel::workspaceMoved, this, [this](int from, int to) {
224 connect(m_original, &WorkspaceModel::workspaceMoved, this, [this](int from, int to) {
205− if (m_original->isSyncingWith(this)) return;
225+ if (m_original->isSyncing()) return;
206
226
207 move(from, to);
227 move(from, to);
208 });
228 });
209}
229}
210
230
211−WorkspaceModelProxy::~WorkspaceModelProxy()
231+ProxyWorkspaceModel::~ProxyWorkspaceModel()
212{
232{
213 qDeleteAll(m_workspaces.toList()); // make a copy so the list doesnt edit itself during delete.
233 qDeleteAll(m_workspaces.toList()); // make a copy so the list doesnt edit itself during delete.
214 m_workspaces.clear();
234 m_workspaces.clear();
215}
235}
216
236
217−void WorkspaceModelProxy::move(int from, int to)
237+void ProxyWorkspaceModel::move(int from, int to)
218{
238{
219 WorkspaceModel::move(from, to);
239 WorkspaceModel::move(from, to);
220}
240}
plugins/WindowManager/WorkspaceModel.h+10−6
@@ -24,7 +24,7 @@
24Q_DECLARE_LOGGING_CATEGORY(WORKSPACES)
24Q_DECLARE_LOGGING_CATEGORY(WORKSPACES)
25
25
26class Workspace;
26class Workspace;
27−class WorkspaceModelProxy;
27+class ProxyWorkspaceModel;
28
28
29class WorkspaceModel : public QAbstractListModel
29class WorkspaceModel : public QAbstractListModel
30{
30{
@@ -60,8 +60,11 @@ public:
60
60
61 const QVector<Workspace*>& list() const { return m_workspaces; }
61 const QVector<Workspace*>& list() const { return m_workspaces; }
62
62
63+ void setSyncing(bool);
63 void sync(WorkspaceModel* proxy);
64 void sync(WorkspaceModel* proxy);
64− bool isSyncingWith(WorkspaceModel*);
65+ void finishSync();
66+
67+ bool isSyncing() { return m_syncing; }
65
68
66Q_SIGNALS:
69Q_SIGNALS:
67 void countChanged();
70 void countChanged();
@@ -72,15 +75,16 @@ Q_SIGNALS:
72
75
73protected:
76protected:
74 QVector<Workspace*> m_workspaces;
77 QVector<Workspace*> m_workspaces;
78+ QSet<Workspace*> m_unassignedWorkspaces;
75− WorkspaceModel* m_syncing;
79+ bool m_syncing;
76};
80};
77
81
78−class WorkspaceModelProxy : public WorkspaceModel
82+class ProxyWorkspaceModel : public WorkspaceModel
79{
83{
80 Q_OBJECT
84 Q_OBJECT
81public:
85public:
82− WorkspaceModelProxy(WorkspaceModel*const model);
86+ explicit ProxyWorkspaceModel(WorkspaceModel*const model);
83− ~WorkspaceModelProxy();
87+ ~ProxyWorkspaceModel();
84
88
85 Q_INVOKABLE void move(int from, int to) override;
89 Q_INVOKABLE void move(int from, int to) override;
86
90
tests/mocks/WindowManager/MockScreens.cpp+2−1
@@ -97,6 +97,7 @@ public:
97 }
97 }
98
98
99 QScreen* qscreen() const override {
99 QScreen* qscreen() const override {
100+ qDebug() << "GET SCREEN" << qGuiApp->topLevelWindows();
100 if (qGuiApp->topLevelWindows().count() > 0) {
101 if (qGuiApp->topLevelWindows().count() > 0) {
101 return qGuiApp->topLevelWindows()[0]->screen();
102 return qGuiApp->topLevelWindows()[0]->screen();
102 }
103 }
@@ -196,7 +197,7 @@ QSharedPointer<MockScreens> MockScreens::instance()
196
197
197void MockScreens::connectWindow(ScreenWindow *w)
198void MockScreens::connectWindow(ScreenWindow *w)
198{
199{
199− Screen* screen = w->screenWrapper();
200+ ConcreteScreen* screen = w->screenWrapper();
200 if (!screen) return;
201 if (!screen) return;
201
202
202 auto mockScreen = qobject_cast<MockScreen*>(screen->wrapped());
203 auto mockScreen = qobject_cast<MockScreen*>(screen->wrapped());
tests/mocks/WindowManager/MockScreens.h+1−1
@@ -27,7 +27,7 @@ namespace qtmir
27class Screens;
27class Screens;
28}
28}
29
29
30−class Screen;
30+class ConcreteScreen;
31class ScreenWindow;
31class ScreenWindow;
32
32
33class MockScreens : public qtmir::Screens
33class MockScreens : public qtmir::Screens
tests/mocks/WindowManager/WindowManagerPlugin.cpp+6−5
@@ -42,7 +42,7 @@ static QObject *workspace_manager(QQmlEngine *engine, QJSEngine *scriptEngine)
42QObject* screensSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
42QObject* screensSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
43 Q_UNUSED(engine);
43 Q_UNUSED(engine);
44 Q_UNUSED(scriptEngine);
44 Q_UNUSED(scriptEngine);
45− return new Screens(MockScreens::instance());
45+ return ConcreteScreens::self();
46}
46}
47QObject* objectsSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
47QObject* objectsSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
48 Q_UNUSED(engine);
48 Q_UNUSED(engine);
@@ -54,13 +54,12 @@ void WindowManagerPlugin::registerTypes(const char *uri)
54{
54{
55 qmlRegisterSingletonType<WorkspaceManager>(uri, 1, 0, "WorkspaceManager", workspace_manager);
55 qmlRegisterSingletonType<WorkspaceManager>(uri, 1, 0, "WorkspaceManager", workspace_manager);
56 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", notInstantiatable);
56 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", notInstantiatable);
57− qmlRegisterSingletonType<Screens>(uri, 1, 0, "Screens", screensSingleton);
57+ qmlRegisterSingletonType<ConcreteScreens>(uri, 1, 0, "Screens", screensSingleton);
58 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", notInstantiatable);
58 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", notInstantiatable);
59− qmlRegisterUncreatableType<Workspace>(uri, 1, 0, "Workspace", notInstantiatable);
60 qmlRegisterSingletonType<WindowManagerObjects>(uri, 1, 0, "WindowManagerObjects", objectsSingleton);
59 qmlRegisterSingletonType<WindowManagerObjects>(uri, 1, 0, "WindowManagerObjects", objectsSingleton);
61
60
62− qRegisterMetaType<Screen*>("Screen*");
61+ qRegisterMetaType<ConcreteScreen*>("ConcreteScreen*");
63− qRegisterMetaType<ScreensProxy*>("ScreensProxy*");
62+ qRegisterMetaType<ProxyScreens*>("ProxyScreens*");
64 qRegisterMetaType<Workspace*>("Workspace*");
63 qRegisterMetaType<Workspace*>("Workspace*");
65 qRegisterMetaType<TopLevelWindowModel*>("TopLevelWindowModel*");
64 qRegisterMetaType<TopLevelWindowModel*>("TopLevelWindowModel*");
66
65
@@ -79,4 +78,6 @@ void WindowManagerPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
79
78
80 // Make sure we've initialized the wm policy.
79 // Make sure we've initialized the wm policy.
81 WindowManagementPolicy::instance();
80 WindowManagementPolicy::instance();
81+ // Create Screens
82+ new ConcreteScreens(MockScreens::instance());
82}
83}
tests/qmltests/Stage/tst_DesktopStage.qml+1−5
@@ -71,11 +71,7 @@ Item {
71 id: appMenuData
71 id: appMenuData
72 }
72 }
73
73
74− TopLevelWindowModel {
74+ readonly property var topSurfaceList: WorkspaceManager.activeWorkspace.windowModel
75− id: topSurfaceList
76− applicationManager: ApplicationManager
77− surfaceManager: SurfaceManager
78− }
79
75
80 Loader {
76 Loader {
81 id: stageLoader
77 id: stageLoader