Merge lp:~gerboland/miral/qtmir-555 into lp:miral

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
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+305112@code.launchpad.net

This proposal has been superseded by a proposal from 2016-09-07.

Commit message

[miral-qt] Merge rev 555 of qtmir: Added implementation for MirSurfaceInterface::persistentId - adapted to suit new arch

Based on https://code.launchpad.net/~unity-team/qtmir/persistent_surface_id/+merge/303580 by Daniel d'Andrada

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
=== modified file 'debian/libmiral1.symbols'
--- debian/libmiral1.symbols 2016-09-06 08:05:38 +0000
+++ debian/libmiral1.symbols 2016-09-07 20:36:39 +0000
@@ -163,6 +163,7 @@
163 (c++)"miral::WindowManagerTools::focus_next_application()@MIRAL_0.1" 0.1.0163 (c++)"miral::WindowManagerTools::focus_next_application()@MIRAL_0.1" 0.1.0
164 (c++)"miral::WindowManagerTools::focus_next_within_application()@MIRAL_0.1" 0.1.0164 (c++)"miral::WindowManagerTools::focus_next_within_application()@MIRAL_0.1" 0.1.0
165 (c++)"miral::WindowManagerTools::for_each_application(std::function<void (miral::ApplicationInfo&)> const&)@MIRAL_0.1" 0.1.0165 (c++)"miral::WindowManagerTools::for_each_application(std::function<void (miral::ApplicationInfo&)> const&)@MIRAL_0.1" 0.1.0
166 (c++)"miral::WindowManagerTools::id_for_window[abi:cxx11](miral::Window const&) const@MIRAL_0.1" 0.1.0
166 (c++)"miral::WindowManagerTools::info_for(miral::Window const&) const@MIRAL_0.1" 0.1.0167 (c++)"miral::WindowManagerTools::info_for(miral::Window const&) const@MIRAL_0.1" 0.1.0
167 (c++)"miral::WindowManagerTools::info_for(std::weak_ptr<mir::scene::Session> const&) const@MIRAL_0.1" 0.1.0168 (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::Surface> const&) const@MIRAL_0.1" 0.1.0169 (c++)"miral::WindowManagerTools::info_for(std::weak_ptr<mir::scene::Surface> const&) const@MIRAL_0.1" 0.1.0
169170
=== modified file 'include/miral/window_manager_tools.h'
--- include/miral/window_manager_tools.h 2016-08-15 15:36:00 +0000
+++ include/miral/window_manager_tools.h 2016-09-07 20:36:39 +0000
@@ -105,6 +105,13 @@
105 */105 */
106 auto info_for_window_id(std::string const& id) const -> WindowInfo&;106 auto info_for_window_id(std::string const& id) const -> WindowInfo&;
107107
108 /** retrieve the persistent surface id for a window
109 *
110 * @param id the window
111 * @return the persistent surface id
112 */
113 auto id_for_window(Window const& window) const -> std::string;
114
108 /// Send close request to the window115 /// Send close request to the window
109 void ask_client_to_close(Window const& window);116 void ask_client_to_close(Window const& window);
110117
111118
=== modified file 'miral-qt/CMakeLists.txt'
--- miral-qt/CMakeLists.txt 2016-08-16 14:21:14 +0000
+++ miral-qt/CMakeLists.txt 2016-09-07 20:36:39 +0000
@@ -90,7 +90,7 @@
90pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)90pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
91pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)91pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)
92pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)92pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)
93pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=20)93pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=21)
94pkg_check_modules(CGMANAGER libcgmanager REQUIRED)94pkg_check_modules(CGMANAGER libcgmanager REQUIRED)
9595
96add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1)96add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1)
9797
=== modified file 'miral-qt/debian/control'
--- miral-qt/debian/control 2016-08-16 14:21:14 +0000
+++ miral-qt/debian/control 2016-09-07 20:36:39 +0000
@@ -23,7 +23,7 @@
23 libubuntu-app-launch2-dev (>= 0.9),23 libubuntu-app-launch2-dev (>= 0.9),
24 libubuntu-application-api-dev (>= 2.1.0),24 libubuntu-application-api-dev (>= 2.1.0),
25 libudev-dev,25 libudev-dev,
26 libunity-api-dev (>= 7.117),26 libunity-api-dev (>= 7.118),
27 liburl-dispatcher1-dev,27 liburl-dispatcher1-dev,
28 libxkbcommon-dev,28 libxkbcommon-dev,
29 libxrender-dev,29 libxrender-dev,
@@ -37,6 +37,8 @@
37 qtdeclarative5-dev,37 qtdeclarative5-dev,
38 qtdeclarative5-private-dev,38 qtdeclarative5-private-dev,
39 quilt,39 quilt,
40# libmirserver-dev should have brought this dep. Bug lp:1617435
41 uuid-dev,
40Standards-Version: 3.9.542Standards-Version: 3.9.5
41Homepage: https://launchpad.net/qtmir43Homepage: https://launchpad.net/qtmir
42# if you don't have have commit access to this branch but would like to upload44# if you don't have have commit access to this branch but would like to upload
@@ -94,7 +96,7 @@
94Conflicts: libqtmir,96Conflicts: libqtmir,
95 libunity-mir1,97 libunity-mir1,
96Provides: unity-application-impl,98Provides: unity-application-impl,
97 unity-application-impl-20,99 unity-application-impl-21,
98Description: Qt plugin for Unity specific Mir APIs100Description: Qt plugin for Unity specific Mir APIs
99 QtMir provides Qt/QML bindings for Mir features that are exposed through the101 QtMir provides Qt/QML bindings for Mir features that are exposed through the
100 qtmir-desktop or qtmir-android QPA plugin such as Application management102 qtmir-desktop or qtmir-android QPA plugin such as Application management
101103
=== modified file 'miral-qt/debian/gles-patches/convert-to-gles.patch'
--- miral-qt/debian/gles-patches/convert-to-gles.patch 2016-08-16 14:21:14 +0000
+++ miral-qt/debian/gles-patches/convert-to-gles.patch 2016-09-07 20:36:39 +0000
@@ -9,7 +9,7 @@
9 Priority: optional9 Priority: optional
10 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>10 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
11@@ -16,7 +16,13 @@ Build-Depends: cmake,11@@ -16,7 +16,13 @@ Build-Depends: cmake,
12 libmirserver-dev (>= 0.19.0),12 libmirserver-dev (>= 0.24.0),
13 libmtdev-dev,13 libmtdev-dev,
14 libprocess-cpp-dev,14 libprocess-cpp-dev,
15+ libqt5gui5-gles,15+ libqt5gui5-gles,
@@ -84,7 +84,7 @@
84-Conflicts: libqtmir,84-Conflicts: libqtmir,
85- libunity-mir1,85- libunity-mir1,
86-Provides: unity-application-impl,86-Provides: unity-application-impl,
87- unity-application-impl-20,87- unity-application-impl-21,
88-Description: Qt plugin for Unity specific Mir APIs88-Description: Qt plugin for Unity specific Mir APIs
89- QtMir provides Qt/QML bindings for Mir features that are exposed through the89- QtMir provides Qt/QML bindings for Mir features that are exposed through the
90- qtmir-desktop or qtmir-android QPA plugin such as Application management90- qtmir-desktop or qtmir-android QPA plugin such as Application management
9191
=== modified file 'miral-qt/src/common/windowmodelnotifierinterface.h'
--- miral-qt/src/common/windowmodelnotifierinterface.h 2016-09-01 11:37:38 +0000
+++ miral-qt/src/common/windowmodelnotifierinterface.h 2016-09-07 20:36:39 +0000
@@ -31,8 +31,7 @@
31public:31public:
32 WindowInfo() = default;32 WindowInfo() = default;
33 WindowInfo(const miral::WindowInfo &windowInfo)33 WindowInfo(const miral::WindowInfo &windowInfo)
34 : window(windowInfo.window())34 : name(windowInfo.name())
35 , name(windowInfo.name())
36 , type(windowInfo.type())35 , type(windowInfo.type())
37 , state(windowInfo.state())36 , state(windowInfo.state())
38 , restoreRect(windowInfo.restore_rect())37 , restoreRect(windowInfo.restore_rect())
@@ -42,10 +41,8 @@
42 , minHeight(windowInfo.min_height())41 , minHeight(windowInfo.min_height())
43 , maxWidth(windowInfo.max_width())42 , maxWidth(windowInfo.max_width())
44 , maxHeight(windowInfo.max_height())43 , maxHeight(windowInfo.max_height())
45 , surface(window)
46 {}44 {}
4745
48 miral::Window window;
49 mir::optional_value<std::string> name;46 mir::optional_value<std::string> name;
50 MirSurfaceType type;47 MirSurfaceType type;
51 MirSurfaceState state;48 MirSurfaceState state;
@@ -56,6 +53,20 @@
56 mir::geometry::Height minHeight;53 mir::geometry::Height minHeight;
57 mir::geometry::Width maxWidth;54 mir::geometry::Width maxWidth;
58 mir::geometry::Height maxHeight;55 mir::geometry::Height maxHeight;
56};
57
58class NewWindowInfo : public WindowInfo {
59public:
60 NewWindowInfo() = default;
61 NewWindowInfo(const miral::WindowInfo &windowInfo, const std::string &persistentId = "")
62 : WindowInfo(windowInfo)
63 , window(windowInfo.window())
64 , persistentId(persistentId)
65 , surface(window)
66 {}
67
68 miral::Window window;
69 std::string persistentId;
5970
60 // hold copy of Surface shared pointer, as miral::Window has just a weak pointer to the Surface71 // hold copy of Surface shared pointer, as miral::Window has just a weak pointer to the Surface
61 // but MirSurface needs to share ownership of the Surface with Mir72 // but MirSurface needs to share ownership of the Surface with Mir
@@ -71,7 +82,7 @@
71 virtual ~WindowModelNotifierInterface() = default;82 virtual ~WindowModelNotifierInterface() = default;
7283
73Q_SIGNALS:84Q_SIGNALS:
74 void windowAdded(const qtmir::WindowInfo, const int index);85 void windowAdded(const qtmir::NewWindowInfo, const int index);
75 void windowRemoved(const int index);86 void windowRemoved(const int index);
76 void windowMoved(const QPoint topLeft, const int index);87 void windowMoved(const QPoint topLeft, const int index);
77 void windowResized(const QSize size, const int index);88 void windowResized(const QSize size, const int index);
@@ -85,6 +96,7 @@
8596
86} // namespace qtmir97} // namespace qtmir
8798
99Q_DECLARE_METATYPE(qtmir::NewWindowInfo)
88Q_DECLARE_METATYPE(qtmir::WindowInfo)100Q_DECLARE_METATYPE(qtmir::WindowInfo)
89101
90#endif // WINDOWMODELNOTIFIERINTERFACE_H102#endif // WINDOWMODELNOTIFIERINTERFACE_H
91103
=== modified file 'miral-qt/src/modules/Unity/Application/dbusfocusinfo.cpp'
--- miral-qt/src/modules/Unity/Application/dbusfocusinfo.cpp 2016-07-26 12:30:51 +0000
+++ miral-qt/src/modules/Unity/Application/dbusfocusinfo.cpp 2016-09-07 20:36:39 +0000
@@ -18,6 +18,9 @@
1818
19// local19// local
20#include "cgmanager.h"20#include "cgmanager.h"
21#include "mirsurfacelistmodel.h"
22#include "mirsurfaceinterface.h"
23#include "session_interface.h"
2124
22// QPA mirserver25// QPA mirserver
23#include <logging.h>26#include <logging.h>
@@ -87,3 +90,35 @@
87 }90 }
88 return nullptr;91 return nullptr;
89}92}
93
94bool DBusFocusInfo::isSurfaceFocused(const QString &serializedId)
95{
96 MirSurfaceInterface *qmlSurface = findQmlSurface(serializedId);
97 bool result = qmlSurface ? qmlSurface->activeFocus() : false;
98 qCDebug(QTMIR_DBUS).nospace() << "DBusFocusInfo: isSurfaceFocused("<<serializedId<<") -> " << result;
99 return result;
100}
101
102MirSurfaceInterface *DBusFocusInfo::findQmlSurface(const QString &serializedId)
103{
104 for (Application* application : m_applications) {
105 auto session = application->session();
106
107 auto surfaceList = static_cast<MirSurfaceListModel*>(session->surfaceList());
108 for (int i = 0; i < surfaceList->count(); ++i) {
109 auto qmlSurface = static_cast<MirSurfaceInterface*>(surfaceList->get(i));
110 if (qmlSurface->persistentId() == serializedId) {
111 return qmlSurface;
112 }
113 }
114
115 surfaceList = static_cast<MirSurfaceListModel*>(session->promptSurfaceList());
116 for (int i = 0; i < surfaceList->count(); ++i) {
117 auto qmlSurface = static_cast<MirSurfaceInterface*>(surfaceList->get(i));
118 if (qmlSurface->persistentId() == serializedId) {
119 return qmlSurface;
120 }
121 }
122 }
123 return nullptr;
124}
90125
=== modified file 'miral-qt/src/modules/Unity/Application/dbusfocusinfo.h'
--- miral-qt/src/modules/Unity/Application/dbusfocusinfo.h 2016-07-26 12:30:36 +0000
+++ miral-qt/src/modules/Unity/Application/dbusfocusinfo.h 2016-09-07 20:36:39 +0000
@@ -22,10 +22,11 @@
22namespace qtmir {22namespace qtmir {
2323
24class CGManager;24class CGManager;
25class MirSurfaceInterface;
2526
26/*27/*
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,
28 Remove when possible29 normally for security purposes.
29 */30 */
30class DBusFocusInfo : public QObject31class DBusFocusInfo : public QObject
31{32{
@@ -39,12 +40,21 @@
3940
40 /*41 /*
41 Returns true if the application with the given PID has input focus42 Returns true if the application with the given PID has input focus
43
44 FIXME: Identifying an app through its PID is deemed racy.
45 isSurfaceFocused() is the preferred method.
42 */46 */
43 Q_SCRIPTABLE bool isPidFocused(unsigned int pid);47 Q_SCRIPTABLE bool isPidFocused(unsigned int pid);
4448
49 /*
50 Returns true if the surface with the given id has input focus
51 */
52 Q_SCRIPTABLE bool isSurfaceFocused(const QString &surfaceId);
53
45private:54private:
46 QSet<pid_t> fetchAssociatedPids(pid_t pid);55 QSet<pid_t> fetchAssociatedPids(pid_t pid);
47 SessionInterface* findSessionWithPid(const QSet<pid_t> &pidSet);56 SessionInterface* findSessionWithPid(const QSet<pid_t> &pidSet);
57 MirSurfaceInterface *findQmlSurface(const QString &serializedId);
4858
49 const QList<Application*> &m_applications;59 const QList<Application*> &m_applications;
5060
5161
=== modified file 'miral-qt/src/modules/Unity/Application/mirsurface.cpp'
--- miral-qt/src/modules/Unity/Application/mirsurface.cpp 2016-09-01 10:58:43 +0000
+++ miral-qt/src/modules/Unity/Application/mirsurface.cpp 2016-09-07 20:36:39 +0000
@@ -44,8 +44,8 @@
4444
45using namespace qtmir;45using namespace qtmir;
4646
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__
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__
4949
50namespace {50namespace {
5151
@@ -195,25 +195,28 @@
195195
196} // namespace {196} // namespace {
197197
198MirSurface::MirSurface(WindowInfo windowInfo,198MirSurface::MirSurface(NewWindowInfo windowInfo,
199 WindowControllerInterface* controller)199 WindowControllerInterface* controller)
200 : MirSurfaceInterface()200 : MirSurfaceInterface()
201 , m_windowInfo(windowInfo)201 , m_windowInfo(windowInfo)
202 , m_window(windowInfo.window)
203 , m_surface(windowInfo.surface)
202 , m_controller(controller)204 , m_controller(controller)
205 , m_persistentId(QString::fromStdString(windowInfo.persistentId))
203 , m_firstFrameDrawn(false)206 , m_firstFrameDrawn(false)
204 , m_orientationAngle(Mir::Angle0)207 , m_orientationAngle(Mir::Angle0)
205 , m_textureUpdated(false)208 , m_textureUpdated(false)
206 , m_currentFrameNumber(0)209 , m_currentFrameNumber(0)
207 , m_live(true)210 , m_live(true)
208 , m_surfaceObserver(std::make_shared<SurfaceObserver>())211 , m_surfaceObserver(std::make_shared<SurfaceObserver>())
209 , m_position(toQPoint(windowInfo.window.top_left()))212 , m_position(toQPoint(m_window.top_left()))
210 , m_size(toQSize(windowInfo.window.size()))213 , m_size(toQSize(m_window.size()))
211 , m_shellChrome(Mir::NormalChrome)214 , m_shellChrome(Mir::NormalChrome)
212{215{
213 DEBUG_MSG << "()";216 DEBUG_MSG << "()";
214217
215 SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), windowInfo.surface.get());218 SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface.get());
216 m_windowInfo.surface->add_observer(m_surfaceObserver);219 m_surface->add_observer(m_surfaceObserver);
217220
218 //m_shellChrome = creationHints.shellChrome; TODO - where will this come from now?221 //m_shellChrome = creationHints.shellChrome; TODO - where will this come from now?
219222
@@ -253,12 +256,12 @@
253256
254MirSurface::~MirSurface()257MirSurface::~MirSurface()
255{258{
256 qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "]::~MirSurface() viewCount=" << m_views.count();259 DEBUG_MSG << "() viewCount=" << m_views.count();
257260
258 Q_ASSERT(m_views.isEmpty());261 Q_ASSERT(m_views.isEmpty());
259262
260 QMutexLocker locker(&m_mutex);263 QMutexLocker locker(&m_mutex);
261 m_windowInfo.surface->remove_observer(m_surfaceObserver);264 m_surface->remove_observer(m_surfaceObserver);
262265
263 delete m_closeTimer;266 delete m_closeTimer;
264267
@@ -339,7 +342,7 @@
339342
340 const void* const userId = (void*)123; // TODO: Multimonitor support343 const void* const userId = (void*)123; // TODO: Multimonitor support
341344
342 const int framesPending = m_windowInfo.surface->buffers_ready_for_compositor(userId);345 const int framesPending = m_surface->buffers_ready_for_compositor(userId);
343 if (framesPending > 0) {346 if (framesPending > 0) {
344 m_textureUpdated = false;347 m_textureUpdated = false;
345348
@@ -400,10 +403,10 @@
400 }403 }
401404
402 const void* const userId = (void*)123;405 const void* const userId = (void*)123;
403 auto renderables = m_windowInfo.surface->generate_renderables(userId);406 auto renderables = m_surface->generate_renderables(userId);
404407
405 if (renderables.size() > 0 &&408 if (renderables.size() > 0 &&
406 (m_windowInfo.surface->buffers_ready_for_compositor(userId) > 0 || !texture->hasBuffer())409 (m_surface->buffers_ready_for_compositor(userId) > 0 || !texture->hasBuffer())
407 ) {410 ) {
408 // Avoid holding two buffers for the compositor at the same time. Thus free the current411 // Avoid holding two buffers for the compositor at the same time. Thus free the current
409 // before acquiring the next412 // before acquiring the next
@@ -419,7 +422,7 @@
419 m_textureUpdated = true;422 m_textureUpdated = true;
420 }423 }
421424
422 if (m_windowInfo.surface->buffers_ready_for_compositor(userId) > 0) {425 if (m_surface->buffers_ready_for_compositor(userId) > 0) {
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.
424 // queued since the timer lives in a different thread427 // queued since the timer lives in a different thread
425 QMetaObject::invokeMethod(&m_frameDropperTimer, "start", Qt::QueuedConnection);428 QMetaObject::invokeMethod(&m_frameDropperTimer, "start", Qt::QueuedConnection);
@@ -438,7 +441,7 @@
438{441{
439 QMutexLocker locker(&m_mutex);442 QMutexLocker locker(&m_mutex);
440 const void* const userId = (void*)123;443 const void* const userId = (void*)123;
441 return m_windowInfo.surface->buffers_ready_for_compositor(userId);444 return m_surface->buffers_ready_for_compositor(userId);
442}445}
443446
444void MirSurface::setFocused(bool value)447void MirSurface::setFocused(bool value)
@@ -481,10 +484,10 @@
481484
482 if (m_activelyFocusedViews.isEmpty()) {485 if (m_activelyFocusedViews.isEmpty()) {
483 DEBUG_MSG << "() unfocused";486 DEBUG_MSG << "() unfocused";
484 m_controller->setActiveFocus(m_windowInfo.window, false);487 m_controller->setActiveFocus(m_window, false);
485 } else {488 } else {
486 DEBUG_MSG << "() focused";489 DEBUG_MSG << "() focused";
487 m_controller->setActiveFocus(m_windowInfo.window, true);490 m_controller->setActiveFocus(m_window, true);
488 }491 }
489492
490 m_neverSetSurfaceFocus = false;493 m_neverSetSurfaceFocus = false;
@@ -502,14 +505,14 @@
502 Q_EMIT closeRequested();505 Q_EMIT closeRequested();
503 m_closeTimer->start();506 m_closeTimer->start();
504507
505 if (m_windowInfo.window) {508 if (m_window) {
506 m_windowInfo.surface->request_client_surface_close();509 m_surface->request_client_surface_close();
507 }510 }
508}511}
509512
510void MirSurface::resize(int width, int height)513void MirSurface::resize(int width, int height)
511{514{
512 auto const &window = m_windowInfo.window;515 auto const &window = m_window;
513516
514 bool mirSizeIsDifferent = width != m_size.width() || height != m_size.height();517 bool mirSizeIsDifferent = width != m_size.width() || height != m_size.height();
515518
@@ -535,7 +538,7 @@
535538
536void MirSurface::requestPosition(const QPoint newPosition)539void MirSurface::requestPosition(const QPoint newPosition)
537{540{
538 m_controller->move(m_windowInfo.window, newPosition);541 m_controller->move(m_window, newPosition);
539}542}
540543
541void MirSurface::setSize(const QSize newSize)544void MirSurface::setSize(const QSize newSize)
@@ -608,8 +611,8 @@
608 return;611 return;
609 }612 }
610613
611 if (m_windowInfo.window) {614 if (m_surface) {
612 m_windowInfo.surface->set_orientation(mirOrientation);615 m_surface->set_orientation(mirOrientation);
613 }616 }
614617
615 Q_EMIT orientationAngleChanged(angle);618 Q_EMIT orientationAngleChanged(angle);
@@ -623,6 +626,11 @@
623 return QString::fromStdString(m_windowInfo.name.value());626 return QString::fromStdString(m_windowInfo.name.value());
624}627}
625628
629QString MirSurface::persistentId() const
630{
631 return m_persistentId;
632}
633
626void MirSurface::setState(Mir::State qmlState)634void MirSurface::setState(Mir::State qmlState)
627{635{
628 MirSurfaceState mirState;636 MirSurfaceState mirState;
@@ -662,7 +670,7 @@
662 break;670 break;
663 }671 }
664672
665 m_controller->setState(m_windowInfo.window, mirState);673 m_controller->setState(m_window, mirState);
666}674}
667675
668void MirSurface::setLive(bool value)676void MirSurface::setLive(bool value)
@@ -692,7 +700,7 @@
692{700{
693 auto ev = makeMirEvent(event, mir_pointer_action_button_down);701 auto ev = makeMirEvent(event, mir_pointer_action_button_down);
694 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());702 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
695 m_controller->deliverPointerEvent(m_windowInfo.window, ev1);703 m_controller->deliverPointerEvent(m_window, ev1);
696 event->accept();704 event->accept();
697}705}
698706
@@ -700,7 +708,7 @@
700{708{
701 auto ev = makeMirEvent(event, mir_pointer_action_motion);709 auto ev = makeMirEvent(event, mir_pointer_action_motion);
702 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());710 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
703 m_controller->deliverPointerEvent(m_windowInfo.window, ev1);711 m_controller->deliverPointerEvent(m_window, ev1);
704 event->accept();712 event->accept();
705}713}
706714
@@ -708,7 +716,7 @@
708{716{
709 auto ev = makeMirEvent(event, mir_pointer_action_button_up);717 auto ev = makeMirEvent(event, mir_pointer_action_button_up);
710 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());718 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
711 m_controller->deliverPointerEvent(m_windowInfo.window, ev1);719 m_controller->deliverPointerEvent(m_window, ev1);
712 event->accept();720 event->accept();
713}721}
714722
@@ -716,7 +724,7 @@
716{724{
717 auto ev = makeMirEvent(event, mir_pointer_action_enter);725 auto ev = makeMirEvent(event, mir_pointer_action_enter);
718 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());726 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
719 m_controller->deliverPointerEvent(m_windowInfo.window, ev1);727 m_controller->deliverPointerEvent(m_window, ev1);
720 event->accept();728 event->accept();
721}729}
722730
@@ -724,7 +732,7 @@
724{732{
725 auto ev = makeMirEvent(event, mir_pointer_action_leave);733 auto ev = makeMirEvent(event, mir_pointer_action_leave);
726 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());734 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
727 m_controller->deliverPointerEvent(m_windowInfo.window, ev1);735 m_controller->deliverPointerEvent(m_window, ev1);
728 event->accept();736 event->accept();
729}737}
730738
@@ -732,7 +740,7 @@
732{740{
733 auto ev = makeMirEvent(event, mir_pointer_action_motion);741 auto ev = makeMirEvent(event, mir_pointer_action_motion);
734 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());742 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
735 m_controller->deliverPointerEvent(m_windowInfo.window, ev1);743 m_controller->deliverPointerEvent(m_window, ev1);
736 event->accept();744 event->accept();
737}745}
738746
@@ -740,7 +748,7 @@
740{748{
741 auto ev = makeMirEvent(event);749 auto ev = makeMirEvent(event);
742 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());750 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
743 m_controller->deliverPointerEvent(m_windowInfo.window, ev1);751 m_controller->deliverPointerEvent(m_window, ev1);
744 event->accept();752 event->accept();
745}753}
746754
@@ -748,7 +756,7 @@
748{756{
749 auto ev = makeMirEvent(qtEvent);757 auto ev = makeMirEvent(qtEvent);
750 auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get());758 auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get());
751 m_controller->deliverKeyboardEvent(m_windowInfo.window, ev1);759 m_controller->deliverKeyboardEvent(m_window, ev1);
752 qtEvent->accept();760 qtEvent->accept();
753}761}
754762
@@ -756,7 +764,7 @@
756{764{
757 auto ev = makeMirEvent(qtEvent);765 auto ev = makeMirEvent(qtEvent);
758 auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get());766 auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get());
759 m_controller->deliverKeyboardEvent(m_windowInfo.window, ev1);767 m_controller->deliverKeyboardEvent(m_window, ev1);
760 qtEvent->accept();768 qtEvent->accept();
761}769}
762770
@@ -767,7 +775,7 @@
767{775{
768 auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp);776 auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp);
769 auto ev1 = reinterpret_cast<MirTouchEvent const*>(ev.get());777 auto ev1 = reinterpret_cast<MirTouchEvent const*>(ev.get());
770 m_controller->deliverTouchEvent(m_windowInfo.window, ev1);778 m_controller->deliverTouchEvent(m_window, ev1);
771}779}
772780
773bool MirSurface::clientIsRunning() const781bool MirSurface::clientIsRunning() const
@@ -900,7 +908,7 @@
900 return;908 return;
901 }909 }
902910
903 m_windowInfo.surface->set_keymap(MirInputDeviceId(), "", layout.toStdString(), variant.toStdString(), "");911 m_surface->set_keymap(MirInputDeviceId(), "", layout.toStdString(), variant.toStdString(), "");
904}912}
905913
906QCursor MirSurface::cursor() const914QCursor MirSurface::cursor() const
@@ -1054,7 +1062,7 @@
10541062
1055 m_closingState = CloseOverdue;1063 m_closingState = CloseOverdue;
10561064
1057 m_controller->requestClose(m_windowInfo.window);1065 m_controller->requestClose(m_window);
1058}1066}
10591067
1060void MirSurface::setCloseTimer(AbstractTimer *timer)1068void MirSurface::setCloseTimer(AbstractTimer *timer)
10611069
=== modified file 'miral-qt/src/modules/Unity/Application/mirsurface.h'
--- miral-qt/src/modules/Unity/Application/mirsurface.h 2016-08-22 22:31:41 +0000
+++ miral-qt/src/modules/Unity/Application/mirsurface.h 2016-09-07 20:36:39 +0000
@@ -49,7 +49,7 @@
49 Q_OBJECT49 Q_OBJECT
5050
51public:51public:
52 MirSurface(WindowInfo windowInfo,52 MirSurface(NewWindowInfo windowInfo,
53 WindowControllerInterface *controller);53 WindowControllerInterface *controller);
54 virtual ~MirSurface();54 virtual ~MirSurface();
5555
@@ -60,6 +60,8 @@
6060
61 QString name() const override;61 QString name() const override;
6262
63 QString persistentId() const override;
64
63 QSize size() const override;65 QSize size() const override;
64 void resize(int width, int height) override;66 void resize(int width, int height) override;
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()); }
@@ -158,7 +160,7 @@
158 // useful for tests160 // useful for tests
159 void setCloseTimer(AbstractTimer *timer);161 void setCloseTimer(AbstractTimer *timer);
160 std::shared_ptr<SurfaceObserver> surfaceObserver() const;162 std::shared_ptr<SurfaceObserver> surfaceObserver() const;
161 WindowInfo windowInfo() const { return m_windowInfo; }163 miral::Window window() const { return m_window; }
162164
163public Q_SLOTS:165public Q_SLOTS:
164 void onCompositorSwappedBuffers() override;166 void onCompositorSwappedBuffers() override;
@@ -183,8 +185,11 @@
183 void updateActiveFocus();185 void updateActiveFocus();
184186
185 WindowInfo m_windowInfo;187 WindowInfo m_windowInfo;
188 miral::Window m_window;
189 std::shared_ptr<mir::scene::Surface> m_surface; // keep copy of the Surface for lifecycle
186 QPointer<SessionInterface> m_session;190 QPointer<SessionInterface> m_session;
187 WindowControllerInterface *const m_controller;191 WindowControllerInterface *const m_controller;
192 QString m_persistentId;
188 bool m_firstFrameDrawn;193 bool m_firstFrameDrawn;
189194
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)
191196
=== modified file 'miral-qt/src/modules/Unity/Application/windowmodel.cpp'
--- miral-qt/src/modules/Unity/Application/windowmodel.cpp 2016-09-06 15:21:11 +0000
+++ miral-qt/src/modules/Unity/Application/windowmodel.cpp 2016-09-07 20:36:39 +0000
@@ -69,7 +69,7 @@
69 return roleNames;69 return roleNames;
70}70}
7171
72void WindowModel::onWindowAdded(const WindowInfo windowInfo, const int index)72void WindowModel::onWindowAdded(const NewWindowInfo windowInfo, const int index)
73{73{
74 auto mirSurface = new MirSurface(windowInfo, m_windowController);74 auto mirSurface = new MirSurface(windowInfo, m_windowController);
75 beginInsertRows(QModelIndex(), index, index);75 beginInsertRows(QModelIndex(), index, index);
7676
=== modified file 'miral-qt/src/modules/Unity/Application/windowmodel.h'
--- miral-qt/src/modules/Unity/Application/windowmodel.h 2016-08-24 12:40:48 +0000
+++ miral-qt/src/modules/Unity/Application/windowmodel.h 2016-09-07 20:36:39 +0000
@@ -53,7 +53,7 @@
53 void countChanged();53 void countChanged();
5454
55private Q_SLOTS:55private Q_SLOTS:
56 void onWindowAdded(const WindowInfo windowInfo, const int index);56 void onWindowAdded(const NewWindowInfo windowInfo, const int index);
57 void onWindowRemoved(const int index);57 void onWindowRemoved(const int index);
58 void onWindowMoved(const QPoint topLeft, const int index);58 void onWindowMoved(const QPoint topLeft, const int index);
59 void onWindowResized(const QSize size, const int index);59 void onWindowResized(const QSize size, const int index);
6060
=== modified file 'miral-qt/src/platforms/mirserver/nativeinterface.h'
--- miral-qt/src/platforms/mirserver/nativeinterface.h 2016-08-16 14:15:26 +0000
+++ miral-qt/src/platforms/mirserver/nativeinterface.h 2016-09-07 20:36:39 +0000
@@ -28,6 +28,7 @@
2828
29// mir29// mir
30namespace mir { namespace scene { class PromptSessionManager; }}30namespace mir { namespace scene { class PromptSessionManager; }}
31namespace mir { namespace shell { class PersistentSurfaceStore; }}
3132
32class NativeInterface : public QPlatformNativeInterface33class NativeInterface : public QPlatformNativeInterface
33{34{
@@ -42,6 +43,7 @@
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;
4344
44 std::shared_ptr<mir::scene::PromptSessionManager> thePromptSessionManager() const;45 std::shared_ptr<mir::scene::PromptSessionManager> thePromptSessionManager() const;
46 std::shared_ptr<mir::shell::PersistentSurfaceStore> thePersistentSurfaceStore() const;
4547
46private:48private:
47 QMirServer *m_qMirServer;49 QMirServer *m_qMirServer;
4850
=== modified file 'miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp'
--- miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp 2016-09-06 12:21:43 +0000
+++ miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp 2016-09-07 20:36:39 +0000
@@ -21,7 +21,7 @@
21#include "miral/window_manager_tools.h"21#include "miral/window_manager_tools.h"
22#include "miral/window_specification.h"22#include "miral/window_specification.h"
2323
24#include "mir/scene/surface.h"24#include <mir/scene/surface.h>
25#include <QDebug>25#include <QDebug>
2626
27WindowManagementPolicy::WindowManagementPolicy(const miral::WindowManagerTools &tools,27WindowManagementPolicy::WindowManagementPolicy(const miral::WindowManagerTools &tools,
@@ -88,7 +88,9 @@
88void WindowManagementPolicy::advise_new_window(const miral::WindowInfo &windowInfo)88void WindowManagementPolicy::advise_new_window(const miral::WindowInfo &windowInfo)
89{89{
90 // TODO: attach surface observer here90 // TODO: attach surface observer here
91 m_windowModel.addWindow(windowInfo);91 std::string persistentId = m_tools.id_for_window(windowInfo.window());
92
93 m_windowModel.addWindow(windowInfo, persistentId);
92}94}
9395
94void WindowManagementPolicy::advise_delete_window(const miral::WindowInfo &windowInfo)96void WindowManagementPolicy::advise_delete_window(const miral::WindowInfo &windowInfo)
9597
=== modified file 'miral-qt/src/platforms/mirserver/windowmodelnotifier.cpp'
--- miral-qt/src/platforms/mirserver/windowmodelnotifier.cpp 2016-09-06 15:31:41 +0000
+++ miral-qt/src/platforms/mirserver/windowmodelnotifier.cpp 2016-09-07 20:36:39 +0000
@@ -31,6 +31,7 @@
3131
32WindowModelNotifier::WindowModelNotifier()32WindowModelNotifier::WindowModelNotifier()
33{33{
34 qRegisterMetaType<qtmir::NewWindowInfo>();
34 qRegisterMetaType<qtmir::WindowInfo>();35 qRegisterMetaType<qtmir::WindowInfo>();
35 qRegisterMetaType<QVector<int>>();36 qRegisterMetaType<QVector<int>>();
36}37}
@@ -40,12 +41,13 @@
4041
41}42}
4243
43void WindowModelNotifier::addWindow(const miral::WindowInfo &windowInfo)44void WindowModelNotifier::addWindow(const miral::WindowInfo &windowInfo, const std::string &persistentId)
44{45{
45 auto stackPosition = m_windowStack.count();46 auto stackPosition = m_windowStack.count();
46 m_windowStack.push_back(windowInfo.window()); // ASSUMPTION: Mir should tell us where in stack47 m_windowStack.push_back(windowInfo.window()); // ASSUMPTION: Mir should tell us where in stack
4748
48 Q_EMIT windowAdded(windowInfo, stackPosition);49 NewWindowInfo newWindowInfo{windowInfo, persistentId};
50 Q_EMIT windowAdded(newWindowInfo, stackPosition);
49}51}
5052
51void WindowModelNotifier::removeWindow(const miral::WindowInfo &windowInfo)53void WindowModelNotifier::removeWindow(const miral::WindowInfo &windowInfo)
5254
=== modified file 'miral-qt/src/platforms/mirserver/windowmodelnotifier.h'
--- miral-qt/src/platforms/mirserver/windowmodelnotifier.h 2016-08-24 12:30:45 +0000
+++ miral-qt/src/platforms/mirserver/windowmodelnotifier.h 2016-09-07 20:36:39 +0000
@@ -32,7 +32,7 @@
32 WindowModelNotifier();32 WindowModelNotifier();
33 virtual ~WindowModelNotifier();33 virtual ~WindowModelNotifier();
3434
35 void addWindow(const miral::WindowInfo &windowInfo);35 void addWindow(const miral::WindowInfo &windowInfo, const std::string &persistentId = "");
36 void removeWindow(const miral::WindowInfo &windowInfo);36 void removeWindow(const miral::WindowInfo &windowInfo);
3737
38 void moveWindow(const miral::WindowInfo &windowInfo, mir::geometry::Point topLeft);38 void moveWindow(const miral::WindowInfo &windowInfo, mir::geometry::Point topLeft);
3939
=== modified file 'miral-qt/tests/framework/CMakeLists.txt'
--- miral-qt/tests/framework/CMakeLists.txt 2016-08-22 21:34:31 +0000
+++ miral-qt/tests/framework/CMakeLists.txt 2016-09-07 20:36:39 +0000
@@ -29,6 +29,7 @@
29 mock_shared_wakelock.cpp29 mock_shared_wakelock.cpp
30 mock_surface.cpp30 mock_surface.cpp
31 mock_task_controller.cpp31 mock_task_controller.cpp
32 mock_persistent_surface_store.cpp
32 stub_input_channel.cpp33 stub_input_channel.cpp
33 fake_surface.h34 fake_surface.h
34 qtmir_test.cpp35 qtmir_test.cpp
3536
=== modified file 'miral-qt/tests/framework/fake_mirsurface.cpp'
--- miral-qt/tests/framework/fake_mirsurface.cpp 2016-08-10 15:01:44 +0000
+++ miral-qt/tests/framework/fake_mirsurface.cpp 2016-09-07 20:36:39 +0000
@@ -54,6 +54,8 @@
5454
55QString FakeMirSurface::name() const { return QString("Fake MirSurface"); }55QString FakeMirSurface::name() const { return QString("Fake MirSurface"); }
5656
57QString FakeMirSurface::persistentId() const { return QString("FakeSurfaceId"); }
58
57QSize FakeMirSurface::size() const { return m_size; }59QSize FakeMirSurface::size() const { return m_size; }
5860
59QPoint FakeMirSurface::position() const { return m_position; }61QPoint FakeMirSurface::position() const { return m_position; }
6062
=== modified file 'miral-qt/tests/framework/fake_mirsurface.h'
--- miral-qt/tests/framework/fake_mirsurface.h 2016-08-10 15:01:44 +0000
+++ miral-qt/tests/framework/fake_mirsurface.h 2016-09-07 20:36:39 +0000
@@ -53,6 +53,7 @@
53 // unity.shell.application.MirSurfaceInterface53 // unity.shell.application.MirSurfaceInterface
54 Mir::Type type() const override;54 Mir::Type type() const override;
55 QString name() const override;55 QString name() const override;
56 QString persistentId() const override;
56 QSize size() const override;57 QSize size() const override;
57 void resize(int width, int height) override;58 void resize(int width, int height) override;
58 void resize(const QSize &size) override;59 void resize(const QSize &size) override;
5960
=== added file 'miral-qt/tests/framework/mock_persistent_surface_store.cpp'
--- miral-qt/tests/framework/mock_persistent_surface_store.cpp 1970-01-01 00:00:00 +0000
+++ miral-qt/tests/framework/mock_persistent_surface_store.cpp 2016-09-07 20:36:39 +0000
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "mock_persistent_surface_store.h"
18
19namespace mir
20{
21namespace shell
22{
23
24MockPersistentSurfaceStore::MockPersistentSurfaceStore()
25{
26
27}
28
29} // namespace shell
30} // namespace mir
031
=== added file 'miral-qt/tests/framework/mock_persistent_surface_store.h'
--- miral-qt/tests/framework/mock_persistent_surface_store.h 1970-01-01 00:00:00 +0000
+++ miral-qt/tests/framework/mock_persistent_surface_store.h 2016-09-07 20:36:39 +0000
@@ -0,0 +1,24 @@
1#ifndef MOCKPERSISTENTSURFACESTORE_H
2#define MOCKPERSISTENTSURFACESTORE_H
3
4#include <mir/shell/persistent_surface_store.h>
5#include <gmock/gmock.h>
6
7namespace mir
8{
9namespace shell
10{
11
12class MockPersistentSurfaceStore : public PersistentSurfaceStore
13{
14public:
15 MockPersistentSurfaceStore();
16
17 MOCK_METHOD1(id_for_surface, Id(std::shared_ptr<scene::Surface> const& surface));
18 MOCK_CONST_METHOD1(surface_for_id, std::shared_ptr<scene::Surface>(Id const& id));
19};
20
21}
22}
23
24#endif // MOCKPERSISTENTSURFACESTORE_H
025
=== modified file 'miral-qt/tests/framework/qtmir_test.cpp'
--- miral-qt/tests/framework/qtmir_test.cpp 2016-08-23 11:42:28 +0000
+++ miral-qt/tests/framework/qtmir_test.cpp 2016-09-07 20:36:39 +0000
@@ -109,6 +109,7 @@
109109
110QtMirTest::QtMirTest()110QtMirTest::QtMirTest()
111 : promptSessionManager(std::make_shared<StubPromptSessionManager>())111 : promptSessionManager(std::make_shared<StubPromptSessionManager>())
112 , persistentSurfaceStore(std::make_shared<StubPersistentSurfaceStore>())
112 , applicationManager(taskControllerSharedPointer,113 , applicationManager(taskControllerSharedPointer,
113 QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}),114 QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}),
114 QSharedPointer<ProcInfo>(&procInfo,[](ProcInfo *){}),115 QSharedPointer<ProcInfo>(&procInfo,[](ProcInfo *){}),
115116
=== modified file 'miral-qt/tests/framework/qtmir_test.h'
--- miral-qt/tests/framework/qtmir_test.h 2016-08-23 11:42:28 +0000
+++ miral-qt/tests/framework/qtmir_test.h 2016-09-07 20:36:39 +0000
@@ -38,6 +38,7 @@
38#include "mock_shared_wakelock.h"38#include "mock_shared_wakelock.h"
39#include "mock_settings.h"39#include "mock_settings.h"
40#include "mock_task_controller.h"40#include "mock_task_controller.h"
41#include "mock_persistent_surface_store.h"
4142
42namespace ms = mir::scene;43namespace ms = mir::scene;
43using namespace qtmir;44using namespace qtmir;
@@ -45,6 +46,7 @@
45namespace qtmir {46namespace qtmir {
4647
47typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager;48typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager;
49typedef testing::NiceMock<mir::shell::MockPersistentSurfaceStore> StubPersistentSurfaceStore;
4850
49// For better output in ASSERT_* and EXPECT_* error messages51// For better output in ASSERT_* and EXPECT_* error messages
50void PrintTo(const Application::InternalState& state, ::std::ostream* os);52void PrintTo(const Application::InternalState& state, ::std::ostream* os);
@@ -71,6 +73,7 @@
71 testing::NiceMock<MockSharedWakelock> sharedWakelock;73 testing::NiceMock<MockSharedWakelock> sharedWakelock;
72 testing::NiceMock<MockSettings> settings;74 testing::NiceMock<MockSettings> settings;
73 std::shared_ptr<StubPromptSessionManager> promptSessionManager;75 std::shared_ptr<StubPromptSessionManager> promptSessionManager;
76 std::shared_ptr<StubPersistentSurfaceStore> persistentSurfaceStore;
7477
75 mir::shell::Shell *mirShell{nullptr};78 mir::shell::Shell *mirShell{nullptr};
76 ApplicationManager applicationManager;79 ApplicationManager applicationManager;
7780
=== modified file 'miral-qt/tests/modules/WindowManager/windowmodel_test.cpp'
--- miral-qt/tests/modules/WindowManager/windowmodel_test.cpp 2016-08-25 10:34:52 +0000
+++ miral-qt/tests/modules/WindowManager/windowmodel_test.cpp 2016-09-07 20:36:39 +0000
@@ -66,7 +66,7 @@
6666
67 miral::Window getMirALWindowFromModel(const WindowModel &model, int index)67 miral::Window getMirALWindowFromModel(const WindowModel &model, int index)
68 {68 {
69 return getMirSurfaceFromModel(model, index)->windowInfo().window;69 return getMirSurfaceFromModel(model, index)->window();
70 }70 }
7171
72 const std::shared_ptr<StubSession> stubSession{std::make_shared<StubSession>()};72 const std::shared_ptr<StubSession> stubSession{std::make_shared<StubSession>()};
7373
=== modified file 'miral/basic_window_manager.cpp'
--- miral/basic_window_manager.cpp 2016-09-05 15:50:13 +0000
+++ miral/basic_window_manager.cpp 2016-09-07 20:36:39 +0000
@@ -646,6 +646,17 @@
646#endif646#endif
647}647}
648648
649auto miral::BasicWindowManager::id_for_window(Window const& window) const -> std::string
650{
651 if (!window)
652 BOOST_THROW_EXCEPTION(std::runtime_error{"Null Window has no Persistent ID"});
653
654#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0)
655 return persistent_surface_store->id_for_surface(window).serialize_to_string();
656#else
657 BOOST_THROW_EXCEPTION(std::runtime_error{"Persistent IDs unavailable with this Mir server version"});
658#endif
659}
649660
650void miral::BasicWindowManager::place_and_size(WindowInfo& root, Point const& new_pos, Size const& new_size)661void miral::BasicWindowManager::place_and_size(WindowInfo& root, Point const& new_pos, Size const& new_size)
651{662{
652663
=== modified file 'miral/basic_window_manager.h'
--- miral/basic_window_manager.h 2016-08-29 16:17:16 +0000
+++ miral/basic_window_manager.h 2016-09-07 20:36:39 +0000
@@ -131,6 +131,8 @@
131131
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;
133133
134 auto id_for_window(Window const& window) const -> std::string override;
135
134 void invoke_under_lock(std::function<void()> const& callback) override;136 void invoke_under_lock(std::function<void()> const& callback) override;
135137
136private:138private:
137139
=== modified file 'miral/symbols.map'
--- miral/symbols.map 2016-09-06 08:05:38 +0000
+++ miral/symbols.map 2016-09-07 20:36:39 +0000
@@ -152,6 +152,7 @@
152 miral::WindowManagerTools::focus_next_application*;152 miral::WindowManagerTools::focus_next_application*;
153 miral::WindowManagerTools::focus_next_within_application*;153 miral::WindowManagerTools::focus_next_within_application*;
154 miral::WindowManagerTools::for_each_application*;154 miral::WindowManagerTools::for_each_application*;
155 miral::WindowManagerTools::id_for_window*;
155 miral::WindowManagerTools::info_for*;156 miral::WindowManagerTools::info_for*;
156 miral::WindowManagerTools::info_for_window_id*;157 miral::WindowManagerTools::info_for_window_id*;
157 miral::WindowManagerTools::invoke_under_lock*;158 miral::WindowManagerTools::invoke_under_lock*;
158159
=== modified file 'miral/window_manager_tools.cpp'
--- miral/window_manager_tools.cpp 2016-08-15 15:36:00 +0000
+++ miral/window_manager_tools.cpp 2016-09-07 20:36:39 +0000
@@ -80,5 +80,8 @@
80auto miral::WindowManagerTools::info_for_window_id(std::string const& id) const -> WindowInfo&80auto miral::WindowManagerTools::info_for_window_id(std::string const& id) const -> WindowInfo&
81{ return tools->info_for_window_id(id); }81{ return tools->info_for_window_id(id); }
8282
83auto miral::WindowManagerTools::id_for_window(Window const& window) const -> std::string
84{ return tools->id_for_window(window); }
85
83void miral::WindowManagerTools::invoke_under_lock(std::function<void()> const& callback)86void miral::WindowManagerTools::invoke_under_lock(std::function<void()> const& callback)
84{ tools->invoke_under_lock(callback); }87{ tools->invoke_under_lock(callback); }
8588
=== modified file 'miral/window_manager_tools_implementation.h'
--- miral/window_manager_tools_implementation.h 2016-08-15 15:36:00 +0000
+++ miral/window_manager_tools_implementation.h 2016-09-07 20:36:39 +0000
@@ -63,6 +63,7 @@
63 virtual void raise_tree(Window const& root) = 0;63 virtual void raise_tree(Window const& root) = 0;
64 virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0;64 virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0;
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;
66 virtual auto id_for_window(Window const& window) const -> std::string = 0;
66/** @} */67/** @} */
6768
68/** @name Multi-thread support69/** @name Multi-thread support
6970
=== modified file 'test/persistent_surface_store.cpp'
--- test/persistent_surface_store.cpp 2016-08-12 11:27:38 +0000
+++ test/persistent_surface_store.cpp 2016-09-07 20:36:39 +0000
@@ -20,6 +20,8 @@
20#include <miral/toolkit/surface.h>20#include <miral/toolkit/surface.h>
21#include <miral/toolkit/surface_spec.h>21#include <miral/toolkit/surface_spec.h>
2222
23#include <miral/application_info.h>
24
23#include <mir/version.h>25#include <mir/version.h>
2426
25#include <gtest/gtest.h>27#include <gtest/gtest.h>
@@ -56,6 +58,31 @@
56 ASSERT_THAT(window_info.name(), Eq(test_name));58 ASSERT_THAT(window_info.name(), Eq(test_name));
57 });59 });
58}60}
61
62TEST_F(PersistentSurfaceId, server_returns_correct_id_for_window)
63{
64 char const* const test_name = __PRETTY_FUNCTION__;
65 using namespace miral::toolkit;
66
67 auto const connection = connect_client(test_name);
68 auto const spec = SurfaceSpec::for_normal_surface(connection, 50, 50, mir_pixel_format_argb_8888)
69 .set_name(test_name);
70
71 Surface const surface{spec.create_surface()};
72
73 miral::toolkit::PersistentId client_surface_id{surface};
74
75 tools.invoke_under_lock([&]
76 {
77 // Bit of a journey to get the miral::Window for the above surface
78 auto app = tools.find_application([&](miral::ApplicationInfo const& /*info*/){return true;});
79 auto app_info = tools.info_for(app);
80 auto window = app_info.windows()[0];
81 auto id = tools.id_for_window(window);
82
83 ASSERT_THAT(client_surface_id.c_str(), Eq(id));
84 });
85}
59#else86#else
60TEST_F(PersistentSurfaceId, server_fails_gracefully_to_identify_window_specified_by_client)87TEST_F(PersistentSurfaceId, server_fails_gracefully_to_identify_window_specified_by_client)
61{88{
@@ -75,6 +102,30 @@
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);
76 });103 });
77}104}
105
106TEST_F(PersistentSurfaceId, server_fails_gracefully_to_return_id_for_window)
107{
108 char const* const test_name = __PRETTY_FUNCTION__;
109 using namespace miral::toolkit;
110
111 auto const connection = connect_client(test_name);
112 auto const spec = SurfaceSpec::for_normal_surface(connection, 50, 50, mir_pixel_format_argb_8888)
113 .set_name(test_name);
114
115 Surface const surface{spec.create_surface()};
116
117 miral::toolkit::PersistentId client_surface_id{surface};
118
119 tools.invoke_under_lock([&]
120 {
121 // Bit of a journey to get the miral::Window for the above surface
122 auto app = tools.find_application([&](miral::ApplicationInfo const& /*info*/){return true;});
123 auto app_info = tools.info_for(app);
124 auto window = app_info.windows()[0];
125
126 EXPECT_THROW(tools.id_for_window(window), std::runtime_error);
127 });
128}
78#endif129#endif
79130
80TEST_F(PersistentSurfaceId, server_fails_gracefully_to_identify_window_from_garbage_id)131TEST_F(PersistentSurfaceId, server_fails_gracefully_to_identify_window_from_garbage_id)
@@ -95,3 +146,12 @@
95 EXPECT_THROW(tools.info_for_window_id("garbage"), std::exception);146 EXPECT_THROW(tools.info_for_window_id("garbage"), std::exception);
96 });147 });
97}148}
149
150TEST_F(PersistentSurfaceId, server_fails_gracefully_when_id_for_null_window_requested)
151{
152 tools.invoke_under_lock([&]
153 {
154 miral::Window window;
155 EXPECT_THROW(tools.id_for_window(window), std::runtime_error);
156 });
157}

Subscribers

People subscribed via source and target branches