Merge lp:~gerboland/unity-mir/add-surface-attribute-updates into lp:unity-mir
- add-surface-attribute-updates
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Albert Astals Cid |
Approved revision: | 47 |
Merged at revision: | 47 |
Proposed branch: | lp:~gerboland/unity-mir/add-surface-attribute-updates |
Merge into: | lp:unity-mir |
Diff against target: |
369 lines (+160/-12) 9 files modified
src/modules/Unity/SurfaceManager/mirsurface.cpp (+33/-5) src/modules/Unity/SurfaceManager/mirsurface.h (+5/-0) src/modules/Unity/SurfaceManager/mirsurfacemanager.cpp (+17/-1) src/modules/Unity/SurfaceManager/mirsurfacemanager.h (+7/-2) src/unity-mir/shellserverconfiguration.cpp (+14/-1) src/unity-mir/shellserverconfiguration.h (+6/-2) src/unity-mir/surfaceconfigurator.cpp (+34/-0) src/unity-mir/surfaceconfigurator.h (+41/-0) src/unity-mir/unity-mir.pro (+3/-1) |
To merge this branch: | bzr merge lp:~gerboland/unity-mir/add-surface-attribute-updates |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Astals Cid (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email:
|
Commit message
Listen for Mir Surface type and state property changes, propagate them up to QML
Mir added a SurfaceConfigurator interface, whose method attribute_set is called when any surface requests a property change. Here we inherit this class, and emit signals to the SurfaceManager when a property change occurs.
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Albert Astals Cid (aacid) wrote : | # |
Wonder if we should declare one Type/State to be the default values and in the constructor also emit the changed signals in case the passed values are not the ones we deem to be the default ones.
- 36. By Gerry Boland
-
Add licences
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:36
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 37. By Gerry Boland
-
Remove private copies of Mir Surface properties, just wrap the properties from Mir
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gerry Boland (gerboland) wrote : | # |
Your comment made me aware that the code was copying the properties that Mir Surface supplies. I've changed it to only wrap those properties instead. Let me know if it is a satisfactory result
- 38. By Gerry Boland
-
Duplicate header included, fixed
- 39. By Gerry Boland
-
Remove extra newline
- 40. By Gerry Boland
-
Small formatting tweak
- 41. By Gerry Boland
-
Header file, remove path supplied by pkgconfig
- 42. By Gerry Boland
-
Header file, remove path supplied by pkgconfig in other place
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:42
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 43. By Gerry Boland
-
Correctly deal with attribute changescoming from Mir
- 44. By Gerry Boland
-
Nitpick in pro file
- 45. By Gerry Boland
-
Wait for confirmation from Mir before emitting changed signals
- 46. By Gerry Boland
-
Whitespace
- 47. By Gerry Boland
-
Merge trunk
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:47
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'src/modules/Unity/SurfaceManager/mirsurface.cpp' |
2 | --- src/modules/Unity/SurfaceManager/mirsurface.cpp 2013-08-09 13:16:13 +0000 |
3 | +++ src/modules/Unity/SurfaceManager/mirsurface.cpp 2013-08-20 12:03:24 +0000 |
4 | @@ -21,8 +21,9 @@ |
5 | // unity-mir |
6 | #include "logging.h" |
7 | |
8 | -// Qt |
9 | -#include <mircommon/mir/geometry/rectangle.h> |
10 | +// Mir |
11 | +#include <mir/shell/surface.h> |
12 | +#include <mir/geometry/rectangle.h> |
13 | |
14 | namespace mg = mir::geometry; |
15 | |
16 | @@ -132,16 +133,13 @@ |
17 | Q_EMIT visibleChanged(); |
18 | } |
19 | |
20 | - |
21 | MirSurface::Type MirSurface::type() const |
22 | { |
23 | - //FIXME - how to listen to change in this property |
24 | return static_cast<MirSurface::Type>(m_surface->type()); |
25 | } |
26 | |
27 | MirSurface::State MirSurface::state() const |
28 | { |
29 | - //FIXME - how to listen to change in this property |
30 | return static_cast<MirSurface::State>(m_surface->state()); |
31 | } |
32 | |
33 | @@ -192,3 +190,33 @@ |
34 | } |
35 | m_surface->set_input_region(mirInputAreas); |
36 | } |
37 | + |
38 | +void MirSurface::setType(const Type &type) |
39 | +{ |
40 | + if (this->type() != type) { |
41 | + m_surface->configure(mir_surface_attrib_type, static_cast<int>(type)); |
42 | + } |
43 | +} |
44 | + |
45 | +void MirSurface::setState(const State &state) |
46 | +{ |
47 | + if (this->state() != state) { |
48 | + m_surface->configure(mir_surface_attrib_state, static_cast<int>(state)); |
49 | + } |
50 | +} |
51 | + |
52 | +// Called by MirSurfaceManager upon a msh::Surface attribute change |
53 | +void MirSurface::setAttribute(const MirSurfaceAttrib attribute, const int /*value*/) |
54 | +{ |
55 | + switch (attribute) { |
56 | + case mir_surface_attrib_type: |
57 | + Q_EMIT typeChanged(); |
58 | + break; |
59 | + case mir_surface_attrib_state: |
60 | + Q_EMIT stateChanged(); |
61 | + break; |
62 | + default: |
63 | + break; |
64 | + } |
65 | +} |
66 | + |
67 | |
68 | === modified file 'src/modules/Unity/SurfaceManager/mirsurface.h' |
69 | --- src/modules/Unity/SurfaceManager/mirsurface.h 2013-08-09 13:16:13 +0000 |
70 | +++ src/modules/Unity/SurfaceManager/mirsurface.h 2013-08-20 12:03:24 +0000 |
71 | @@ -23,6 +23,7 @@ |
72 | |
73 | // mir |
74 | #include <mir/shell/surface.h> |
75 | +#include <mir_toolkit/common.h> |
76 | |
77 | |
78 | namespace mir { namespace geometry { struct Rectangle; }} |
79 | @@ -86,6 +87,8 @@ |
80 | void setHeight(qreal); |
81 | void setVisible(bool); |
82 | |
83 | + void setAttribute(const MirSurfaceAttrib, const int); |
84 | + |
85 | Q_SIGNALS: |
86 | void typeChanged(); |
87 | void stateChanged(); |
88 | @@ -108,6 +111,8 @@ |
89 | // end of methods used by InputArea |
90 | |
91 | void updateMirInputRegion(); |
92 | + void setType(const Type&); |
93 | + void setState(const State&); |
94 | |
95 | bool disableMirInputArea(const mir::geometry::Rectangle& rect); |
96 | |
97 | |
98 | === modified file 'src/modules/Unity/SurfaceManager/mirsurfacemanager.cpp' |
99 | --- src/modules/Unity/SurfaceManager/mirsurfacemanager.cpp 2013-08-20 08:20:36 +0000 |
100 | +++ src/modules/Unity/SurfaceManager/mirsurfacemanager.cpp 2013-08-20 12:03:24 +0000 |
101 | @@ -25,6 +25,7 @@ |
102 | #include "qmirserverapplication.h" |
103 | #include "shellserverconfiguration.h" |
104 | #include "sessionlistener.h" |
105 | +#include "surfaceconfigurator.h" |
106 | #include "surfacesource.h" |
107 | #include "logging.h" |
108 | |
109 | @@ -61,6 +62,9 @@ |
110 | this, &MirSurfaceManager::sessionCreatedSurface); |
111 | QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionDestroyingSurface, |
112 | this, &MirSurfaceManager::sessionDestroyingSurface); |
113 | + |
114 | + QObject::connect(m_mirServer->surfaceConfigurator(), &SurfaceConfigurator::surfaceAttributeChanged, |
115 | + this, &MirSurfaceManager::surfaceAttributeChanged); |
116 | } |
117 | |
118 | MirSurfaceManager::~MirSurfaceManager() |
119 | @@ -108,14 +112,26 @@ |
120 | m_surfaces.erase(it); |
121 | Q_EMIT surfaceDestroyed(*it); |
122 | delete *it; |
123 | + return; |
124 | } |
125 | |
126 | DLOG("MirSurfaceManager::sessionDestroyingSurface: unable to find MirSurface corresponding to surface '%s'", surface->name().c_str()); |
127 | } |
128 | |
129 | -void MirSurfaceManager::shellSurfaceCreated(const std::shared_ptr<mir::shell::Surface> &surface) |
130 | +void MirSurfaceManager::shellSurfaceCreated(const std::shared_ptr<msh::Surface> &surface) |
131 | { |
132 | DLOG("MirSurfaceManager::shellSurfaceCreated (this=%p)", this); |
133 | m_shellSurface = new MirSurface(surface); |
134 | Q_EMIT shellSurfaceChanged(m_shellSurface); |
135 | } |
136 | + |
137 | +void MirSurfaceManager::surfaceAttributeChanged(const msh::Surface *surface, const MirSurfaceAttrib attribute, const int value) |
138 | +{ |
139 | + DLOG("MirSurfaceManager::surfaceAttributeChanged (this=%p, attrib=%d, value=%d)", |
140 | + this, static_cast<int>(attribute), value); |
141 | + |
142 | + auto it = m_surfaces.find(surface); |
143 | + if (it != m_surfaces.end()) { |
144 | + it.value()->setAttribute(attribute, value); |
145 | + } |
146 | +} |
147 | |
148 | === modified file 'src/modules/Unity/SurfaceManager/mirsurfacemanager.h' |
149 | --- src/modules/Unity/SurfaceManager/mirsurfacemanager.h 2013-08-09 13:16:13 +0000 |
150 | +++ src/modules/Unity/SurfaceManager/mirsurfacemanager.h 2013-08-20 12:03:24 +0000 |
151 | @@ -23,7 +23,10 @@ |
152 | // Qt |
153 | #include <QObject> |
154 | |
155 | -// mir |
156 | +// Mir |
157 | +#include <mir_toolkit/common.h> |
158 | + |
159 | +// local |
160 | #include "mirsurface.h" |
161 | |
162 | class ShellServerConfiguration; |
163 | @@ -55,8 +58,10 @@ |
164 | void sessionDestroyingSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const&); |
165 | void shellSurfaceCreated(std::shared_ptr<mir::shell::Surface> const&); |
166 | |
167 | + void surfaceAttributeChanged(mir::shell::Surface const*, MirSurfaceAttrib, int); |
168 | + |
169 | private: |
170 | - QHash<mir::shell::Surface *, MirSurface *> m_surfaces; |
171 | + QHash<const mir::shell::Surface *, MirSurface *> m_surfaces; |
172 | MirSurface* m_shellSurface; |
173 | ShellServerConfiguration* m_mirServer; |
174 | static MirSurfaceManager *the_surface_manager; |
175 | |
176 | === modified file 'src/unity-mir/shellserverconfiguration.cpp' |
177 | --- src/unity-mir/shellserverconfiguration.cpp 2013-08-09 13:16:13 +0000 |
178 | +++ src/unity-mir/shellserverconfiguration.cpp 2013-08-20 12:03:24 +0000 |
179 | @@ -18,6 +18,7 @@ |
180 | |
181 | #include "initialsurfaceplacementstrategy.h" |
182 | #include "sessionlistener.h" |
183 | +#include "surfaceconfigurator.h" |
184 | #include "surfacesource.h" |
185 | #include "sessionauthorizer.h" |
186 | #include "surfacebuilder.h" |
187 | @@ -34,6 +35,7 @@ |
188 | : QObject(parent) |
189 | , DefaultServerConfiguration(argc, argv) |
190 | , m_surfaceBuilder(new SurfaceBuilder(the_surface_stack_model())) |
191 | + , m_surfaceConfigurator(new SurfaceConfigurator) |
192 | , m_sessionListener(new SessionListener) |
193 | , m_surfaceSource(new SurfaceSource(the_surface_builder(), the_shell_surface_configurator())) |
194 | , m_sessionAuthorizer(new SessionAuthorizer(the_session_manager())) |
195 | @@ -66,6 +68,12 @@ |
196 | }); |
197 | } |
198 | |
199 | +std::shared_ptr<msh::SurfaceConfigurator> |
200 | +ShellServerConfiguration::the_shell_surface_configurator() |
201 | +{ |
202 | + return m_surfaceConfigurator; |
203 | +} |
204 | + |
205 | std::shared_ptr<msh::SurfaceFactory> |
206 | ShellServerConfiguration::the_shell_surface_factory() |
207 | { |
208 | @@ -90,7 +98,12 @@ |
209 | return m_sessionAuthorizer; |
210 | } |
211 | |
212 | -SessionListener* ShellServerConfiguration::sessionListener() const |
213 | +SurfaceConfigurator *ShellServerConfiguration::surfaceConfigurator() const |
214 | +{ |
215 | + return m_surfaceConfigurator.get(); |
216 | +} |
217 | + |
218 | +SessionListener *ShellServerConfiguration::sessionListener() const |
219 | { |
220 | return m_sessionListener.get(); |
221 | } |
222 | |
223 | === modified file 'src/unity-mir/shellserverconfiguration.h' |
224 | --- src/unity-mir/shellserverconfiguration.h 2013-08-09 13:16:13 +0000 |
225 | +++ src/unity-mir/shellserverconfiguration.h 2013-08-20 12:03:24 +0000 |
226 | @@ -24,11 +24,13 @@ |
227 | class SessionAuthorizer; |
228 | class SurfaceSource; |
229 | class SurfaceBuilder; |
230 | +class SurfaceConfigurator; |
231 | |
232 | class ShellServerConfiguration : public QObject, public mir::DefaultServerConfiguration |
233 | { |
234 | Q_OBJECT |
235 | |
236 | + Q_PROPERTY(SurfaceConfigurator* surfaceConfigurator READ surfaceConfigurator CONSTANT) |
237 | Q_PROPERTY(SessionListener* sessionListener READ sessionListener CONSTANT) |
238 | Q_PROPERTY(SurfaceSource* surfaceSource READ surfaceSource CONSTANT) |
239 | |
240 | @@ -39,18 +41,20 @@ |
241 | /* mir specific */ |
242 | std::shared_ptr<mir::shell::PlacementStrategy> the_shell_placement_strategy() override; |
243 | std::shared_ptr<mir::shell::SessionListener> the_shell_session_listener() override; |
244 | - |
245 | + std::shared_ptr<mir::shell::SurfaceConfigurator> the_shell_surface_configurator() override; |
246 | std::shared_ptr<mir::shell::SurfaceFactory> the_shell_surface_factory() override; |
247 | std::shared_ptr<mir::frontend::SessionAuthorizer> the_session_authorizer() override; |
248 | std::shared_ptr<mir::shell::SurfaceBuilder> the_surface_builder() override; |
249 | |
250 | /* qt specific */ |
251 | // getters |
252 | + SurfaceConfigurator *surfaceConfigurator() const; |
253 | SessionListener *sessionListener() const; |
254 | - SurfaceSource* surfaceSource() const; |
255 | + SurfaceSource *surfaceSource() const; |
256 | |
257 | protected: |
258 | std::shared_ptr<SurfaceBuilder> m_surfaceBuilder; |
259 | + std::shared_ptr<SurfaceConfigurator> m_surfaceConfigurator; |
260 | std::shared_ptr<SessionListener> m_sessionListener; |
261 | std::shared_ptr<SurfaceSource> m_surfaceSource; |
262 | std::shared_ptr<SessionAuthorizer> m_sessionAuthorizer; |
263 | |
264 | === added file 'src/unity-mir/surfaceconfigurator.cpp' |
265 | --- src/unity-mir/surfaceconfigurator.cpp 1970-01-01 00:00:00 +0000 |
266 | +++ src/unity-mir/surfaceconfigurator.cpp 2013-08-20 12:03:24 +0000 |
267 | @@ -0,0 +1,34 @@ |
268 | +/* |
269 | + * Copyright (C) 2013 Canonical, Ltd. |
270 | + * |
271 | + * This program is free software: you can redistribute it and/or modify it under |
272 | + * the terms of the GNU Lesser General Public License version 3, as published by |
273 | + * the Free Software Foundation. |
274 | + * |
275 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
276 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
277 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
278 | + * Lesser General Public License for more details. |
279 | + * |
280 | + * You should have received a copy of the GNU Lesser General Public License |
281 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
282 | + */ |
283 | + |
284 | +#include "surfaceconfigurator.h" |
285 | + |
286 | +namespace msh = mir::shell; |
287 | + |
288 | +SurfaceConfigurator::SurfaceConfigurator() |
289 | +{ |
290 | + qRegisterMetaType<MirSurfaceAttrib>("MirSurfaceAttrib"); |
291 | +} |
292 | + |
293 | +int SurfaceConfigurator::select_attribute_value(msh::Surface const&, MirSurfaceAttrib, int requested_value) |
294 | +{ |
295 | + return requested_value; |
296 | +} |
297 | + |
298 | +void SurfaceConfigurator::attribute_set(msh::Surface const& surface, MirSurfaceAttrib attrib, int value) |
299 | +{ |
300 | + Q_EMIT surfaceAttributeChanged(&surface, attrib, value); |
301 | +} |
302 | |
303 | === added file 'src/unity-mir/surfaceconfigurator.h' |
304 | --- src/unity-mir/surfaceconfigurator.h 1970-01-01 00:00:00 +0000 |
305 | +++ src/unity-mir/surfaceconfigurator.h 2013-08-20 12:03:24 +0000 |
306 | @@ -0,0 +1,41 @@ |
307 | +/* |
308 | + * Copyright (C) 2013 Canonical, Ltd. |
309 | + * |
310 | + * This program is free software: you can redistribute it and/or modify it under |
311 | + * the terms of the GNU Lesser General Public License version 3, as published by |
312 | + * the Free Software Foundation. |
313 | + * |
314 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
315 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
316 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
317 | + * Lesser General Public License for more details. |
318 | + * |
319 | + * You should have received a copy of the GNU Lesser General Public License |
320 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
321 | + */ |
322 | + |
323 | +#ifndef SURFACECONFIGURATOR_H |
324 | +#define SURFACECONFIGURATOR_H |
325 | + |
326 | +#include <QObject> |
327 | + |
328 | +#include <mir/shell/surface_configurator.h> |
329 | +#include <mir_toolkit/common.h> |
330 | + |
331 | +namespace mir { namespace shell { class Surface; }} |
332 | + |
333 | +class SurfaceConfigurator : public QObject, public mir::shell::SurfaceConfigurator |
334 | +{ |
335 | + Q_OBJECT |
336 | + |
337 | +public: |
338 | + SurfaceConfigurator(); |
339 | + |
340 | + int select_attribute_value(mir::shell::Surface const&, MirSurfaceAttrib, int) override; |
341 | + void attribute_set(mir::shell::Surface const&, MirSurfaceAttrib, int) override; |
342 | + |
343 | +Q_SIGNALS: |
344 | + void surfaceAttributeChanged(mir::shell::Surface const*, const MirSurfaceAttrib, const int); |
345 | +}; |
346 | + |
347 | +#endif // SURFACECONFIGURATOR_H |
348 | |
349 | === modified file 'src/unity-mir/unity-mir.pro' |
350 | --- src/unity-mir/unity-mir.pro 2013-08-20 08:25:11 +0000 |
351 | +++ src/unity-mir/unity-mir.pro 2013-08-20 12:03:24 +0000 |
352 | @@ -19,7 +19,8 @@ |
353 | sessionlistener.cpp \ |
354 | shellserverconfiguration.cpp \ |
355 | surfacebuilder.cpp \ |
356 | - surfacesource.cpp |
357 | + surfacesource.cpp \ |
358 | + surfaceconfigurator.cpp |
359 | |
360 | HEADERS += initialsurfaceplacementstrategy.h \ |
361 | qmirserverapplication.h \ |
362 | @@ -29,6 +30,7 @@ |
363 | shellserverconfiguration.h \ |
364 | surfacebuilder.h \ |
365 | surfacesource.h \ |
366 | + surfaceconfigurator.h \ |
367 | logging.h |
368 | |
369 | CONFIG(debug) { |
FAILED: Continuous integration, rev:35 jenkins. qa.ubuntu. com/job/ unity-mir- ci/22/ jenkins. qa.ubuntu. com/job/ unity-mir- saucy-armhf- ci/22/console jenkins. qa.ubuntu. com/job/ unity-mir- saucy-i386- ci/22/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ unity-mir- ci/22/rebuild
http://