Merge lp:~gerboland/miral/qtmir-555 into lp:miral
- qtmir-555
- Merge into trunk
Proposed by
Gerry Boland
Status: | Superseded |
---|---|
Proposed branch: | lp:~gerboland/miral/qtmir-555 |
Merge into: | lp:miral |
Diff against target: |
1001 lines (+283/-57) 30 files modified
debian/libmiral1.symbols (+1/-0) include/miral/window_manager_tools.h (+7/-0) miral-qt/CMakeLists.txt (+1/-1) miral-qt/debian/control (+4/-2) miral-qt/debian/gles-patches/convert-to-gles.patch (+2/-2) miral-qt/src/common/windowmodelnotifierinterface.h (+17/-5) miral-qt/src/modules/Unity/Application/dbusfocusinfo.cpp (+35/-0) miral-qt/src/modules/Unity/Application/dbusfocusinfo.h (+12/-2) miral-qt/src/modules/Unity/Application/mirsurface.cpp (+43/-35) miral-qt/src/modules/Unity/Application/mirsurface.h (+7/-2) miral-qt/src/modules/Unity/Application/windowmodel.cpp (+1/-1) miral-qt/src/modules/Unity/Application/windowmodel.h (+1/-1) miral-qt/src/platforms/mirserver/nativeinterface.h (+2/-0) miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp (+4/-2) miral-qt/src/platforms/mirserver/windowmodelnotifier.cpp (+4/-2) miral-qt/src/platforms/mirserver/windowmodelnotifier.h (+1/-1) miral-qt/tests/framework/CMakeLists.txt (+1/-0) miral-qt/tests/framework/fake_mirsurface.cpp (+2/-0) miral-qt/tests/framework/fake_mirsurface.h (+1/-0) miral-qt/tests/framework/mock_persistent_surface_store.cpp (+30/-0) miral-qt/tests/framework/mock_persistent_surface_store.h (+24/-0) miral-qt/tests/framework/qtmir_test.cpp (+1/-0) miral-qt/tests/framework/qtmir_test.h (+3/-0) miral-qt/tests/modules/WindowManager/windowmodel_test.cpp (+1/-1) miral/basic_window_manager.cpp (+11/-0) miral/basic_window_manager.h (+2/-0) miral/symbols.map (+1/-0) miral/window_manager_tools.cpp (+3/-0) miral/window_manager_tools_implementation.h (+1/-0) test/persistent_surface_store.cpp (+60/-0) |
To merge this branch: | bzr merge lp:~gerboland/miral/qtmir-555 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email:
|
This proposal has been superseded by a proposal from 2016-09-07.
Commit message
[miral-qt] Merge rev 555 of qtmir: Added implementation for MirSurfaceInter
Based on https:/
Description of the change
To post a comment you must log in.
lp:~gerboland/miral/qtmir-555
updated
- 318. By Gerry Boland
-
Merge miral trunk
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/libmiral1.symbols' | |||
2 | --- debian/libmiral1.symbols 2016-09-06 08:05:38 +0000 | |||
3 | +++ debian/libmiral1.symbols 2016-09-07 20:36:39 +0000 | |||
4 | @@ -163,6 +163,7 @@ | |||
5 | 163 | (c++)"miral::WindowManagerTools::focus_next_application()@MIRAL_0.1" 0.1.0 | 163 | (c++)"miral::WindowManagerTools::focus_next_application()@MIRAL_0.1" 0.1.0 |
6 | 164 | (c++)"miral::WindowManagerTools::focus_next_within_application()@MIRAL_0.1" 0.1.0 | 164 | (c++)"miral::WindowManagerTools::focus_next_within_application()@MIRAL_0.1" 0.1.0 |
7 | 165 | (c++)"miral::WindowManagerTools::for_each_application(std::function<void (miral::ApplicationInfo&)> const&)@MIRAL_0.1" 0.1.0 | 165 | (c++)"miral::WindowManagerTools::for_each_application(std::function<void (miral::ApplicationInfo&)> const&)@MIRAL_0.1" 0.1.0 |
8 | 166 | (c++)"miral::WindowManagerTools::id_for_window[abi:cxx11](miral::Window const&) const@MIRAL_0.1" 0.1.0 | ||
9 | 166 | (c++)"miral::WindowManagerTools::info_for(miral::Window const&) const@MIRAL_0.1" 0.1.0 | 167 | (c++)"miral::WindowManagerTools::info_for(miral::Window const&) const@MIRAL_0.1" 0.1.0 |
10 | 167 | (c++)"miral::WindowManagerTools::info_for(std::weak_ptr<mir::scene::Session> const&) const@MIRAL_0.1" 0.1.0 | 168 | (c++)"miral::WindowManagerTools::info_for(std::weak_ptr<mir::scene::Session> const&) const@MIRAL_0.1" 0.1.0 |
11 | 168 | (c++)"miral::WindowManagerTools::info_for(std::weak_ptr<mir::scene::Surface> const&) const@MIRAL_0.1" 0.1.0 | 169 | (c++)"miral::WindowManagerTools::info_for(std::weak_ptr<mir::scene::Surface> const&) const@MIRAL_0.1" 0.1.0 |
12 | 169 | 170 | ||
13 | === modified file 'include/miral/window_manager_tools.h' | |||
14 | --- include/miral/window_manager_tools.h 2016-08-15 15:36:00 +0000 | |||
15 | +++ include/miral/window_manager_tools.h 2016-09-07 20:36:39 +0000 | |||
16 | @@ -105,6 +105,13 @@ | |||
17 | 105 | */ | 105 | */ |
18 | 106 | auto info_for_window_id(std::string const& id) const -> WindowInfo&; | 106 | auto info_for_window_id(std::string const& id) const -> WindowInfo&; |
19 | 107 | 107 | ||
20 | 108 | /** retrieve the persistent surface id for a window | ||
21 | 109 | * | ||
22 | 110 | * @param id the window | ||
23 | 111 | * @return the persistent surface id | ||
24 | 112 | */ | ||
25 | 113 | auto id_for_window(Window const& window) const -> std::string; | ||
26 | 114 | |||
27 | 108 | /// Send close request to the window | 115 | /// Send close request to the window |
28 | 109 | void ask_client_to_close(Window const& window); | 116 | void ask_client_to_close(Window const& window); |
29 | 110 | 117 | ||
30 | 111 | 118 | ||
31 | === modified file 'miral-qt/CMakeLists.txt' | |||
32 | --- miral-qt/CMakeLists.txt 2016-08-16 14:21:14 +0000 | |||
33 | +++ miral-qt/CMakeLists.txt 2016-09-07 20:36:39 +0000 | |||
34 | @@ -90,7 +90,7 @@ | |||
35 | 90 | pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt) | 90 | pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt) |
36 | 91 | pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED) | 91 | pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED) |
37 | 92 | pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED) | 92 | pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED) |
39 | 93 | pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=20) | 93 | pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=21) |
40 | 94 | pkg_check_modules(CGMANAGER libcgmanager REQUIRED) | 94 | pkg_check_modules(CGMANAGER libcgmanager REQUIRED) |
41 | 95 | 95 | ||
42 | 96 | add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1) | 96 | add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1) |
43 | 97 | 97 | ||
44 | === modified file 'miral-qt/debian/control' | |||
45 | --- miral-qt/debian/control 2016-08-16 14:21:14 +0000 | |||
46 | +++ miral-qt/debian/control 2016-09-07 20:36:39 +0000 | |||
47 | @@ -23,7 +23,7 @@ | |||
48 | 23 | libubuntu-app-launch2-dev (>= 0.9), | 23 | libubuntu-app-launch2-dev (>= 0.9), |
49 | 24 | libubuntu-application-api-dev (>= 2.1.0), | 24 | libubuntu-application-api-dev (>= 2.1.0), |
50 | 25 | libudev-dev, | 25 | libudev-dev, |
52 | 26 | libunity-api-dev (>= 7.117), | 26 | libunity-api-dev (>= 7.118), |
53 | 27 | liburl-dispatcher1-dev, | 27 | liburl-dispatcher1-dev, |
54 | 28 | libxkbcommon-dev, | 28 | libxkbcommon-dev, |
55 | 29 | libxrender-dev, | 29 | libxrender-dev, |
56 | @@ -37,6 +37,8 @@ | |||
57 | 37 | qtdeclarative5-dev, | 37 | qtdeclarative5-dev, |
58 | 38 | qtdeclarative5-private-dev, | 38 | qtdeclarative5-private-dev, |
59 | 39 | quilt, | 39 | quilt, |
60 | 40 | # libmirserver-dev should have brought this dep. Bug lp:1617435 | ||
61 | 41 | uuid-dev, | ||
62 | 40 | Standards-Version: 3.9.5 | 42 | Standards-Version: 3.9.5 |
63 | 41 | Homepage: https://launchpad.net/qtmir | 43 | Homepage: https://launchpad.net/qtmir |
64 | 42 | # if you don't have have commit access to this branch but would like to upload | 44 | # if you don't have have commit access to this branch but would like to upload |
65 | @@ -94,7 +96,7 @@ | |||
66 | 94 | Conflicts: libqtmir, | 96 | Conflicts: libqtmir, |
67 | 95 | libunity-mir1, | 97 | libunity-mir1, |
68 | 96 | Provides: unity-application-impl, | 98 | Provides: unity-application-impl, |
70 | 97 | unity-application-impl-20, | 99 | unity-application-impl-21, |
71 | 98 | Description: Qt plugin for Unity specific Mir APIs | 100 | Description: Qt plugin for Unity specific Mir APIs |
72 | 99 | QtMir provides Qt/QML bindings for Mir features that are exposed through the | 101 | QtMir provides Qt/QML bindings for Mir features that are exposed through the |
73 | 100 | qtmir-desktop or qtmir-android QPA plugin such as Application management | 102 | qtmir-desktop or qtmir-android QPA plugin such as Application management |
74 | 101 | 103 | ||
75 | === modified file 'miral-qt/debian/gles-patches/convert-to-gles.patch' | |||
76 | --- miral-qt/debian/gles-patches/convert-to-gles.patch 2016-08-16 14:21:14 +0000 | |||
77 | +++ miral-qt/debian/gles-patches/convert-to-gles.patch 2016-09-07 20:36:39 +0000 | |||
78 | @@ -9,7 +9,7 @@ | |||
79 | 9 | Priority: optional | 9 | Priority: optional |
80 | 10 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> | 10 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
81 | 11 | @@ -16,7 +16,13 @@ Build-Depends: cmake, | 11 | @@ -16,7 +16,13 @@ Build-Depends: cmake, |
83 | 12 | libmirserver-dev (>= 0.19.0), | 12 | libmirserver-dev (>= 0.24.0), |
84 | 13 | libmtdev-dev, | 13 | libmtdev-dev, |
85 | 14 | libprocess-cpp-dev, | 14 | libprocess-cpp-dev, |
86 | 15 | + libqt5gui5-gles, | 15 | + libqt5gui5-gles, |
87 | @@ -84,7 +84,7 @@ | |||
88 | 84 | -Conflicts: libqtmir, | 84 | -Conflicts: libqtmir, |
89 | 85 | - libunity-mir1, | 85 | - libunity-mir1, |
90 | 86 | -Provides: unity-application-impl, | 86 | -Provides: unity-application-impl, |
92 | 87 | - unity-application-impl-20, | 87 | - unity-application-impl-21, |
93 | 88 | -Description: Qt plugin for Unity specific Mir APIs | 88 | -Description: Qt plugin for Unity specific Mir APIs |
94 | 89 | - QtMir provides Qt/QML bindings for Mir features that are exposed through the | 89 | - QtMir provides Qt/QML bindings for Mir features that are exposed through the |
95 | 90 | - qtmir-desktop or qtmir-android QPA plugin such as Application management | 90 | - qtmir-desktop or qtmir-android QPA plugin such as Application management |
96 | 91 | 91 | ||
97 | === modified file 'miral-qt/src/common/windowmodelnotifierinterface.h' | |||
98 | --- miral-qt/src/common/windowmodelnotifierinterface.h 2016-09-01 11:37:38 +0000 | |||
99 | +++ miral-qt/src/common/windowmodelnotifierinterface.h 2016-09-07 20:36:39 +0000 | |||
100 | @@ -31,8 +31,7 @@ | |||
101 | 31 | public: | 31 | public: |
102 | 32 | WindowInfo() = default; | 32 | WindowInfo() = default; |
103 | 33 | WindowInfo(const miral::WindowInfo &windowInfo) | 33 | WindowInfo(const miral::WindowInfo &windowInfo) |
106 | 34 | : window(windowInfo.window()) | 34 | : name(windowInfo.name()) |
105 | 35 | , name(windowInfo.name()) | ||
107 | 36 | , type(windowInfo.type()) | 35 | , type(windowInfo.type()) |
108 | 37 | , state(windowInfo.state()) | 36 | , state(windowInfo.state()) |
109 | 38 | , restoreRect(windowInfo.restore_rect()) | 37 | , restoreRect(windowInfo.restore_rect()) |
110 | @@ -42,10 +41,8 @@ | |||
111 | 42 | , minHeight(windowInfo.min_height()) | 41 | , minHeight(windowInfo.min_height()) |
112 | 43 | , maxWidth(windowInfo.max_width()) | 42 | , maxWidth(windowInfo.max_width()) |
113 | 44 | , maxHeight(windowInfo.max_height()) | 43 | , maxHeight(windowInfo.max_height()) |
114 | 45 | , surface(window) | ||
115 | 46 | {} | 44 | {} |
116 | 47 | 45 | ||
117 | 48 | miral::Window window; | ||
118 | 49 | mir::optional_value<std::string> name; | 46 | mir::optional_value<std::string> name; |
119 | 50 | MirSurfaceType type; | 47 | MirSurfaceType type; |
120 | 51 | MirSurfaceState state; | 48 | MirSurfaceState state; |
121 | @@ -56,6 +53,20 @@ | |||
122 | 56 | mir::geometry::Height minHeight; | 53 | mir::geometry::Height minHeight; |
123 | 57 | mir::geometry::Width maxWidth; | 54 | mir::geometry::Width maxWidth; |
124 | 58 | mir::geometry::Height maxHeight; | 55 | mir::geometry::Height maxHeight; |
125 | 56 | }; | ||
126 | 57 | |||
127 | 58 | class NewWindowInfo : public WindowInfo { | ||
128 | 59 | public: | ||
129 | 60 | NewWindowInfo() = default; | ||
130 | 61 | NewWindowInfo(const miral::WindowInfo &windowInfo, const std::string &persistentId = "") | ||
131 | 62 | : WindowInfo(windowInfo) | ||
132 | 63 | , window(windowInfo.window()) | ||
133 | 64 | , persistentId(persistentId) | ||
134 | 65 | , surface(window) | ||
135 | 66 | {} | ||
136 | 67 | |||
137 | 68 | miral::Window window; | ||
138 | 69 | std::string persistentId; | ||
139 | 59 | 70 | ||
140 | 60 | // hold copy of Surface shared pointer, as miral::Window has just a weak pointer to the Surface | 71 | // hold copy of Surface shared pointer, as miral::Window has just a weak pointer to the Surface |
141 | 61 | // but MirSurface needs to share ownership of the Surface with Mir | 72 | // but MirSurface needs to share ownership of the Surface with Mir |
142 | @@ -71,7 +82,7 @@ | |||
143 | 71 | virtual ~WindowModelNotifierInterface() = default; | 82 | virtual ~WindowModelNotifierInterface() = default; |
144 | 72 | 83 | ||
145 | 73 | Q_SIGNALS: | 84 | Q_SIGNALS: |
147 | 74 | void windowAdded(const qtmir::WindowInfo, const int index); | 85 | void windowAdded(const qtmir::NewWindowInfo, const int index); |
148 | 75 | void windowRemoved(const int index); | 86 | void windowRemoved(const int index); |
149 | 76 | void windowMoved(const QPoint topLeft, const int index); | 87 | void windowMoved(const QPoint topLeft, const int index); |
150 | 77 | void windowResized(const QSize size, const int index); | 88 | void windowResized(const QSize size, const int index); |
151 | @@ -85,6 +96,7 @@ | |||
152 | 85 | 96 | ||
153 | 86 | } // namespace qtmir | 97 | } // namespace qtmir |
154 | 87 | 98 | ||
155 | 99 | Q_DECLARE_METATYPE(qtmir::NewWindowInfo) | ||
156 | 88 | Q_DECLARE_METATYPE(qtmir::WindowInfo) | 100 | Q_DECLARE_METATYPE(qtmir::WindowInfo) |
157 | 89 | 101 | ||
158 | 90 | #endif // WINDOWMODELNOTIFIERINTERFACE_H | 102 | #endif // WINDOWMODELNOTIFIERINTERFACE_H |
159 | 91 | 103 | ||
160 | === modified file 'miral-qt/src/modules/Unity/Application/dbusfocusinfo.cpp' | |||
161 | --- miral-qt/src/modules/Unity/Application/dbusfocusinfo.cpp 2016-07-26 12:30:51 +0000 | |||
162 | +++ miral-qt/src/modules/Unity/Application/dbusfocusinfo.cpp 2016-09-07 20:36:39 +0000 | |||
163 | @@ -18,6 +18,9 @@ | |||
164 | 18 | 18 | ||
165 | 19 | // local | 19 | // local |
166 | 20 | #include "cgmanager.h" | 20 | #include "cgmanager.h" |
167 | 21 | #include "mirsurfacelistmodel.h" | ||
168 | 22 | #include "mirsurfaceinterface.h" | ||
169 | 23 | #include "session_interface.h" | ||
170 | 21 | 24 | ||
171 | 22 | // QPA mirserver | 25 | // QPA mirserver |
172 | 23 | #include <logging.h> | 26 | #include <logging.h> |
173 | @@ -87,3 +90,35 @@ | |||
174 | 87 | } | 90 | } |
175 | 88 | return nullptr; | 91 | return nullptr; |
176 | 89 | } | 92 | } |
177 | 93 | |||
178 | 94 | bool DBusFocusInfo::isSurfaceFocused(const QString &serializedId) | ||
179 | 95 | { | ||
180 | 96 | MirSurfaceInterface *qmlSurface = findQmlSurface(serializedId); | ||
181 | 97 | bool result = qmlSurface ? qmlSurface->activeFocus() : false; | ||
182 | 98 | qCDebug(QTMIR_DBUS).nospace() << "DBusFocusInfo: isSurfaceFocused("<<serializedId<<") -> " << result; | ||
183 | 99 | return result; | ||
184 | 100 | } | ||
185 | 101 | |||
186 | 102 | MirSurfaceInterface *DBusFocusInfo::findQmlSurface(const QString &serializedId) | ||
187 | 103 | { | ||
188 | 104 | for (Application* application : m_applications) { | ||
189 | 105 | auto session = application->session(); | ||
190 | 106 | |||
191 | 107 | auto surfaceList = static_cast<MirSurfaceListModel*>(session->surfaceList()); | ||
192 | 108 | for (int i = 0; i < surfaceList->count(); ++i) { | ||
193 | 109 | auto qmlSurface = static_cast<MirSurfaceInterface*>(surfaceList->get(i)); | ||
194 | 110 | if (qmlSurface->persistentId() == serializedId) { | ||
195 | 111 | return qmlSurface; | ||
196 | 112 | } | ||
197 | 113 | } | ||
198 | 114 | |||
199 | 115 | surfaceList = static_cast<MirSurfaceListModel*>(session->promptSurfaceList()); | ||
200 | 116 | for (int i = 0; i < surfaceList->count(); ++i) { | ||
201 | 117 | auto qmlSurface = static_cast<MirSurfaceInterface*>(surfaceList->get(i)); | ||
202 | 118 | if (qmlSurface->persistentId() == serializedId) { | ||
203 | 119 | return qmlSurface; | ||
204 | 120 | } | ||
205 | 121 | } | ||
206 | 122 | } | ||
207 | 123 | return nullptr; | ||
208 | 124 | } | ||
209 | 90 | 125 | ||
210 | === modified file 'miral-qt/src/modules/Unity/Application/dbusfocusinfo.h' | |||
211 | --- miral-qt/src/modules/Unity/Application/dbusfocusinfo.h 2016-07-26 12:30:36 +0000 | |||
212 | +++ miral-qt/src/modules/Unity/Application/dbusfocusinfo.h 2016-09-07 20:36:39 +0000 | |||
213 | @@ -22,10 +22,11 @@ | |||
214 | 22 | namespace qtmir { | 22 | namespace qtmir { |
215 | 23 | 23 | ||
216 | 24 | class CGManager; | 24 | class CGManager; |
217 | 25 | class MirSurfaceInterface; | ||
218 | 25 | 26 | ||
219 | 26 | /* | 27 | /* |
222 | 27 | FIXME: This is a hack to provide OSK with needed info for avoiding input snooping. | 28 | Enables other processes to check what is the currently focused application or surface, |
223 | 28 | Remove when possible | 29 | normally for security purposes. |
224 | 29 | */ | 30 | */ |
225 | 30 | class DBusFocusInfo : public QObject | 31 | class DBusFocusInfo : public QObject |
226 | 31 | { | 32 | { |
227 | @@ -39,12 +40,21 @@ | |||
228 | 39 | 40 | ||
229 | 40 | /* | 41 | /* |
230 | 41 | Returns true if the application with the given PID has input focus | 42 | Returns true if the application with the given PID has input focus |
231 | 43 | |||
232 | 44 | FIXME: Identifying an app through its PID is deemed racy. | ||
233 | 45 | isSurfaceFocused() is the preferred method. | ||
234 | 42 | */ | 46 | */ |
235 | 43 | Q_SCRIPTABLE bool isPidFocused(unsigned int pid); | 47 | Q_SCRIPTABLE bool isPidFocused(unsigned int pid); |
236 | 44 | 48 | ||
237 | 49 | /* | ||
238 | 50 | Returns true if the surface with the given id has input focus | ||
239 | 51 | */ | ||
240 | 52 | Q_SCRIPTABLE bool isSurfaceFocused(const QString &surfaceId); | ||
241 | 53 | |||
242 | 45 | private: | 54 | private: |
243 | 46 | QSet<pid_t> fetchAssociatedPids(pid_t pid); | 55 | QSet<pid_t> fetchAssociatedPids(pid_t pid); |
244 | 47 | SessionInterface* findSessionWithPid(const QSet<pid_t> &pidSet); | 56 | SessionInterface* findSessionWithPid(const QSet<pid_t> &pidSet); |
245 | 57 | MirSurfaceInterface *findQmlSurface(const QString &serializedId); | ||
246 | 48 | 58 | ||
247 | 49 | const QList<Application*> &m_applications; | 59 | const QList<Application*> &m_applications; |
248 | 50 | 60 | ||
249 | 51 | 61 | ||
250 | === modified file 'miral-qt/src/modules/Unity/Application/mirsurface.cpp' | |||
251 | --- miral-qt/src/modules/Unity/Application/mirsurface.cpp 2016-09-01 10:58:43 +0000 | |||
252 | +++ miral-qt/src/modules/Unity/Application/mirsurface.cpp 2016-09-07 20:36:39 +0000 | |||
253 | @@ -44,8 +44,8 @@ | |||
254 | 44 | 44 | ||
255 | 45 | using namespace qtmir; | 45 | using namespace qtmir; |
256 | 46 | 46 | ||
259 | 47 | #define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() <<"]::" << __func__ | 47 | #define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__ |
260 | 48 | #define WARNING_MSG qCWarning(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() <<"]::" << __func__ | 48 | #define WARNING_MSG qCWarning(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__ |
261 | 49 | 49 | ||
262 | 50 | namespace { | 50 | namespace { |
263 | 51 | 51 | ||
264 | @@ -195,25 +195,28 @@ | |||
265 | 195 | 195 | ||
266 | 196 | } // namespace { | 196 | } // namespace { |
267 | 197 | 197 | ||
269 | 198 | MirSurface::MirSurface(WindowInfo windowInfo, | 198 | MirSurface::MirSurface(NewWindowInfo windowInfo, |
270 | 199 | WindowControllerInterface* controller) | 199 | WindowControllerInterface* controller) |
271 | 200 | : MirSurfaceInterface() | 200 | : MirSurfaceInterface() |
272 | 201 | , m_windowInfo(windowInfo) | 201 | , m_windowInfo(windowInfo) |
273 | 202 | , m_window(windowInfo.window) | ||
274 | 203 | , m_surface(windowInfo.surface) | ||
275 | 202 | , m_controller(controller) | 204 | , m_controller(controller) |
276 | 205 | , m_persistentId(QString::fromStdString(windowInfo.persistentId)) | ||
277 | 203 | , m_firstFrameDrawn(false) | 206 | , m_firstFrameDrawn(false) |
278 | 204 | , m_orientationAngle(Mir::Angle0) | 207 | , m_orientationAngle(Mir::Angle0) |
279 | 205 | , m_textureUpdated(false) | 208 | , m_textureUpdated(false) |
280 | 206 | , m_currentFrameNumber(0) | 209 | , m_currentFrameNumber(0) |
281 | 207 | , m_live(true) | 210 | , m_live(true) |
282 | 208 | , m_surfaceObserver(std::make_shared<SurfaceObserver>()) | 211 | , m_surfaceObserver(std::make_shared<SurfaceObserver>()) |
285 | 209 | , m_position(toQPoint(windowInfo.window.top_left())) | 212 | , m_position(toQPoint(m_window.top_left())) |
286 | 210 | , m_size(toQSize(windowInfo.window.size())) | 213 | , m_size(toQSize(m_window.size())) |
287 | 211 | , m_shellChrome(Mir::NormalChrome) | 214 | , m_shellChrome(Mir::NormalChrome) |
288 | 212 | { | 215 | { |
289 | 213 | DEBUG_MSG << "()"; | 216 | DEBUG_MSG << "()"; |
290 | 214 | 217 | ||
293 | 215 | SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), windowInfo.surface.get()); | 218 | SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface.get()); |
294 | 216 | m_windowInfo.surface->add_observer(m_surfaceObserver); | 219 | m_surface->add_observer(m_surfaceObserver); |
295 | 217 | 220 | ||
296 | 218 | //m_shellChrome = creationHints.shellChrome; TODO - where will this come from now? | 221 | //m_shellChrome = creationHints.shellChrome; TODO - where will this come from now? |
297 | 219 | 222 | ||
298 | @@ -253,12 +256,12 @@ | |||
299 | 253 | 256 | ||
300 | 254 | MirSurface::~MirSurface() | 257 | MirSurface::~MirSurface() |
301 | 255 | { | 258 | { |
303 | 256 | qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "]::~MirSurface() viewCount=" << m_views.count(); | 259 | DEBUG_MSG << "() viewCount=" << m_views.count(); |
304 | 257 | 260 | ||
305 | 258 | Q_ASSERT(m_views.isEmpty()); | 261 | Q_ASSERT(m_views.isEmpty()); |
306 | 259 | 262 | ||
307 | 260 | QMutexLocker locker(&m_mutex); | 263 | QMutexLocker locker(&m_mutex); |
309 | 261 | m_windowInfo.surface->remove_observer(m_surfaceObserver); | 264 | m_surface->remove_observer(m_surfaceObserver); |
310 | 262 | 265 | ||
311 | 263 | delete m_closeTimer; | 266 | delete m_closeTimer; |
312 | 264 | 267 | ||
313 | @@ -339,7 +342,7 @@ | |||
314 | 339 | 342 | ||
315 | 340 | const void* const userId = (void*)123; // TODO: Multimonitor support | 343 | const void* const userId = (void*)123; // TODO: Multimonitor support |
316 | 341 | 344 | ||
318 | 342 | const int framesPending = m_windowInfo.surface->buffers_ready_for_compositor(userId); | 345 | const int framesPending = m_surface->buffers_ready_for_compositor(userId); |
319 | 343 | if (framesPending > 0) { | 346 | if (framesPending > 0) { |
320 | 344 | m_textureUpdated = false; | 347 | m_textureUpdated = false; |
321 | 345 | 348 | ||
322 | @@ -400,10 +403,10 @@ | |||
323 | 400 | } | 403 | } |
324 | 401 | 404 | ||
325 | 402 | const void* const userId = (void*)123; | 405 | const void* const userId = (void*)123; |
327 | 403 | auto renderables = m_windowInfo.surface->generate_renderables(userId); | 406 | auto renderables = m_surface->generate_renderables(userId); |
328 | 404 | 407 | ||
329 | 405 | if (renderables.size() > 0 && | 408 | if (renderables.size() > 0 && |
331 | 406 | (m_windowInfo.surface->buffers_ready_for_compositor(userId) > 0 || !texture->hasBuffer()) | 409 | (m_surface->buffers_ready_for_compositor(userId) > 0 || !texture->hasBuffer()) |
332 | 407 | ) { | 410 | ) { |
333 | 408 | // Avoid holding two buffers for the compositor at the same time. Thus free the current | 411 | // Avoid holding two buffers for the compositor at the same time. Thus free the current |
334 | 409 | // before acquiring the next | 412 | // before acquiring the next |
335 | @@ -419,7 +422,7 @@ | |||
336 | 419 | m_textureUpdated = true; | 422 | m_textureUpdated = true; |
337 | 420 | } | 423 | } |
338 | 421 | 424 | ||
340 | 422 | if (m_windowInfo.surface->buffers_ready_for_compositor(userId) > 0) { | 425 | if (m_surface->buffers_ready_for_compositor(userId) > 0) { |
341 | 423 | // restart the frame dropper to give MirSurfaceItems enough time to render the next frame. | 426 | // restart the frame dropper to give MirSurfaceItems enough time to render the next frame. |
342 | 424 | // queued since the timer lives in a different thread | 427 | // queued since the timer lives in a different thread |
343 | 425 | QMetaObject::invokeMethod(&m_frameDropperTimer, "start", Qt::QueuedConnection); | 428 | QMetaObject::invokeMethod(&m_frameDropperTimer, "start", Qt::QueuedConnection); |
344 | @@ -438,7 +441,7 @@ | |||
345 | 438 | { | 441 | { |
346 | 439 | QMutexLocker locker(&m_mutex); | 442 | QMutexLocker locker(&m_mutex); |
347 | 440 | const void* const userId = (void*)123; | 443 | const void* const userId = (void*)123; |
349 | 441 | return m_windowInfo.surface->buffers_ready_for_compositor(userId); | 444 | return m_surface->buffers_ready_for_compositor(userId); |
350 | 442 | } | 445 | } |
351 | 443 | 446 | ||
352 | 444 | void MirSurface::setFocused(bool value) | 447 | void MirSurface::setFocused(bool value) |
353 | @@ -481,10 +484,10 @@ | |||
354 | 481 | 484 | ||
355 | 482 | if (m_activelyFocusedViews.isEmpty()) { | 485 | if (m_activelyFocusedViews.isEmpty()) { |
356 | 483 | DEBUG_MSG << "() unfocused"; | 486 | DEBUG_MSG << "() unfocused"; |
358 | 484 | m_controller->setActiveFocus(m_windowInfo.window, false); | 487 | m_controller->setActiveFocus(m_window, false); |
359 | 485 | } else { | 488 | } else { |
360 | 486 | DEBUG_MSG << "() focused"; | 489 | DEBUG_MSG << "() focused"; |
362 | 487 | m_controller->setActiveFocus(m_windowInfo.window, true); | 490 | m_controller->setActiveFocus(m_window, true); |
363 | 488 | } | 491 | } |
364 | 489 | 492 | ||
365 | 490 | m_neverSetSurfaceFocus = false; | 493 | m_neverSetSurfaceFocus = false; |
366 | @@ -502,14 +505,14 @@ | |||
367 | 502 | Q_EMIT closeRequested(); | 505 | Q_EMIT closeRequested(); |
368 | 503 | m_closeTimer->start(); | 506 | m_closeTimer->start(); |
369 | 504 | 507 | ||
372 | 505 | if (m_windowInfo.window) { | 508 | if (m_window) { |
373 | 506 | m_windowInfo.surface->request_client_surface_close(); | 509 | m_surface->request_client_surface_close(); |
374 | 507 | } | 510 | } |
375 | 508 | } | 511 | } |
376 | 509 | 512 | ||
377 | 510 | void MirSurface::resize(int width, int height) | 513 | void MirSurface::resize(int width, int height) |
378 | 511 | { | 514 | { |
380 | 512 | auto const &window = m_windowInfo.window; | 515 | auto const &window = m_window; |
381 | 513 | 516 | ||
382 | 514 | bool mirSizeIsDifferent = width != m_size.width() || height != m_size.height(); | 517 | bool mirSizeIsDifferent = width != m_size.width() || height != m_size.height(); |
383 | 515 | 518 | ||
384 | @@ -535,7 +538,7 @@ | |||
385 | 535 | 538 | ||
386 | 536 | void MirSurface::requestPosition(const QPoint newPosition) | 539 | void MirSurface::requestPosition(const QPoint newPosition) |
387 | 537 | { | 540 | { |
389 | 538 | m_controller->move(m_windowInfo.window, newPosition); | 541 | m_controller->move(m_window, newPosition); |
390 | 539 | } | 542 | } |
391 | 540 | 543 | ||
392 | 541 | void MirSurface::setSize(const QSize newSize) | 544 | void MirSurface::setSize(const QSize newSize) |
393 | @@ -608,8 +611,8 @@ | |||
394 | 608 | return; | 611 | return; |
395 | 609 | } | 612 | } |
396 | 610 | 613 | ||
399 | 611 | if (m_windowInfo.window) { | 614 | if (m_surface) { |
400 | 612 | m_windowInfo.surface->set_orientation(mirOrientation); | 615 | m_surface->set_orientation(mirOrientation); |
401 | 613 | } | 616 | } |
402 | 614 | 617 | ||
403 | 615 | Q_EMIT orientationAngleChanged(angle); | 618 | Q_EMIT orientationAngleChanged(angle); |
404 | @@ -623,6 +626,11 @@ | |||
405 | 623 | return QString::fromStdString(m_windowInfo.name.value()); | 626 | return QString::fromStdString(m_windowInfo.name.value()); |
406 | 624 | } | 627 | } |
407 | 625 | 628 | ||
408 | 629 | QString MirSurface::persistentId() const | ||
409 | 630 | { | ||
410 | 631 | return m_persistentId; | ||
411 | 632 | } | ||
412 | 633 | |||
413 | 626 | void MirSurface::setState(Mir::State qmlState) | 634 | void MirSurface::setState(Mir::State qmlState) |
414 | 627 | { | 635 | { |
415 | 628 | MirSurfaceState mirState; | 636 | MirSurfaceState mirState; |
416 | @@ -662,7 +670,7 @@ | |||
417 | 662 | break; | 670 | break; |
418 | 663 | } | 671 | } |
419 | 664 | 672 | ||
421 | 665 | m_controller->setState(m_windowInfo.window, mirState); | 673 | m_controller->setState(m_window, mirState); |
422 | 666 | } | 674 | } |
423 | 667 | 675 | ||
424 | 668 | void MirSurface::setLive(bool value) | 676 | void MirSurface::setLive(bool value) |
425 | @@ -692,7 +700,7 @@ | |||
426 | 692 | { | 700 | { |
427 | 693 | auto ev = makeMirEvent(event, mir_pointer_action_button_down); | 701 | auto ev = makeMirEvent(event, mir_pointer_action_button_down); |
428 | 694 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); | 702 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
430 | 695 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | 703 | m_controller->deliverPointerEvent(m_window, ev1); |
431 | 696 | event->accept(); | 704 | event->accept(); |
432 | 697 | } | 705 | } |
433 | 698 | 706 | ||
434 | @@ -700,7 +708,7 @@ | |||
435 | 700 | { | 708 | { |
436 | 701 | auto ev = makeMirEvent(event, mir_pointer_action_motion); | 709 | auto ev = makeMirEvent(event, mir_pointer_action_motion); |
437 | 702 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); | 710 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
439 | 703 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | 711 | m_controller->deliverPointerEvent(m_window, ev1); |
440 | 704 | event->accept(); | 712 | event->accept(); |
441 | 705 | } | 713 | } |
442 | 706 | 714 | ||
443 | @@ -708,7 +716,7 @@ | |||
444 | 708 | { | 716 | { |
445 | 709 | auto ev = makeMirEvent(event, mir_pointer_action_button_up); | 717 | auto ev = makeMirEvent(event, mir_pointer_action_button_up); |
446 | 710 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); | 718 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
448 | 711 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | 719 | m_controller->deliverPointerEvent(m_window, ev1); |
449 | 712 | event->accept(); | 720 | event->accept(); |
450 | 713 | } | 721 | } |
451 | 714 | 722 | ||
452 | @@ -716,7 +724,7 @@ | |||
453 | 716 | { | 724 | { |
454 | 717 | auto ev = makeMirEvent(event, mir_pointer_action_enter); | 725 | auto ev = makeMirEvent(event, mir_pointer_action_enter); |
455 | 718 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); | 726 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
457 | 719 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | 727 | m_controller->deliverPointerEvent(m_window, ev1); |
458 | 720 | event->accept(); | 728 | event->accept(); |
459 | 721 | } | 729 | } |
460 | 722 | 730 | ||
461 | @@ -724,7 +732,7 @@ | |||
462 | 724 | { | 732 | { |
463 | 725 | auto ev = makeMirEvent(event, mir_pointer_action_leave); | 733 | auto ev = makeMirEvent(event, mir_pointer_action_leave); |
464 | 726 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); | 734 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
466 | 727 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | 735 | m_controller->deliverPointerEvent(m_window, ev1); |
467 | 728 | event->accept(); | 736 | event->accept(); |
468 | 729 | } | 737 | } |
469 | 730 | 738 | ||
470 | @@ -732,7 +740,7 @@ | |||
471 | 732 | { | 740 | { |
472 | 733 | auto ev = makeMirEvent(event, mir_pointer_action_motion); | 741 | auto ev = makeMirEvent(event, mir_pointer_action_motion); |
473 | 734 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); | 742 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
475 | 735 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | 743 | m_controller->deliverPointerEvent(m_window, ev1); |
476 | 736 | event->accept(); | 744 | event->accept(); |
477 | 737 | } | 745 | } |
478 | 738 | 746 | ||
479 | @@ -740,7 +748,7 @@ | |||
480 | 740 | { | 748 | { |
481 | 741 | auto ev = makeMirEvent(event); | 749 | auto ev = makeMirEvent(event); |
482 | 742 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); | 750 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
484 | 743 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | 751 | m_controller->deliverPointerEvent(m_window, ev1); |
485 | 744 | event->accept(); | 752 | event->accept(); |
486 | 745 | } | 753 | } |
487 | 746 | 754 | ||
488 | @@ -748,7 +756,7 @@ | |||
489 | 748 | { | 756 | { |
490 | 749 | auto ev = makeMirEvent(qtEvent); | 757 | auto ev = makeMirEvent(qtEvent); |
491 | 750 | auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get()); | 758 | auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get()); |
493 | 751 | m_controller->deliverKeyboardEvent(m_windowInfo.window, ev1); | 759 | m_controller->deliverKeyboardEvent(m_window, ev1); |
494 | 752 | qtEvent->accept(); | 760 | qtEvent->accept(); |
495 | 753 | } | 761 | } |
496 | 754 | 762 | ||
497 | @@ -756,7 +764,7 @@ | |||
498 | 756 | { | 764 | { |
499 | 757 | auto ev = makeMirEvent(qtEvent); | 765 | auto ev = makeMirEvent(qtEvent); |
500 | 758 | auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get()); | 766 | auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get()); |
502 | 759 | m_controller->deliverKeyboardEvent(m_windowInfo.window, ev1); | 767 | m_controller->deliverKeyboardEvent(m_window, ev1); |
503 | 760 | qtEvent->accept(); | 768 | qtEvent->accept(); |
504 | 761 | } | 769 | } |
505 | 762 | 770 | ||
506 | @@ -767,7 +775,7 @@ | |||
507 | 767 | { | 775 | { |
508 | 768 | auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp); | 776 | auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp); |
509 | 769 | auto ev1 = reinterpret_cast<MirTouchEvent const*>(ev.get()); | 777 | auto ev1 = reinterpret_cast<MirTouchEvent const*>(ev.get()); |
511 | 770 | m_controller->deliverTouchEvent(m_windowInfo.window, ev1); | 778 | m_controller->deliverTouchEvent(m_window, ev1); |
512 | 771 | } | 779 | } |
513 | 772 | 780 | ||
514 | 773 | bool MirSurface::clientIsRunning() const | 781 | bool MirSurface::clientIsRunning() const |
515 | @@ -900,7 +908,7 @@ | |||
516 | 900 | return; | 908 | return; |
517 | 901 | } | 909 | } |
518 | 902 | 910 | ||
520 | 903 | m_windowInfo.surface->set_keymap(MirInputDeviceId(), "", layout.toStdString(), variant.toStdString(), ""); | 911 | m_surface->set_keymap(MirInputDeviceId(), "", layout.toStdString(), variant.toStdString(), ""); |
521 | 904 | } | 912 | } |
522 | 905 | 913 | ||
523 | 906 | QCursor MirSurface::cursor() const | 914 | QCursor MirSurface::cursor() const |
524 | @@ -1054,7 +1062,7 @@ | |||
525 | 1054 | 1062 | ||
526 | 1055 | m_closingState = CloseOverdue; | 1063 | m_closingState = CloseOverdue; |
527 | 1056 | 1064 | ||
529 | 1057 | m_controller->requestClose(m_windowInfo.window); | 1065 | m_controller->requestClose(m_window); |
530 | 1058 | } | 1066 | } |
531 | 1059 | 1067 | ||
532 | 1060 | void MirSurface::setCloseTimer(AbstractTimer *timer) | 1068 | void MirSurface::setCloseTimer(AbstractTimer *timer) |
533 | 1061 | 1069 | ||
534 | === modified file 'miral-qt/src/modules/Unity/Application/mirsurface.h' | |||
535 | --- miral-qt/src/modules/Unity/Application/mirsurface.h 2016-08-22 22:31:41 +0000 | |||
536 | +++ miral-qt/src/modules/Unity/Application/mirsurface.h 2016-09-07 20:36:39 +0000 | |||
537 | @@ -49,7 +49,7 @@ | |||
538 | 49 | Q_OBJECT | 49 | Q_OBJECT |
539 | 50 | 50 | ||
540 | 51 | public: | 51 | public: |
542 | 52 | MirSurface(WindowInfo windowInfo, | 52 | MirSurface(NewWindowInfo windowInfo, |
543 | 53 | WindowControllerInterface *controller); | 53 | WindowControllerInterface *controller); |
544 | 54 | virtual ~MirSurface(); | 54 | virtual ~MirSurface(); |
545 | 55 | 55 | ||
546 | @@ -60,6 +60,8 @@ | |||
547 | 60 | 60 | ||
548 | 61 | QString name() const override; | 61 | QString name() const override; |
549 | 62 | 62 | ||
550 | 63 | QString persistentId() const override; | ||
551 | 64 | |||
552 | 63 | QSize size() const override; | 65 | QSize size() const override; |
553 | 64 | void resize(int width, int height) override; | 66 | void resize(int width, int height) override; |
554 | 65 | Q_INVOKABLE void resize(const QSize &size) override { resize(size.width(), size.height()); } | 67 | Q_INVOKABLE void resize(const QSize &size) override { resize(size.width(), size.height()); } |
555 | @@ -158,7 +160,7 @@ | |||
556 | 158 | // useful for tests | 160 | // useful for tests |
557 | 159 | void setCloseTimer(AbstractTimer *timer); | 161 | void setCloseTimer(AbstractTimer *timer); |
558 | 160 | std::shared_ptr<SurfaceObserver> surfaceObserver() const; | 162 | std::shared_ptr<SurfaceObserver> surfaceObserver() const; |
560 | 161 | WindowInfo windowInfo() const { return m_windowInfo; } | 163 | miral::Window window() const { return m_window; } |
561 | 162 | 164 | ||
562 | 163 | public Q_SLOTS: | 165 | public Q_SLOTS: |
563 | 164 | void onCompositorSwappedBuffers() override; | 166 | void onCompositorSwappedBuffers() override; |
564 | @@ -183,8 +185,11 @@ | |||
565 | 183 | void updateActiveFocus(); | 185 | void updateActiveFocus(); |
566 | 184 | 186 | ||
567 | 185 | WindowInfo m_windowInfo; | 187 | WindowInfo m_windowInfo; |
568 | 188 | miral::Window m_window; | ||
569 | 189 | std::shared_ptr<mir::scene::Surface> m_surface; // keep copy of the Surface for lifecycle | ||
570 | 186 | QPointer<SessionInterface> m_session; | 190 | QPointer<SessionInterface> m_session; |
571 | 187 | WindowControllerInterface *const m_controller; | 191 | WindowControllerInterface *const m_controller; |
572 | 192 | QString m_persistentId; | ||
573 | 188 | bool m_firstFrameDrawn; | 193 | bool m_firstFrameDrawn; |
574 | 189 | 194 | ||
575 | 190 | //FIXME - have to save the state as Mir has no getter for it (bug:1357429) | 195 | //FIXME - have to save the state as Mir has no getter for it (bug:1357429) |
576 | 191 | 196 | ||
577 | === modified file 'miral-qt/src/modules/Unity/Application/windowmodel.cpp' | |||
578 | --- miral-qt/src/modules/Unity/Application/windowmodel.cpp 2016-09-06 15:21:11 +0000 | |||
579 | +++ miral-qt/src/modules/Unity/Application/windowmodel.cpp 2016-09-07 20:36:39 +0000 | |||
580 | @@ -69,7 +69,7 @@ | |||
581 | 69 | return roleNames; | 69 | return roleNames; |
582 | 70 | } | 70 | } |
583 | 71 | 71 | ||
585 | 72 | void WindowModel::onWindowAdded(const WindowInfo windowInfo, const int index) | 72 | void WindowModel::onWindowAdded(const NewWindowInfo windowInfo, const int index) |
586 | 73 | { | 73 | { |
587 | 74 | auto mirSurface = new MirSurface(windowInfo, m_windowController); | 74 | auto mirSurface = new MirSurface(windowInfo, m_windowController); |
588 | 75 | beginInsertRows(QModelIndex(), index, index); | 75 | beginInsertRows(QModelIndex(), index, index); |
589 | 76 | 76 | ||
590 | === modified file 'miral-qt/src/modules/Unity/Application/windowmodel.h' | |||
591 | --- miral-qt/src/modules/Unity/Application/windowmodel.h 2016-08-24 12:40:48 +0000 | |||
592 | +++ miral-qt/src/modules/Unity/Application/windowmodel.h 2016-09-07 20:36:39 +0000 | |||
593 | @@ -53,7 +53,7 @@ | |||
594 | 53 | void countChanged(); | 53 | void countChanged(); |
595 | 54 | 54 | ||
596 | 55 | private Q_SLOTS: | 55 | private Q_SLOTS: |
598 | 56 | void onWindowAdded(const WindowInfo windowInfo, const int index); | 56 | void onWindowAdded(const NewWindowInfo windowInfo, const int index); |
599 | 57 | void onWindowRemoved(const int index); | 57 | void onWindowRemoved(const int index); |
600 | 58 | void onWindowMoved(const QPoint topLeft, const int index); | 58 | void onWindowMoved(const QPoint topLeft, const int index); |
601 | 59 | void onWindowResized(const QSize size, const int index); | 59 | void onWindowResized(const QSize size, const int index); |
602 | 60 | 60 | ||
603 | === modified file 'miral-qt/src/platforms/mirserver/nativeinterface.h' | |||
604 | --- miral-qt/src/platforms/mirserver/nativeinterface.h 2016-08-16 14:15:26 +0000 | |||
605 | +++ miral-qt/src/platforms/mirserver/nativeinterface.h 2016-09-07 20:36:39 +0000 | |||
606 | @@ -28,6 +28,7 @@ | |||
607 | 28 | 28 | ||
608 | 29 | // mir | 29 | // mir |
609 | 30 | namespace mir { namespace scene { class PromptSessionManager; }} | 30 | namespace mir { namespace scene { class PromptSessionManager; }} |
610 | 31 | namespace mir { namespace shell { class PersistentSurfaceStore; }} | ||
611 | 31 | 32 | ||
612 | 32 | class NativeInterface : public QPlatformNativeInterface | 33 | class NativeInterface : public QPlatformNativeInterface |
613 | 33 | { | 34 | { |
614 | @@ -42,6 +43,7 @@ | |||
615 | 42 | QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const override; | 43 | QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const override; |
616 | 43 | 44 | ||
617 | 44 | std::shared_ptr<mir::scene::PromptSessionManager> thePromptSessionManager() const; | 45 | std::shared_ptr<mir::scene::PromptSessionManager> thePromptSessionManager() const; |
618 | 46 | std::shared_ptr<mir::shell::PersistentSurfaceStore> thePersistentSurfaceStore() const; | ||
619 | 45 | 47 | ||
620 | 46 | private: | 48 | private: |
621 | 47 | QMirServer *m_qMirServer; | 49 | QMirServer *m_qMirServer; |
622 | 48 | 50 | ||
623 | === modified file 'miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp' | |||
624 | --- miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp 2016-09-06 12:21:43 +0000 | |||
625 | +++ miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp 2016-09-07 20:36:39 +0000 | |||
626 | @@ -21,7 +21,7 @@ | |||
627 | 21 | #include "miral/window_manager_tools.h" | 21 | #include "miral/window_manager_tools.h" |
628 | 22 | #include "miral/window_specification.h" | 22 | #include "miral/window_specification.h" |
629 | 23 | 23 | ||
631 | 24 | #include "mir/scene/surface.h" | 24 | #include <mir/scene/surface.h> |
632 | 25 | #include <QDebug> | 25 | #include <QDebug> |
633 | 26 | 26 | ||
634 | 27 | WindowManagementPolicy::WindowManagementPolicy(const miral::WindowManagerTools &tools, | 27 | WindowManagementPolicy::WindowManagementPolicy(const miral::WindowManagerTools &tools, |
635 | @@ -88,7 +88,9 @@ | |||
636 | 88 | void WindowManagementPolicy::advise_new_window(const miral::WindowInfo &windowInfo) | 88 | void WindowManagementPolicy::advise_new_window(const miral::WindowInfo &windowInfo) |
637 | 89 | { | 89 | { |
638 | 90 | // TODO: attach surface observer here | 90 | // TODO: attach surface observer here |
640 | 91 | m_windowModel.addWindow(windowInfo); | 91 | std::string persistentId = m_tools.id_for_window(windowInfo.window()); |
641 | 92 | |||
642 | 93 | m_windowModel.addWindow(windowInfo, persistentId); | ||
643 | 92 | } | 94 | } |
644 | 93 | 95 | ||
645 | 94 | void WindowManagementPolicy::advise_delete_window(const miral::WindowInfo &windowInfo) | 96 | void WindowManagementPolicy::advise_delete_window(const miral::WindowInfo &windowInfo) |
646 | 95 | 97 | ||
647 | === modified file 'miral-qt/src/platforms/mirserver/windowmodelnotifier.cpp' | |||
648 | --- miral-qt/src/platforms/mirserver/windowmodelnotifier.cpp 2016-09-06 15:31:41 +0000 | |||
649 | +++ miral-qt/src/platforms/mirserver/windowmodelnotifier.cpp 2016-09-07 20:36:39 +0000 | |||
650 | @@ -31,6 +31,7 @@ | |||
651 | 31 | 31 | ||
652 | 32 | WindowModelNotifier::WindowModelNotifier() | 32 | WindowModelNotifier::WindowModelNotifier() |
653 | 33 | { | 33 | { |
654 | 34 | qRegisterMetaType<qtmir::NewWindowInfo>(); | ||
655 | 34 | qRegisterMetaType<qtmir::WindowInfo>(); | 35 | qRegisterMetaType<qtmir::WindowInfo>(); |
656 | 35 | qRegisterMetaType<QVector<int>>(); | 36 | qRegisterMetaType<QVector<int>>(); |
657 | 36 | } | 37 | } |
658 | @@ -40,12 +41,13 @@ | |||
659 | 40 | 41 | ||
660 | 41 | } | 42 | } |
661 | 42 | 43 | ||
663 | 43 | void WindowModelNotifier::addWindow(const miral::WindowInfo &windowInfo) | 44 | void WindowModelNotifier::addWindow(const miral::WindowInfo &windowInfo, const std::string &persistentId) |
664 | 44 | { | 45 | { |
665 | 45 | auto stackPosition = m_windowStack.count(); | 46 | auto stackPosition = m_windowStack.count(); |
666 | 46 | m_windowStack.push_back(windowInfo.window()); // ASSUMPTION: Mir should tell us where in stack | 47 | m_windowStack.push_back(windowInfo.window()); // ASSUMPTION: Mir should tell us where in stack |
667 | 47 | 48 | ||
669 | 48 | Q_EMIT windowAdded(windowInfo, stackPosition); | 49 | NewWindowInfo newWindowInfo{windowInfo, persistentId}; |
670 | 50 | Q_EMIT windowAdded(newWindowInfo, stackPosition); | ||
671 | 49 | } | 51 | } |
672 | 50 | 52 | ||
673 | 51 | void WindowModelNotifier::removeWindow(const miral::WindowInfo &windowInfo) | 53 | void WindowModelNotifier::removeWindow(const miral::WindowInfo &windowInfo) |
674 | 52 | 54 | ||
675 | === modified file 'miral-qt/src/platforms/mirserver/windowmodelnotifier.h' | |||
676 | --- miral-qt/src/platforms/mirserver/windowmodelnotifier.h 2016-08-24 12:30:45 +0000 | |||
677 | +++ miral-qt/src/platforms/mirserver/windowmodelnotifier.h 2016-09-07 20:36:39 +0000 | |||
678 | @@ -32,7 +32,7 @@ | |||
679 | 32 | WindowModelNotifier(); | 32 | WindowModelNotifier(); |
680 | 33 | virtual ~WindowModelNotifier(); | 33 | virtual ~WindowModelNotifier(); |
681 | 34 | 34 | ||
683 | 35 | void addWindow(const miral::WindowInfo &windowInfo); | 35 | void addWindow(const miral::WindowInfo &windowInfo, const std::string &persistentId = ""); |
684 | 36 | void removeWindow(const miral::WindowInfo &windowInfo); | 36 | void removeWindow(const miral::WindowInfo &windowInfo); |
685 | 37 | 37 | ||
686 | 38 | void moveWindow(const miral::WindowInfo &windowInfo, mir::geometry::Point topLeft); | 38 | void moveWindow(const miral::WindowInfo &windowInfo, mir::geometry::Point topLeft); |
687 | 39 | 39 | ||
688 | === modified file 'miral-qt/tests/framework/CMakeLists.txt' | |||
689 | --- miral-qt/tests/framework/CMakeLists.txt 2016-08-22 21:34:31 +0000 | |||
690 | +++ miral-qt/tests/framework/CMakeLists.txt 2016-09-07 20:36:39 +0000 | |||
691 | @@ -29,6 +29,7 @@ | |||
692 | 29 | mock_shared_wakelock.cpp | 29 | mock_shared_wakelock.cpp |
693 | 30 | mock_surface.cpp | 30 | mock_surface.cpp |
694 | 31 | mock_task_controller.cpp | 31 | mock_task_controller.cpp |
695 | 32 | mock_persistent_surface_store.cpp | ||
696 | 32 | stub_input_channel.cpp | 33 | stub_input_channel.cpp |
697 | 33 | fake_surface.h | 34 | fake_surface.h |
698 | 34 | qtmir_test.cpp | 35 | qtmir_test.cpp |
699 | 35 | 36 | ||
700 | === modified file 'miral-qt/tests/framework/fake_mirsurface.cpp' | |||
701 | --- miral-qt/tests/framework/fake_mirsurface.cpp 2016-08-10 15:01:44 +0000 | |||
702 | +++ miral-qt/tests/framework/fake_mirsurface.cpp 2016-09-07 20:36:39 +0000 | |||
703 | @@ -54,6 +54,8 @@ | |||
704 | 54 | 54 | ||
705 | 55 | QString FakeMirSurface::name() const { return QString("Fake MirSurface"); } | 55 | QString FakeMirSurface::name() const { return QString("Fake MirSurface"); } |
706 | 56 | 56 | ||
707 | 57 | QString FakeMirSurface::persistentId() const { return QString("FakeSurfaceId"); } | ||
708 | 58 | |||
709 | 57 | QSize FakeMirSurface::size() const { return m_size; } | 59 | QSize FakeMirSurface::size() const { return m_size; } |
710 | 58 | 60 | ||
711 | 59 | QPoint FakeMirSurface::position() const { return m_position; } | 61 | QPoint FakeMirSurface::position() const { return m_position; } |
712 | 60 | 62 | ||
713 | === modified file 'miral-qt/tests/framework/fake_mirsurface.h' | |||
714 | --- miral-qt/tests/framework/fake_mirsurface.h 2016-08-10 15:01:44 +0000 | |||
715 | +++ miral-qt/tests/framework/fake_mirsurface.h 2016-09-07 20:36:39 +0000 | |||
716 | @@ -53,6 +53,7 @@ | |||
717 | 53 | // unity.shell.application.MirSurfaceInterface | 53 | // unity.shell.application.MirSurfaceInterface |
718 | 54 | Mir::Type type() const override; | 54 | Mir::Type type() const override; |
719 | 55 | QString name() const override; | 55 | QString name() const override; |
720 | 56 | QString persistentId() const override; | ||
721 | 56 | QSize size() const override; | 57 | QSize size() const override; |
722 | 57 | void resize(int width, int height) override; | 58 | void resize(int width, int height) override; |
723 | 58 | void resize(const QSize &size) override; | 59 | void resize(const QSize &size) override; |
724 | 59 | 60 | ||
725 | === added file 'miral-qt/tests/framework/mock_persistent_surface_store.cpp' | |||
726 | --- miral-qt/tests/framework/mock_persistent_surface_store.cpp 1970-01-01 00:00:00 +0000 | |||
727 | +++ miral-qt/tests/framework/mock_persistent_surface_store.cpp 2016-09-07 20:36:39 +0000 | |||
728 | @@ -0,0 +1,30 @@ | |||
729 | 1 | /* | ||
730 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
731 | 3 | * | ||
732 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
733 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
734 | 6 | * the Free Software Foundation. | ||
735 | 7 | * | ||
736 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
737 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
738 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
739 | 11 | * Lesser General Public License for more details. | ||
740 | 12 | * | ||
741 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
742 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
743 | 15 | */ | ||
744 | 16 | |||
745 | 17 | #include "mock_persistent_surface_store.h" | ||
746 | 18 | |||
747 | 19 | namespace mir | ||
748 | 20 | { | ||
749 | 21 | namespace shell | ||
750 | 22 | { | ||
751 | 23 | |||
752 | 24 | MockPersistentSurfaceStore::MockPersistentSurfaceStore() | ||
753 | 25 | { | ||
754 | 26 | |||
755 | 27 | } | ||
756 | 28 | |||
757 | 29 | } // namespace shell | ||
758 | 30 | } // namespace mir | ||
759 | 0 | 31 | ||
760 | === added file 'miral-qt/tests/framework/mock_persistent_surface_store.h' | |||
761 | --- miral-qt/tests/framework/mock_persistent_surface_store.h 1970-01-01 00:00:00 +0000 | |||
762 | +++ miral-qt/tests/framework/mock_persistent_surface_store.h 2016-09-07 20:36:39 +0000 | |||
763 | @@ -0,0 +1,24 @@ | |||
764 | 1 | #ifndef MOCKPERSISTENTSURFACESTORE_H | ||
765 | 2 | #define MOCKPERSISTENTSURFACESTORE_H | ||
766 | 3 | |||
767 | 4 | #include <mir/shell/persistent_surface_store.h> | ||
768 | 5 | #include <gmock/gmock.h> | ||
769 | 6 | |||
770 | 7 | namespace mir | ||
771 | 8 | { | ||
772 | 9 | namespace shell | ||
773 | 10 | { | ||
774 | 11 | |||
775 | 12 | class MockPersistentSurfaceStore : public PersistentSurfaceStore | ||
776 | 13 | { | ||
777 | 14 | public: | ||
778 | 15 | MockPersistentSurfaceStore(); | ||
779 | 16 | |||
780 | 17 | MOCK_METHOD1(id_for_surface, Id(std::shared_ptr<scene::Surface> const& surface)); | ||
781 | 18 | MOCK_CONST_METHOD1(surface_for_id, std::shared_ptr<scene::Surface>(Id const& id)); | ||
782 | 19 | }; | ||
783 | 20 | |||
784 | 21 | } | ||
785 | 22 | } | ||
786 | 23 | |||
787 | 24 | #endif // MOCKPERSISTENTSURFACESTORE_H | ||
788 | 0 | 25 | ||
789 | === modified file 'miral-qt/tests/framework/qtmir_test.cpp' | |||
790 | --- miral-qt/tests/framework/qtmir_test.cpp 2016-08-23 11:42:28 +0000 | |||
791 | +++ miral-qt/tests/framework/qtmir_test.cpp 2016-09-07 20:36:39 +0000 | |||
792 | @@ -109,6 +109,7 @@ | |||
793 | 109 | 109 | ||
794 | 110 | QtMirTest::QtMirTest() | 110 | QtMirTest::QtMirTest() |
795 | 111 | : promptSessionManager(std::make_shared<StubPromptSessionManager>()) | 111 | : promptSessionManager(std::make_shared<StubPromptSessionManager>()) |
796 | 112 | , persistentSurfaceStore(std::make_shared<StubPersistentSurfaceStore>()) | ||
797 | 112 | , applicationManager(taskControllerSharedPointer, | 113 | , applicationManager(taskControllerSharedPointer, |
798 | 113 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), | 114 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), |
799 | 114 | QSharedPointer<ProcInfo>(&procInfo,[](ProcInfo *){}), | 115 | QSharedPointer<ProcInfo>(&procInfo,[](ProcInfo *){}), |
800 | 115 | 116 | ||
801 | === modified file 'miral-qt/tests/framework/qtmir_test.h' | |||
802 | --- miral-qt/tests/framework/qtmir_test.h 2016-08-23 11:42:28 +0000 | |||
803 | +++ miral-qt/tests/framework/qtmir_test.h 2016-09-07 20:36:39 +0000 | |||
804 | @@ -38,6 +38,7 @@ | |||
805 | 38 | #include "mock_shared_wakelock.h" | 38 | #include "mock_shared_wakelock.h" |
806 | 39 | #include "mock_settings.h" | 39 | #include "mock_settings.h" |
807 | 40 | #include "mock_task_controller.h" | 40 | #include "mock_task_controller.h" |
808 | 41 | #include "mock_persistent_surface_store.h" | ||
809 | 41 | 42 | ||
810 | 42 | namespace ms = mir::scene; | 43 | namespace ms = mir::scene; |
811 | 43 | using namespace qtmir; | 44 | using namespace qtmir; |
812 | @@ -45,6 +46,7 @@ | |||
813 | 45 | namespace qtmir { | 46 | namespace qtmir { |
814 | 46 | 47 | ||
815 | 47 | typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager; | 48 | typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager; |
816 | 49 | typedef testing::NiceMock<mir::shell::MockPersistentSurfaceStore> StubPersistentSurfaceStore; | ||
817 | 48 | 50 | ||
818 | 49 | // For better output in ASSERT_* and EXPECT_* error messages | 51 | // For better output in ASSERT_* and EXPECT_* error messages |
819 | 50 | void PrintTo(const Application::InternalState& state, ::std::ostream* os); | 52 | void PrintTo(const Application::InternalState& state, ::std::ostream* os); |
820 | @@ -71,6 +73,7 @@ | |||
821 | 71 | testing::NiceMock<MockSharedWakelock> sharedWakelock; | 73 | testing::NiceMock<MockSharedWakelock> sharedWakelock; |
822 | 72 | testing::NiceMock<MockSettings> settings; | 74 | testing::NiceMock<MockSettings> settings; |
823 | 73 | std::shared_ptr<StubPromptSessionManager> promptSessionManager; | 75 | std::shared_ptr<StubPromptSessionManager> promptSessionManager; |
824 | 76 | std::shared_ptr<StubPersistentSurfaceStore> persistentSurfaceStore; | ||
825 | 74 | 77 | ||
826 | 75 | mir::shell::Shell *mirShell{nullptr}; | 78 | mir::shell::Shell *mirShell{nullptr}; |
827 | 76 | ApplicationManager applicationManager; | 79 | ApplicationManager applicationManager; |
828 | 77 | 80 | ||
829 | === modified file 'miral-qt/tests/modules/WindowManager/windowmodel_test.cpp' | |||
830 | --- miral-qt/tests/modules/WindowManager/windowmodel_test.cpp 2016-08-25 10:34:52 +0000 | |||
831 | +++ miral-qt/tests/modules/WindowManager/windowmodel_test.cpp 2016-09-07 20:36:39 +0000 | |||
832 | @@ -66,7 +66,7 @@ | |||
833 | 66 | 66 | ||
834 | 67 | miral::Window getMirALWindowFromModel(const WindowModel &model, int index) | 67 | miral::Window getMirALWindowFromModel(const WindowModel &model, int index) |
835 | 68 | { | 68 | { |
837 | 69 | return getMirSurfaceFromModel(model, index)->windowInfo().window; | 69 | return getMirSurfaceFromModel(model, index)->window(); |
838 | 70 | } | 70 | } |
839 | 71 | 71 | ||
840 | 72 | const std::shared_ptr<StubSession> stubSession{std::make_shared<StubSession>()}; | 72 | const std::shared_ptr<StubSession> stubSession{std::make_shared<StubSession>()}; |
841 | 73 | 73 | ||
842 | === modified file 'miral/basic_window_manager.cpp' | |||
843 | --- miral/basic_window_manager.cpp 2016-09-05 15:50:13 +0000 | |||
844 | +++ miral/basic_window_manager.cpp 2016-09-07 20:36:39 +0000 | |||
845 | @@ -646,6 +646,17 @@ | |||
846 | 646 | #endif | 646 | #endif |
847 | 647 | } | 647 | } |
848 | 648 | 648 | ||
849 | 649 | auto miral::BasicWindowManager::id_for_window(Window const& window) const -> std::string | ||
850 | 650 | { | ||
851 | 651 | if (!window) | ||
852 | 652 | BOOST_THROW_EXCEPTION(std::runtime_error{"Null Window has no Persistent ID"}); | ||
853 | 653 | |||
854 | 654 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0) | ||
855 | 655 | return persistent_surface_store->id_for_surface(window).serialize_to_string(); | ||
856 | 656 | #else | ||
857 | 657 | BOOST_THROW_EXCEPTION(std::runtime_error{"Persistent IDs unavailable with this Mir server version"}); | ||
858 | 658 | #endif | ||
859 | 659 | } | ||
860 | 649 | 660 | ||
861 | 650 | void miral::BasicWindowManager::place_and_size(WindowInfo& root, Point const& new_pos, Size const& new_size) | 661 | void miral::BasicWindowManager::place_and_size(WindowInfo& root, Point const& new_pos, Size const& new_size) |
862 | 651 | { | 662 | { |
863 | 652 | 663 | ||
864 | === modified file 'miral/basic_window_manager.h' | |||
865 | --- miral/basic_window_manager.h 2016-08-29 16:17:16 +0000 | |||
866 | +++ miral/basic_window_manager.h 2016-09-07 20:36:39 +0000 | |||
867 | @@ -131,6 +131,8 @@ | |||
868 | 131 | 131 | ||
869 | 132 | auto info_for_window_id(std::string const& id) const -> WindowInfo& override; | 132 | auto info_for_window_id(std::string const& id) const -> WindowInfo& override; |
870 | 133 | 133 | ||
871 | 134 | auto id_for_window(Window const& window) const -> std::string override; | ||
872 | 135 | |||
873 | 134 | void invoke_under_lock(std::function<void()> const& callback) override; | 136 | void invoke_under_lock(std::function<void()> const& callback) override; |
874 | 135 | 137 | ||
875 | 136 | private: | 138 | private: |
876 | 137 | 139 | ||
877 | === modified file 'miral/symbols.map' | |||
878 | --- miral/symbols.map 2016-09-06 08:05:38 +0000 | |||
879 | +++ miral/symbols.map 2016-09-07 20:36:39 +0000 | |||
880 | @@ -152,6 +152,7 @@ | |||
881 | 152 | miral::WindowManagerTools::focus_next_application*; | 152 | miral::WindowManagerTools::focus_next_application*; |
882 | 153 | miral::WindowManagerTools::focus_next_within_application*; | 153 | miral::WindowManagerTools::focus_next_within_application*; |
883 | 154 | miral::WindowManagerTools::for_each_application*; | 154 | miral::WindowManagerTools::for_each_application*; |
884 | 155 | miral::WindowManagerTools::id_for_window*; | ||
885 | 155 | miral::WindowManagerTools::info_for*; | 156 | miral::WindowManagerTools::info_for*; |
886 | 156 | miral::WindowManagerTools::info_for_window_id*; | 157 | miral::WindowManagerTools::info_for_window_id*; |
887 | 157 | miral::WindowManagerTools::invoke_under_lock*; | 158 | miral::WindowManagerTools::invoke_under_lock*; |
888 | 158 | 159 | ||
889 | === modified file 'miral/window_manager_tools.cpp' | |||
890 | --- miral/window_manager_tools.cpp 2016-08-15 15:36:00 +0000 | |||
891 | +++ miral/window_manager_tools.cpp 2016-09-07 20:36:39 +0000 | |||
892 | @@ -80,5 +80,8 @@ | |||
893 | 80 | auto miral::WindowManagerTools::info_for_window_id(std::string const& id) const -> WindowInfo& | 80 | auto miral::WindowManagerTools::info_for_window_id(std::string const& id) const -> WindowInfo& |
894 | 81 | { return tools->info_for_window_id(id); } | 81 | { return tools->info_for_window_id(id); } |
895 | 82 | 82 | ||
896 | 83 | auto miral::WindowManagerTools::id_for_window(Window const& window) const -> std::string | ||
897 | 84 | { return tools->id_for_window(window); } | ||
898 | 85 | |||
899 | 83 | void miral::WindowManagerTools::invoke_under_lock(std::function<void()> const& callback) | 86 | void miral::WindowManagerTools::invoke_under_lock(std::function<void()> const& callback) |
900 | 84 | { tools->invoke_under_lock(callback); } | 87 | { tools->invoke_under_lock(callback); } |
901 | 85 | 88 | ||
902 | === modified file 'miral/window_manager_tools_implementation.h' | |||
903 | --- miral/window_manager_tools_implementation.h 2016-08-15 15:36:00 +0000 | |||
904 | +++ miral/window_manager_tools_implementation.h 2016-09-07 20:36:39 +0000 | |||
905 | @@ -63,6 +63,7 @@ | |||
906 | 63 | virtual void raise_tree(Window const& root) = 0; | 63 | virtual void raise_tree(Window const& root) = 0; |
907 | 64 | virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0; | 64 | virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0; |
908 | 65 | virtual auto info_for_window_id(std::string const& id) const -> WindowInfo& = 0; | 65 | virtual auto info_for_window_id(std::string const& id) const -> WindowInfo& = 0; |
909 | 66 | virtual auto id_for_window(Window const& window) const -> std::string = 0; | ||
910 | 66 | /** @} */ | 67 | /** @} */ |
911 | 67 | 68 | ||
912 | 68 | /** @name Multi-thread support | 69 | /** @name Multi-thread support |
913 | 69 | 70 | ||
914 | === modified file 'test/persistent_surface_store.cpp' | |||
915 | --- test/persistent_surface_store.cpp 2016-08-12 11:27:38 +0000 | |||
916 | +++ test/persistent_surface_store.cpp 2016-09-07 20:36:39 +0000 | |||
917 | @@ -20,6 +20,8 @@ | |||
918 | 20 | #include <miral/toolkit/surface.h> | 20 | #include <miral/toolkit/surface.h> |
919 | 21 | #include <miral/toolkit/surface_spec.h> | 21 | #include <miral/toolkit/surface_spec.h> |
920 | 22 | 22 | ||
921 | 23 | #include <miral/application_info.h> | ||
922 | 24 | |||
923 | 23 | #include <mir/version.h> | 25 | #include <mir/version.h> |
924 | 24 | 26 | ||
925 | 25 | #include <gtest/gtest.h> | 27 | #include <gtest/gtest.h> |
926 | @@ -56,6 +58,31 @@ | |||
927 | 56 | ASSERT_THAT(window_info.name(), Eq(test_name)); | 58 | ASSERT_THAT(window_info.name(), Eq(test_name)); |
928 | 57 | }); | 59 | }); |
929 | 58 | } | 60 | } |
930 | 61 | |||
931 | 62 | TEST_F(PersistentSurfaceId, server_returns_correct_id_for_window) | ||
932 | 63 | { | ||
933 | 64 | char const* const test_name = __PRETTY_FUNCTION__; | ||
934 | 65 | using namespace miral::toolkit; | ||
935 | 66 | |||
936 | 67 | auto const connection = connect_client(test_name); | ||
937 | 68 | auto const spec = SurfaceSpec::for_normal_surface(connection, 50, 50, mir_pixel_format_argb_8888) | ||
938 | 69 | .set_name(test_name); | ||
939 | 70 | |||
940 | 71 | Surface const surface{spec.create_surface()}; | ||
941 | 72 | |||
942 | 73 | miral::toolkit::PersistentId client_surface_id{surface}; | ||
943 | 74 | |||
944 | 75 | tools.invoke_under_lock([&] | ||
945 | 76 | { | ||
946 | 77 | // Bit of a journey to get the miral::Window for the above surface | ||
947 | 78 | auto app = tools.find_application([&](miral::ApplicationInfo const& /*info*/){return true;}); | ||
948 | 79 | auto app_info = tools.info_for(app); | ||
949 | 80 | auto window = app_info.windows()[0]; | ||
950 | 81 | auto id = tools.id_for_window(window); | ||
951 | 82 | |||
952 | 83 | ASSERT_THAT(client_surface_id.c_str(), Eq(id)); | ||
953 | 84 | }); | ||
954 | 85 | } | ||
955 | 59 | #else | 86 | #else |
956 | 60 | TEST_F(PersistentSurfaceId, server_fails_gracefully_to_identify_window_specified_by_client) | 87 | TEST_F(PersistentSurfaceId, server_fails_gracefully_to_identify_window_specified_by_client) |
957 | 61 | { | 88 | { |
958 | @@ -75,6 +102,30 @@ | |||
959 | 75 | EXPECT_THROW(tools.info_for_window_id(client_surface_id.c_str()), std::runtime_error); | 102 | EXPECT_THROW(tools.info_for_window_id(client_surface_id.c_str()), std::runtime_error); |
960 | 76 | }); | 103 | }); |
961 | 77 | } | 104 | } |
962 | 105 | |||
963 | 106 | TEST_F(PersistentSurfaceId, server_fails_gracefully_to_return_id_for_window) | ||
964 | 107 | { | ||
965 | 108 | char const* const test_name = __PRETTY_FUNCTION__; | ||
966 | 109 | using namespace miral::toolkit; | ||
967 | 110 | |||
968 | 111 | auto const connection = connect_client(test_name); | ||
969 | 112 | auto const spec = SurfaceSpec::for_normal_surface(connection, 50, 50, mir_pixel_format_argb_8888) | ||
970 | 113 | .set_name(test_name); | ||
971 | 114 | |||
972 | 115 | Surface const surface{spec.create_surface()}; | ||
973 | 116 | |||
974 | 117 | miral::toolkit::PersistentId client_surface_id{surface}; | ||
975 | 118 | |||
976 | 119 | tools.invoke_under_lock([&] | ||
977 | 120 | { | ||
978 | 121 | // Bit of a journey to get the miral::Window for the above surface | ||
979 | 122 | auto app = tools.find_application([&](miral::ApplicationInfo const& /*info*/){return true;}); | ||
980 | 123 | auto app_info = tools.info_for(app); | ||
981 | 124 | auto window = app_info.windows()[0]; | ||
982 | 125 | |||
983 | 126 | EXPECT_THROW(tools.id_for_window(window), std::runtime_error); | ||
984 | 127 | }); | ||
985 | 128 | } | ||
986 | 78 | #endif | 129 | #endif |
987 | 79 | 130 | ||
988 | 80 | TEST_F(PersistentSurfaceId, server_fails_gracefully_to_identify_window_from_garbage_id) | 131 | TEST_F(PersistentSurfaceId, server_fails_gracefully_to_identify_window_from_garbage_id) |
989 | @@ -95,3 +146,12 @@ | |||
990 | 95 | EXPECT_THROW(tools.info_for_window_id("garbage"), std::exception); | 146 | EXPECT_THROW(tools.info_for_window_id("garbage"), std::exception); |
991 | 96 | }); | 147 | }); |
992 | 97 | } | 148 | } |
993 | 149 | |||
994 | 150 | TEST_F(PersistentSurfaceId, server_fails_gracefully_when_id_for_null_window_requested) | ||
995 | 151 | { | ||
996 | 152 | tools.invoke_under_lock([&] | ||
997 | 153 | { | ||
998 | 154 | miral::Window window; | ||
999 | 155 | EXPECT_THROW(tools.id_for_window(window), std::runtime_error); | ||
1000 | 156 | }); | ||
1001 | 157 | } |