Merge lp:~dandrader/qtmir/content-hub-clipboard into lp:qtmir
- content-hub-clipboard
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~dandrader/qtmir/content-hub-clipboard |
Merge into: | lp:qtmir |
Diff against target: |
1379 lines (+386/-426) 33 files modified
CMakeLists.txt (+2/-1) debian/control (+3/-2) debian/gles-patches/convert-to-gles.patch (+2/-2) src/modules/Unity/Application/dbusfocusinfo.cpp (+41/-0) src/modules/Unity/Application/dbusfocusinfo.h (+12/-2) src/modules/Unity/Application/mirsurface.cpp (+10/-3) src/modules/Unity/Application/mirsurface.h (+4/-0) src/modules/Unity/Application/mirsurfacemanager.cpp (+15/-2) src/modules/Unity/Application/mirsurfacemanager.h (+6/-1) src/platforms/mirserver/CMakeLists.txt (+5/-0) src/platforms/mirserver/clipboard.cpp (+91/-241) src/platforms/mirserver/clipboard.h (+36/-53) src/platforms/mirserver/mirserver.h (+1/-0) src/platforms/mirserver/mirserverintegration.cpp (+5/-4) src/platforms/mirserver/mirserverintegration.h (+0/-5) src/platforms/mirserver/nativeinterface.cpp (+5/-0) src/platforms/mirserver/nativeinterface.h (+2/-0) src/platforms/mirserver/qmirserver.cpp (+7/-0) src/platforms/mirserver/qmirserver.h (+2/-0) src/platforms/mirserver/shelluuid.cpp (+35/-0) src/platforms/mirserver/shelluuid.h (+33/-0) tests/framework/CMakeLists.txt (+1/-0) tests/framework/fake_mirsurface.cpp (+2/-0) tests/framework/fake_mirsurface.h (+1/-0) tests/framework/mock_persistent_surface_store.cpp (+30/-0) tests/framework/mock_persistent_surface_store.h (+24/-0) tests/framework/qtmir_test.cpp (+2/-1) tests/framework/qtmir_test.h (+3/-0) tests/mirserver/CMakeLists.txt (+0/-1) tests/mirserver/Clipboard/CMakeLists.txt (+0/-27) tests/mirserver/Clipboard/clipboard_test.cpp (+0/-75) tests/modules/SurfaceManager/mirsurface_test.cpp (+4/-4) tests/modules/SurfaceManager/mirsurfaceitem_test.cpp (+2/-2) |
To merge this branch: | bzr merge lp:~dandrader/qtmir/content-hub-clipboard |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity8 CI Bot (community) | continuous-integration | Needs Fixing | |
Gerry Boland (community) | code | Approve | |
Review via email: mp+301705@code.launchpad.net |
This proposal has been superseded by a proposal from 2016-08-24.
Commit message
Use content-hub for clipboard services
And remove our own implementation of such service
Description of the change
* Are there any related MPs required for this MP to build/function as expected? Please list.
It's all in silo 056 (https:/
* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes, but not copy & pasting from within unity8 itself. Don't know if it has any text field at all.
* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
Gerry Boland (gerboland) wrote : | # |
=== modified file 'src/platforms/
+ * Copyright (C) 2014,2016 Canonical, Ltd.
2014-2016
+ QMimeData *mMimeData;
Using a QScopedPointer here would mean you don't have to worry about deleting the contents before you change it.
Similar for mPasteReply, that I don't see ever being deleted here - leak?
=== modified file 'src/platforms/
+ QDBusPendingCal
one of those times "auto" is nicer, since you state the type twice.
Everything else quite sensible. I need to test the silo though
Daniel d'Andrada (dandrader) wrote : | # |
On 03/08/2016 13:30, Gerry Boland wrote:
> Review: Needs Fixing
>
> === modified file 'src/platforms/
> + * Copyright (C) 2014,2016 Canonical, Ltd.
> 2014-2016
Done.
> + QMimeData *mMimeData;
> Using a QScopedPointer here would mean you don't have to worry about deleting the contents before you change it.
Done.
> Similar for mPasteReply, that I don't see ever being deleted here - leak?
Yes, leak. Fixed. Thanks!
> === modified file 'src/platforms/
> + QDBusPendingCal
> one of those times "auto" is nicer, since you state the type twice.
>
Right. Done.
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:531
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:534
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Gerry Boland (gerboland) wrote : | # |
+Clipboard:
+{
+ mMimeData.reset(new QMimeData);
This is nicer:
+Clipboard:
+ : mMimeData(new QMimeData);
+void Clipboard:
+ QDBusPendingCall reply = mContentHub-
+
+ // Don't care whether it succeeded
+ auto *watcher = new QDBusPendingCal
+ connect(watcher, &QDBusPendingCa
+ watcher, &QObject:
if you don't care, why do you do this at all? I would think just calling createPaste and throwing away the returned QDBusPendingCall is enough.
Rest looks good though
Daniel d'Andrada (dandrader) wrote : | # |
> +void Clipboard:
> + QDBusPendingCall reply = mContentHub-
> +
> + // Don't care whether it succeeded
> + auto *watcher = new QDBusPendingCal
> + connect(watcher, &QDBusPendingCa
> + watcher, &QObject:
> if you don't care, why do you do this at all? I would think just calling
> createPaste and throwing away the returned QDBusPendingCall is enough.
I also thought that when I first wrote it. But the destructor of a QDBusPendingCall cancels the call if it's still ongoing and we don't want that. Thus we have to keep a QDBusPendingCall instance around (such as a QDBusPendingCal
Daniel d'Andrada (dandrader) wrote : | # |
> +Clipboard:
> +{
> + mMimeData.reset(new QMimeData);
> This is nicer:
> +Clipboard:
> + : mMimeData(new QMimeData);
Done.
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:535
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Gerry Boland (gerboland) wrote : | # |
> > if you don't care, why do you do this at all? I would think just calling
> > createPaste and throwing away the returned QDBusPendingCall is enough.
>
> I also thought that when I first wrote it. But the destructor of a
> QDBusPendingCall cancels the call if it's still ongoing and we don't want
> that. Thus we have to keep a QDBusPendingCall instance around (such as a
> QDBusPendingCal
Oh wow, that's unexpected. Would you please add comment saying this? It's totally code that someone would delete in the future if they just looked at it:)
Daniel d'Andrada (dandrader) wrote : | # |
> > > if you don't care, why do you do this at all? I would think just calling
> > > createPaste and throwing away the returned QDBusPendingCall is enough.
> >
> > I also thought that when I first wrote it. But the destructor of a
> > QDBusPendingCall cancels the call if it's still ongoing and we don't want
> > that. Thus we have to keep a QDBusPendingCall instance around (such as a
> > QDBusPendingCal
>
> Oh wow, that's unexpected. Would you please add comment saying this? It's
> totally code that someone would delete in the future if they just looked at
> it:)
Sure, done.
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:536
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:540
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 540. By Alan Griffiths
-
Reduce MirServer to an implementation detail of QMirServer (nothing else needs to touch it).
Approved by: Daniel d'Andrada, Unity8 CI Bot
- 541. By Albert Astals Cid
-
Improvements from running clazy over the code
* Use QStringLiterals for literals
* Add some QLatin1Strings
* Add some reserve() calls
* Change a QList to QVector since QList is not optimal on big items
* Add some const &
* Add one override
* Fix some struct/class mistmatchesclazy: https:/
/quickgit. kde.org/ ?p=scratch% 2Fsmartins% 2Fclazy. git
Run over the src folderApproved by: Gerry Boland
- 542. By Albert Astals Cid
-
Compile with clang
Approved by: Gerry Boland
- 543. By Daniel d'Andrada
-
Remove Application.stage and RoleStage from ApplicationManager
They're not used anymore
Approved by: Gerry Boland
- 544. By Daniel van Vugt
-
Fix incorrect mouse wheel/touchpad scrolling scale (LP: #1607240)
and also add sufficient precision that high-resolution touchpad
scrolling now works! (LP: #1607223)This fixes two mistakes:
1. angleDelta is not in degrees but eighths of a degree, so the magic
constant 15 should be 120 (QWheelEvent::DefaultDeltasP erStep)
[http://doc.qt. io/qt-5/ qwheelevent. html#angleDelta].
2. When converting from Qt back into a Mir event we forgot completely
to divide by the same factor to get back to the Mir scale of things. (LP: #1607223, #1607240)Approved by: Lukáš Tinkl, Unity8 CI Bot
- 545. By CI Train Bot Account
-
Releasing 0.4.8+16.
10.20160810- 0ubuntu1 - 546. By Kevin DuBois
-
compatibility changes for mir 0.24.0
Approved by: Daniel d'Andrada
- 547. By CI Train Bot Account
-
Releasing 0.4.8+16.
10.20160816. 1-0ubuntu1 - 548. By Ted Gould
-
No change rebuild for UAL ABI change
Approved by: Gerry Boland
- 549. By CI Train Bot Account
-
Releasing 0.4.8+16.
10.20160819- 0ubuntu1
Gerry Boland (gerboland) wrote : | # |
Am waiting for the silo to be rebuilt before testing. Code is fine however
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:549
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 550. By Daniel d'Andrada
-
DBusFocusInfo.
isPidFocused: search sessions recursively (LP: #1612166) Approved by: Gerry Boland, Unity8 CI Bot
- 551. By Michał Sawicz
-
Revert r538 that's causing a unity8 crash when launching emergency dialer over greeter (LP: #1616842)
Approved by: Unity8 CI Bot
- 552. By CI Train Bot Account
-
Releasing 0.4.8+16.
10.20160826. 1-0ubuntu1 - 553. By Daniel d'Andrada
- 554. By Daniel d'Andrada
-
DBusFocusInfo: added isSurfaceFocuse
d(serializedId) - 555. By Daniel d'Andrada
-
Use content-hub for clipboard services
And remove our own implementation of such service
Unmerged revisions
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2016-08-16 11:04:25 +0000 |
3 | +++ CMakeLists.txt 2016-08-24 20:15:29 +0000 |
4 | @@ -83,8 +83,9 @@ |
5 | pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt) |
6 | pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED) |
7 | pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED) |
8 | -pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=20) |
9 | +pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=21) |
10 | pkg_check_modules(CGMANAGER libcgmanager REQUIRED) |
11 | +pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED) |
12 | |
13 | include_directories(SYSTEM ${APPLICATION_API_INCLUDE_DIRS}) |
14 | |
15 | |
16 | === modified file 'debian/control' |
17 | --- debian/control 2016-08-16 11:04:25 +0000 |
18 | +++ debian/control 2016-08-24 20:15:29 +0000 |
19 | @@ -7,6 +7,7 @@ |
20 | debhelper (>= 9), |
21 | google-mock (>= 1.6.0+svn437), |
22 | libcgmanager-dev, |
23 | + libcontent-hub-dev (>= 0.2), |
24 | libfontconfig1-dev, |
25 | libgles2-mesa-dev, |
26 | libglib2.0-dev, |
27 | @@ -23,7 +24,7 @@ |
28 | libubuntu-app-launch2-dev (>= 0.9), |
29 | libubuntu-application-api-dev (>= 2.1.0), |
30 | libudev-dev, |
31 | - libunity-api-dev (>= 7.117), |
32 | + libunity-api-dev (>= 7.118), |
33 | liburl-dispatcher1-dev, |
34 | libxkbcommon-dev, |
35 | libxrender-dev, |
36 | @@ -94,7 +95,7 @@ |
37 | Conflicts: libqtmir, |
38 | libunity-mir1, |
39 | Provides: unity-application-impl, |
40 | - unity-application-impl-20, |
41 | + unity-application-impl-21, |
42 | Description: Qt plugin for Unity specific Mir APIs |
43 | QtMir provides Qt/QML bindings for Mir features that are exposed through the |
44 | qtmir-desktop or qtmir-android QPA plugin such as Application management |
45 | |
46 | === modified file 'debian/gles-patches/convert-to-gles.patch' |
47 | --- debian/gles-patches/convert-to-gles.patch 2016-07-25 19:15:58 +0000 |
48 | +++ debian/gles-patches/convert-to-gles.patch 2016-08-24 20:15:29 +0000 |
49 | @@ -9,7 +9,7 @@ |
50 | Priority: optional |
51 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
52 | @@ -16,7 +16,13 @@ Build-Depends: cmake, |
53 | - libmirserver-dev (>= 0.19.0), |
54 | + libmirserver-dev (>= 0.24.0), |
55 | libmtdev-dev, |
56 | libprocess-cpp-dev, |
57 | + libqt5gui5-gles, |
58 | @@ -84,7 +84,7 @@ |
59 | -Conflicts: libqtmir, |
60 | - libunity-mir1, |
61 | -Provides: unity-application-impl, |
62 | -- unity-application-impl-20, |
63 | +- unity-application-impl-21, |
64 | -Description: Qt plugin for Unity specific Mir APIs |
65 | - QtMir provides Qt/QML bindings for Mir features that are exposed through the |
66 | - qtmir-desktop or qtmir-android QPA plugin such as Application management |
67 | |
68 | === modified file 'src/modules/Unity/Application/dbusfocusinfo.cpp' |
69 | --- src/modules/Unity/Application/dbusfocusinfo.cpp 2016-07-05 13:26:14 +0000 |
70 | +++ src/modules/Unity/Application/dbusfocusinfo.cpp 2016-08-24 20:15:29 +0000 |
71 | @@ -18,9 +18,13 @@ |
72 | |
73 | // local |
74 | #include "cgmanager.h" |
75 | +#include "mirsurfacelistmodel.h" |
76 | +#include "mirsurfaceinterface.h" |
77 | +#include "session_interface.h" |
78 | |
79 | // QPA mirserver |
80 | #include <logging.h> |
81 | +#include <shelluuid.h> |
82 | |
83 | #include <QDBusConnection> |
84 | |
85 | @@ -87,3 +91,40 @@ |
86 | } |
87 | return nullptr; |
88 | } |
89 | + |
90 | +bool DBusFocusInfo::isSurfaceFocused(const QString &serializedId) |
91 | +{ |
92 | + bool result = false; |
93 | + if (serializedId == ShellUuId::toString()) { |
94 | + result = true; |
95 | + } else { |
96 | + MirSurfaceInterface *qmlSurface = findQmlSurface(serializedId); |
97 | + result = qmlSurface ? qmlSurface->activeFocus() : false; |
98 | + } |
99 | + qCDebug(QTMIR_DBUS).nospace() << "DBusFocusInfo: isSurfaceFocused("<<serializedId<<") -> " << result; |
100 | + return result; |
101 | +} |
102 | + |
103 | +MirSurfaceInterface *DBusFocusInfo::findQmlSurface(const QString &serializedId) |
104 | +{ |
105 | + for (Application* application : m_applications) { |
106 | + auto session = application->session(); |
107 | + |
108 | + auto surfaceList = static_cast<MirSurfaceListModel*>(session->surfaceList()); |
109 | + for (int i = 0; i < surfaceList->count(); ++i) { |
110 | + auto qmlSurface = static_cast<MirSurfaceInterface*>(surfaceList->get(i)); |
111 | + if (qmlSurface->persistentId() == serializedId) { |
112 | + return qmlSurface; |
113 | + } |
114 | + } |
115 | + |
116 | + surfaceList = static_cast<MirSurfaceListModel*>(session->promptSurfaceList()); |
117 | + for (int i = 0; i < surfaceList->count(); ++i) { |
118 | + auto qmlSurface = static_cast<MirSurfaceInterface*>(surfaceList->get(i)); |
119 | + if (qmlSurface->persistentId() == serializedId) { |
120 | + return qmlSurface; |
121 | + } |
122 | + } |
123 | + } |
124 | + return nullptr; |
125 | +} |
126 | |
127 | === modified file 'src/modules/Unity/Application/dbusfocusinfo.h' |
128 | --- src/modules/Unity/Application/dbusfocusinfo.h 2016-07-01 16:15:54 +0000 |
129 | +++ src/modules/Unity/Application/dbusfocusinfo.h 2016-08-24 20:15:29 +0000 |
130 | @@ -22,10 +22,11 @@ |
131 | namespace qtmir { |
132 | |
133 | class CGManager; |
134 | +class MirSurfaceInterface; |
135 | |
136 | /* |
137 | - FIXME: This is a hack to provide OSK with needed info for avoiding input snooping. |
138 | - Remove when possible |
139 | + Enables other processes to check what is the currently focused application or surface, |
140 | + normally for security purposes. |
141 | */ |
142 | class DBusFocusInfo : public QObject |
143 | { |
144 | @@ -39,12 +40,21 @@ |
145 | |
146 | /* |
147 | Returns true if the application with the given PID has input focus |
148 | + |
149 | + FIXME: Identifying an app through its PID is deemed racy. |
150 | + isSurfaceFocused() is the preferred method. |
151 | */ |
152 | Q_SCRIPTABLE bool isPidFocused(unsigned int pid); |
153 | |
154 | + /* |
155 | + Returns true if the surface with the given id has input focus |
156 | + */ |
157 | + Q_SCRIPTABLE bool isSurfaceFocused(const QString &surfaceId); |
158 | + |
159 | private: |
160 | QSet<pid_t> fetchAssociatedPids(pid_t pid); |
161 | SessionInterface* findSessionWithPid(const QSet<pid_t> &pidSet); |
162 | + MirSurfaceInterface *findQmlSurface(const QString &serializedId); |
163 | |
164 | const QList<Application*> &m_applications; |
165 | |
166 | |
167 | === modified file 'src/modules/Unity/Application/mirsurface.cpp' |
168 | --- src/modules/Unity/Application/mirsurface.cpp 2016-08-10 06:52:25 +0000 |
169 | +++ src/modules/Unity/Application/mirsurface.cpp 2016-08-24 20:15:29 +0000 |
170 | @@ -43,8 +43,8 @@ |
171 | |
172 | using namespace qtmir; |
173 | |
174 | -#define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() <<"]::" << __func__ |
175 | -#define WARNING_MSG qCWarning(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() <<"]::" << __func__ |
176 | +#define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__ |
177 | +#define WARNING_MSG qCWarning(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__ |
178 | |
179 | namespace { |
180 | |
181 | @@ -183,6 +183,7 @@ |
182 | } // namespace { |
183 | |
184 | MirSurface::MirSurface(std::shared_ptr<mir::scene::Surface> surface, |
185 | + const QString& persistentId, |
186 | SessionInterface* session, |
187 | mir::shell::Shell* shell, |
188 | std::shared_ptr<SurfaceObserver> observer, |
189 | @@ -191,6 +192,7 @@ |
190 | , m_surface(surface) |
191 | , m_session(session) |
192 | , m_shell(shell) |
193 | + , m_persistentId(persistentId) |
194 | , m_firstFrameDrawn(false) |
195 | , m_orientationAngle(Mir::Angle0) |
196 | , m_textureUpdated(false) |
197 | @@ -253,7 +255,7 @@ |
198 | |
199 | MirSurface::~MirSurface() |
200 | { |
201 | - qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "]::~MirSurface() viewCount=" << m_views.count(); |
202 | + DEBUG_MSG << "() viewCount=" << m_views.count(); |
203 | |
204 | Q_ASSERT(m_views.isEmpty()); |
205 | |
206 | @@ -596,6 +598,11 @@ |
207 | return QString::fromStdString(m_surface->name()); |
208 | } |
209 | |
210 | +QString MirSurface::persistentId() const |
211 | +{ |
212 | + return m_persistentId; |
213 | +} |
214 | + |
215 | void MirSurface::setState(Mir::State qmlState) |
216 | { |
217 | int mirState; |
218 | |
219 | === modified file 'src/modules/Unity/Application/mirsurface.h' |
220 | --- src/modules/Unity/Application/mirsurface.h 2016-07-15 15:38:04 +0000 |
221 | +++ src/modules/Unity/Application/mirsurface.h 2016-08-24 20:15:29 +0000 |
222 | @@ -55,6 +55,7 @@ |
223 | |
224 | public: |
225 | MirSurface(std::shared_ptr<mir::scene::Surface> surface, |
226 | + const QString& persistentId, |
227 | SessionInterface* session, |
228 | mir::shell::Shell *shell, |
229 | std::shared_ptr<SurfaceObserver> observer, |
230 | @@ -68,6 +69,8 @@ |
231 | |
232 | QString name() const override; |
233 | |
234 | + QString persistentId() const override; |
235 | + |
236 | QSize size() const override; |
237 | void resize(int width, int height) override; |
238 | void resize(const QSize &size) override { resize(size.width(), size.height()); } |
239 | @@ -193,6 +196,7 @@ |
240 | std::shared_ptr<mir::scene::Surface> m_surface; |
241 | QPointer<SessionInterface> m_session; |
242 | mir::shell::Shell *const m_shell; |
243 | + QString m_persistentId; |
244 | bool m_firstFrameDrawn; |
245 | |
246 | //FIXME - have to save the state as Mir has no getter for it (bug:1357429) |
247 | |
248 | === modified file 'src/modules/Unity/Application/mirsurfacemanager.cpp' |
249 | --- src/modules/Unity/Application/mirsurfacemanager.cpp 2016-06-06 19:25:20 +0000 |
250 | +++ src/modules/Unity/Application/mirsurfacemanager.cpp 2016-08-24 20:15:29 +0000 |
251 | @@ -34,12 +34,15 @@ |
252 | #include "sessionlistener.h" |
253 | #include "logging.h" |
254 | #include "creationhints.h" |
255 | +#include "mirserver.h" |
256 | |
257 | // mir |
258 | #include <mir/scene/surface.h> |
259 | +#include <mir/shell/persistent_surface_store.h> |
260 | |
261 | |
262 | namespace ms = mir::scene; |
263 | +namespace msh = mir::shell; |
264 | |
265 | namespace qtmir { |
266 | |
267 | @@ -69,7 +72,10 @@ |
268 | SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener")); |
269 | mir::shell::Shell *shell = static_cast<mir::shell::Shell*>(nativeInterface->nativeResourceForIntegration("Shell")); |
270 | |
271 | - instance = new MirSurfaceManager(shell, SessionManager::singleton()); |
272 | + |
273 | + instance = new MirSurfaceManager(shell, |
274 | + SessionManager::singleton(), |
275 | + nativeInterface->thePersistentSurfaceStore()); |
276 | |
277 | connectToSessionListener(instance, sessionListener); |
278 | } |
279 | @@ -79,10 +85,12 @@ |
280 | MirSurfaceManager::MirSurfaceManager( |
281 | mir::shell::Shell* shell, |
282 | SessionManager* sessionManager, |
283 | + std::shared_ptr<msh::PersistentSurfaceStore> surfaceStore, |
284 | QObject* parent) |
285 | : QObject(parent) |
286 | , m_shell(shell) |
287 | , m_sessionManager(sessionManager) |
288 | + , m_surfaceStore(surfaceStore) |
289 | { |
290 | qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::MirSurfaceManager - this=" << this; |
291 | setObjectName(QStringLiteral("qtmir::SurfaceManager")); |
292 | @@ -105,7 +113,12 @@ |
293 | << "creationHints=" << creationHints.toString(); |
294 | |
295 | SessionInterface* session = m_sessionManager->findSession(mirSession); |
296 | - auto qmlSurface = new MirSurface(surface, session, m_shell, observer, creationHints); |
297 | + auto qmlSurface = new MirSurface(surface, |
298 | + QString::fromStdString(m_surfaceStore->id_for_surface(surface).serialize_to_string()), |
299 | + session, |
300 | + m_shell, |
301 | + observer, |
302 | + creationHints); |
303 | { |
304 | QMutexLocker lock(&m_mutex); |
305 | m_mirSurfaceToQmlSurfaceHash.insert(surface.get(), qmlSurface); |
306 | |
307 | === modified file 'src/modules/Unity/Application/mirsurfacemanager.h' |
308 | --- src/modules/Unity/Application/mirsurfacemanager.h 2016-06-06 19:25:20 +0000 |
309 | +++ src/modules/Unity/Application/mirsurfacemanager.h 2016-08-24 20:15:29 +0000 |
310 | @@ -38,7 +38,10 @@ |
311 | class Session; |
312 | class PromptSession; |
313 | } |
314 | - namespace shell { class Shell; } |
315 | + namespace shell { |
316 | + class Shell; |
317 | + class PersistentSurfaceStore; |
318 | + } |
319 | } |
320 | |
321 | class SurfaceObserver; |
322 | @@ -58,6 +61,7 @@ |
323 | explicit MirSurfaceManager( |
324 | mir::shell::Shell* shell, |
325 | SessionManager* sessionManager, |
326 | + std::shared_ptr<mir::shell::PersistentSurfaceStore> surfaceStore, |
327 | QObject* parent = nullptr |
328 | ); |
329 | ~MirSurfaceManager(); |
330 | @@ -85,6 +89,7 @@ |
331 | private: |
332 | mir::shell::Shell *const m_shell; |
333 | SessionManager* m_sessionManager; |
334 | + std::shared_ptr<mir::shell::PersistentSurfaceStore> m_surfaceStore; |
335 | static MirSurfaceManager *instance; |
336 | MirSurfaceInterface* m_inputMethodSurface = nullptr; |
337 | }; |
338 | |
339 | === modified file 'src/platforms/mirserver/CMakeLists.txt' |
340 | --- src/platforms/mirserver/CMakeLists.txt 2016-07-15 15:38:04 +0000 |
341 | +++ src/platforms/mirserver/CMakeLists.txt 2016-08-24 20:15:29 +0000 |
342 | @@ -44,6 +44,8 @@ |
343 | ${Qt5Quick_PRIVATE_INCLUDE_DIRS} |
344 | |
345 | ${APPLICATION_API_INCLUDE_DIRS} |
346 | + |
347 | + ${CONTENT_HUB_INCLUDE_DIRS} |
348 | ) |
349 | |
350 | # We have to remove -pedantic for tracepoints.c |
351 | @@ -66,6 +68,7 @@ |
352 | qmirserver_p.cpp |
353 | sessionauthorizer.cpp |
354 | sessionlistener.cpp |
355 | + shelluuid.cpp |
356 | surfaceobserver.cpp |
357 | promptsessionlistener.cpp |
358 | mirserver.cpp |
359 | @@ -112,6 +115,8 @@ |
360 | ${FONTCONFIG_LDFLAGS} |
361 | ${XKBCOMMON_LIBRARIES} |
362 | |
363 | + ${CONTENT_HUB_LIBRARIES} |
364 | + |
365 | Qt5::Core |
366 | Qt5::DBus |
367 | Qt5::Quick |
368 | |
369 | === modified file 'src/platforms/mirserver/clipboard.cpp' |
370 | --- src/platforms/mirserver/clipboard.cpp 2016-06-06 19:25:20 +0000 |
371 | +++ src/platforms/mirserver/clipboard.cpp 2016-08-24 20:15:29 +0000 |
372 | @@ -1,5 +1,5 @@ |
373 | /* |
374 | - * Copyright (C) 2014-2015 Canonical, Ltd. |
375 | + * Copyright (C) 2014,2016 Canonical, Ltd. |
376 | * |
377 | * This program is free software: you can redistribute it and/or modify it under |
378 | * the terms of the GNU Lesser General Public License version 3, as published by |
379 | @@ -15,245 +15,95 @@ |
380 | */ |
381 | |
382 | #include "clipboard.h" |
383 | -#include "logging.h" |
384 | - |
385 | -// C++ std lib |
386 | -#include <utility> |
387 | - |
388 | -#include <QDBusConnection> |
389 | -#include <QDBusError> |
390 | -#include <QMimeData> |
391 | - |
392 | -// FIXME(loicm) The clipboard data format is not defined by Ubuntu Platform API |
393 | -// which makes it impossible to have non-Qt applications communicate with Qt |
394 | -// applications through the clipboard API. The solution would be to have |
395 | -// Ubuntu Platform define the data format or propose an API that supports |
396 | -// embedding different mime types in the clipboard. |
397 | - |
398 | -// Data format: |
399 | -// number of mime types (sizeof(int)) |
400 | -// data layout ((4 * sizeof(int)) * number of mime types) |
401 | -// mime type string offset (sizeof(int)) |
402 | -// mime type string size (sizeof(int)) |
403 | -// data offset (sizeof(int)) |
404 | -// data size (sizeof(int)) |
405 | -// data (n bytes) |
406 | - |
407 | -namespace { |
408 | - |
409 | -const int maxFormatsCount = 16; |
410 | - |
411 | -} |
412 | - |
413 | -namespace qtmir { |
414 | - |
415 | -QByteArray serializeMimeData(QMimeData *mimeData) |
416 | -{ |
417 | - const QStringList formats = mimeData->formats(); |
418 | - const int formatCount = qMin(formats.size(), maxFormatsCount); |
419 | - const int headerSize = sizeof(int) + (formatCount * 4 * sizeof(int)); |
420 | - int bufferSize = headerSize; |
421 | - |
422 | - for (int i = 0; i < formatCount; i++) |
423 | - bufferSize += formats[i].size() + mimeData->data(formats[i]).size(); |
424 | - |
425 | - // Serialize data. |
426 | - QByteArray serializedMimeData(bufferSize, 0 /* char to fill with */); |
427 | - { |
428 | - char *buffer = serializedMimeData.data(); |
429 | - int* header = reinterpret_cast<int*>(serializedMimeData.data()); |
430 | - int offset = headerSize; |
431 | - header[0] = formatCount; |
432 | - for (int i = 0; i < formatCount; i++) { |
433 | - const QByteArray data = mimeData->data(formats[i]); |
434 | - const int formatOffset = offset; |
435 | - const int formatSize = formats[i].size(); |
436 | - const int dataOffset = offset + formatSize; |
437 | - const int dataSize = data.size(); |
438 | - memcpy(&buffer[formatOffset], formats[i].toLatin1().data(), formatSize); |
439 | - memcpy(&buffer[dataOffset], data.data(), dataSize); |
440 | - header[i*4+1] = formatOffset; |
441 | - header[i*4+2] = formatSize; |
442 | - header[i*4+3] = dataOffset; |
443 | - header[i*4+4] = dataSize; |
444 | - offset += formatSize + dataSize; |
445 | - } |
446 | - } |
447 | - |
448 | - return serializedMimeData; |
449 | -} |
450 | - |
451 | -QMimeData *deserializeMimeData(const QByteArray &serializedMimeData) |
452 | -{ |
453 | - if (static_cast<std::size_t>(serializedMimeData.size()) < sizeof(int)) { |
454 | - // Data is invalid |
455 | - return nullptr; |
456 | - } |
457 | - |
458 | - QMimeData *mimeData = new QMimeData; |
459 | - |
460 | - const char* const buffer = serializedMimeData.constData(); |
461 | - const int* const header = reinterpret_cast<const int*>(serializedMimeData.constData()); |
462 | - |
463 | - const int count = qMin(header[0], maxFormatsCount); |
464 | - |
465 | - for (int i = 0; i < count; i++) { |
466 | - const int formatOffset = header[i*4+1]; |
467 | - const int formatSize = header[i*4+2]; |
468 | - const int dataOffset = header[i*4+3]; |
469 | - const int dataSize = header[i*4+4]; |
470 | - |
471 | - if (formatOffset + formatSize <= serializedMimeData.size() |
472 | - && dataOffset + dataSize <= serializedMimeData.size()) { |
473 | - |
474 | - QString mimeType = QString::fromLatin1(&buffer[formatOffset], formatSize); |
475 | - QByteArray mimeDataBytes(&buffer[dataOffset], dataSize); |
476 | - |
477 | - mimeData->setData(mimeType, mimeDataBytes); |
478 | - } |
479 | - } |
480 | - |
481 | - return mimeData; |
482 | -} |
483 | - |
484 | -/************************************ DBusClipboard *****************************************/ |
485 | - |
486 | -bool DBusClipboard::skipDBusRegistration = false; |
487 | - |
488 | -DBusClipboard::DBusClipboard(QObject *parent) |
489 | - : QObject(parent) |
490 | -{ |
491 | - if (!skipDBusRegistration) { |
492 | - performDBusRegistration(); |
493 | - } |
494 | -} |
495 | - |
496 | -void DBusClipboard::setContents(QByteArray newContents) |
497 | -{ |
498 | - setContentsHelper(std::move(newContents)); |
499 | -} |
500 | - |
501 | -void DBusClipboard::SetContents(QByteArray newContents) |
502 | -{ |
503 | - qCDebug(QTMIR_CLIPBOARD, "D-Bus SetContents - %d bytes", newContents.size()); |
504 | - |
505 | - if (setContentsHelper(std::move(newContents))) { |
506 | - Q_EMIT contentsChangedRemotely(); |
507 | - } |
508 | -} |
509 | - |
510 | -bool DBusClipboard::setContentsHelper(QByteArray newContents) |
511 | -{ |
512 | - if (newContents.size() > maxContentsSize) { |
513 | - qCWarning(QTMIR_CLIPBOARD, "D-Bus clipboard refused the new contents (%d bytes) as they're" |
514 | - " bigger than the maximum allowed size of %d bytes.", |
515 | - newContents.size(), maxContentsSize); |
516 | - return false; |
517 | - } |
518 | - |
519 | - if (newContents != m_contents) { |
520 | - m_contents = std::move(newContents); |
521 | - Q_EMIT ContentsChanged(m_contents); |
522 | - return true; |
523 | - } else { |
524 | - return false; |
525 | - } |
526 | -} |
527 | - |
528 | -QByteArray DBusClipboard::GetContents() const |
529 | -{ |
530 | - qCDebug(QTMIR_CLIPBOARD, "D-Bus GetContents - returning %d bytes", m_contents.size()); |
531 | - return m_contents; |
532 | -} |
533 | - |
534 | -void DBusClipboard::performDBusRegistration() |
535 | -{ |
536 | - QDBusConnection connection = QDBusConnection::sessionBus(); |
537 | - const char *serviceName = "com.canonical.QtMir"; |
538 | - const char *objectName = "/com/canonical/QtMir/Clipboard"; |
539 | - |
540 | - bool serviceOk = connection.registerService(serviceName); |
541 | - if (!serviceOk) { |
542 | - QDBusError error = connection.lastError(); |
543 | - QString errorMessage; |
544 | - if (error.isValid()) { |
545 | - errorMessage = error.message(); |
546 | - } |
547 | - qCCritical(QTMIR_CLIPBOARD, "Failed to register service %s. %s", serviceName, qPrintable(errorMessage)); |
548 | - } |
549 | - |
550 | - bool objectOk = connection.registerObject(objectName, this, |
551 | - QDBusConnection::ExportScriptableSignals |
552 | - | QDBusConnection::ExportScriptableSlots); |
553 | - if (!objectOk) { |
554 | - QDBusError error = connection.lastError(); |
555 | - QString errorMessage; |
556 | - if (error.isValid()) { |
557 | - errorMessage = error.message(); |
558 | - } |
559 | - qCCritical(QTMIR_CLIPBOARD, "Failed to register object %s. %s", objectName, qPrintable(errorMessage)); |
560 | - } |
561 | - |
562 | - if (serviceOk && objectOk) { |
563 | - qCDebug(QTMIR_CLIPBOARD, "D-Bus registration successful."); |
564 | - } |
565 | -} |
566 | - |
567 | -/************************************ Clipboard *****************************************/ |
568 | - |
569 | -Clipboard::Clipboard(QObject *parent) |
570 | - : QObject(parent) |
571 | - , m_dbusClipboard(nullptr) |
572 | -{ |
573 | -} |
574 | - |
575 | -QMimeData *Clipboard::mimeData(QClipboard::Mode mode) |
576 | -{ |
577 | - if (mode == QClipboard::Clipboard) { |
578 | - return QPlatformClipboard::mimeData(mode); |
579 | - } else { |
580 | - return nullptr; |
581 | - } |
582 | -} |
583 | - |
584 | -void Clipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) |
585 | +#include "shelluuid.h" |
586 | + |
587 | +#include <QDBusPendingCallWatcher> |
588 | +#include <QSignalBlocker> |
589 | + |
590 | +// content-hub |
591 | +#include <com/ubuntu/content/hub.h> |
592 | + |
593 | +// get this cumbersome nested namespace out of the way |
594 | +using namespace com::ubuntu::content; |
595 | + |
596 | +using namespace qtmir; |
597 | + |
598 | +Clipboard::Clipboard() |
599 | + : QObject(nullptr) |
600 | + , m_mimeData(new QMimeData) |
601 | + , m_contentHub(Hub::Client::instance()) |
602 | +{ |
603 | + connect(m_contentHub, &Hub::pasteboardChanged, this, [this]() { |
604 | + if (m_clipboardState == Clipboard::SyncedClipboard) { |
605 | + m_clipboardState = Clipboard::OutdatedClipboard; |
606 | + requestMimeData(); |
607 | + } |
608 | + }); |
609 | + |
610 | + requestMimeData(); |
611 | +} |
612 | + |
613 | +Clipboard::~Clipboard() |
614 | +{ |
615 | +} |
616 | + |
617 | +QMimeData* Clipboard::mimeData(QClipboard::Mode mode) |
618 | { |
619 | if (mode != QClipboard::Clipboard) |
620 | - return; |
621 | - |
622 | - if (m_dbusClipboard) { |
623 | - QByteArray serializedMimeData = serializeMimeData(data); |
624 | - m_dbusClipboard->setContents(std::move(serializedMimeData)); |
625 | - } |
626 | - |
627 | - QPlatformClipboard::setMimeData(data, mode); |
628 | -} |
629 | - |
630 | -void Clipboard::setupDBusService() |
631 | -{ |
632 | - Q_ASSERT(!m_dbusClipboard); |
633 | - |
634 | - m_dbusClipboard = new DBusClipboard(this); |
635 | - |
636 | - connect(m_dbusClipboard, &DBusClipboard::contentsChangedRemotely, |
637 | - this, &Clipboard::setMimeDataWithDBusClibpboardContents); |
638 | -} |
639 | - |
640 | -void Clipboard::setMimeDataWithDBusClibpboardContents() |
641 | -{ |
642 | - Q_ASSERT(m_dbusClipboard); |
643 | - QMimeData *newMimeData = deserializeMimeData(m_dbusClipboard->contents()); |
644 | - if (newMimeData) { |
645 | - // Don't call Clipboard::setMimeData as it will also propagate the change |
646 | - // to the D-Bus clipboard, which doesn't make sense here as we're doing |
647 | - // the other way round (propagating the D-Bus clipboard change to the local |
648 | - // clipboard). |
649 | - QPlatformClipboard::setMimeData(newMimeData, QClipboard::Clipboard); |
650 | - } else { |
651 | - qCWarning(QTMIR_CLIPBOARD, "Failed to deserialize D-Bus clipboard contents (%d bytes)", |
652 | - m_dbusClipboard->contents().size()); |
653 | - } |
654 | -} |
655 | - |
656 | -} // namespace qtmir |
657 | - |
658 | + return nullptr; |
659 | + |
660 | + return m_mimeData.data(); |
661 | +} |
662 | + |
663 | +void Clipboard::setMimeData(QMimeData* mimeData, QClipboard::Mode mode) |
664 | +{ |
665 | + if (mode == QClipboard::Clipboard && mimeData != nullptr) { |
666 | + QDBusPendingCall reply = m_contentHub->createPaste(ShellUuId::toString(), *mimeData); |
667 | + |
668 | + // Don't care whether it succeeded |
669 | + // But I have to keep a QDBusPendingCall instance around (such as this watcher) until |
670 | + // the call is finished otherwise the QDBusPendingCall destructor will cancel the call |
671 | + // if it's still ongoing. |
672 | + auto *watcher = new QDBusPendingCallWatcher(reply, this); |
673 | + connect(watcher, &QDBusPendingCallWatcher::finished, |
674 | + watcher, &QObject::deleteLater); |
675 | + |
676 | + m_mimeData.reset(mimeData); |
677 | + m_clipboardState = SyncedClipboard; |
678 | + emitChanged(QClipboard::Clipboard); |
679 | + } |
680 | +} |
681 | + |
682 | +bool Clipboard::supportsMode(QClipboard::Mode mode) const |
683 | +{ |
684 | + return mode == QClipboard::Clipboard; |
685 | +} |
686 | + |
687 | +bool Clipboard::ownsMode(QClipboard::Mode mode) const |
688 | +{ |
689 | + Q_UNUSED(mode); |
690 | + return false; |
691 | +} |
692 | + |
693 | +void Clipboard::updateMimeData() |
694 | +{ |
695 | + m_mimeData.reset(m_contentHub->latestPaste(ShellUuId::toString())); |
696 | + m_clipboardState = SyncedClipboard; |
697 | + emitChanged(QClipboard::Clipboard); |
698 | +} |
699 | + |
700 | +void Clipboard::requestMimeData() |
701 | +{ |
702 | + QDBusPendingCall reply = m_contentHub->requestLatestPaste(ShellUuId::toString()); |
703 | + m_clipboardState = SyncingClipboard; |
704 | + |
705 | + m_pasteReply = new QDBusPendingCallWatcher(reply, this); |
706 | + connect(m_pasteReply, &QDBusPendingCallWatcher::finished, |
707 | + this, [this]() { |
708 | + m_mimeData.reset(m_contentHub->paste(*m_pasteReply)); |
709 | + m_clipboardState = SyncedClipboard; |
710 | + m_pasteReply->deleteLater(); |
711 | + m_pasteReply = nullptr; |
712 | + emitChanged(QClipboard::Clipboard); |
713 | + }); |
714 | +} |
715 | |
716 | === modified file 'src/platforms/mirserver/clipboard.h' |
717 | --- src/platforms/mirserver/clipboard.h 2015-08-11 12:08:32 +0000 |
718 | +++ src/platforms/mirserver/clipboard.h 2016-08-24 20:15:29 +0000 |
719 | @@ -1,5 +1,5 @@ |
720 | /* |
721 | - * Copyright (C) 2014-2015 Canonical, Ltd. |
722 | + * Copyright (C) 2014-2016 Canonical, Ltd. |
723 | * |
724 | * This program is free software: you can redistribute it and/or modify it under |
725 | * the terms of the GNU Lesser General Public License version 3, as published by |
726 | @@ -18,69 +18,52 @@ |
727 | #define QTMIR_CLIPBOARD_H |
728 | |
729 | #include <qpa/qplatformclipboard.h> |
730 | -#include <QObject> |
731 | + |
732 | +#include <QMimeData> |
733 | +#include <QScopedPointer> |
734 | + |
735 | +namespace com { |
736 | + namespace ubuntu { |
737 | + namespace content { |
738 | + class Hub; |
739 | + } |
740 | + } |
741 | +} |
742 | + |
743 | +class QDBusPendingCallWatcher; |
744 | |
745 | namespace qtmir { |
746 | |
747 | -class DBusClipboard : public QObject { |
748 | - Q_OBJECT |
749 | - Q_CLASSINFO("D-Bus Interface", "com.canonical.QtMir.Clipboard") |
750 | -public: |
751 | - DBusClipboard(QObject *parent = nullptr); |
752 | - virtual ~DBusClipboard() {} |
753 | - |
754 | - void setContents(QByteArray contents); |
755 | - const QByteArray &contents() const { return m_contents; } |
756 | - |
757 | - static const int maxContentsSize = 4 * 1024 * 1024; // 4 Mb |
758 | - |
759 | - // To make it testable |
760 | - static bool skipDBusRegistration; |
761 | - |
762 | -Q_SIGNALS: |
763 | - Q_SCRIPTABLE void ContentsChanged(const QByteArray &contents); |
764 | - void contentsChangedRemotely(); |
765 | - |
766 | -public Q_SLOTS: |
767 | - Q_SCRIPTABLE QByteArray GetContents() const; |
768 | - Q_SCRIPTABLE void SetContents(QByteArray contents); |
769 | - |
770 | -private: |
771 | - void performDBusRegistration(); |
772 | - bool setContentsHelper(QByteArray newContents); |
773 | - |
774 | - // Contains a serialized QMimeData |
775 | - // Serialization and deserialization is done by the QPlatformClipboard |
776 | - // implementation. |
777 | - QByteArray m_contents; |
778 | -}; |
779 | - |
780 | class Clipboard : public QObject, public QPlatformClipboard |
781 | { |
782 | Q_OBJECT |
783 | public: |
784 | - Clipboard(QObject *parent = nullptr); |
785 | - virtual ~Clipboard() {} |
786 | - |
787 | - QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard) override; |
788 | - void setMimeData(QMimeData *data, QClipboard::Mode mode) override; |
789 | - |
790 | - void setupDBusService(); |
791 | - |
792 | -private Q_SLOTS: |
793 | - void setMimeDataWithDBusClibpboardContents(); |
794 | + Clipboard(); |
795 | + virtual ~Clipboard(); |
796 | + |
797 | + // QPlatformClipboard methods. |
798 | + QMimeData* mimeData(QClipboard::Mode mode = QClipboard::Clipboard) override; |
799 | + void setMimeData(QMimeData* data, QClipboard::Mode mode = QClipboard::Clipboard) override; |
800 | + bool supportsMode(QClipboard::Mode mode) const override; |
801 | + bool ownsMode(QClipboard::Mode mode) const override; |
802 | |
803 | private: |
804 | - |
805 | - DBusClipboard *m_dbusClipboard; |
806 | + void updateMimeData(); |
807 | + void requestMimeData(); |
808 | + |
809 | + QScopedPointer<QMimeData> m_mimeData; |
810 | + |
811 | + enum { |
812 | + OutdatedClipboard, // Our mimeData is outdated, need to fetch latest from ContentHub |
813 | + SyncingClipboard, // Our mimeData is outdated and we are waiting for ContentHub to reply with the latest paste |
814 | + SyncedClipboard // Our mimeData is in sync with what ContentHub has |
815 | + } m_clipboardState{OutdatedClipboard}; |
816 | + |
817 | + com::ubuntu::content::Hub *m_contentHub; |
818 | + |
819 | + QDBusPendingCallWatcher *m_pasteReply{nullptr}; |
820 | }; |
821 | |
822 | -// NB: Copied from qtubuntu. Must be kept in sync with the original version! |
823 | -// Best thing would be to share this code somehow, but not bothering with it right now |
824 | -// as the clipboard will move to content-hub at some point. |
825 | -QByteArray serializeMimeData(QMimeData *mimeData); |
826 | -QMimeData *deserializeMimeData(const QByteArray &serializedMimeData); |
827 | - |
828 | } // namespace qtmir |
829 | |
830 | #endif // QTMIR_CLIPBOARD_H |
831 | |
832 | === modified file 'src/platforms/mirserver/mirserver.h' |
833 | --- src/platforms/mirserver/mirserver.h 2016-05-06 08:28:44 +0000 |
834 | +++ src/platforms/mirserver/mirserver.h 2016-08-24 20:15:29 +0000 |
835 | @@ -51,6 +51,7 @@ |
836 | using mir::Server::the_gl_config; |
837 | using mir::Server::the_main_loop; |
838 | using mir::Server::the_prompt_session_manager; |
839 | + using mir::Server::the_persistent_surface_store; |
840 | |
841 | void stop(); |
842 | |
843 | |
844 | === modified file 'src/platforms/mirserver/mirserverintegration.cpp' |
845 | --- src/platforms/mirserver/mirserverintegration.cpp 2016-08-10 06:51:37 +0000 |
846 | +++ src/platforms/mirserver/mirserverintegration.cpp 2016-08-24 20:15:29 +0000 |
847 | @@ -56,7 +56,6 @@ |
848 | , m_services(new Services) |
849 | , m_mirServer(new QMirServer(argc, argv)) |
850 | , m_nativeInterface(nullptr) |
851 | - , m_clipboard(new Clipboard) |
852 | { |
853 | // For access to sensors, qtmir uses qtubuntu-sensors. qtubuntu-sensors reads the |
854 | // UBUNTU_PLATFORM_API_BACKEND variable to decide if to load a valid sensor backend or not. |
855 | @@ -159,8 +158,6 @@ |
856 | } |
857 | |
858 | m_nativeInterface = new NativeInterface(m_mirServer.data()); |
859 | - |
860 | - m_clipboard->setupDBusService(); |
861 | } |
862 | |
863 | QPlatformAccessibility *MirServerIntegration::accessibility() const |
864 | @@ -196,7 +193,11 @@ |
865 | |
866 | QPlatformClipboard *MirServerIntegration::clipboard() const |
867 | { |
868 | - return m_clipboard.data(); |
869 | + static QPlatformClipboard *clipboard = nullptr; |
870 | + if (!clipboard) { |
871 | + clipboard = new Clipboard; |
872 | + } |
873 | + return clipboard; |
874 | } |
875 | |
876 | QPlatformOffscreenSurface *MirServerIntegration::createPlatformOffscreenSurface( |
877 | |
878 | === modified file 'src/platforms/mirserver/mirserverintegration.h' |
879 | --- src/platforms/mirserver/mirserverintegration.h 2015-10-29 19:51:56 +0000 |
880 | +++ src/platforms/mirserver/mirserverintegration.h 2016-08-24 20:15:29 +0000 |
881 | @@ -24,10 +24,6 @@ |
882 | class NativeInterface; |
883 | class QMirServer; |
884 | |
885 | -namespace qtmir { |
886 | - class Clipboard; |
887 | -} |
888 | - |
889 | class MirServerIntegration : public QPlatformIntegration |
890 | { |
891 | public: |
892 | @@ -67,7 +63,6 @@ |
893 | |
894 | NativeInterface *m_nativeInterface; |
895 | QPlatformInputContext* m_inputContext; |
896 | - QScopedPointer<qtmir::Clipboard> m_clipboard; |
897 | }; |
898 | |
899 | #endif // MIRSERVERINTEGRATION_H |
900 | |
901 | === modified file 'src/platforms/mirserver/nativeinterface.cpp' |
902 | --- src/platforms/mirserver/nativeinterface.cpp 2016-08-10 06:51:55 +0000 |
903 | +++ src/platforms/mirserver/nativeinterface.cpp 2016-08-24 20:15:29 +0000 |
904 | @@ -77,3 +77,8 @@ |
905 | { |
906 | return m_qMirServer->thePromptSessionManager(); |
907 | } |
908 | + |
909 | +std::shared_ptr<mir::shell::PersistentSurfaceStore> NativeInterface::thePersistentSurfaceStore() const |
910 | +{ |
911 | + return m_qMirServer->thePersistentSurfaceStore(); |
912 | +} |
913 | |
914 | === modified file 'src/platforms/mirserver/nativeinterface.h' |
915 | --- src/platforms/mirserver/nativeinterface.h 2016-08-10 06:51:55 +0000 |
916 | +++ src/platforms/mirserver/nativeinterface.h 2016-08-24 20:15:29 +0000 |
917 | @@ -28,6 +28,7 @@ |
918 | |
919 | // mir |
920 | namespace mir { namespace scene { class PromptSessionManager; }} |
921 | +namespace mir { namespace shell { class PersistentSurfaceStore; }} |
922 | |
923 | class NativeInterface : public QPlatformNativeInterface |
924 | { |
925 | @@ -42,6 +43,7 @@ |
926 | QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const override; |
927 | |
928 | std::shared_ptr<mir::scene::PromptSessionManager> thePromptSessionManager() const; |
929 | + std::shared_ptr<mir::shell::PersistentSurfaceStore> thePersistentSurfaceStore() const; |
930 | |
931 | private: |
932 | QMirServer *m_qMirServer; |
933 | |
934 | === modified file 'src/platforms/mirserver/qmirserver.cpp' |
935 | --- src/platforms/mirserver/qmirserver.cpp 2016-08-10 06:51:55 +0000 |
936 | +++ src/platforms/mirserver/qmirserver.cpp 2016-08-24 20:15:29 +0000 |
937 | @@ -130,3 +130,10 @@ |
938 | |
939 | return d->server->the_prompt_session_manager(); |
940 | } |
941 | + |
942 | +std::shared_ptr<mir::shell::PersistentSurfaceStore> QMirServer::thePersistentSurfaceStore() const |
943 | +{ |
944 | + Q_D(const QMirServer); |
945 | + |
946 | + return d->server->the_persistent_surface_store(); |
947 | +} |
948 | |
949 | === modified file 'src/platforms/mirserver/qmirserver.h' |
950 | --- src/platforms/mirserver/qmirserver.h 2016-08-10 06:51:37 +0000 |
951 | +++ src/platforms/mirserver/qmirserver.h 2016-08-24 20:15:29 +0000 |
952 | @@ -25,6 +25,7 @@ |
953 | |
954 | // mir |
955 | namespace mir { namespace scene { class PromptSessionManager; }} |
956 | +namespace mir { namespace shell { class PersistentSurfaceStore; }} |
957 | |
958 | class QMirServerPrivate; |
959 | class ScreensController; |
960 | @@ -49,6 +50,7 @@ |
961 | QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; |
962 | void *nativeResourceForIntegration(const QByteArray &resource) const; |
963 | std::shared_ptr<mir::scene::PromptSessionManager> thePromptSessionManager() const; |
964 | + std::shared_ptr<mir::shell::PersistentSurfaceStore> thePersistentSurfaceStore() const; |
965 | |
966 | Q_SIGNALS: |
967 | void started(); |
968 | |
969 | === added file 'src/platforms/mirserver/shelluuid.cpp' |
970 | --- src/platforms/mirserver/shelluuid.cpp 1970-01-01 00:00:00 +0000 |
971 | +++ src/platforms/mirserver/shelluuid.cpp 2016-08-24 20:15:29 +0000 |
972 | @@ -0,0 +1,35 @@ |
973 | +/* |
974 | + * Copyright (C) 2016 Canonical, Ltd. |
975 | + * |
976 | + * This program is free software: you can redistribute it and/or modify it under |
977 | + * the terms of the GNU Lesser General Public License version 3, as published by |
978 | + * the Free Software Foundation. |
979 | + * |
980 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
981 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
982 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
983 | + * Lesser General Public License for more details. |
984 | + * |
985 | + * You should have received a copy of the GNU Lesser General Public License |
986 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
987 | + */ |
988 | + |
989 | +#include "shelluuid.h" |
990 | + |
991 | +#include <QMutexLocker> |
992 | + |
993 | +using namespace qtmir; |
994 | + |
995 | +QUuid ShellUuId::m_uuid; |
996 | +QMutex ShellUuId::m_mutex; |
997 | + |
998 | +QString ShellUuId::toString() |
999 | +{ |
1000 | + QMutexLocker mutexLocker(&m_mutex); |
1001 | + |
1002 | + if (m_uuid.isNull()) { |
1003 | + m_uuid = QUuid::createUuid(); |
1004 | + } |
1005 | + |
1006 | + return m_uuid.toString(); |
1007 | +} |
1008 | |
1009 | === added file 'src/platforms/mirserver/shelluuid.h' |
1010 | --- src/platforms/mirserver/shelluuid.h 1970-01-01 00:00:00 +0000 |
1011 | +++ src/platforms/mirserver/shelluuid.h 2016-08-24 20:15:29 +0000 |
1012 | @@ -0,0 +1,33 @@ |
1013 | +/* |
1014 | + * Copyright (C) 2016 Canonical, Ltd. |
1015 | + * |
1016 | + * This program is free software: you can redistribute it and/or modify it under |
1017 | + * the terms of the GNU Lesser General Public License version 3, as published by |
1018 | + * the Free Software Foundation. |
1019 | + * |
1020 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
1021 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
1022 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1023 | + * Lesser General Public License for more details. |
1024 | + * |
1025 | + * You should have received a copy of the GNU Lesser General Public License |
1026 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1027 | + */ |
1028 | + |
1029 | +#include <QUuid> |
1030 | +#include <QMutex> |
1031 | + |
1032 | +namespace qtmir { |
1033 | + |
1034 | +/* |
1035 | + A UUID accessible by all shell code. |
1036 | + */ |
1037 | +class ShellUuId { |
1038 | +public: |
1039 | + static QString toString(); |
1040 | +private: |
1041 | + static QUuid m_uuid; |
1042 | + static QMutex m_mutex; |
1043 | +}; |
1044 | + |
1045 | +} // namespace qtmir |
1046 | |
1047 | === modified file 'tests/framework/CMakeLists.txt' |
1048 | --- tests/framework/CMakeLists.txt 2016-06-06 18:12:07 +0000 |
1049 | +++ tests/framework/CMakeLists.txt 2016-08-24 20:15:29 +0000 |
1050 | @@ -32,6 +32,7 @@ |
1051 | mock_shared_wakelock.cpp |
1052 | mock_surface.cpp |
1053 | mock_task_controller.cpp |
1054 | + mock_persistent_surface_store.cpp |
1055 | stub_input_channel.cpp |
1056 | fake_surface.h |
1057 | qtmir_test.cpp |
1058 | |
1059 | === modified file 'tests/framework/fake_mirsurface.cpp' |
1060 | --- tests/framework/fake_mirsurface.cpp 2016-05-24 20:13:10 +0000 |
1061 | +++ tests/framework/fake_mirsurface.cpp 2016-08-24 20:15:29 +0000 |
1062 | @@ -54,6 +54,8 @@ |
1063 | |
1064 | QString FakeMirSurface::name() const { return QString("Fake MirSurface"); } |
1065 | |
1066 | +QString FakeMirSurface::persistentId() const { return QString("FakeSurfaceId"); } |
1067 | + |
1068 | QSize FakeMirSurface::size() const { return m_size; } |
1069 | |
1070 | void FakeMirSurface::resize(int width, int height) |
1071 | |
1072 | === modified file 'tests/framework/fake_mirsurface.h' |
1073 | --- tests/framework/fake_mirsurface.h 2016-08-08 13:55:43 +0000 |
1074 | +++ tests/framework/fake_mirsurface.h 2016-08-24 20:15:29 +0000 |
1075 | @@ -53,6 +53,7 @@ |
1076 | // unity.shell.application.MirSurfaceInterface |
1077 | Mir::Type type() const override; |
1078 | QString name() const override; |
1079 | + QString persistentId() const override; |
1080 | QSize size() const override; |
1081 | void resize(int width, int height) override; |
1082 | void resize(const QSize &size) override; |
1083 | |
1084 | === added file 'tests/framework/mock_persistent_surface_store.cpp' |
1085 | --- tests/framework/mock_persistent_surface_store.cpp 1970-01-01 00:00:00 +0000 |
1086 | +++ tests/framework/mock_persistent_surface_store.cpp 2016-08-24 20:15:29 +0000 |
1087 | @@ -0,0 +1,30 @@ |
1088 | +/* |
1089 | + * Copyright (C) 2016 Canonical, Ltd. |
1090 | + * |
1091 | + * This program is free software: you can redistribute it and/or modify it under |
1092 | + * the terms of the GNU Lesser General Public License version 3, as published by |
1093 | + * the Free Software Foundation. |
1094 | + * |
1095 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
1096 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
1097 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1098 | + * Lesser General Public License for more details. |
1099 | + * |
1100 | + * You should have received a copy of the GNU Lesser General Public License |
1101 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1102 | + */ |
1103 | + |
1104 | +#include "mock_persistent_surface_store.h" |
1105 | + |
1106 | +namespace mir |
1107 | +{ |
1108 | +namespace shell |
1109 | +{ |
1110 | + |
1111 | +MockPersistentSurfaceStore::MockPersistentSurfaceStore() |
1112 | +{ |
1113 | + |
1114 | +} |
1115 | + |
1116 | +} // namespace shell |
1117 | +} // namespace mir |
1118 | |
1119 | === added file 'tests/framework/mock_persistent_surface_store.h' |
1120 | --- tests/framework/mock_persistent_surface_store.h 1970-01-01 00:00:00 +0000 |
1121 | +++ tests/framework/mock_persistent_surface_store.h 2016-08-24 20:15:29 +0000 |
1122 | @@ -0,0 +1,24 @@ |
1123 | +#ifndef MOCKPERSISTENTSURFACESTORE_H |
1124 | +#define MOCKPERSISTENTSURFACESTORE_H |
1125 | + |
1126 | +#include <mir/shell/persistent_surface_store.h> |
1127 | +#include <gmock/gmock.h> |
1128 | + |
1129 | +namespace mir |
1130 | +{ |
1131 | +namespace shell |
1132 | +{ |
1133 | + |
1134 | +class MockPersistentSurfaceStore : public PersistentSurfaceStore |
1135 | +{ |
1136 | +public: |
1137 | + MockPersistentSurfaceStore(); |
1138 | + |
1139 | + MOCK_METHOD1(id_for_surface, Id(std::shared_ptr<scene::Surface> const& surface)); |
1140 | + MOCK_CONST_METHOD1(surface_for_id, std::shared_ptr<scene::Surface>(Id const& id)); |
1141 | +}; |
1142 | + |
1143 | +} |
1144 | +} |
1145 | + |
1146 | +#endif // MOCKPERSISTENTSURFACESTORE_H |
1147 | |
1148 | === modified file 'tests/framework/qtmir_test.cpp' |
1149 | --- tests/framework/qtmir_test.cpp 2016-08-10 06:51:37 +0000 |
1150 | +++ tests/framework/qtmir_test.cpp 2016-08-24 20:15:29 +0000 |
1151 | @@ -84,12 +84,13 @@ |
1152 | |
1153 | QtMirTest::QtMirTest() |
1154 | : promptSessionManager(std::make_shared<StubPromptSessionManager>()) |
1155 | + , persistentSurfaceStore(std::make_shared<StubPersistentSurfaceStore>()) |
1156 | , applicationManager(taskControllerSharedPointer, |
1157 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), |
1158 | QSharedPointer<ProcInfo>(&procInfo,[](ProcInfo *){}), |
1159 | QSharedPointer<MockSettings>(&settings,[](MockSettings *){})) |
1160 | , sessionManager(promptSessionManager, &applicationManager) |
1161 | - , surfaceManager(mirShell, &sessionManager) |
1162 | + , surfaceManager(mirShell, &sessionManager, persistentSurfaceStore) |
1163 | { |
1164 | } |
1165 | |
1166 | |
1167 | === modified file 'tests/framework/qtmir_test.h' |
1168 | --- tests/framework/qtmir_test.h 2016-05-06 10:04:17 +0000 |
1169 | +++ tests/framework/qtmir_test.h 2016-08-24 20:15:29 +0000 |
1170 | @@ -38,6 +38,7 @@ |
1171 | #include "mock_shared_wakelock.h" |
1172 | #include "mock_settings.h" |
1173 | #include "mock_task_controller.h" |
1174 | +#include "mock_persistent_surface_store.h" |
1175 | |
1176 | namespace ms = mir::scene; |
1177 | using namespace qtmir; |
1178 | @@ -45,6 +46,7 @@ |
1179 | namespace qtmir { |
1180 | |
1181 | typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager; |
1182 | +typedef testing::NiceMock<mir::shell::MockPersistentSurfaceStore> StubPersistentSurfaceStore; |
1183 | |
1184 | // For better output in ASSERT_* and EXPECT_* error messages |
1185 | void PrintTo(const Application::InternalState& state, ::std::ostream* os); |
1186 | @@ -68,6 +70,7 @@ |
1187 | testing::NiceMock<MockSharedWakelock> sharedWakelock; |
1188 | testing::NiceMock<MockSettings> settings; |
1189 | std::shared_ptr<StubPromptSessionManager> promptSessionManager; |
1190 | + std::shared_ptr<StubPersistentSurfaceStore> persistentSurfaceStore; |
1191 | |
1192 | mir::shell::Shell *mirShell{nullptr}; |
1193 | ApplicationManager applicationManager; |
1194 | |
1195 | === modified file 'tests/mirserver/CMakeLists.txt' |
1196 | --- tests/mirserver/CMakeLists.txt 2016-04-13 14:25:42 +0000 |
1197 | +++ tests/mirserver/CMakeLists.txt 2016-08-24 20:15:29 +0000 |
1198 | @@ -1,6 +1,5 @@ |
1199 | add_subdirectory(ArgvHelper) |
1200 | add_subdirectory(QtEventFeeder) |
1201 | -add_subdirectory(Clipboard) |
1202 | add_subdirectory(Screen) |
1203 | add_subdirectory(ScreensModel) |
1204 | add_subdirectory(WindowManager) |
1205 | |
1206 | === removed directory 'tests/mirserver/Clipboard' |
1207 | === removed file 'tests/mirserver/Clipboard/CMakeLists.txt' |
1208 | --- tests/mirserver/Clipboard/CMakeLists.txt 2016-06-06 18:12:07 +0000 |
1209 | +++ tests/mirserver/Clipboard/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1210 | @@ -1,27 +0,0 @@ |
1211 | -set( |
1212 | - CLIPBOARD_TEST_SOURCES |
1213 | - clipboard_test.cpp |
1214 | - ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp |
1215 | -) |
1216 | - |
1217 | -include_directories( |
1218 | - ${CMAKE_SOURCE_DIR}/src/platforms/mirserver |
1219 | -) |
1220 | - |
1221 | -include_directories( |
1222 | - SYSTEM |
1223 | - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} |
1224 | - ${MIRSERVER_INCLUDE_DIRS} |
1225 | -) |
1226 | - |
1227 | -add_executable(ClipboardTest ${CLIPBOARD_TEST_SOURCES}) |
1228 | - |
1229 | -target_link_libraries( |
1230 | - ClipboardTest |
1231 | - qpa-mirserver |
1232 | - |
1233 | - ${GTEST_BOTH_LIBRARIES} |
1234 | - ${GMOCK_LIBRARIES} |
1235 | -) |
1236 | - |
1237 | -add_test(Clipboard, ClipboardTest) |
1238 | |
1239 | === removed file 'tests/mirserver/Clipboard/clipboard_test.cpp' |
1240 | --- tests/mirserver/Clipboard/clipboard_test.cpp 2015-08-11 12:08:32 +0000 |
1241 | +++ tests/mirserver/Clipboard/clipboard_test.cpp 1970-01-01 00:00:00 +0000 |
1242 | @@ -1,75 +0,0 @@ |
1243 | -/* |
1244 | - * Copyright (C) 2014-2015 Canonical, Ltd. |
1245 | - * |
1246 | - * This program is free software: you can redistribute it and/or modify it under |
1247 | - * the terms of the GNU Lesser General Public License version 3, as published by |
1248 | - * the Free Software Foundation. |
1249 | - * |
1250 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
1251 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
1252 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1253 | - * Lesser General Public License for more details. |
1254 | - * |
1255 | - * You should have received a copy of the GNU Lesser General Public License |
1256 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1257 | - */ |
1258 | - |
1259 | -#include <gtest/gtest.h> |
1260 | - |
1261 | -#include <clipboard.h> |
1262 | - |
1263 | -#include <QLoggingCategory> |
1264 | -#include <QMimeData> |
1265 | - |
1266 | -using namespace qtmir; |
1267 | - |
1268 | -TEST(ClipboardTest, MimeDataSerialization) |
1269 | -{ |
1270 | - QMimeData *mimeData = new QMimeData; |
1271 | - mimeData->setData("text/plain", "Hello World!"); |
1272 | - mimeData->setData("text/html", "<html lang=\"en\"><body>Hello World!</body></html>"); |
1273 | - |
1274 | - QByteArray serializedMimeData = serializeMimeData(mimeData); |
1275 | - |
1276 | - ASSERT_TRUE(serializedMimeData.size() > 0); |
1277 | - |
1278 | - QMimeData *deserializedMimeData = deserializeMimeData(serializedMimeData); |
1279 | - |
1280 | - ASSERT_TRUE(deserializedMimeData != nullptr); |
1281 | - |
1282 | - ASSERT_TRUE(deserializedMimeData->hasFormat("text/plain")); |
1283 | - ASSERT_EQ(mimeData->data("text/plain"), deserializedMimeData->data("text/plain")); |
1284 | - |
1285 | - ASSERT_TRUE(deserializedMimeData->hasFormat("text/html")); |
1286 | - ASSERT_EQ(mimeData->data("text/html"), deserializedMimeData->data("text/html")); |
1287 | - |
1288 | - delete mimeData; |
1289 | - delete deserializedMimeData; |
1290 | -} |
1291 | - |
1292 | -TEST(ClipboardTest, RefuseContentsThatAreTooBig) |
1293 | -{ |
1294 | - QLoggingCategory::setFilterRules(QStringLiteral("*=false")); |
1295 | - DBusClipboard::skipDBusRegistration = true; |
1296 | - DBusClipboard *dbusClipboard = new DBusClipboard; |
1297 | - |
1298 | - // Was getting a "warning: overflow in implicit constant conversion [-Woverflow]" |
1299 | - // when I used that constant directly in the QByteArray constructors below. Don't |
1300 | - // understand why so here's the workaround for it. |
1301 | - int maxContentsSize = DBusClipboard::maxContentsSize; |
1302 | - |
1303 | - QByteArray reasonableContents(maxContentsSize * 0.9, 'R'); |
1304 | - QByteArray tooBigContents(maxContentsSize * 1.2, 'B'); |
1305 | - |
1306 | - dbusClipboard->SetContents(reasonableContents); |
1307 | - |
1308 | - ASSERT_EQ(dbusClipboard->contents(), reasonableContents); |
1309 | - |
1310 | - dbusClipboard->SetContents(tooBigContents); |
1311 | - |
1312 | - // tooBigContents were refused. So it stays with the previously |
1313 | - // set contents |
1314 | - ASSERT_EQ(dbusClipboard->contents(), reasonableContents); |
1315 | - |
1316 | - delete dbusClipboard; |
1317 | -} |
1318 | |
1319 | === modified file 'tests/modules/SurfaceManager/mirsurface_test.cpp' |
1320 | --- tests/modules/SurfaceManager/mirsurface_test.cpp 2016-05-24 20:13:10 +0000 |
1321 | +++ tests/modules/SurfaceManager/mirsurface_test.cpp 2016-08-24 20:15:29 +0000 |
1322 | @@ -71,7 +71,7 @@ |
1323 | EXPECT_CALL(*mockSurface.get(),buffers_ready_for_compositor(_)) |
1324 | .WillRepeatedly(Return(1)); |
1325 | |
1326 | - MirSurface *surface = new MirSurface(mockSurface, fakeSession, &m_mockShell, surfaceObserver, CreationHints()); |
1327 | + MirSurface *surface = new MirSurface(mockSurface, "1234", fakeSession, &m_mockShell, surfaceObserver, CreationHints()); |
1328 | surfaceObserver->frame_posted(1, mir::geometry::Size{1,1}); |
1329 | |
1330 | QSignalSpy spyFrameDropped(surface, SIGNAL(frameDropped())); |
1331 | @@ -92,7 +92,7 @@ |
1332 | auto fakeSession = new FakeSession(); |
1333 | auto mockSurface = std::make_shared<NiceMock<ms::MockSurface>>(); |
1334 | |
1335 | - MirSurface *surface = new MirSurface(mockSurface, fakeSession, &m_mockShell, nullptr, CreationHints()); |
1336 | + MirSurface *surface = new MirSurface(mockSurface, "1234", fakeSession, &m_mockShell, nullptr, CreationHints()); |
1337 | bool surfaceDeleted = false; |
1338 | QObject::connect(surface, &QObject::destroyed, surface, [&surfaceDeleted](){ surfaceDeleted = true; }); |
1339 | |
1340 | @@ -123,7 +123,7 @@ |
1341 | auto fakeSession = new FakeSession(); |
1342 | auto mockSurface = std::make_shared<NiceMock<ms::MockSurface>>(); |
1343 | |
1344 | - MirSurface *surface = new MirSurface(mockSurface, fakeSession, &m_mockShell, nullptr, CreationHints()); |
1345 | + MirSurface *surface = new MirSurface(mockSurface, "1234", fakeSession, &m_mockShell, nullptr, CreationHints()); |
1346 | bool surfaceDeleted = false; |
1347 | QObject::connect(surface, &QObject::destroyed, surface, [&surfaceDeleted](){ surfaceDeleted = true; }); |
1348 | |
1349 | @@ -161,7 +161,7 @@ |
1350 | |
1351 | auto mockSurface = std::make_shared<NiceMock<ms::MockSurface>>(); |
1352 | |
1353 | - MirSurface *surface = new MirSurface(mockSurface, fakeSession, &m_mockShell, nullptr, CreationHints()); |
1354 | + MirSurface *surface = new MirSurface(mockSurface, "1234", fakeSession, &m_mockShell, nullptr, CreationHints()); |
1355 | bool surfaceDeleted = false; |
1356 | QObject::connect(surface, &QObject::destroyed, surface, [&surfaceDeleted](){ surfaceDeleted = true; }); |
1357 | |
1358 | |
1359 | === modified file 'tests/modules/SurfaceManager/mirsurfaceitem_test.cpp' |
1360 | --- tests/modules/SurfaceManager/mirsurfaceitem_test.cpp 2016-05-24 20:13:10 +0000 |
1361 | +++ tests/modules/SurfaceManager/mirsurfaceitem_test.cpp 2016-08-24 20:15:29 +0000 |
1362 | @@ -174,7 +174,7 @@ |
1363 | auto surfaceObserver = std::make_shared<SurfaceObserver>(); |
1364 | mir::shell::MockShell mockShell; |
1365 | |
1366 | - MirSurface *surface = new MirSurface(mockSurface, fakeSession, &mockShell, surfaceObserver, CreationHints()); |
1367 | + MirSurface *surface = new MirSurface(mockSurface, "1234", fakeSession, &mockShell, surfaceObserver, CreationHints()); |
1368 | |
1369 | MirSurfaceItem *surfaceItem = new MirSurfaceItem; |
1370 | QQuickItemPrivate *surfaceItemPrivate = QQuickItemPrivate::get(surfaceItem); |
1371 | @@ -230,7 +230,7 @@ |
1372 | auto surfaceObserver = std::make_shared<SurfaceObserver>(); |
1373 | mir::shell::MockShell mockShell; |
1374 | |
1375 | - MirSurface *surface = new MirSurface(mockSurface, fakeSession, &mockShell, surfaceObserver, CreationHints()); |
1376 | + MirSurface *surface = new MirSurface(mockSurface, "1234", fakeSession, &mockShell, surfaceObserver, CreationHints()); |
1377 | |
1378 | MirSurfaceItem *surfaceItem1 = new MirSurfaceItem; |
1379 | QQuickItemPrivate *surfaceItem1Private = QQuickItemPrivate::get(surfaceItem1); |
FAILED: Continuous integration, rev:530 /code.launchpad .net/~dandrader /qtmir/ content- hub-clipboard/ +merge/ 301705/ +edit-commit- message
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
https:/ /unity8- jenkins. ubuntu. com/job/ lp-qtmir- ci/317/ /unity8- jenkins. ubuntu. com/job/ build/2430/ console /unity8- jenkins. ubuntu. com/job/ build-0- fetch/2458 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= vivid+overlay/ 2345 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial+ overlay/ 2345 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= yakkety/ 2345 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 2338/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 2338/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 2338/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 2338/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 2338/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 2338/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 2338/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 2338/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= yakkety/ 2338/console
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /unity8- jenkins. ubuntu. com/job/ lp-qtmir- ci/317/ rebuild
https:/