Merge lp:~gerboland/miral/add-interactivity-to-WM into lp:miral
- add-interactivity-to-WM
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 271 |
Proposed branch: | lp:~gerboland/miral/add-interactivity-to-WM |
Merge into: | lp:miral |
Diff against target: |
2067 lines (+752/-431) 22 files modified
miral-qt/demos/qml-demo-shell/windowModel.qml (+104/-25) miral-qt/src/common/windowcontrollerinterface.h (+53/-0) miral-qt/src/common/windowmodelinterface.h (+36/-30) miral-qt/src/modules/Unity/Application/mirsurface.cpp (+152/-124) miral-qt/src/modules/Unity/Application/mirsurface.h (+12/-30) miral-qt/src/modules/Unity/Application/mirsurfaceinterface.h (+1/-7) miral-qt/src/modules/Unity/Application/mirsurfacemanager.cpp (+54/-54) miral-qt/src/modules/Unity/Application/windowmodel.cpp (+43/-29) miral-qt/src/modules/Unity/Application/windowmodel.h (+9/-2) miral-qt/src/platforms/mirserver/CMakeLists.txt (+2/-0) miral-qt/src/platforms/mirserver/mirserver.cpp (+3/-4) miral-qt/src/platforms/mirserver/mirserver.h (+4/-2) miral-qt/src/platforms/mirserver/qmirserver.cpp (+2/-2) miral-qt/src/platforms/mirserver/windowcontroller.cpp (+85/-0) miral-qt/src/platforms/mirserver/windowcontroller.h (+51/-0) miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp (+48/-20) miral-qt/src/platforms/mirserver/windowmanagementpolicy.h (+13/-8) miral-qt/src/platforms/mirserver/windowmodel.cpp (+10/-26) miral-qt/tests/framework/fake_mirsurface.cpp (+6/-4) miral-qt/tests/framework/fake_mirsurface.h (+5/-10) miral-qt/tests/modules/SurfaceManager/CMakeLists.txt (+3/-1) miral-qt/tests/modules/SurfaceManager/mirsurface_test.cpp (+56/-53) |
To merge this branch: | bzr merge lp:~gerboland/miral/add-interactivity-to-WM |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alan Griffiths | Approve | ||
Review via email:
|
Commit message
[miral-qt] Refactor out MirSurfaceManager and replace with qtmir::WindowModel. Add WindowController which enables window move & resize.
- MirSurfaceManager managed lifetimes of MirSurfaces. With MirAL, this responsibility must move to the WindowModel. Will fully remove MirSurfaceManager in a later MP (commented out for now).
- WindowController allows shell to control the window manager
- MirSurface refactored to wrap miral::WindowInfo which has nearly all the info it needs, and given access to the WindowController.
- redid the signal/slot interface between mirserver:
- mir::shell::Shell no longer exported in the top-level MirServer class.
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
/home/alan/
FakeMirSurface *surface = new FakeMirSurface;
/home/alan/
virtual void requestPosition
^
/home/alan/
virtual void setShellChrome(
^
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
Possibly not new with this MP, but after starting "qml-demo-shell --x11-displays 648x480" and running mir_demo_
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gerry Boland (gerboland) wrote : | # |
That's what I get for leaving NO_TESTS=1 set!
I've made whatever tests that should be workable compile - they fail still. Other tests I've not updated until the functionality they rely on has been restored.
On your crash find, I cannot reproduce it here. Could you grab me a backtrace?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
Crash seems fairly consistent. If it matters, this is g++/yakkety:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007fdbe02508fb in qtmir::
at /home/alan/
406 auto renderables = window-
[Current thread is 1 (Thread 0x7fdbce4d5700 (LWP 9694))]
(gdb) bt
#0 0x00007fdbe02508fb in qtmir::
at /home/alan/
#1 0x00007fdbe025bf81 in qtmir::
this=
at /home/alan/
#2 0x00007fdc011132c8 in QQuickWindowPri
from /usr/lib/
#3 0x00007fdc01113b3b in QQuickWindowPri
from /usr/lib/
#4 0x00007fdc01113cb0 in QQuickWindowPri
from /usr/lib/
#5 0x00007fdc010e4d53 in ?? () from /usr/lib/
#6 0x00007fdc010e5f95 in ?? () from /usr/lib/
#7 0x00007fdc010eb07c in ?? () from /usr/lib/
#8 0x00007fdc001d77be in ?? () from /usr/lib/
#9 0x00007fdbff2ab70a in start_thread (arg=0x7fdbce4d
#10 0x00007fdbff8d06ad in clone () at ../sysdeps/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
On balance I think it better to land this "wiring" than to try to perfect it first.
~~~~
+#include "miral/
Once MirAL supports everything we need we intend to separate the Qt use of MirAL from the project. So I'd be inclined to use <> includes for miral headers.
~~~~
I see this a few times: "static_
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
> With Vivid+Overlay/clang I need:
>
> #pragma clang diagnostic push
> #pragma clang diagnostic ignored "-Wunused-function"
> Q_DECLARE_
> #pragma clang diagnostic pop
Oh g++ errors on these. We need something like:
#if defined(__clang__)
- 266. By Gerry Boland
-
ifdef the clang workaround
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gerry Boland (gerboland) wrote : | # |
Done. Your g++/clang++ are more fussy than mine on xenial!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-function"
+Q_DECLARE_
+#pragma clang diagnostic pop
+#endif
Do you really mean we only need Q_DECLARE_
- 267. By Gerry Boland
-
The | operator for QFlags not actually needed - yet! Remove, add back only when I need it
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gerry Boland (gerboland) wrote : | # |
> +#if defined(__clang__)
> +#pragma clang diagnostic push
> +#pragma clang diagnostic ignored "-Wunused-function"
> +Q_DECLARE_
> +#pragma clang diagnostic pop
> +#endif
>
> Do you really mean we only need Q_DECLARE_
> Maybe we just don't need it?
Quite right, it's not needed until I start combining flags with the | operator. I've removed it entirely
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
There's an orphaned comment but WTF
- 268. By Gerry Boland
-
remove defunkt comment
Preview Diff
1 | === modified file 'miral-qt/demos/qml-demo-shell/windowModel.qml' | |||
2 | --- miral-qt/demos/qml-demo-shell/windowModel.qml 2016-07-27 12:37:01 +0000 | |||
3 | +++ miral-qt/demos/qml-demo-shell/windowModel.qml 2016-08-12 12:04:26 +0000 | |||
4 | @@ -2,37 +2,116 @@ | |||
5 | 2 | import Unity.Application 0.1 | 2 | import Unity.Application 0.1 |
6 | 3 | 3 | ||
7 | 4 | FocusScope { | 4 | FocusScope { |
8 | 5 | id: root | ||
9 | 5 | focus: true | 6 | focus: true |
10 | 6 | 7 | ||
11 | 7 | WindowModel { | 8 | WindowModel { |
12 | 8 | id: windowModel; | 9 | id: windowModel; |
13 | 9 | } | 10 | } |
14 | 10 | 11 | ||
40 | 11 | Repeater { | 12 | Item { |
41 | 12 | anchors.fill: parent | 13 | id: windowViewContainer |
42 | 13 | model: windowModel | 14 | anchors.fill: parent |
43 | 14 | 15 | ||
44 | 15 | delegate: MirSurfaceItem { | 16 | Repeater { |
45 | 16 | id: surfaceItem | 17 | model: windowModel |
46 | 17 | surface: model.surface | 18 | |
47 | 18 | consumesInput: true // QUESTION: why is this non-default? | 19 | delegate: MirSurfaceItem { |
48 | 19 | x: surface.position.x | 20 | id: surfaceItem |
49 | 20 | y: surface.position.y | 21 | surface: model.surface |
50 | 21 | width: surface.size.width | 22 | consumesInput: true // QUESTION: why is this non-default? |
51 | 22 | height: surface.size.height | 23 | x: surface.position.x |
52 | 23 | focus: surface.focused | 24 | y: surface.position.y |
53 | 24 | 25 | width: surface.size.width | |
54 | 25 | Rectangle { | 26 | height: surface.size.height |
55 | 26 | anchors { top: parent.bottom; right: parent.right } | 27 | focus: surface.focused |
56 | 27 | width: childrenRect.width | 28 | |
57 | 28 | height: childrenRect.height | 29 | Rectangle { |
58 | 29 | color: surface.focused ? "red" : "lightsteelblue" | 30 | anchors { top: parent.bottom; right: parent.right } |
59 | 30 | opacity: 0.8 | 31 | width: childrenRect.width |
60 | 31 | Text { | 32 | height: childrenRect.height |
61 | 32 | text: surface.position.x + "," + surface.position.y + " " + surface.size.width + "x" + surface.size.height | 33 | color: surface.focused ? "red" : "lightsteelblue" |
62 | 33 | font.pixelSize: 10 | 34 | opacity: 0.8 |
63 | 34 | } | 35 | Text { |
64 | 35 | } | 36 | text: surface.position.x + "," + surface.position.y + " " + surface.size.width + "x" + surface.size.height |
65 | 37 | font.pixelSize: 10 | ||
66 | 38 | } | ||
67 | 39 | } | ||
68 | 40 | } | ||
69 | 41 | } | ||
70 | 42 | } | ||
71 | 43 | |||
72 | 44 | Button { | ||
73 | 45 | anchors { right: parent.right; bottom: parent.bottom } | ||
74 | 46 | height: 30 | ||
75 | 47 | width: 80 | ||
76 | 48 | text: "Quit" | ||
77 | 49 | onClicked: Qt.quit() | ||
78 | 50 | } | ||
79 | 51 | |||
80 | 52 | Text { | ||
81 | 53 | anchors { left: parent.left; bottom: parent.bottom } | ||
82 | 54 | text: "Move window: Ctrl+click\n | ||
83 | 55 | Resize window: Ctrl+Right click" | ||
84 | 56 | } | ||
85 | 57 | |||
86 | 58 | MouseArea { | ||
87 | 59 | anchors.fill: parent | ||
88 | 60 | acceptedButtons: Qt.LeftButton | Qt.RightButton | ||
89 | 61 | property variant window: null | ||
90 | 62 | property int initialWindowXPosition | ||
91 | 63 | property int initialWindowYPosition | ||
92 | 64 | property int initialWindowWidth | ||
93 | 65 | property int initialWindowHeight | ||
94 | 66 | property int initialMouseXPosition | ||
95 | 67 | property int initialMouseYPosition | ||
96 | 68 | property var action | ||
97 | 69 | |||
98 | 70 | function moveWindowBy(window, delta) { | ||
99 | 71 | window.surface.requestPosition(Qt.point(initialWindowXPosition + delta.x, | ||
100 | 72 | initialWindowYPosition + delta.y)) | ||
101 | 73 | } | ||
102 | 74 | function resizeWindowBy(window, delta) { | ||
103 | 75 | window.surface.resize(Qt.size(initialWindowWidth + delta.x, | ||
104 | 76 | initialWindowHeight + delta.y)) | ||
105 | 77 | } | ||
106 | 78 | |||
107 | 79 | onPressed: { | ||
108 | 80 | if (mouse.modifiers & Qt.ControlModifier) { | ||
109 | 81 | window = windowViewContainer.childAt(mouse.x, mouse.y) | ||
110 | 82 | if (!window) return; | ||
111 | 83 | |||
112 | 84 | if (mouse.button == Qt.LeftButton) { | ||
113 | 85 | initialWindowXPosition = window.surface.position.x | ||
114 | 86 | initialWindowYPosition = window.surface.position.y | ||
115 | 87 | action = moveWindowBy | ||
116 | 88 | } else if (mouse.button == Qt.RightButton) { | ||
117 | 89 | initialWindowHeight = window.surface.size.height | ||
118 | 90 | initialWindowWidth = window.surface.size.width | ||
119 | 91 | action = resizeWindowBy | ||
120 | 92 | } | ||
121 | 93 | initialMouseXPosition = mouse.x | ||
122 | 94 | initialMouseYPosition = mouse.y | ||
123 | 95 | } else { | ||
124 | 96 | mouse.accepted = false | ||
125 | 97 | } | ||
126 | 98 | } | ||
127 | 99 | |||
128 | 100 | onPositionChanged: { | ||
129 | 101 | if (!window) { | ||
130 | 102 | mouse.accepted = false | ||
131 | 103 | return | ||
132 | 104 | } | ||
133 | 105 | action(window, Qt.point(mouse.x - initialMouseXPosition, mouse.y - initialMouseYPosition)) | ||
134 | 106 | } | ||
135 | 107 | |||
136 | 108 | onReleased: { | ||
137 | 109 | if (!window) { | ||
138 | 110 | mouse.accepted = false | ||
139 | 111 | return | ||
140 | 112 | } | ||
141 | 113 | action(window, Qt.point(mouse.x - initialMouseXPosition, mouse.y - initialMouseYPosition)) | ||
142 | 114 | window = null; | ||
143 | 36 | } | 115 | } |
144 | 37 | } | 116 | } |
145 | 38 | } | 117 | } |
146 | 39 | 118 | ||
147 | === added file 'miral-qt/src/common/windowcontrollerinterface.h' | |||
148 | --- miral-qt/src/common/windowcontrollerinterface.h 1970-01-01 00:00:00 +0000 | |||
149 | +++ miral-qt/src/common/windowcontrollerinterface.h 2016-08-12 12:04:26 +0000 | |||
150 | @@ -0,0 +1,53 @@ | |||
151 | 1 | /* | ||
152 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
153 | 3 | * | ||
154 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
155 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
156 | 6 | * the Free Software Foundation. | ||
157 | 7 | * | ||
158 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
159 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
160 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
161 | 11 | * Lesser General Public License for more details. | ||
162 | 12 | * | ||
163 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
164 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
165 | 15 | */ | ||
166 | 16 | |||
167 | 17 | #ifndef WINDOWCONTROLLERINTERFACE_H | ||
168 | 18 | #define WINDOWCONTROLLERINTERFACE_H | ||
169 | 19 | |||
170 | 20 | #include "miral/window.h" | ||
171 | 21 | |||
172 | 22 | #include "mir_toolkit/event.h" | ||
173 | 23 | |||
174 | 24 | #include <QPoint> | ||
175 | 25 | #include <QSize> | ||
176 | 26 | |||
177 | 27 | namespace qtmir { | ||
178 | 28 | |||
179 | 29 | class MirSurface; | ||
180 | 30 | |||
181 | 31 | class WindowControllerInterface { | ||
182 | 32 | public: | ||
183 | 33 | WindowControllerInterface() = default; | ||
184 | 34 | virtual ~WindowControllerInterface() = default; | ||
185 | 35 | |||
186 | 36 | // focus() asks Mir to bring particular window to the front and recommend to shell that it be focused | ||
187 | 37 | virtual void focus (const miral::Window &window) = 0; | ||
188 | 38 | // setActiveFocus() is how shell notifies Mir/application that a window actually has input focus | ||
189 | 39 | virtual void setActiveFocus(const miral::Window &window, const bool activeFocus) = 0; | ||
190 | 40 | |||
191 | 41 | virtual void resize(const miral::Window &window, const QSize &size) = 0; | ||
192 | 42 | virtual void move (const miral::Window &window, const QPoint &topLeft) = 0; | ||
193 | 43 | |||
194 | 44 | virtual void setState(const miral::Window &window, const MirSurfaceState state) = 0; | ||
195 | 45 | |||
196 | 46 | virtual void deliverKeyboardEvent(const miral::Window &window, const MirKeyboardEvent *event) = 0; | ||
197 | 47 | virtual void deliverTouchEvent (const miral::Window &window, const MirTouchEvent *event) = 0; | ||
198 | 48 | virtual void deliverPointerEvent (const miral::Window &window, const MirPointerEvent *event) = 0; | ||
199 | 49 | }; | ||
200 | 50 | |||
201 | 51 | } // namespace qtmir | ||
202 | 52 | |||
203 | 53 | #endif // WINDOWCONTROLLERINTERFACE_H | ||
204 | 0 | 54 | ||
205 | === modified file 'miral-qt/src/common/windowmodelinterface.h' | |||
206 | --- miral-qt/src/common/windowmodelinterface.h 2016-07-27 17:41:48 +0000 | |||
207 | +++ miral-qt/src/common/windowmodelinterface.h 2016-08-12 12:04:26 +0000 | |||
208 | @@ -22,35 +22,39 @@ | |||
209 | 22 | #include <QPoint> | 22 | #include <QPoint> |
210 | 23 | #include <QVector> | 23 | #include <QVector> |
211 | 24 | 24 | ||
213 | 25 | #include <mir/scene/surface.h> | 25 | #include "miral/window_info.h" |
214 | 26 | 26 | ||
215 | 27 | namespace qtmir { | 27 | namespace qtmir { |
216 | 28 | 28 | ||
242 | 29 | // miral::WindowInfo contains all the metadata the WindowManager{,Policy} needs. However the | 29 | // miral::WindowInfo missing a default constructor, needed by MOC. Need to wrap it instead |
243 | 30 | // WindowModel only needs a read-only subset of this data, which is what the struct is for. | 30 | class WindowInfo { |
244 | 31 | struct WindowInfo { | 31 | public: |
245 | 32 | QSize size; | 32 | WindowInfo() = default; |
246 | 33 | QPoint position; | 33 | WindowInfo(const miral::WindowInfo &windowInfo) |
247 | 34 | bool focused; | 34 | : window(windowInfo.window()) |
248 | 35 | const std::shared_ptr<mir::scene::Surface> surface; | 35 | , name(windowInfo.name()) |
249 | 36 | 36 | , type(windowInfo.type()) | |
250 | 37 | enum class DirtyStates { | 37 | , state(windowInfo.state()) |
251 | 38 | Size = 1, | 38 | , restoreRect(windowInfo.restore_rect()) |
252 | 39 | Position = 2, | 39 | , parent(windowInfo.parent()) |
253 | 40 | Focus = 4 | 40 | , children(windowInfo.children()) |
254 | 41 | }; | 41 | , minWidth(windowInfo.min_width()) |
255 | 42 | }; | 42 | , minHeight(windowInfo.min_height()) |
256 | 43 | 43 | , maxWidth(windowInfo.max_width()) | |
257 | 44 | // We assign each Window with an index which corresponds to the position it has in the window stack. | 44 | , maxHeight(windowInfo.max_height()) |
258 | 45 | struct NumberedWindow { | 45 | {} |
259 | 46 | unsigned int index; | 46 | |
260 | 47 | WindowInfo windowInfo; | 47 | miral::Window window; |
261 | 48 | }; | 48 | mir::optional_value<std::string> name; |
262 | 49 | 49 | MirSurfaceType type; | |
263 | 50 | struct DirtiedWindow { | 50 | MirSurfaceState state; |
264 | 51 | unsigned int index; | 51 | mir::geometry::Rectangle restoreRect; |
265 | 52 | WindowInfo windowInfo; | 52 | miral::Window parent; |
266 | 53 | WindowInfo::DirtyStates dirtyWindowInfo; | 53 | std::vector<miral::Window> children; |
267 | 54 | mir::geometry::Width minWidth; | ||
268 | 55 | mir::geometry::Height minHeight; | ||
269 | 56 | mir::geometry::Width maxWidth; | ||
270 | 57 | mir::geometry::Height maxHeight; | ||
271 | 54 | }; | 58 | }; |
272 | 55 | 59 | ||
273 | 56 | 60 | ||
274 | @@ -62,9 +66,12 @@ | |||
275 | 62 | virtual ~WindowModelInterface() = default; | 66 | virtual ~WindowModelInterface() = default; |
276 | 63 | 67 | ||
277 | 64 | Q_SIGNALS: | 68 | Q_SIGNALS: |
279 | 65 | void windowAdded(const qtmir::NumberedWindow); | 69 | void windowAdded(const qtmir::WindowInfo, const unsigned int index); |
280 | 66 | void windowRemoved(const unsigned int index); | 70 | void windowRemoved(const unsigned int index); |
282 | 67 | void windowChanged(const qtmir::DirtiedWindow); | 71 | void windowMoved(const QPoint topLeft, const unsigned int index); |
283 | 72 | void windowResized(const QSize size, const unsigned int index); | ||
284 | 73 | void windowFocused(const unsigned int index); | ||
285 | 74 | void windowInfoChanged(const qtmir::WindowInfo, const unsigned int index); | ||
286 | 68 | 75 | ||
287 | 69 | private: | 76 | private: |
288 | 70 | Q_DISABLE_COPY(WindowModelInterface) | 77 | Q_DISABLE_COPY(WindowModelInterface) |
289 | @@ -72,7 +79,6 @@ | |||
290 | 72 | 79 | ||
291 | 73 | } // namespace qtmir | 80 | } // namespace qtmir |
292 | 74 | 81 | ||
295 | 75 | Q_DECLARE_METATYPE(qtmir::NumberedWindow) | 82 | Q_DECLARE_METATYPE(qtmir::WindowInfo) |
294 | 76 | Q_DECLARE_METATYPE(qtmir::DirtiedWindow) | ||
296 | 77 | 83 | ||
297 | 78 | #endif // WINDOWMODELINTERFACE_H | 84 | #endif // WINDOWMODELINTERFACE_H |
298 | 79 | 85 | ||
299 | === modified file 'miral-qt/src/modules/Unity/Application/mirsurface.cpp' | |||
300 | --- miral-qt/src/modules/Unity/Application/mirsurface.cpp 2016-07-27 12:42:21 +0000 | |||
301 | +++ miral-qt/src/modules/Unity/Application/mirsurface.cpp 2016-08-12 12:04:26 +0000 | |||
302 | @@ -177,34 +177,38 @@ | |||
303 | 177 | return ev; | 177 | return ev; |
304 | 178 | } | 178 | } |
305 | 179 | 179 | ||
306 | 180 | enum class DirtyState { | ||
307 | 181 | Clean = 0, | ||
308 | 182 | Name = 1 << 1, | ||
309 | 183 | Type = 1 << 2, | ||
310 | 184 | State = 1 << 3, | ||
311 | 185 | RestoreRect = 1 << 4, | ||
312 | 186 | Children = 1 << 5, | ||
313 | 187 | MinSize = 1 << 6, | ||
314 | 188 | MaxSize = 1 << 7, | ||
315 | 189 | }; | ||
316 | 190 | Q_DECLARE_FLAGS(DirtyStates, DirtyState) | ||
317 | 191 | |||
318 | 180 | } // namespace { | 192 | } // namespace { |
319 | 181 | 193 | ||
325 | 182 | MirSurface::MirSurface(std::shared_ptr<mir::scene::Surface> surface, | 194 | MirSurface::MirSurface(WindowInfo windowInfo, |
326 | 183 | SessionInterface* session, | 195 | WindowControllerInterface* controller, |
327 | 184 | mir::shell::Shell* shell, | 196 | std::shared_ptr<SurfaceObserver> observer) |
323 | 185 | std::shared_ptr<SurfaceObserver> observer, | ||
324 | 186 | const CreationHints &creationHints) | ||
328 | 187 | : MirSurfaceInterface() | 197 | : MirSurfaceInterface() |
332 | 188 | , m_surface(surface) | 198 | , m_windowInfo(windowInfo) |
333 | 189 | , m_session(session) | 199 | , m_controller(controller) |
331 | 190 | , m_shell(shell) | ||
334 | 191 | , m_firstFrameDrawn(false) | 200 | , m_firstFrameDrawn(false) |
335 | 192 | , m_orientationAngle(Mir::Angle0) | 201 | , m_orientationAngle(Mir::Angle0) |
336 | 193 | , m_textureUpdated(false) | 202 | , m_textureUpdated(false) |
337 | 194 | , m_currentFrameNumber(0) | 203 | , m_currentFrameNumber(0) |
338 | 195 | , m_live(true) | 204 | , m_live(true) |
339 | 205 | , m_position(toQPoint(windowInfo.window.top_left())) | ||
340 | 206 | , m_size(toQSize(windowInfo.window.size())) | ||
341 | 196 | , m_shellChrome(Mir::NormalChrome) | 207 | , m_shellChrome(Mir::NormalChrome) |
342 | 197 | { | 208 | { |
343 | 198 | DEBUG_MSG << "()"; | 209 | DEBUG_MSG << "()"; |
344 | 199 | 210 | ||
353 | 200 | m_position = toQPoint(surface->top_left()); | 211 | //m_shellChrome = creationHints.shellChrome; TODO - where will this come from now? |
346 | 201 | m_minimumWidth = creationHints.minWidth; | ||
347 | 202 | m_minimumHeight = creationHints.minHeight; | ||
348 | 203 | m_maximumWidth = creationHints.maxWidth; | ||
349 | 204 | m_maximumHeight = creationHints.maxHeight; | ||
350 | 205 | m_widthIncrement = creationHints.widthIncrement; | ||
351 | 206 | m_heightIncrement = creationHints.heightIncrement; | ||
352 | 207 | m_shellChrome = creationHints.shellChrome; | ||
354 | 208 | 212 | ||
355 | 209 | m_surfaceObserver = observer; | 213 | m_surfaceObserver = observer; |
356 | 210 | if (observer) { | 214 | if (observer) { |
357 | @@ -212,12 +216,6 @@ | |||
358 | 212 | connect(observer.get(), &SurfaceObserver::attributeChanged, this, &MirSurface::onAttributeChanged); | 216 | connect(observer.get(), &SurfaceObserver::attributeChanged, this, &MirSurface::onAttributeChanged); |
359 | 213 | connect(observer.get(), &SurfaceObserver::nameChanged, this, &MirSurface::nameChanged); | 217 | connect(observer.get(), &SurfaceObserver::nameChanged, this, &MirSurface::nameChanged); |
360 | 214 | connect(observer.get(), &SurfaceObserver::cursorChanged, this, &MirSurface::setCursor); | 218 | connect(observer.get(), &SurfaceObserver::cursorChanged, this, &MirSurface::setCursor); |
361 | 215 | connect(observer.get(), &SurfaceObserver::minimumWidthChanged, this, &MirSurface::setMinimumWidth); | ||
362 | 216 | connect(observer.get(), &SurfaceObserver::minimumHeightChanged, this, &MirSurface::setMinimumHeight); | ||
363 | 217 | connect(observer.get(), &SurfaceObserver::maximumWidthChanged, this, &MirSurface::setMaximumWidth); | ||
364 | 218 | connect(observer.get(), &SurfaceObserver::maximumHeightChanged, this, &MirSurface::setMaximumHeight); | ||
365 | 219 | connect(observer.get(), &SurfaceObserver::widthIncrementChanged, this, &MirSurface::setWidthIncrement); | ||
366 | 220 | connect(observer.get(), &SurfaceObserver::heightIncrementChanged, this, &MirSurface::setHeightIncrement); | ||
367 | 221 | connect(observer.get(), &SurfaceObserver::shellChromeChanged, this, [&](MirShellChrome shell_chrome) { | 219 | connect(observer.get(), &SurfaceObserver::shellChromeChanged, this, [&](MirShellChrome shell_chrome) { |
368 | 222 | setShellChrome(static_cast<Mir::ShellChrome>(shell_chrome)); | 220 | setShellChrome(static_cast<Mir::ShellChrome>(shell_chrome)); |
369 | 223 | }); | 221 | }); |
370 | @@ -225,7 +223,7 @@ | |||
371 | 225 | observer->setListener(this); | 223 | observer->setListener(this); |
372 | 226 | } | 224 | } |
373 | 227 | 225 | ||
375 | 228 | connect(session, &QObject::destroyed, this, &MirSurface::onSessionDestroyed); | 226 | //connect(session, &QObject::destroyed, this, &MirSurface::onSessionDestroyed); // TODO try using Shared pointer for lifecycle |
376 | 229 | 227 | ||
377 | 230 | connect(&m_frameDropperTimer, &QTimer::timeout, | 228 | connect(&m_frameDropperTimer, &QTimer::timeout, |
378 | 231 | this, &MirSurface::dropPendingBuffer); | 229 | this, &MirSurface::dropPendingBuffer); |
379 | @@ -256,7 +254,8 @@ | |||
380 | 256 | Q_ASSERT(m_views.isEmpty()); | 254 | Q_ASSERT(m_views.isEmpty()); |
381 | 257 | 255 | ||
382 | 258 | QMutexLocker locker(&m_mutex); | 256 | QMutexLocker locker(&m_mutex); |
384 | 259 | m_surface->remove_observer(m_surfaceObserver); | 257 | // auto const &window = static_cast<std::shared_ptr<mir::scene::Surface>>(m_windowInfo.window); |
385 | 258 | // window->remove_observer(m_surfaceObserver); // FIXME - window null at this stage! | ||
386 | 260 | 259 | ||
387 | 261 | delete m_closeTimer; | 260 | delete m_closeTimer; |
388 | 262 | 261 | ||
389 | @@ -298,7 +297,7 @@ | |||
390 | 298 | 297 | ||
391 | 299 | Mir::Type MirSurface::type() const | 298 | Mir::Type MirSurface::type() const |
392 | 300 | { | 299 | { |
394 | 301 | switch (m_surface->type()) { | 300 | switch (m_windowInfo.type) { |
395 | 302 | case mir_surface_type_normal: | 301 | case mir_surface_type_normal: |
396 | 303 | return Mir::NormalType; | 302 | return Mir::NormalType; |
397 | 304 | 303 | ||
398 | @@ -337,7 +336,8 @@ | |||
399 | 337 | 336 | ||
400 | 338 | const void* const userId = (void*)123; // TODO: Multimonitor support | 337 | const void* const userId = (void*)123; // TODO: Multimonitor support |
401 | 339 | 338 | ||
403 | 340 | int framesPending = m_surface->buffers_ready_for_compositor(userId); | 339 | auto const &window = static_cast<std::shared_ptr<mir::scene::Surface>>(m_windowInfo.window); |
404 | 340 | int framesPending = window->buffers_ready_for_compositor(userId); | ||
405 | 341 | if (framesPending > 0) { | 341 | if (framesPending > 0) { |
406 | 342 | m_textureUpdated = false; | 342 | m_textureUpdated = false; |
407 | 343 | 343 | ||
408 | @@ -398,10 +398,11 @@ | |||
409 | 398 | } | 398 | } |
410 | 399 | 399 | ||
411 | 400 | const void* const userId = (void*)123; | 400 | const void* const userId = (void*)123; |
413 | 401 | auto renderables = m_surface->generate_renderables(userId); | 401 | auto const &window = static_cast<std::shared_ptr<mir::scene::Surface>>(m_windowInfo.window); |
414 | 402 | auto renderables = window->generate_renderables(userId); | ||
415 | 402 | 403 | ||
416 | 403 | if (renderables.size() > 0 && | 404 | if (renderables.size() > 0 && |
418 | 404 | (m_surface->buffers_ready_for_compositor(userId) > 0 || !texture->hasBuffer()) | 405 | (window->buffers_ready_for_compositor(userId) > 0 || !texture->hasBuffer()) |
419 | 405 | ) { | 406 | ) { |
420 | 406 | // Avoid holding two buffers for the compositor at the same time. Thus free the current | 407 | // Avoid holding two buffers for the compositor at the same time. Thus free the current |
421 | 407 | // before acquiring the next | 408 | // before acquiring the next |
422 | @@ -409,7 +410,7 @@ | |||
423 | 409 | texture->setBuffer(renderables[0]->buffer()); | 410 | texture->setBuffer(renderables[0]->buffer()); |
424 | 410 | ++m_currentFrameNumber; | 411 | ++m_currentFrameNumber; |
425 | 411 | 412 | ||
427 | 412 | if (texture->textureSize() != m_size) { | 413 | if (texture->textureSize() != size()) { |
428 | 413 | m_size = texture->textureSize(); | 414 | m_size = texture->textureSize(); |
429 | 414 | QMetaObject::invokeMethod(this, "emitSizeChanged", Qt::QueuedConnection); | 415 | QMetaObject::invokeMethod(this, "emitSizeChanged", Qt::QueuedConnection); |
430 | 415 | } | 416 | } |
431 | @@ -417,7 +418,7 @@ | |||
432 | 417 | m_textureUpdated = true; | 418 | m_textureUpdated = true; |
433 | 418 | } | 419 | } |
434 | 419 | 420 | ||
436 | 420 | if (m_surface->buffers_ready_for_compositor(userId) > 0) { | 421 | if (window->buffers_ready_for_compositor(userId) > 0) { |
437 | 421 | // restart the frame dropper to give MirSurfaceItems enough time to render the next frame. | 422 | // restart the frame dropper to give MirSurfaceItems enough time to render the next frame. |
438 | 422 | // queued since the timer lives in a different thread | 423 | // queued since the timer lives in a different thread |
439 | 423 | QMetaObject::invokeMethod(&m_frameDropperTimer, "start", Qt::QueuedConnection); | 424 | QMetaObject::invokeMethod(&m_frameDropperTimer, "start", Qt::QueuedConnection); |
440 | @@ -436,7 +437,8 @@ | |||
441 | 436 | { | 437 | { |
442 | 437 | QMutexLocker locker(&m_mutex); | 438 | QMutexLocker locker(&m_mutex); |
443 | 438 | const void* const userId = (void*)123; | 439 | const void* const userId = (void*)123; |
445 | 439 | return m_surface->buffers_ready_for_compositor(userId); | 440 | auto const &window = static_cast<std::shared_ptr<mir::scene::Surface>>(m_windowInfo.window); |
446 | 441 | return window->buffers_ready_for_compositor(userId); | ||
447 | 440 | } | 442 | } |
448 | 441 | 443 | ||
449 | 442 | void MirSurface::setFocused(bool value) | 444 | void MirSurface::setFocused(bool value) |
450 | @@ -479,10 +481,10 @@ | |||
451 | 479 | 481 | ||
452 | 480 | if (m_activelyFocusedViews.isEmpty()) { | 482 | if (m_activelyFocusedViews.isEmpty()) { |
453 | 481 | DEBUG_MSG << "() unfocused"; | 483 | DEBUG_MSG << "() unfocused"; |
455 | 482 | m_shell->set_surface_attribute(m_session->session(), m_surface, mir_surface_attrib_focus, mir_surface_unfocused); | 484 | m_controller->setActiveFocus(m_windowInfo.window, false); |
456 | 483 | } else { | 485 | } else { |
457 | 484 | DEBUG_MSG << "() focused"; | 486 | DEBUG_MSG << "() focused"; |
459 | 485 | m_shell->set_surface_attribute(m_session->session(), m_surface, mir_surface_attrib_focus, mir_surface_focused); | 487 | m_controller->setActiveFocus(m_windowInfo.window, true); |
460 | 486 | } | 488 | } |
461 | 487 | 489 | ||
462 | 488 | m_neverSetSurfaceFocus = false; | 490 | m_neverSetSurfaceFocus = false; |
463 | @@ -500,22 +502,21 @@ | |||
464 | 500 | Q_EMIT closeRequested(); | 502 | Q_EMIT closeRequested(); |
465 | 501 | m_closeTimer->start(); | 503 | m_closeTimer->start(); |
466 | 502 | 504 | ||
469 | 503 | if (m_surface) { | 505 | if (m_windowInfo.window) { |
470 | 504 | m_surface->request_client_surface_close(); | 506 | auto const &window = static_cast<std::shared_ptr<mir::scene::Surface>>(m_windowInfo.window); |
471 | 507 | window->request_client_surface_close(); | ||
472 | 505 | } | 508 | } |
473 | 506 | } | 509 | } |
474 | 507 | 510 | ||
475 | 508 | void MirSurface::resize(int width, int height) | 511 | void MirSurface::resize(int width, int height) |
476 | 509 | { | 512 | { |
479 | 510 | int mirWidth = m_surface->size().width.as_int(); | 513 | auto const &window = m_windowInfo.window; |
478 | 511 | int mirHeight = m_surface->size().height.as_int(); | ||
480 | 512 | 514 | ||
482 | 513 | bool mirSizeIsDifferent = width != mirWidth || height != mirHeight; | 515 | bool mirSizeIsDifferent = width != m_size.width() || height != m_size.height(); |
483 | 514 | 516 | ||
484 | 515 | if (clientIsRunning() && mirSizeIsDifferent) { | 517 | if (clientIsRunning() && mirSizeIsDifferent) { |
488 | 516 | mir::geometry::Size newMirSize(width, height); | 518 | m_controller->resize(window, QSize(width, height)); |
489 | 517 | m_surface->resize(newMirSize); | 519 | DEBUG_MSG << " old (" << m_size.width() << "," << m_size.height() << ")" |
487 | 518 | DEBUG_MSG << " old (" << mirWidth << "," << mirHeight << ")" | ||
490 | 519 | << ", new (" << width << "," << height << ")"; | 520 | << ", new (" << width << "," << height << ")"; |
491 | 520 | } | 521 | } |
492 | 521 | } | 522 | } |
493 | @@ -525,6 +526,27 @@ | |||
494 | 525 | return m_position; | 526 | return m_position; |
495 | 526 | } | 527 | } |
496 | 527 | 528 | ||
497 | 529 | void MirSurface::setPosition(const QPoint newPosition) | ||
498 | 530 | { | ||
499 | 531 | if (m_position != newPosition) { | ||
500 | 532 | m_position = newPosition; | ||
501 | 533 | Q_EMIT positionChanged(newPosition); | ||
502 | 534 | } | ||
503 | 535 | } | ||
504 | 536 | |||
505 | 537 | void MirSurface::requestPosition(const QPoint newPosition) | ||
506 | 538 | { | ||
507 | 539 | m_controller->move(m_windowInfo.window, newPosition); | ||
508 | 540 | } | ||
509 | 541 | |||
510 | 542 | void MirSurface::setSize(const QSize newSize) | ||
511 | 543 | { | ||
512 | 544 | if (m_size != newSize) { | ||
513 | 545 | m_size = newSize; | ||
514 | 546 | Q_EMIT sizeChanged(newSize); | ||
515 | 547 | } | ||
516 | 548 | } | ||
517 | 549 | |||
518 | 528 | QSize MirSurface::size() const | 550 | QSize MirSurface::size() const |
519 | 529 | { | 551 | { |
520 | 530 | return m_size; | 552 | return m_size; |
521 | @@ -532,7 +554,7 @@ | |||
522 | 532 | 554 | ||
523 | 533 | Mir::State MirSurface::state() const | 555 | Mir::State MirSurface::state() const |
524 | 534 | { | 556 | { |
526 | 535 | switch (m_surface->state()) { | 557 | switch (m_windowInfo.state) { |
527 | 536 | case mir_surface_state_unknown: | 558 | case mir_surface_state_unknown: |
528 | 537 | return Mir::UnknownState; | 559 | return Mir::UnknownState; |
529 | 538 | case mir_surface_state_restored: | 560 | case mir_surface_state_restored: |
530 | @@ -587,8 +609,9 @@ | |||
531 | 587 | return; | 609 | return; |
532 | 588 | } | 610 | } |
533 | 589 | 611 | ||
536 | 590 | if (m_surface) { | 612 | if (m_windowInfo.window) { |
537 | 591 | m_surface->set_orientation(mirOrientation); | 613 | auto const &window = static_cast<std::shared_ptr<mir::scene::Surface>>(m_windowInfo.window); |
538 | 614 | window->set_orientation(mirOrientation); | ||
539 | 592 | } | 615 | } |
540 | 593 | 616 | ||
541 | 594 | Q_EMIT orientationAngleChanged(angle); | 617 | Q_EMIT orientationAngleChanged(angle); |
542 | @@ -596,12 +619,15 @@ | |||
543 | 596 | 619 | ||
544 | 597 | QString MirSurface::name() const | 620 | QString MirSurface::name() const |
545 | 598 | { | 621 | { |
547 | 599 | return QString::fromStdString(m_surface->name()); | 622 | if (!m_windowInfo.name.is_set()) { |
548 | 623 | return QStringLiteral(); | ||
549 | 624 | } | ||
550 | 625 | return QString::fromStdString(m_windowInfo.name.value()); | ||
551 | 600 | } | 626 | } |
552 | 601 | 627 | ||
553 | 602 | void MirSurface::setState(Mir::State qmlState) | 628 | void MirSurface::setState(Mir::State qmlState) |
554 | 603 | { | 629 | { |
556 | 604 | int mirState; | 630 | MirSurfaceState mirState; |
557 | 605 | 631 | ||
558 | 606 | switch (qmlState) { | 632 | switch (qmlState) { |
559 | 607 | default: | 633 | default: |
560 | @@ -638,7 +664,7 @@ | |||
561 | 638 | break; | 664 | break; |
562 | 639 | } | 665 | } |
563 | 640 | 666 | ||
565 | 641 | m_shell->set_surface_attribute(m_session->session(), m_surface, mir_surface_attrib_state, mirState); | 667 | m_controller->setState(m_windowInfo.window, mirState); |
566 | 642 | } | 668 | } |
567 | 643 | 669 | ||
568 | 644 | void MirSurface::setLive(bool value) | 670 | void MirSurface::setLive(bool value) |
569 | @@ -660,69 +686,79 @@ | |||
570 | 660 | 686 | ||
571 | 661 | bool MirSurface::visible() const | 687 | bool MirSurface::visible() const |
572 | 662 | { | 688 | { |
574 | 663 | return m_surface->query(mir_surface_attrib_visibility) == mir_surface_visibility_exposed; | 689 | //return m_windowInfo->query(mir_surface_attrib_visibility) == mir_surface_visibility_exposed; |
575 | 690 | return true; //FIXME | ||
576 | 664 | } | 691 | } |
578 | 665 | 692 | #include <mir_toolkit/event.h> | |
579 | 666 | void MirSurface::mousePressEvent(QMouseEvent *event) | 693 | void MirSurface::mousePressEvent(QMouseEvent *event) |
580 | 667 | { | 694 | { |
581 | 668 | auto ev = makeMirEvent(event, mir_pointer_action_button_down); | 695 | auto ev = makeMirEvent(event, mir_pointer_action_button_down); |
583 | 669 | m_surface->consume(ev.get()); | 696 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
584 | 697 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | ||
585 | 670 | event->accept(); | 698 | event->accept(); |
586 | 671 | } | 699 | } |
587 | 672 | 700 | ||
588 | 673 | void MirSurface::mouseMoveEvent(QMouseEvent *event) | 701 | void MirSurface::mouseMoveEvent(QMouseEvent *event) |
589 | 674 | { | 702 | { |
590 | 675 | auto ev = makeMirEvent(event, mir_pointer_action_motion); | 703 | auto ev = makeMirEvent(event, mir_pointer_action_motion); |
592 | 676 | m_surface->consume(ev.get()); | 704 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
593 | 705 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | ||
594 | 677 | event->accept(); | 706 | event->accept(); |
595 | 678 | } | 707 | } |
596 | 679 | 708 | ||
597 | 680 | void MirSurface::mouseReleaseEvent(QMouseEvent *event) | 709 | void MirSurface::mouseReleaseEvent(QMouseEvent *event) |
598 | 681 | { | 710 | { |
599 | 682 | auto ev = makeMirEvent(event, mir_pointer_action_button_up); | 711 | auto ev = makeMirEvent(event, mir_pointer_action_button_up); |
601 | 683 | m_surface->consume(ev.get()); | 712 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
602 | 713 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | ||
603 | 684 | event->accept(); | 714 | event->accept(); |
604 | 685 | } | 715 | } |
605 | 686 | 716 | ||
606 | 687 | void MirSurface::hoverEnterEvent(QHoverEvent *event) | 717 | void MirSurface::hoverEnterEvent(QHoverEvent *event) |
607 | 688 | { | 718 | { |
608 | 689 | auto ev = makeMirEvent(event, mir_pointer_action_enter); | 719 | auto ev = makeMirEvent(event, mir_pointer_action_enter); |
610 | 690 | m_surface->consume(ev.get()); | 720 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
611 | 721 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | ||
612 | 691 | event->accept(); | 722 | event->accept(); |
613 | 692 | } | 723 | } |
614 | 693 | 724 | ||
615 | 694 | void MirSurface::hoverLeaveEvent(QHoverEvent *event) | 725 | void MirSurface::hoverLeaveEvent(QHoverEvent *event) |
616 | 695 | { | 726 | { |
617 | 696 | auto ev = makeMirEvent(event, mir_pointer_action_leave); | 727 | auto ev = makeMirEvent(event, mir_pointer_action_leave); |
619 | 697 | m_surface->consume(ev.get()); | 728 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
620 | 729 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | ||
621 | 698 | event->accept(); | 730 | event->accept(); |
622 | 699 | } | 731 | } |
623 | 700 | 732 | ||
624 | 701 | void MirSurface::hoverMoveEvent(QHoverEvent *event) | 733 | void MirSurface::hoverMoveEvent(QHoverEvent *event) |
625 | 702 | { | 734 | { |
626 | 703 | auto ev = makeMirEvent(event, mir_pointer_action_motion); | 735 | auto ev = makeMirEvent(event, mir_pointer_action_motion); |
628 | 704 | m_surface->consume(ev.get()); | 736 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
629 | 737 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | ||
630 | 705 | event->accept(); | 738 | event->accept(); |
631 | 706 | } | 739 | } |
632 | 707 | 740 | ||
633 | 708 | void MirSurface::wheelEvent(QWheelEvent *event) | 741 | void MirSurface::wheelEvent(QWheelEvent *event) |
634 | 709 | { | 742 | { |
635 | 710 | auto ev = makeMirEvent(event); | 743 | auto ev = makeMirEvent(event); |
637 | 711 | m_surface->consume(ev.get()); | 744 | auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
638 | 745 | m_controller->deliverPointerEvent(m_windowInfo.window, ev1); | ||
639 | 712 | event->accept(); | 746 | event->accept(); |
640 | 713 | } | 747 | } |
641 | 714 | 748 | ||
642 | 715 | void MirSurface::keyPressEvent(QKeyEvent *qtEvent) | 749 | void MirSurface::keyPressEvent(QKeyEvent *qtEvent) |
643 | 716 | { | 750 | { |
644 | 717 | auto ev = makeMirEvent(qtEvent); | 751 | auto ev = makeMirEvent(qtEvent); |
646 | 718 | m_surface->consume(ev.get()); | 752 | auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get()); |
647 | 753 | m_controller->deliverKeyboardEvent(m_windowInfo.window, ev1); | ||
648 | 719 | qtEvent->accept(); | 754 | qtEvent->accept(); |
649 | 720 | } | 755 | } |
650 | 721 | 756 | ||
651 | 722 | void MirSurface::keyReleaseEvent(QKeyEvent *qtEvent) | 757 | void MirSurface::keyReleaseEvent(QKeyEvent *qtEvent) |
652 | 723 | { | 758 | { |
653 | 724 | auto ev = makeMirEvent(qtEvent); | 759 | auto ev = makeMirEvent(qtEvent); |
655 | 725 | m_surface->consume(ev.get()); | 760 | auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get()); |
656 | 761 | m_controller->deliverKeyboardEvent(m_windowInfo.window, ev1); | ||
657 | 726 | qtEvent->accept(); | 762 | qtEvent->accept(); |
658 | 727 | } | 763 | } |
659 | 728 | 764 | ||
660 | @@ -732,7 +768,8 @@ | |||
661 | 732 | ulong timestamp) | 768 | ulong timestamp) |
662 | 733 | { | 769 | { |
663 | 734 | auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp); | 770 | auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp); |
665 | 735 | m_surface->consume(ev.get()); | 771 | auto ev1 = reinterpret_cast<MirTouchEvent const*>(ev.get()); |
666 | 772 | m_controller->deliverTouchEvent(m_windowInfo.window, ev1); | ||
667 | 736 | } | 773 | } |
668 | 737 | 774 | ||
669 | 738 | bool MirSurface::clientIsRunning() const | 775 | bool MirSurface::clientIsRunning() const |
670 | @@ -865,7 +902,9 @@ | |||
671 | 865 | return; | 902 | return; |
672 | 866 | } | 903 | } |
673 | 867 | 904 | ||
675 | 868 | m_surface->set_keymap(MirInputDeviceId(), "", layout.toStdString(), variant.toStdString(), ""); | 905 | auto const &window = static_cast<std::shared_ptr<mir::scene::Surface>>(m_windowInfo.window); |
676 | 906 | |||
677 | 907 | window->set_keymap(MirInputDeviceId(), "", layout.toStdString(), variant.toStdString(), ""); | ||
678 | 869 | } | 908 | } |
679 | 870 | 909 | ||
680 | 871 | QCursor MirSurface::cursor() const | 910 | QCursor MirSurface::cursor() const |
681 | @@ -905,6 +944,52 @@ | |||
682 | 905 | return result; | 944 | return result; |
683 | 906 | } | 945 | } |
684 | 907 | 946 | ||
685 | 947 | void MirSurface::updateWindowInfo(const WindowInfo &windowInfo) | ||
686 | 948 | { | ||
687 | 949 | qDebug() << "MirSurface::updateWindowInfo"; | ||
688 | 950 | // Need to compare the new windowInfo instance with the existing one to figure out what changed | ||
689 | 951 | DirtyStates dirt = DirtyState::Clean; | ||
690 | 952 | |||
691 | 953 | if (windowInfo.name != m_windowInfo.name) { | ||
692 | 954 | dirt &= DirtyState::Name; qDebug("Name changed"); | ||
693 | 955 | } | ||
694 | 956 | if (windowInfo.type != m_windowInfo.type) { | ||
695 | 957 | dirt &= DirtyState::Type; qDebug("Type changed"); | ||
696 | 958 | } | ||
697 | 959 | if (windowInfo.state != m_windowInfo.state) { | ||
698 | 960 | dirt &= DirtyState::State; qDebug("State changed"); | ||
699 | 961 | } | ||
700 | 962 | if (windowInfo.restoreRect != m_windowInfo.restoreRect) { | ||
701 | 963 | dirt &= DirtyState::RestoreRect; qDebug("RestoreRect changed"); | ||
702 | 964 | } | ||
703 | 965 | if (windowInfo.children != m_windowInfo.children) { | ||
704 | 966 | dirt &= DirtyState::Children; qDebug("Children changed"); | ||
705 | 967 | } | ||
706 | 968 | if (windowInfo.minWidth != m_windowInfo.minWidth | ||
707 | 969 | && windowInfo.minHeight != m_windowInfo.minHeight) { | ||
708 | 970 | dirt &= DirtyState::MinSize; qDebug("MinSize changed"); | ||
709 | 971 | } | ||
710 | 972 | if (windowInfo.maxWidth != m_windowInfo.maxWidth | ||
711 | 973 | && windowInfo.maxHeight != m_windowInfo.maxHeight) { | ||
712 | 974 | dirt &= DirtyState::MaxSize; qDebug("MaxHeight changed"); | ||
713 | 975 | } | ||
714 | 976 | |||
715 | 977 | if (dirt | DirtyState::Clean) { | ||
716 | 978 | return; | ||
717 | 979 | } | ||
718 | 980 | m_windowInfo = windowInfo; | ||
719 | 981 | |||
720 | 982 | if (dirt | DirtyState::Name) { | ||
721 | 983 | Q_EMIT nameChanged(name()); | ||
722 | 984 | } | ||
723 | 985 | if (dirt | DirtyState::Type) { | ||
724 | 986 | Q_EMIT typeChanged(type()); | ||
725 | 987 | } | ||
726 | 988 | if (dirt | DirtyState::State) { | ||
727 | 989 | Q_EMIT stateChanged(state()); | ||
728 | 990 | } | ||
729 | 991 | } | ||
730 | 992 | |||
731 | 908 | void MirSurface::setCursor(const QCursor &cursor) | 993 | void MirSurface::setCursor(const QCursor &cursor) |
732 | 909 | { | 994 | { |
733 | 910 | DEBUG_MSG << "(" << qtCursorShapeToStr(cursor.shape()) << ")"; | 995 | DEBUG_MSG << "(" << qtCursorShapeToStr(cursor.shape()) << ")"; |
734 | @@ -915,80 +1000,32 @@ | |||
735 | 915 | 1000 | ||
736 | 916 | int MirSurface::minimumWidth() const | 1001 | int MirSurface::minimumWidth() const |
737 | 917 | { | 1002 | { |
739 | 918 | return m_minimumWidth; | 1003 | return m_windowInfo.minWidth.as_int(); |
740 | 919 | } | 1004 | } |
741 | 920 | 1005 | ||
742 | 921 | int MirSurface::minimumHeight() const | 1006 | int MirSurface::minimumHeight() const |
743 | 922 | { | 1007 | { |
745 | 923 | return m_minimumHeight; | 1008 | return m_windowInfo.minHeight.as_int(); |
746 | 924 | } | 1009 | } |
747 | 925 | 1010 | ||
748 | 926 | int MirSurface::maximumWidth() const | 1011 | int MirSurface::maximumWidth() const |
749 | 927 | { | 1012 | { |
751 | 928 | return m_maximumWidth; | 1013 | return m_windowInfo.maxWidth.as_int(); |
752 | 929 | } | 1014 | } |
753 | 930 | 1015 | ||
754 | 931 | int MirSurface::maximumHeight() const | 1016 | int MirSurface::maximumHeight() const |
755 | 932 | { | 1017 | { |
757 | 933 | return m_maximumHeight; | 1018 | return m_windowInfo.maxHeight.as_int(); |
758 | 934 | } | 1019 | } |
759 | 935 | 1020 | ||
760 | 936 | int MirSurface::widthIncrement() const | 1021 | int MirSurface::widthIncrement() const |
761 | 937 | { | 1022 | { |
763 | 938 | return m_widthIncrement; | 1023 | return 0; //TODO |
764 | 939 | } | 1024 | } |
765 | 940 | 1025 | ||
766 | 941 | int MirSurface::heightIncrement() const | 1026 | int MirSurface::heightIncrement() const |
767 | 942 | { | 1027 | { |
817 | 943 | return m_heightIncrement; | 1028 | return 0; //TODO |
769 | 944 | } | ||
770 | 945 | |||
771 | 946 | void MirSurface::setMinimumWidth(int value) | ||
772 | 947 | { | ||
773 | 948 | if (value != m_minimumWidth) { | ||
774 | 949 | m_minimumWidth = value; | ||
775 | 950 | Q_EMIT minimumWidthChanged(value); | ||
776 | 951 | } | ||
777 | 952 | } | ||
778 | 953 | |||
779 | 954 | void MirSurface::setMinimumHeight(int value) | ||
780 | 955 | { | ||
781 | 956 | if (value != m_minimumHeight) { | ||
782 | 957 | m_minimumHeight = value; | ||
783 | 958 | Q_EMIT minimumHeightChanged(value); | ||
784 | 959 | } | ||
785 | 960 | } | ||
786 | 961 | |||
787 | 962 | void MirSurface::setMaximumWidth(int value) | ||
788 | 963 | { | ||
789 | 964 | if (value != m_maximumWidth) { | ||
790 | 965 | m_maximumWidth = value; | ||
791 | 966 | Q_EMIT maximumWidthChanged(value); | ||
792 | 967 | } | ||
793 | 968 | } | ||
794 | 969 | |||
795 | 970 | void MirSurface::setMaximumHeight(int value) | ||
796 | 971 | { | ||
797 | 972 | if (value != m_maximumHeight) { | ||
798 | 973 | m_maximumHeight = value; | ||
799 | 974 | Q_EMIT maximumHeightChanged(value); | ||
800 | 975 | } | ||
801 | 976 | } | ||
802 | 977 | |||
803 | 978 | void MirSurface::setWidthIncrement(int value) | ||
804 | 979 | { | ||
805 | 980 | if (value != m_widthIncrement) { | ||
806 | 981 | m_widthIncrement = value; | ||
807 | 982 | Q_EMIT widthIncrementChanged(value); | ||
808 | 983 | } | ||
809 | 984 | } | ||
810 | 985 | |||
811 | 986 | void MirSurface::setHeightIncrement(int value) | ||
812 | 987 | { | ||
813 | 988 | if (value != m_heightIncrement) { | ||
814 | 989 | m_heightIncrement = value; | ||
815 | 990 | Q_EMIT heightIncrementChanged(value); | ||
816 | 991 | } | ||
818 | 992 | } | 1029 | } |
819 | 993 | 1030 | ||
820 | 994 | bool MirSurface::focused() const | 1031 | bool MirSurface::focused() const |
821 | @@ -1021,16 +1058,7 @@ | |||
822 | 1021 | 1058 | ||
823 | 1022 | m_closingState = CloseOverdue; | 1059 | m_closingState = CloseOverdue; |
824 | 1023 | 1060 | ||
835 | 1024 | m_session->session()->destroy_surface(m_surface); | 1061 | //m_session->session()->destroy_surface(m_windowInfo); TODO use WindowManagerTools::ask_client_to_close(window) |
826 | 1025 | } | ||
827 | 1026 | |||
828 | 1027 | void MirSurface::setPosition(const QPoint newPosition) | ||
829 | 1028 | { | ||
830 | 1029 | if (m_position == newPosition) { | ||
831 | 1030 | return; | ||
832 | 1031 | } | ||
833 | 1032 | m_position = newPosition; | ||
834 | 1033 | Q_EMIT positionChanged(m_position); | ||
836 | 1034 | } | 1062 | } |
837 | 1035 | 1063 | ||
838 | 1036 | void MirSurface::setCloseTimer(AbstractTimer *timer) | 1064 | void MirSurface::setCloseTimer(AbstractTimer *timer) |
839 | 1037 | 1065 | ||
840 | === modified file 'miral-qt/src/modules/Unity/Application/mirsurface.h' | |||
841 | --- miral-qt/src/modules/Unity/Application/mirsurface.h 2016-07-27 12:05:20 +0000 | |||
842 | +++ miral-qt/src/modules/Unity/Application/mirsurface.h 2016-08-12 12:04:26 +0000 | |||
843 | @@ -31,17 +31,11 @@ | |||
844 | 31 | 31 | ||
845 | 32 | #include "mirbuffersgtexture.h" | 32 | #include "mirbuffersgtexture.h" |
846 | 33 | #include "session.h" | 33 | #include "session.h" |
851 | 34 | 34 | #include "windowcontrollerinterface.h" | |
852 | 35 | // mirserver | 35 | #include "windowmodelinterface.h" |
849 | 36 | #include "creationhints.h" | ||
850 | 37 | |||
853 | 38 | // mir | 36 | // mir |
854 | 39 | #include <mir_toolkit/common.h> | 37 | #include <mir_toolkit/common.h> |
855 | 40 | 38 | ||
856 | 41 | namespace mir { | ||
857 | 42 | namespace shell { class Shell; } | ||
858 | 43 | namespace scene {class Surface; } | ||
859 | 44 | } | ||
860 | 45 | 39 | ||
861 | 46 | class SurfaceObserver; | 40 | class SurfaceObserver; |
862 | 47 | 41 | ||
863 | @@ -54,11 +48,9 @@ | |||
864 | 54 | Q_OBJECT | 48 | Q_OBJECT |
865 | 55 | 49 | ||
866 | 56 | public: | 50 | public: |
872 | 57 | MirSurface(std::shared_ptr<mir::scene::Surface> surface, | 51 | MirSurface(WindowInfo windowInfo, |
873 | 58 | SessionInterface* session, | 52 | WindowControllerInterface *controller, |
874 | 59 | mir::shell::Shell *shell, | 53 | std::shared_ptr<SurfaceObserver> observer); |
870 | 60 | std::shared_ptr<SurfaceObserver> observer, | ||
871 | 61 | const CreationHints &); | ||
875 | 62 | virtual ~MirSurface(); | 54 | virtual ~MirSurface(); |
876 | 63 | 55 | ||
877 | 64 | //// | 56 | //// |
878 | @@ -70,10 +62,10 @@ | |||
879 | 70 | 62 | ||
880 | 71 | QSize size() const override; | 63 | QSize size() const override; |
881 | 72 | void resize(int width, int height) override; | 64 | void resize(int width, int height) override; |
883 | 73 | void resize(const QSize &size) override { resize(size.width(), size.height()); } | 65 | Q_INVOKABLE void resize(const QSize &size) override { resize(size.width(), size.height()); } |
884 | 74 | 66 | ||
885 | 75 | QPoint position() const override; | 67 | QPoint position() const override; |
887 | 76 | void setPosition(const QPoint newPosition) override; | 68 | Q_INVOKABLE void requestPosition(const QPoint newPosition) override; |
888 | 77 | 69 | ||
889 | 78 | Mir::State state() const override; | 70 | Mir::State state() const override; |
890 | 79 | void setState(Mir::State qmlState) override; | 71 | void setState(Mir::State qmlState) override; |
891 | @@ -159,6 +151,9 @@ | |||
892 | 159 | 151 | ||
893 | 160 | //// | 152 | //// |
894 | 161 | // Own API | 153 | // Own API |
895 | 154 | void setPosition(const QPoint newPosition); | ||
896 | 155 | void setSize(const QSize newSize); | ||
897 | 156 | void updateWindowInfo(const WindowInfo &windowInfo); | ||
898 | 162 | 157 | ||
899 | 163 | // useful for tests | 158 | // useful for tests |
900 | 164 | void setCloseTimer(AbstractTimer *timer); | 159 | void setCloseTimer(AbstractTimer *timer); |
901 | @@ -166,12 +161,6 @@ | |||
902 | 166 | public Q_SLOTS: | 161 | public Q_SLOTS: |
903 | 167 | void onCompositorSwappedBuffers() override; | 162 | void onCompositorSwappedBuffers() override; |
904 | 168 | 163 | ||
905 | 169 | void setMinimumWidth(int) override; | ||
906 | 170 | void setMinimumHeight(int) override; | ||
907 | 171 | void setMaximumWidth(int) override; | ||
908 | 172 | void setMaximumHeight(int) override; | ||
909 | 173 | void setWidthIncrement(int) override; | ||
910 | 174 | void setHeightIncrement(int) override; | ||
911 | 175 | void setShellChrome(Mir::ShellChrome shellChrome) override; | 164 | void setShellChrome(Mir::ShellChrome shellChrome) override; |
912 | 176 | 165 | ||
913 | 177 | private Q_SLOTS: | 166 | private Q_SLOTS: |
914 | @@ -191,9 +180,9 @@ | |||
915 | 191 | void applyKeymap(); | 180 | void applyKeymap(); |
916 | 192 | void updateActiveFocus(); | 181 | void updateActiveFocus(); |
917 | 193 | 182 | ||
919 | 194 | std::shared_ptr<mir::scene::Surface> m_surface; | 183 | WindowInfo m_windowInfo; |
920 | 195 | QPointer<SessionInterface> m_session; | 184 | QPointer<SessionInterface> m_session; |
922 | 196 | mir::shell::Shell *const m_shell; | 185 | WindowControllerInterface *const m_controller; |
923 | 197 | bool m_firstFrameDrawn; | 186 | bool m_firstFrameDrawn; |
924 | 198 | 187 | ||
925 | 199 | //FIXME - have to save the state as Mir has no getter for it (bug:1357429) | 188 | //FIXME - have to save the state as Mir has no getter for it (bug:1357429) |
926 | @@ -226,13 +215,6 @@ | |||
927 | 226 | QCursor m_cursor; | 215 | QCursor m_cursor; |
928 | 227 | Mir::ShellChrome m_shellChrome; | 216 | Mir::ShellChrome m_shellChrome; |
929 | 228 | 217 | ||
930 | 229 | int m_minimumWidth{0}; | ||
931 | 230 | int m_minimumHeight{0}; | ||
932 | 231 | int m_maximumWidth{0}; | ||
933 | 232 | int m_maximumHeight{0}; | ||
934 | 233 | int m_widthIncrement{0}; | ||
935 | 234 | int m_heightIncrement{0}; | ||
936 | 235 | |||
937 | 236 | QRect m_inputBounds; | 218 | QRect m_inputBounds; |
938 | 237 | 219 | ||
939 | 238 | bool m_focused{false}; | 220 | bool m_focused{false}; |
940 | 239 | 221 | ||
941 | === modified file 'miral-qt/src/modules/Unity/Application/mirsurfaceinterface.h' | |||
942 | --- miral-qt/src/modules/Unity/Application/mirsurfaceinterface.h 2016-07-27 12:05:20 +0000 | |||
943 | +++ miral-qt/src/modules/Unity/Application/mirsurfaceinterface.h 2016-08-12 12:04:26 +0000 | |||
944 | @@ -49,7 +49,7 @@ | |||
945 | 49 | virtual ~MirSurfaceInterface() {} | 49 | virtual ~MirSurfaceInterface() {} |
946 | 50 | 50 | ||
947 | 51 | virtual QPoint position() const = 0; | 51 | virtual QPoint position() const = 0; |
949 | 52 | virtual void setPosition(const QPoint newPosition) = 0; | 52 | virtual void requestPosition(const QPoint newPosition) = 0; |
950 | 53 | 53 | ||
951 | 54 | virtual void setLive(bool value) = 0; | 54 | virtual void setLive(bool value) = 0; |
952 | 55 | 55 | ||
953 | @@ -118,12 +118,6 @@ | |||
954 | 118 | public Q_SLOTS: | 118 | public Q_SLOTS: |
955 | 119 | virtual void onCompositorSwappedBuffers() = 0; | 119 | virtual void onCompositorSwappedBuffers() = 0; |
956 | 120 | 120 | ||
957 | 121 | virtual void setMinimumWidth(int) = 0; | ||
958 | 122 | virtual void setMinimumHeight(int) = 0; | ||
959 | 123 | virtual void setMaximumWidth(int) = 0; | ||
960 | 124 | virtual void setMaximumHeight(int) = 0; | ||
961 | 125 | virtual void setWidthIncrement(int) = 0; | ||
962 | 126 | virtual void setHeightIncrement(int) = 0; | ||
963 | 127 | virtual void setShellChrome(Mir::ShellChrome shellChrome) = 0; | 121 | virtual void setShellChrome(Mir::ShellChrome shellChrome) = 0; |
964 | 128 | 122 | ||
965 | 129 | Q_SIGNALS: | 123 | Q_SIGNALS: |
966 | 130 | 124 | ||
967 | === modified file 'miral-qt/src/modules/Unity/Application/mirsurfacemanager.cpp' | |||
968 | --- miral-qt/src/modules/Unity/Application/mirsurfacemanager.cpp 2016-06-01 22:06:51 +0000 | |||
969 | +++ miral-qt/src/modules/Unity/Application/mirsurfacemanager.cpp 2016-08-12 12:04:26 +0000 | |||
970 | @@ -97,45 +97,45 @@ | |||
971 | 97 | 97 | ||
972 | 98 | void MirSurfaceManager::onSessionCreatedSurface(const mir::scene::Session *mirSession, | 98 | void MirSurfaceManager::onSessionCreatedSurface(const mir::scene::Session *mirSession, |
973 | 99 | const std::shared_ptr<mir::scene::Surface> &surface, | 99 | const std::shared_ptr<mir::scene::Surface> &surface, |
975 | 100 | const std::shared_ptr<SurfaceObserver> &observer, | 100 | const std::shared_ptr<SurfaceObserver> &/*observer*/, |
976 | 101 | qtmir::CreationHints creationHints) | 101 | qtmir::CreationHints creationHints) |
977 | 102 | { | 102 | { |
978 | 103 | qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSessionCreatedSurface - mirSession=" << mirSession | 103 | qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSessionCreatedSurface - mirSession=" << mirSession |
979 | 104 | << "surface=" << surface.get() << "surface.name=" << surface->name().c_str() | 104 | << "surface=" << surface.get() << "surface.name=" << surface->name().c_str() |
980 | 105 | << "creationHints=" << creationHints.toString(); | 105 | << "creationHints=" << creationHints.toString(); |
981 | 106 | 106 | ||
1014 | 107 | SessionInterface* session = m_sessionManager->findSession(mirSession); | 107 | // SessionInterface* session = m_sessionManager->findSession(mirSession); |
1015 | 108 | auto qmlSurface = new MirSurface(surface, session, m_shell, observer, creationHints); | 108 | // auto qmlSurface = new MirSurface(surface, session, m_shell, observer, creationHints); |
1016 | 109 | { | 109 | // { |
1017 | 110 | QMutexLocker lock(&m_mutex); | 110 | // QMutexLocker lock(&m_mutex); |
1018 | 111 | m_mirSurfaceToQmlSurfaceHash.insert(surface.get(), qmlSurface); | 111 | // m_mirSurfaceToQmlSurfaceHash.insert(surface.get(), qmlSurface); |
1019 | 112 | } | 112 | // } |
1020 | 113 | 113 | ||
1021 | 114 | if (session) | 114 | // if (session) |
1022 | 115 | session->registerSurface(qmlSurface); | 115 | // session->registerSurface(qmlSurface); |
1023 | 116 | 116 | ||
1024 | 117 | if (qmlSurface->type() == Mir::InputMethodType) { | 117 | // if (qmlSurface->type() == Mir::InputMethodType) { |
1025 | 118 | m_inputMethodSurface = qmlSurface; | 118 | // m_inputMethodSurface = qmlSurface; |
1026 | 119 | Q_EMIT inputMethodSurfaceChanged(); | 119 | // Q_EMIT inputMethodSurfaceChanged(); |
1027 | 120 | } | 120 | // } |
1028 | 121 | 121 | ||
1029 | 122 | // Only notify QML of surface creation once it has drawn its first frame. | 122 | // // Only notify QML of surface creation once it has drawn its first frame. |
1030 | 123 | connect(qmlSurface, &MirSurfaceInterface::firstFrameDrawn, this, [=]() { | 123 | // connect(qmlSurface, &MirSurfaceInterface::firstFrameDrawn, this, [=]() { |
1031 | 124 | tracepoint(qtmir, firstFrameDrawn); | 124 | // tracepoint(qtmir, firstFrameDrawn); |
1032 | 125 | Q_EMIT surfaceCreated(qmlSurface); | 125 | // Q_EMIT surfaceCreated(qmlSurface); |
1033 | 126 | }); | 126 | // }); |
1034 | 127 | 127 | ||
1035 | 128 | // clean up after MirSurface is destroyed | 128 | // // clean up after MirSurface is destroyed |
1036 | 129 | connect(qmlSurface, &QObject::destroyed, this, [&](QObject *obj) { | 129 | // connect(qmlSurface, &QObject::destroyed, this, [&](QObject *obj) { |
1037 | 130 | auto qmlSurface = static_cast<MirSurfaceInterface*>(obj); | 130 | // auto qmlSurface = static_cast<MirSurfaceInterface*>(obj); |
1038 | 131 | { | 131 | // { |
1039 | 132 | QMutexLocker lock(&m_mutex); | 132 | // QMutexLocker lock(&m_mutex); |
1040 | 133 | m_mirSurfaceToQmlSurfaceHash.remove(m_mirSurfaceToQmlSurfaceHash.key(qmlSurface)); | 133 | // m_mirSurfaceToQmlSurfaceHash.remove(m_mirSurfaceToQmlSurfaceHash.key(qmlSurface)); |
1041 | 134 | } | 134 | // } |
1042 | 135 | 135 | ||
1043 | 136 | tracepoint(qtmir, surfaceDestroyed); | 136 | // tracepoint(qtmir, surfaceDestroyed); |
1044 | 137 | }); | 137 | // }); |
1045 | 138 | tracepoint(qtmir, surfaceCreated); | 138 | // tracepoint(qtmir, surfaceCreated); |
1046 | 139 | } | 139 | } |
1047 | 140 | 140 | ||
1048 | 141 | void MirSurfaceManager::onSessionDestroyingSurface(const mir::scene::Session *session, | 141 | void MirSurfaceManager::onSessionDestroyingSurface(const mir::scene::Session *session, |
1049 | @@ -144,27 +144,27 @@ | |||
1050 | 144 | qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSessionDestroyingSurface - session=" << session | 144 | qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSessionDestroyingSurface - session=" << session |
1051 | 145 | << "surface=" << surface.get() << "surface.name=" << surface->name().c_str(); | 145 | << "surface=" << surface.get() << "surface.name=" << surface->name().c_str(); |
1052 | 146 | 146 | ||
1074 | 147 | MirSurfaceInterface* qmlSurface = nullptr; | 147 | // MirSurfaceInterface* qmlSurface = nullptr; |
1075 | 148 | { | 148 | // { |
1076 | 149 | QMutexLocker lock(&m_mutex); | 149 | // QMutexLocker lock(&m_mutex); |
1077 | 150 | auto it = m_mirSurfaceToQmlSurfaceHash.find(surface.get()); | 150 | // auto it = m_mirSurfaceToQmlSurfaceHash.find(surface.get()); |
1078 | 151 | if (it != m_mirSurfaceToQmlSurfaceHash.end()) { | 151 | // if (it != m_mirSurfaceToQmlSurfaceHash.end()) { |
1079 | 152 | qmlSurface = it.value(); | 152 | // qmlSurface = it.value(); |
1080 | 153 | m_mirSurfaceToQmlSurfaceHash.erase(it); | 153 | // m_mirSurfaceToQmlSurfaceHash.erase(it); |
1081 | 154 | } else { | 154 | // } else { |
1082 | 155 | qCritical() << "MirSurfaceManager::onSessionDestroyingSurface: unable to find MirSurface corresponding" | 155 | // qCritical() << "MirSurfaceManager::onSessionDestroyingSurface: unable to find MirSurface corresponding" |
1083 | 156 | << "to surface=" << surface.get() << "surface.name=" << surface->name().c_str(); | 156 | // << "to surface=" << surface.get() << "surface.name=" << surface->name().c_str(); |
1084 | 157 | return; | 157 | // return; |
1085 | 158 | } | 158 | // } |
1086 | 159 | } | 159 | // } |
1087 | 160 | 160 | ||
1088 | 161 | if (qmlSurface->type() == Mir::InputMethodType) { | 161 | // if (qmlSurface->type() == Mir::InputMethodType) { |
1089 | 162 | m_inputMethodSurface = nullptr; | 162 | // m_inputMethodSurface = nullptr; |
1090 | 163 | Q_EMIT inputMethodSurfaceChanged(); | 163 | // Q_EMIT inputMethodSurfaceChanged(); |
1091 | 164 | } | 164 | // } |
1092 | 165 | 165 | ||
1093 | 166 | qmlSurface->setLive(false); | 166 | // qmlSurface->setLive(false); |
1094 | 167 | Q_EMIT surfaceDestroyed(qmlSurface); | 167 | // Q_EMIT surfaceDestroyed(qmlSurface); |
1095 | 168 | } | 168 | } |
1096 | 169 | 169 | ||
1097 | 170 | MirSurfaceInterface* MirSurfaceManager::inputMethodSurface() const | 170 | MirSurfaceInterface* MirSurfaceManager::inputMethodSurface() const |
1098 | 171 | 171 | ||
1099 | === modified file 'miral-qt/src/modules/Unity/Application/windowmodel.cpp' | |||
1100 | --- miral-qt/src/modules/Unity/Application/windowmodel.cpp 2016-07-27 12:05:20 +0000 | |||
1101 | +++ miral-qt/src/modules/Unity/Application/windowmodel.cpp 2016-08-12 12:04:26 +0000 | |||
1102 | @@ -31,8 +31,8 @@ | |||
1103 | 31 | using namespace qtmir; | 31 | using namespace qtmir; |
1104 | 32 | 32 | ||
1105 | 33 | WindowModel::WindowModel() | 33 | WindowModel::WindowModel() |
1106 | 34 | : m_focusedWindow(nullptr) | ||
1107 | 34 | { | 35 | { |
1108 | 35 | |||
1109 | 36 | auto nativeInterface = dynamic_cast<NativeInterface*>(QGuiApplication::platformNativeInterface()); | 36 | auto nativeInterface = dynamic_cast<NativeInterface*>(QGuiApplication::platformNativeInterface()); |
1110 | 37 | 37 | ||
1111 | 38 | if (!nativeInterface) { | 38 | if (!nativeInterface) { |
1112 | @@ -40,10 +40,14 @@ | |||
1113 | 40 | } | 40 | } |
1114 | 41 | 41 | ||
1115 | 42 | auto windowModel = static_cast<WindowModelInterface*>(nativeInterface->nativeResourceForIntegration("WindowModel")); | 42 | auto windowModel = static_cast<WindowModelInterface*>(nativeInterface->nativeResourceForIntegration("WindowModel")); |
1116 | 43 | m_windowController = static_cast<WindowControllerInterface*>(nativeInterface->nativeResourceForIntegration("WindowController")); | ||
1117 | 43 | 44 | ||
1121 | 44 | connect(windowModel, &WindowModelInterface::windowAdded, this, &WindowModel::onWindowAdded); | 45 | connect(windowModel, &WindowModelInterface::windowAdded, this, &WindowModel::onWindowAdded); |
1122 | 45 | connect(windowModel, &WindowModelInterface::windowRemoved, this, &WindowModel::onWindowRemoved); | 46 | connect(windowModel, &WindowModelInterface::windowRemoved, this, &WindowModel::onWindowRemoved); |
1123 | 46 | connect(windowModel, &WindowModelInterface::windowChanged, this, &WindowModel::onWindowChanged); | 47 | connect(windowModel, &WindowModelInterface::windowMoved, this, &WindowModel::onWindowMoved); |
1124 | 48 | connect(windowModel, &WindowModelInterface::windowResized, this, &WindowModel::onWindowResized); | ||
1125 | 49 | connect(windowModel, &WindowModelInterface::windowFocused, this, &WindowModel::onWindowFocused); | ||
1126 | 50 | connect(windowModel, &WindowModelInterface::windowInfoChanged, this, &WindowModel::onWindowInfoChanged); | ||
1127 | 47 | } | 51 | } |
1128 | 48 | 52 | ||
1129 | 49 | QHash<int, QByteArray> WindowModel::roleNames() const | 53 | QHash<int, QByteArray> WindowModel::roleNames() const |
1130 | @@ -53,17 +57,18 @@ | |||
1131 | 53 | return roleNames; | 57 | return roleNames; |
1132 | 54 | } | 58 | } |
1133 | 55 | 59 | ||
1135 | 56 | void WindowModel::onWindowAdded(const NumberedWindow window) | 60 | void WindowModel::onWindowAdded(const WindowInfo windowInfo, const unsigned int index) |
1136 | 57 | { | 61 | { |
1138 | 58 | qDebug() << "Window Added!" << window.index; | 62 | qDebug() << "Window Added!" << index; |
1139 | 59 | std::shared_ptr<SurfaceObserver> surfaceObserver = std::make_shared<SurfaceObserver>(); | 63 | std::shared_ptr<SurfaceObserver> surfaceObserver = std::make_shared<SurfaceObserver>(); |
1141 | 60 | const auto &surface = window.windowInfo.surface; | 64 | |
1142 | 65 | const auto &surface = static_cast<std::shared_ptr<mir::scene::Surface>>(windowInfo.window); | ||
1143 | 61 | SurfaceObserver::registerObserverForSurface(surfaceObserver.get(), surface.get()); | 66 | SurfaceObserver::registerObserverForSurface(surfaceObserver.get(), surface.get()); |
1144 | 62 | surface->add_observer(surfaceObserver); | 67 | surface->add_observer(surfaceObserver); |
1145 | 63 | 68 | ||
1149 | 64 | auto mirSurface = new MirSurface(surface, nullptr, nullptr, surfaceObserver, CreationHints()); | 69 | auto mirSurface = new MirSurface(windowInfo, m_windowController, surfaceObserver); |
1150 | 65 | beginInsertRows(QModelIndex(), window.index, window.index); | 70 | beginInsertRows(QModelIndex(), index, index); |
1151 | 66 | m_windowModel.insert(window.index, mirSurface); | 71 | m_windowModel.insert(index, mirSurface); |
1152 | 67 | endInsertRows(); | 72 | endInsertRows(); |
1153 | 68 | Q_EMIT countChanged(); | 73 | Q_EMIT countChanged(); |
1154 | 69 | } | 74 | } |
1155 | @@ -77,25 +82,34 @@ | |||
1156 | 77 | Q_EMIT countChanged(); | 82 | Q_EMIT countChanged(); |
1157 | 78 | } | 83 | } |
1158 | 79 | 84 | ||
1178 | 80 | void WindowModel::onWindowChanged(const DirtiedWindow window) | 85 | void WindowModel::onWindowMoved(const QPoint topLeft, const unsigned int index) |
1179 | 81 | { | 86 | { |
1180 | 82 | qDebug() << "Window Change!" << window.index; | 87 | auto mirSurface = static_cast<MirSurface *>(m_windowModel.value(index)); |
1181 | 83 | auto mirSurface = m_windowModel.value(window.index); | 88 | mirSurface->setPosition(topLeft); |
1182 | 84 | 89 | } | |
1183 | 85 | switch(window.dirtyWindowInfo) { | 90 | |
1184 | 86 | case WindowInfo::DirtyStates::Size: { | 91 | void WindowModel::onWindowResized(const QSize size, const unsigned int index) |
1185 | 87 | qDebug() << "size"; | 92 | { |
1186 | 88 | // Do nothing yet, it gets new size from swapped buffer for now | 93 | auto mirSurface = static_cast<MirSurface *>(m_windowModel.value(index)); |
1187 | 89 | } | 94 | mirSurface->setSize(size); |
1188 | 90 | case WindowInfo::DirtyStates::Position: | 95 | } |
1189 | 91 | qDebug() << "position"; | 96 | |
1190 | 92 | mirSurface->setPosition(window.windowInfo.position); | 97 | void WindowModel::onWindowFocused(const unsigned int index) |
1191 | 93 | case WindowInfo::DirtyStates::Focus: | 98 | { |
1192 | 94 | qDebug() << "focus"; | 99 | auto mirSurface = static_cast<MirSurface *>(m_windowModel.value(index)); |
1193 | 95 | mirSurface->setFocused(window.windowInfo.focused); | 100 | if (m_focusedWindow && m_focusedWindow != mirSurface) { |
1194 | 96 | } | 101 | m_focusedWindow->setFocused(false); |
1195 | 97 | 102 | } | |
1196 | 98 | QModelIndex row = index(window.index); | 103 | mirSurface->setFocused(true); |
1197 | 104 | m_focusedWindow = mirSurface; | ||
1198 | 105 | } | ||
1199 | 106 | |||
1200 | 107 | void WindowModel::onWindowInfoChanged(const WindowInfo windowInfo, const unsigned int pos) | ||
1201 | 108 | { | ||
1202 | 109 | auto mirSurface = static_cast<MirSurface *>(m_windowModel.value(pos)); | ||
1203 | 110 | mirSurface->updateWindowInfo(windowInfo); | ||
1204 | 111 | |||
1205 | 112 | QModelIndex row = index(pos); | ||
1206 | 99 | Q_EMIT dataChanged(row, row, QVector<int>() << SurfaceRole); | 113 | Q_EMIT dataChanged(row, row, QVector<int>() << SurfaceRole); |
1207 | 100 | } | 114 | } |
1208 | 101 | 115 | ||
1209 | 102 | 116 | ||
1210 | === modified file 'miral-qt/src/modules/Unity/Application/windowmodel.h' | |||
1211 | --- miral-qt/src/modules/Unity/Application/windowmodel.h 2016-07-27 11:48:55 +0000 | |||
1212 | +++ miral-qt/src/modules/Unity/Application/windowmodel.h 2016-08-12 12:04:26 +0000 | |||
1213 | @@ -24,6 +24,8 @@ | |||
1214 | 24 | 24 | ||
1215 | 25 | namespace qtmir { | 25 | namespace qtmir { |
1216 | 26 | 26 | ||
1217 | 27 | class WindowControllerInterface; | ||
1218 | 28 | |||
1219 | 27 | class WindowModel : public QAbstractListModel | 29 | class WindowModel : public QAbstractListModel |
1220 | 28 | { | 30 | { |
1221 | 29 | Q_OBJECT | 31 | Q_OBJECT |
1222 | @@ -49,12 +51,17 @@ | |||
1223 | 49 | void countChanged(); | 51 | void countChanged(); |
1224 | 50 | 52 | ||
1225 | 51 | private Q_SLOTS: | 53 | private Q_SLOTS: |
1227 | 52 | void onWindowAdded(const NumberedWindow); | 54 | void onWindowAdded(const WindowInfo windowInfo, const unsigned int index); |
1228 | 53 | void onWindowRemoved(const unsigned int index); | 55 | void onWindowRemoved(const unsigned int index); |
1230 | 54 | void onWindowChanged(const DirtiedWindow); | 56 | void onWindowMoved(const QPoint topLeft, const unsigned int index); |
1231 | 57 | void onWindowResized(const QSize size, const unsigned int index); | ||
1232 | 58 | void onWindowFocused(const unsigned int index); | ||
1233 | 59 | void onWindowInfoChanged(const WindowInfo windowInfo, const unsigned int index); | ||
1234 | 55 | 60 | ||
1235 | 56 | private: | 61 | private: |
1236 | 57 | QVector<MirSurfaceInterface *> m_windowModel; | 62 | QVector<MirSurfaceInterface *> m_windowModel; |
1237 | 63 | WindowControllerInterface *m_windowController; | ||
1238 | 64 | MirSurfaceInterface* m_focusedWindow; | ||
1239 | 58 | }; | 65 | }; |
1240 | 59 | 66 | ||
1241 | 60 | } // namespace qtmir | 67 | } // namespace qtmir |
1242 | 61 | 68 | ||
1243 | === modified file 'miral-qt/src/platforms/mirserver/CMakeLists.txt' | |||
1244 | --- miral-qt/src/platforms/mirserver/CMakeLists.txt 2016-07-28 13:37:17 +0000 | |||
1245 | +++ miral-qt/src/platforms/mirserver/CMakeLists.txt 2016-08-12 12:04:26 +0000 | |||
1246 | @@ -79,12 +79,14 @@ | |||
1247 | 79 | ubuntutheme.cpp | 79 | ubuntutheme.cpp |
1248 | 80 | clipboard.cpp | 80 | clipboard.cpp |
1249 | 81 | creationhints.cpp | 81 | creationhints.cpp |
1250 | 82 | windowcontroller.cpp | ||
1251 | 82 | windowmanagementpolicy.cpp | 83 | windowmanagementpolicy.cpp |
1252 | 83 | windowmodel.cpp | 84 | windowmodel.cpp |
1253 | 84 | tracepoints.c | 85 | tracepoints.c |
1254 | 85 | # We need to run moc on these headers | 86 | # We need to run moc on these headers |
1255 | 86 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h | 87 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h |
1256 | 87 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirMousePointerInterface.h | 88 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirMousePointerInterface.h |
1257 | 89 | ${MIRAL_QT_SOURCE_DIR}/src/common/windowcontrollerinterface.h | ||
1258 | 88 | ${MIRAL_QT_SOURCE_DIR}/src/common/windowmodelinterface.h | 90 | ${MIRAL_QT_SOURCE_DIR}/src/common/windowmodelinterface.h |
1259 | 89 | ) | 91 | ) |
1260 | 90 | 92 | ||
1261 | 91 | 93 | ||
1262 | === modified file 'miral-qt/src/platforms/mirserver/mirserver.cpp' | |||
1263 | --- miral-qt/src/platforms/mirserver/mirserver.cpp 2016-07-28 13:37:17 +0000 | |||
1264 | +++ miral-qt/src/platforms/mirserver/mirserver.cpp 2016-08-12 12:04:26 +0000 | |||
1265 | @@ -192,7 +192,7 @@ | |||
1266 | 192 | 192 | ||
1267 | 193 | UsingQtMirWindowManager::UsingQtMirWindowManager(const QSharedPointer<ScreensModel> &model) | 193 | UsingQtMirWindowManager::UsingQtMirWindowManager(const QSharedPointer<ScreensModel> &model) |
1268 | 194 | : m_screensModel(model) | 194 | : m_screensModel(model) |
1270 | 195 | , m_policy(miral::set_window_managment_policy<WindowManagementPolicy>(m_windowModel, m_screensModel)) | 195 | , m_policy(miral::set_window_managment_policy<WindowManagementPolicy>(m_windowModel, m_windowController, m_screensModel)) |
1271 | 196 | { | 196 | { |
1272 | 197 | } | 197 | } |
1273 | 198 | 198 | ||
1274 | @@ -206,10 +206,9 @@ | |||
1275 | 206 | return &m_windowModel; | 206 | return &m_windowModel; |
1276 | 207 | } | 207 | } |
1277 | 208 | 208 | ||
1279 | 209 | mir::shell::Shell *MirServer::shell() | 209 | qtmir::WindowControllerInterface *UsingQtMirWindowManager::windowController() |
1280 | 210 | { | 210 | { |
1283 | 211 | std::weak_ptr<mir::shell::Shell> m_shell = the_shell(); | 211 | return &m_windowController; |
1282 | 212 | return m_shell.lock().get(); | ||
1284 | 213 | } | 212 | } |
1285 | 214 | 213 | ||
1286 | 215 | QSharedPointer<ScreensModel> MirServer::screensModel() const | 214 | QSharedPointer<ScreensModel> MirServer::screensModel() const |
1287 | 216 | 215 | ||
1288 | === modified file 'miral-qt/src/platforms/mirserver/mirserver.h' | |||
1289 | --- miral-qt/src/platforms/mirserver/mirserver.h 2016-07-28 13:37:17 +0000 | |||
1290 | +++ miral-qt/src/platforms/mirserver/mirserver.h 2016-08-12 12:04:26 +0000 | |||
1291 | @@ -22,6 +22,7 @@ | |||
1292 | 22 | #include <mir/server.h> | 22 | #include <mir/server.h> |
1293 | 23 | #include "miral/set_window_managment_policy.h" | 23 | #include "miral/set_window_managment_policy.h" |
1294 | 24 | #include "windowmodel.h" | 24 | #include "windowmodel.h" |
1295 | 25 | #include "windowcontroller.h" | ||
1296 | 25 | 26 | ||
1297 | 26 | class QtEventFeeder; | 27 | class QtEventFeeder; |
1298 | 27 | class MirDisplayConfigurationPolicy; | 28 | class MirDisplayConfigurationPolicy; |
1299 | @@ -70,10 +71,12 @@ | |||
1300 | 70 | UsingQtMirWindowManager(const QSharedPointer<ScreensModel> &model); | 71 | UsingQtMirWindowManager(const QSharedPointer<ScreensModel> &model); |
1301 | 71 | void operator()(mir::Server& server); | 72 | void operator()(mir::Server& server); |
1302 | 72 | qtmir::WindowModelInterface *windowModel(); | 73 | qtmir::WindowModelInterface *windowModel(); |
1303 | 74 | qtmir::WindowControllerInterface *windowController(); | ||
1304 | 73 | 75 | ||
1305 | 74 | private: | 76 | private: |
1306 | 75 | const QSharedPointer<ScreensModel> &m_screensModel; | 77 | const QSharedPointer<ScreensModel> &m_screensModel; |
1307 | 76 | miral::SetWindowManagmentPolicy m_policy; | 78 | miral::SetWindowManagmentPolicy m_policy; |
1308 | 79 | qtmir::WindowController m_windowController; | ||
1309 | 77 | qtmir::WindowModel m_windowModel; | 80 | qtmir::WindowModel m_windowModel; |
1310 | 78 | }; | 81 | }; |
1311 | 79 | 82 | ||
1312 | @@ -92,7 +95,6 @@ | |||
1313 | 92 | 95 | ||
1314 | 93 | Q_PROPERTY(SessionAuthorizer* sessionAuthorizer READ sessionAuthorizer CONSTANT) | 96 | Q_PROPERTY(SessionAuthorizer* sessionAuthorizer READ sessionAuthorizer CONSTANT) |
1315 | 94 | Q_PROPERTY(SessionListener* sessionListener READ sessionListener CONSTANT) | 97 | Q_PROPERTY(SessionListener* sessionListener READ sessionListener CONSTANT) |
1316 | 95 | Q_PROPERTY(mir::shell::Shell* shell READ shell CONSTANT) | ||
1317 | 96 | Q_PROPERTY(PromptSessionListener* promptSessionListener READ promptSessionListener CONSTANT) | 98 | Q_PROPERTY(PromptSessionListener* promptSessionListener READ promptSessionListener CONSTANT) |
1318 | 97 | 99 | ||
1319 | 98 | public: | 100 | public: |
1320 | @@ -115,7 +117,7 @@ | |||
1321 | 115 | using UsingQtMirSessionListener::sessionListener; | 117 | using UsingQtMirSessionListener::sessionListener; |
1322 | 116 | using UsingQtMirPromptSessionListener::promptSessionListener; | 118 | using UsingQtMirPromptSessionListener::promptSessionListener; |
1323 | 117 | using UsingQtMirWindowManager::windowModel; | 119 | using UsingQtMirWindowManager::windowModel; |
1325 | 118 | mir::shell::Shell *shell(); | 120 | using UsingQtMirWindowManager::windowController; |
1326 | 119 | 121 | ||
1327 | 120 | QSharedPointer<ScreensModel> screensModel() const; | 122 | QSharedPointer<ScreensModel> screensModel() const; |
1328 | 121 | 123 | ||
1329 | 122 | 124 | ||
1330 | === modified file 'miral-qt/src/platforms/mirserver/qmirserver.cpp' | |||
1331 | --- miral-qt/src/platforms/mirserver/qmirserver.cpp 2016-07-28 13:37:17 +0000 | |||
1332 | +++ miral-qt/src/platforms/mirserver/qmirserver.cpp 2016-08-12 12:04:26 +0000 | |||
1333 | @@ -113,12 +113,12 @@ | |||
1334 | 113 | if (d->server) { | 113 | if (d->server) { |
1335 | 114 | if (resource == "SessionAuthorizer") | 114 | if (resource == "SessionAuthorizer") |
1336 | 115 | result = d->server->sessionAuthorizer(); | 115 | result = d->server->sessionAuthorizer(); |
1337 | 116 | else if (resource == "Shell") | ||
1338 | 117 | result = d->server->shell(); | ||
1339 | 118 | else if (resource == "SessionListener") | 116 | else if (resource == "SessionListener") |
1340 | 119 | result = d->server->sessionListener(); | 117 | result = d->server->sessionListener(); |
1341 | 120 | else if (resource == "PromptSessionListener") | 118 | else if (resource == "PromptSessionListener") |
1342 | 121 | result = d->server->promptSessionListener(); | 119 | result = d->server->promptSessionListener(); |
1343 | 120 | else if (resource == "WindowController") | ||
1344 | 121 | result = d->server->windowController(); | ||
1345 | 122 | else if (resource == "WindowModel") | 122 | else if (resource == "WindowModel") |
1346 | 123 | result = d->server->windowModel(); | 123 | result = d->server->windowModel(); |
1347 | 124 | else if (resource == "ScreensController") | 124 | else if (resource == "ScreensController") |
1348 | 125 | 125 | ||
1349 | === added file 'miral-qt/src/platforms/mirserver/windowcontroller.cpp' | |||
1350 | --- miral-qt/src/platforms/mirserver/windowcontroller.cpp 1970-01-01 00:00:00 +0000 | |||
1351 | +++ miral-qt/src/platforms/mirserver/windowcontroller.cpp 2016-08-12 12:04:26 +0000 | |||
1352 | @@ -0,0 +1,85 @@ | |||
1353 | 1 | /* | ||
1354 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1355 | 3 | * | ||
1356 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1357 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
1358 | 6 | * the Free Software Foundation. | ||
1359 | 7 | * | ||
1360 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
1361 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
1362 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1363 | 11 | * Lesser General Public License for more details. | ||
1364 | 12 | * | ||
1365 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1366 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1367 | 15 | */ | ||
1368 | 16 | |||
1369 | 17 | #include "windowcontroller.h" | ||
1370 | 18 | |||
1371 | 19 | #include "windowmanagementpolicy.h" | ||
1372 | 20 | #include "mirqtconversion.h" | ||
1373 | 21 | |||
1374 | 22 | using namespace qtmir; | ||
1375 | 23 | |||
1376 | 24 | |||
1377 | 25 | WindowController::WindowController() | ||
1378 | 26 | : m_policy(nullptr) | ||
1379 | 27 | { | ||
1380 | 28 | } | ||
1381 | 29 | |||
1382 | 30 | void WindowController::focus(const miral::Window &window) | ||
1383 | 31 | { | ||
1384 | 32 | if (m_policy) { | ||
1385 | 33 | m_policy->focus(window); | ||
1386 | 34 | } | ||
1387 | 35 | } | ||
1388 | 36 | |||
1389 | 37 | void WindowController::resize(const miral::Window &window, const QSize &size) | ||
1390 | 38 | { | ||
1391 | 39 | if (m_policy) { | ||
1392 | 40 | m_policy->resize(window, toMirSize(size)); | ||
1393 | 41 | } | ||
1394 | 42 | } | ||
1395 | 43 | |||
1396 | 44 | void WindowController::move(const miral::Window &window, const QPoint &topLeft) | ||
1397 | 45 | { | ||
1398 | 46 | if (m_policy) { | ||
1399 | 47 | m_policy->move(window, toMirPoint(topLeft)); | ||
1400 | 48 | } | ||
1401 | 49 | } | ||
1402 | 50 | |||
1403 | 51 | void WindowController::setActiveFocus(const miral::Window &/*window*/, const bool /*activeFocus*/) | ||
1404 | 52 | { | ||
1405 | 53 | |||
1406 | 54 | } | ||
1407 | 55 | |||
1408 | 56 | void WindowController::setState(const miral::Window &/*window*/, const MirSurfaceState /*state*/) | ||
1409 | 57 | { | ||
1410 | 58 | |||
1411 | 59 | } | ||
1412 | 60 | |||
1413 | 61 | void WindowController::deliverKeyboardEvent(const miral::Window &window, const MirKeyboardEvent *event) | ||
1414 | 62 | { | ||
1415 | 63 | if (m_policy) { | ||
1416 | 64 | m_policy->deliver_keyboard_event(event, window); | ||
1417 | 65 | } | ||
1418 | 66 | } | ||
1419 | 67 | |||
1420 | 68 | void WindowController::deliverTouchEvent(const miral::Window &window, const MirTouchEvent *event) | ||
1421 | 69 | { | ||
1422 | 70 | if (m_policy) { | ||
1423 | 71 | m_policy->deliver_touch_event(event, window); | ||
1424 | 72 | } | ||
1425 | 73 | } | ||
1426 | 74 | |||
1427 | 75 | void WindowController::deliverPointerEvent(const miral::Window &window, const MirPointerEvent *event) | ||
1428 | 76 | { | ||
1429 | 77 | if (m_policy) { | ||
1430 | 78 | m_policy->deliver_pointer_event(event, window); | ||
1431 | 79 | } | ||
1432 | 80 | } | ||
1433 | 81 | |||
1434 | 82 | void WindowController::setPolicy(WindowManagementPolicy * const policy) | ||
1435 | 83 | { | ||
1436 | 84 | m_policy = policy; | ||
1437 | 85 | } | ||
1438 | 0 | 86 | ||
1439 | === added file 'miral-qt/src/platforms/mirserver/windowcontroller.h' | |||
1440 | --- miral-qt/src/platforms/mirserver/windowcontroller.h 1970-01-01 00:00:00 +0000 | |||
1441 | +++ miral-qt/src/platforms/mirserver/windowcontroller.h 2016-08-12 12:04:26 +0000 | |||
1442 | @@ -0,0 +1,51 @@ | |||
1443 | 1 | /* | ||
1444 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1445 | 3 | * | ||
1446 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1447 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
1448 | 6 | * the Free Software Foundation. | ||
1449 | 7 | * | ||
1450 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
1451 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
1452 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1453 | 11 | * Lesser General Public License for more details. | ||
1454 | 12 | * | ||
1455 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1456 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1457 | 15 | */ | ||
1458 | 16 | |||
1459 | 17 | #ifndef WINDOWCONTROLLER_H | ||
1460 | 18 | #define WINDOWCONTROLLER_H | ||
1461 | 19 | |||
1462 | 20 | #include "windowcontrollerinterface.h" | ||
1463 | 21 | |||
1464 | 22 | class WindowManagementPolicy; | ||
1465 | 23 | |||
1466 | 24 | namespace qtmir { | ||
1467 | 25 | |||
1468 | 26 | class WindowController : public WindowControllerInterface | ||
1469 | 27 | { | ||
1470 | 28 | public: | ||
1471 | 29 | WindowController(); | ||
1472 | 30 | virtual ~WindowController() = default; | ||
1473 | 31 | |||
1474 | 32 | void focus (const miral::Window &window) override; | ||
1475 | 33 | void resize(const miral::Window &window, const QSize &size) override; | ||
1476 | 34 | void move (const miral::Window &window, const QPoint &topLeft) override; | ||
1477 | 35 | |||
1478 | 36 | void setActiveFocus(const miral::Window &window, const bool activeFocus) override; | ||
1479 | 37 | void setState(const miral::Window &window, const MirSurfaceState state) override; | ||
1480 | 38 | |||
1481 | 39 | void deliverKeyboardEvent(const miral::Window &window, const MirKeyboardEvent *event) override; | ||
1482 | 40 | void deliverTouchEvent (const miral::Window &window, const MirTouchEvent *event) override; | ||
1483 | 41 | void deliverPointerEvent (const miral::Window &window, const MirPointerEvent *event) override; | ||
1484 | 42 | |||
1485 | 43 | void setPolicy(WindowManagementPolicy *policy); | ||
1486 | 44 | |||
1487 | 45 | protected: | ||
1488 | 46 | WindowManagementPolicy *m_policy; | ||
1489 | 47 | }; | ||
1490 | 48 | |||
1491 | 49 | } // namespace qtmir | ||
1492 | 50 | |||
1493 | 51 | #endif // WINDOWCONTROLLER_H | ||
1494 | 0 | 52 | ||
1495 | === modified file 'miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp' | |||
1496 | --- miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp 2016-08-10 11:48:02 +0000 | |||
1497 | +++ miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp 2016-08-12 12:04:26 +0000 | |||
1498 | @@ -26,12 +26,14 @@ | |||
1499 | 26 | 26 | ||
1500 | 27 | WindowManagementPolicy::WindowManagementPolicy(const miral::WindowManagerTools &tools, | 27 | WindowManagementPolicy::WindowManagementPolicy(const miral::WindowManagerTools &tools, |
1501 | 28 | qtmir::WindowModel &windowModel, | 28 | qtmir::WindowModel &windowModel, |
1502 | 29 | qtmir::WindowController &windowController, | ||
1503 | 29 | const QSharedPointer<ScreensModel> screensModel) | 30 | const QSharedPointer<ScreensModel> screensModel) |
1504 | 30 | : CanonicalWindowManagerPolicy(tools) | 31 | : CanonicalWindowManagerPolicy(tools) |
1505 | 31 | , m_tools(tools) | 32 | , m_tools(tools) |
1506 | 32 | , m_windowModel(windowModel) | 33 | , m_windowModel(windowModel) |
1507 | 33 | , m_eventFeeder(new QtEventFeeder(screensModel)) | 34 | , m_eventFeeder(new QtEventFeeder(screensModel)) |
1508 | 34 | { | 35 | { |
1509 | 36 | windowController.setPolicy(this); | ||
1510 | 35 | } | 37 | } |
1511 | 36 | 38 | ||
1512 | 37 | /* Following are hooks to allow custom policy be imposed */ | 39 | /* Following are hooks to allow custom policy be imposed */ |
1513 | @@ -46,7 +48,7 @@ | |||
1514 | 46 | 48 | ||
1515 | 47 | void WindowManagementPolicy::handle_window_ready(miral::WindowInfo &windowInfo) | 49 | void WindowManagementPolicy::handle_window_ready(miral::WindowInfo &windowInfo) |
1516 | 48 | { | 50 | { |
1518 | 49 | qDebug("Window ready"); | 51 | qDebug("Window Ready"); |
1519 | 50 | m_tools.select_active_window(windowInfo.window()); | 52 | m_tools.select_active_window(windowInfo.window()); |
1520 | 51 | } | 53 | } |
1521 | 52 | 54 | ||
1522 | @@ -85,6 +87,7 @@ | |||
1523 | 85 | 87 | ||
1524 | 86 | void WindowManagementPolicy::advise_new_window(const miral::WindowInfo &windowInfo) | 88 | void WindowManagementPolicy::advise_new_window(const miral::WindowInfo &windowInfo) |
1525 | 87 | { | 89 | { |
1526 | 90 | // TODO: attach surface observer here | ||
1527 | 88 | m_windowModel.addWindow(windowInfo); | 91 | m_windowModel.addWindow(windowInfo); |
1528 | 89 | } | 92 | } |
1529 | 90 | 93 | ||
1530 | @@ -115,13 +118,13 @@ | |||
1531 | 115 | 118 | ||
1532 | 116 | void WindowManagementPolicy::advise_move_to(const miral::WindowInfo &windowInfo, Point topLeft) | 119 | void WindowManagementPolicy::advise_move_to(const miral::WindowInfo &windowInfo, Point topLeft) |
1533 | 117 | { | 120 | { |
1535 | 118 | qDebug("Window move"); | 121 | qDebug("Window Moved to (%d, %d)", topLeft.x.as_int(), topLeft.y.as_int()); |
1536 | 119 | m_windowModel.moveWindow(windowInfo, topLeft); | 122 | m_windowModel.moveWindow(windowInfo, topLeft); |
1537 | 120 | } | 123 | } |
1538 | 121 | 124 | ||
1539 | 122 | void WindowManagementPolicy::advise_resize(const miral::WindowInfo &windowInfo, const Size &newSize) | 125 | void WindowManagementPolicy::advise_resize(const miral::WindowInfo &windowInfo, const Size &newSize) |
1540 | 123 | { | 126 | { |
1542 | 124 | qDebug("Window Resize"); | 127 | qDebug("Window Resized to %dx%d", newSize.width.as_int(), newSize.height.as_int()); |
1543 | 125 | m_windowModel.resizeWindow(windowInfo, newSize); | 128 | m_windowModel.resizeWindow(windowInfo, newSize); |
1544 | 126 | } | 129 | } |
1545 | 127 | 130 | ||
1546 | @@ -147,35 +150,60 @@ | |||
1547 | 147 | 150 | ||
1548 | 148 | /* Following methods all called from the Qt GUI thread to deliver events to clients */ | 151 | /* Following methods all called from the Qt GUI thread to deliver events to clients */ |
1549 | 149 | void WindowManagementPolicy::deliver_keyboard_event(const MirKeyboardEvent *event, | 152 | void WindowManagementPolicy::deliver_keyboard_event(const MirKeyboardEvent *event, |
1551 | 150 | const std::shared_ptr<mir::scene::Surface> &surface) | 153 | const miral::Window &window) |
1552 | 151 | { | 154 | { |
1556 | 152 | m_tools.invoke_under_lock([&surface, this]() { | 155 | m_tools.invoke_under_lock([&window, this]() { |
1557 | 153 | auto windowInfo = m_tools.info_for(surface); | 156 | m_tools.select_active_window(window); |
1555 | 154 | m_tools.select_active_window(windowInfo.window()); | ||
1558 | 155 | }); | 157 | }); |
1559 | 156 | auto e = reinterpret_cast<MirEvent const*>(event); // naughty | 158 | auto e = reinterpret_cast<MirEvent const*>(event); // naughty |
1561 | 157 | surface->consume(e); | 159 | |
1562 | 160 | if (auto surface = std::weak_ptr<mir::scene::Surface>(window).lock()) { | ||
1563 | 161 | surface->consume(e); | ||
1564 | 162 | } | ||
1565 | 158 | } | 163 | } |
1566 | 159 | 164 | ||
1567 | 160 | void WindowManagementPolicy::deliver_touch_event(const MirTouchEvent *event, | 165 | void WindowManagementPolicy::deliver_touch_event(const MirTouchEvent *event, |
1569 | 161 | const std::shared_ptr<mir::scene::Surface> &surface) | 166 | const miral::Window &window) |
1570 | 162 | { | 167 | { |
1574 | 163 | m_tools.invoke_under_lock([&surface, this]() { | 168 | m_tools.invoke_under_lock([&window, this]() { |
1575 | 164 | auto windowInfo = m_tools.info_for(surface); | 169 | m_tools.select_active_window(window); |
1573 | 165 | m_tools.select_active_window(windowInfo.window()); | ||
1576 | 166 | }); | 170 | }); |
1577 | 167 | auto e = reinterpret_cast<MirEvent const*>(event); // naughty | 171 | auto e = reinterpret_cast<MirEvent const*>(event); // naughty |
1579 | 168 | surface->consume(e); | 172 | |
1580 | 173 | if (auto surface = std::weak_ptr<mir::scene::Surface>(window).lock()) { | ||
1581 | 174 | surface->consume(e); | ||
1582 | 175 | } | ||
1583 | 169 | } | 176 | } |
1584 | 170 | 177 | ||
1585 | 171 | void WindowManagementPolicy::deliver_pointer_event(const MirPointerEvent *event, | 178 | void WindowManagementPolicy::deliver_pointer_event(const MirPointerEvent *event, |
1587 | 172 | const std::shared_ptr<mir::scene::Surface> &surface) | 179 | const miral::Window &window) |
1588 | 173 | { | 180 | { |
1592 | 174 | m_tools.invoke_under_lock([&surface, this]() { | 181 | m_tools.invoke_under_lock([&window, this]() { |
1593 | 175 | auto windowInfo = m_tools.info_for(surface); | 182 | m_tools.select_active_window(window); |
1591 | 176 | m_tools.select_active_window(windowInfo.window()); | ||
1594 | 177 | }); | 183 | }); |
1595 | 178 | auto e = reinterpret_cast<MirEvent const*>(event); // naughty | 184 | auto e = reinterpret_cast<MirEvent const*>(event); // naughty |
1599 | 179 | surface->consume(e); | 185 | |
1600 | 180 | } | 186 | if (auto surface = std::weak_ptr<mir::scene::Surface>(window).lock()) { |
1601 | 181 | 187 | surface->consume(e); | |
1602 | 188 | } | ||
1603 | 189 | } | ||
1604 | 190 | |||
1605 | 191 | /* Methods to allow Shell to request changes to the window stack */ | ||
1606 | 192 | void WindowManagementPolicy::focus(const miral::Window &window) | ||
1607 | 193 | { | ||
1608 | 194 | m_tools.select_active_window(window); | ||
1609 | 195 | } | ||
1610 | 196 | |||
1611 | 197 | void WindowManagementPolicy::resize(const miral::Window &window, const Size size) | ||
1612 | 198 | { | ||
1613 | 199 | miral::WindowSpecification modifications; | ||
1614 | 200 | modifications.size() = size; | ||
1615 | 201 | m_tools.modify_window(m_tools.info_for(window), modifications); | ||
1616 | 202 | } | ||
1617 | 203 | |||
1618 | 204 | void WindowManagementPolicy::move(const miral::Window &window, const Point topLeft) | ||
1619 | 205 | { | ||
1620 | 206 | miral::WindowSpecification modifications; | ||
1621 | 207 | modifications.top_left() = topLeft; | ||
1622 | 208 | m_tools.modify_window(m_tools.info_for(window), modifications); | ||
1623 | 209 | } | ||
1624 | 182 | 210 | ||
1625 | === modified file 'miral-qt/src/platforms/mirserver/windowmanagementpolicy.h' | |||
1626 | --- miral-qt/src/platforms/mirserver/windowmanagementpolicy.h 2016-08-10 11:48:02 +0000 | |||
1627 | +++ miral-qt/src/platforms/mirserver/windowmanagementpolicy.h 2016-08-12 12:04:26 +0000 | |||
1628 | @@ -20,9 +20,9 @@ | |||
1629 | 20 | #include "miral/canonical_window_manager.h" | 20 | #include "miral/canonical_window_manager.h" |
1630 | 21 | 21 | ||
1631 | 22 | #include "qteventfeeder.h" | 22 | #include "qteventfeeder.h" |
1632 | 23 | #include "windowcontroller.h" | ||
1633 | 23 | #include "windowmodel.h" | 24 | #include "windowmodel.h" |
1634 | 24 | 25 | ||
1635 | 25 | #include <QObject> | ||
1636 | 26 | #include <QScopedPointer> | 26 | #include <QScopedPointer> |
1637 | 27 | #include <QSize> | 27 | #include <QSize> |
1638 | 28 | 28 | ||
1639 | @@ -30,11 +30,12 @@ | |||
1640 | 30 | 30 | ||
1641 | 31 | class ScreensModel; | 31 | class ScreensModel; |
1642 | 32 | 32 | ||
1644 | 33 | class WindowManagementPolicy : public QObject, public miral::CanonicalWindowManagerPolicy | 33 | class WindowManagementPolicy : public miral::CanonicalWindowManagerPolicy |
1645 | 34 | { | 34 | { |
1646 | 35 | public: | 35 | public: |
1647 | 36 | WindowManagementPolicy(const miral::WindowManagerTools &tools, | 36 | WindowManagementPolicy(const miral::WindowManagerTools &tools, |
1648 | 37 | qtmir::WindowModel &windowModel, | 37 | qtmir::WindowModel &windowModel, |
1649 | 38 | qtmir::WindowController &windowController, | ||
1650 | 38 | const QSharedPointer<ScreensModel> screensModel); | 39 | const QSharedPointer<ScreensModel> screensModel); |
1651 | 39 | 40 | ||
1652 | 40 | // From WindowManagementPolicy | 41 | // From WindowManagementPolicy |
1653 | @@ -65,12 +66,16 @@ | |||
1654 | 65 | void advise_move_to(const miral::WindowInfo &windowInfo, Point topLeft) override; | 66 | void advise_move_to(const miral::WindowInfo &windowInfo, Point topLeft) override; |
1655 | 66 | void advise_resize(const miral::WindowInfo &info, const Size &newSize) override; | 67 | void advise_resize(const miral::WindowInfo &info, const Size &newSize) override; |
1656 | 67 | void advise_delete_window(const miral::WindowInfo &windowInfo) override; | 68 | void advise_delete_window(const miral::WindowInfo &windowInfo) override; |
1663 | 68 | void advise_raise(std::vector<miral::Window> const& windows) override; | 69 | void advise_raise(const std::vector<miral::Window> &windows) override; |
1664 | 69 | 70 | ||
1665 | 70 | // Exposing some tools | 71 | // Methods for consumption by WindowControllerInterface |
1666 | 71 | void deliver_keyboard_event(const MirKeyboardEvent *event, const std::shared_ptr<mir::scene::Surface> &surface); | 72 | void deliver_keyboard_event(const MirKeyboardEvent *event, const miral::Window &window); |
1667 | 72 | void deliver_touch_event(const MirTouchEvent *event, const std::shared_ptr<mir::scene::Surface> &surface); | 73 | void deliver_touch_event (const MirTouchEvent *event, const miral::Window &window); |
1668 | 73 | void deliver_pointer_event(const MirPointerEvent *event, const std::shared_ptr<mir::scene::Surface> &surface); | 74 | void deliver_pointer_event (const MirPointerEvent *event, const miral::Window &window); |
1669 | 75 | |||
1670 | 76 | void focus (const miral::Window &window); | ||
1671 | 77 | void resize(const miral::Window &window, const Size size); | ||
1672 | 78 | void move (const miral::Window &window, const Point topLeft); | ||
1673 | 74 | 79 | ||
1674 | 75 | Q_SIGNALS: | 80 | Q_SIGNALS: |
1675 | 76 | 81 | ||
1676 | 77 | 82 | ||
1677 | === modified file 'miral-qt/src/platforms/mirserver/windowmodel.cpp' | |||
1678 | --- miral-qt/src/platforms/mirserver/windowmodel.cpp 2016-08-05 09:54:43 +0000 | |||
1679 | +++ miral-qt/src/platforms/mirserver/windowmodel.cpp 2016-08-12 12:04:26 +0000 | |||
1680 | @@ -32,8 +32,7 @@ | |||
1681 | 32 | WindowModel::WindowModel() | 32 | WindowModel::WindowModel() |
1682 | 33 | { | 33 | { |
1683 | 34 | qDebug("WindowModel::WindowModel"); | 34 | qDebug("WindowModel::WindowModel"); |
1686 | 35 | qRegisterMetaType<qtmir::NumberedWindow>(); | 35 | qRegisterMetaType<qtmir::WindowInfo>(); |
1685 | 36 | qRegisterMetaType<qtmir::DirtiedWindow>(); | ||
1687 | 37 | } | 36 | } |
1688 | 38 | 37 | ||
1689 | 39 | WindowModel::~WindowModel() | 38 | WindowModel::~WindowModel() |
1690 | @@ -47,12 +46,7 @@ | |||
1691 | 47 | auto stackPosition = static_cast<unsigned int>(m_windowStack.count()); | 46 | auto stackPosition = static_cast<unsigned int>(m_windowStack.count()); |
1692 | 48 | m_windowStack.push_back(windowInfo.window()); // ASSUMPTION: Mir should tell us where in stack | 47 | m_windowStack.push_back(windowInfo.window()); // ASSUMPTION: Mir should tell us where in stack |
1693 | 49 | 48 | ||
1700 | 50 | QSize size = toQSize(windowInfo.window().size()); | 49 | Q_EMIT windowAdded(windowInfo, stackPosition); |
1695 | 51 | QPoint position = toQPoint(windowInfo.window().top_left()); | ||
1696 | 52 | |||
1697 | 53 | WindowInfo info{ size, position, false, windowInfo.window() }; | ||
1698 | 54 | NumberedWindow window{ stackPosition, info }; | ||
1699 | 55 | Q_EMIT windowAdded(window); | ||
1701 | 56 | } | 50 | } |
1702 | 57 | 51 | ||
1703 | 58 | void WindowModel::removeWindow(const miral::WindowInfo &windowInfo) | 52 | void WindowModel::removeWindow(const miral::WindowInfo &windowInfo) |
1704 | @@ -76,13 +70,11 @@ | |||
1705 | 76 | return; | 70 | return; |
1706 | 77 | } | 71 | } |
1707 | 78 | auto upos = static_cast<unsigned int>(pos); | 72 | auto upos = static_cast<unsigned int>(pos); |
1708 | 79 | m_focusedWindowIndex = upos; | ||
1709 | 80 | QSize size = toQSize(windowInfo.window().size()); | ||
1710 | 81 | QPoint position = toQPoint(windowInfo.window().top_left()); | ||
1711 | 82 | 73 | ||
1715 | 83 | WindowInfo info{ size, position, focus, windowInfo.window() }; | 74 | if (focus && m_focusedWindowIndex != upos) { |
1716 | 84 | DirtiedWindow window{ upos, info, WindowInfo::DirtyStates::Focus}; | 75 | m_focusedWindowIndex = upos; |
1717 | 85 | Q_EMIT windowChanged(window); | 76 | Q_EMIT windowFocused(upos); |
1718 | 77 | } | ||
1719 | 86 | } | 78 | } |
1720 | 87 | 79 | ||
1721 | 88 | void WindowModel::moveWindow(const miral::WindowInfo &windowInfo, mir::geometry::Point topLeft) | 80 | void WindowModel::moveWindow(const miral::WindowInfo &windowInfo, mir::geometry::Point topLeft) |
1722 | @@ -93,13 +85,9 @@ | |||
1723 | 93 | return; | 85 | return; |
1724 | 94 | } | 86 | } |
1725 | 95 | auto upos = static_cast<unsigned int>(pos); | 87 | auto upos = static_cast<unsigned int>(pos); |
1726 | 96 | const bool focused = (m_focusedWindowIndex == upos); | ||
1727 | 97 | QSize size = toQSize(windowInfo.window().size()); | ||
1728 | 98 | QPoint position = toQPoint(topLeft); | ||
1729 | 99 | 88 | ||
1733 | 100 | WindowInfo info{ size, position, focused, windowInfo.window() }; | 89 | // Note: windowInfo.window() is in the state before the move |
1734 | 101 | DirtiedWindow window{ upos, info, WindowInfo::DirtyStates::Position}; | 90 | Q_EMIT windowMoved(toQPoint(topLeft), upos); |
1732 | 102 | Q_EMIT windowChanged(window); | ||
1735 | 103 | } | 91 | } |
1736 | 104 | 92 | ||
1737 | 105 | void WindowModel::resizeWindow(const miral::WindowInfo &windowInfo, mir::geometry::Size newSize) | 93 | void WindowModel::resizeWindow(const miral::WindowInfo &windowInfo, mir::geometry::Size newSize) |
1738 | @@ -110,13 +98,9 @@ | |||
1739 | 110 | return; | 98 | return; |
1740 | 111 | } | 99 | } |
1741 | 112 | auto upos = static_cast<unsigned int>(pos); | 100 | auto upos = static_cast<unsigned int>(pos); |
1742 | 113 | const bool focused = (m_focusedWindowIndex == upos); | ||
1743 | 114 | QSize size = toQSize(newSize); | ||
1744 | 115 | QPoint position = toQPoint(windowInfo.window().top_left()); | ||
1745 | 116 | 101 | ||
1749 | 117 | WindowInfo info{ size, position, focused, windowInfo.window() }; | 102 | // Note: windowInfo.window() is in the state before the resize |
1750 | 118 | DirtiedWindow window{ upos, info, WindowInfo::DirtyStates::Size}; | 103 | Q_EMIT windowResized(toQSize(newSize), upos); |
1748 | 119 | Q_EMIT windowChanged(window); | ||
1751 | 120 | } | 104 | } |
1752 | 121 | 105 | ||
1753 | 122 | void WindowModel::raiseWindows(const std::vector<miral::Window> &/*windows*/) | 106 | void WindowModel::raiseWindows(const std::vector<miral::Window> &/*windows*/) |
1754 | 123 | 107 | ||
1755 | === modified file 'miral-qt/tests/framework/fake_mirsurface.cpp' | |||
1756 | --- miral-qt/tests/framework/fake_mirsurface.cpp 2016-07-27 12:05:20 +0000 | |||
1757 | +++ miral-qt/tests/framework/fake_mirsurface.cpp 2016-08-12 12:04:26 +0000 | |||
1758 | @@ -58,11 +58,11 @@ | |||
1759 | 58 | 58 | ||
1760 | 59 | QPoint FakeMirSurface::position() const { return m_position; } | 59 | QPoint FakeMirSurface::position() const { return m_position; } |
1761 | 60 | 60 | ||
1763 | 61 | void FakeMirSurface::setPosition(const QPoint position) | 61 | void FakeMirSurface::requestPosition(const QPoint newPosition) |
1764 | 62 | { | 62 | { |
1768 | 63 | if (m_position != position) { | 63 | if (m_position != newPosition) { |
1769 | 64 | m_position = position; | 64 | m_position = newPosition; |
1770 | 65 | Q_EMIT positionChanged(position); | 65 | Q_EMIT positionChanged(newPosition); |
1771 | 66 | } | 66 | } |
1772 | 67 | } | 67 | } |
1773 | 68 | 68 | ||
1774 | @@ -192,6 +192,8 @@ | |||
1775 | 192 | 192 | ||
1776 | 193 | void FakeMirSurface::onCompositorSwappedBuffers() {} | 193 | void FakeMirSurface::onCompositorSwappedBuffers() {} |
1777 | 194 | 194 | ||
1778 | 195 | void FakeMirSurface::setShellChrome(Mir::ShellChrome /*shellChrome*/) {} | ||
1779 | 196 | |||
1780 | 195 | void FakeMirSurface::drawFirstFrame() | 197 | void FakeMirSurface::drawFirstFrame() |
1781 | 196 | { | 198 | { |
1782 | 197 | if (!m_isFirstFrameDrawn) { | 199 | if (!m_isFirstFrameDrawn) { |
1783 | 198 | 200 | ||
1784 | === modified file 'miral-qt/tests/framework/fake_mirsurface.h' | |||
1785 | --- miral-qt/tests/framework/fake_mirsurface.h 2016-07-27 12:05:20 +0000 | |||
1786 | +++ miral-qt/tests/framework/fake_mirsurface.h 2016-08-12 12:04:26 +0000 | |||
1787 | @@ -54,8 +54,6 @@ | |||
1788 | 54 | Mir::Type type() const override; | 54 | Mir::Type type() const override; |
1789 | 55 | QString name() const override; | 55 | QString name() const override; |
1790 | 56 | QSize size() const override; | 56 | QSize size() const override; |
1791 | 57 | QPoint position() const override; | ||
1792 | 58 | void setPosition(const QPoint position) override; | ||
1793 | 59 | void resize(int width, int height) override; | 57 | void resize(int width, int height) override; |
1794 | 60 | void resize(const QSize &size) override; | 58 | void resize(const QSize &size) override; |
1795 | 61 | Mir::State state() const override; | 59 | Mir::State state() const override; |
1796 | @@ -93,6 +91,9 @@ | |||
1797 | 93 | //// | 91 | //// |
1798 | 94 | // qtmir.MirSurfaceInterface | 92 | // qtmir.MirSurfaceInterface |
1799 | 95 | 93 | ||
1800 | 94 | QPoint position() const override; | ||
1801 | 95 | void requestPosition(const QPoint newPosition) override; | ||
1802 | 96 | |||
1803 | 96 | bool isFirstFrameDrawn() const override; | 97 | bool isFirstFrameDrawn() const override; |
1804 | 97 | void stopFrameDropper() override; | 98 | void stopFrameDropper() override; |
1805 | 98 | void startFrameDropper() override; | 99 | void startFrameDropper() override; |
1806 | @@ -112,7 +113,7 @@ | |||
1807 | 112 | 113 | ||
1808 | 113 | void setFocused(bool focus) override; | 114 | void setFocused(bool focus) override; |
1809 | 114 | 115 | ||
1811 | 115 | void setViewActiveFocus(qintptr, bool) override {}; | 116 | void setViewActiveFocus(qintptr, bool) override {} |
1812 | 116 | bool activeFocus() const override { return false; } | 117 | bool activeFocus() const override { return false; } |
1813 | 117 | 118 | ||
1814 | 118 | void mousePressEvent(QMouseEvent *) override; | 119 | void mousePressEvent(QMouseEvent *) override; |
1815 | @@ -141,13 +142,7 @@ | |||
1816 | 141 | public Q_SLOTS: | 142 | public Q_SLOTS: |
1817 | 142 | void onCompositorSwappedBuffers() override; | 143 | void onCompositorSwappedBuffers() override; |
1818 | 143 | 144 | ||
1826 | 144 | void setMinimumWidth(int) {} | 145 | void setShellChrome(Mir::ShellChrome shellChrome) override; |
1820 | 145 | void setMinimumHeight(int) {} | ||
1821 | 146 | void setMaximumWidth(int) {} | ||
1822 | 147 | void setMaximumHeight(int) {} | ||
1823 | 148 | void setWidthIncrement(int) {} | ||
1824 | 149 | void setHeightIncrement(int) {} | ||
1825 | 150 | void setShellChrome(Mir::ShellChrome) override {} | ||
1827 | 151 | 146 | ||
1828 | 152 | //// | 147 | //// |
1829 | 153 | // Test API from now on | 148 | // Test API from now on |
1830 | 154 | 149 | ||
1831 | === modified file 'miral-qt/tests/modules/SurfaceManager/CMakeLists.txt' | |||
1832 | --- miral-qt/tests/modules/SurfaceManager/CMakeLists.txt 2016-06-07 20:32:04 +0000 | |||
1833 | +++ miral-qt/tests/modules/SurfaceManager/CMakeLists.txt 2016-08-12 12:04:26 +0000 | |||
1834 | @@ -1,14 +1,16 @@ | |||
1835 | 1 | set( | 1 | set( |
1836 | 2 | MIR_SURFACE_MANAGER_TEST_SOURCES | 2 | MIR_SURFACE_MANAGER_TEST_SOURCES |
1838 | 3 | mirsurfaceitem_test.cpp | 3 | # mirsurfaceitem_test.cpp #FIXME - reinstate these tests when functionality there |
1839 | 4 | mirsurface_test.cpp | 4 | mirsurface_test.cpp |
1840 | 5 | ${MIRAL_QT_SOURCE_DIR}/src/common/debughelpers.cpp | 5 | ${MIRAL_QT_SOURCE_DIR}/src/common/debughelpers.cpp |
1841 | 6 | ) | 6 | ) |
1842 | 7 | 7 | ||
1843 | 8 | include_directories( | 8 | include_directories( |
1844 | 9 | ${MIRAL_QT_SOURCE_DIR}/src/common | ||
1845 | 9 | ${MIRAL_QT_SOURCE_DIR}/src/modules | 10 | ${MIRAL_QT_SOURCE_DIR}/src/modules |
1846 | 10 | ${MIRAL_QT_SOURCE_DIR}/src/platforms/mirserver | 11 | ${MIRAL_QT_SOURCE_DIR}/src/platforms/mirserver |
1847 | 11 | ${MIRAL_QT_SOURCE_DIR}/tests/framework | 12 | ${MIRAL_QT_SOURCE_DIR}/tests/framework |
1848 | 13 | ${CMAKE_SOURCE_DIR}/include/miral #FIXME | ||
1849 | 12 | ${MIRSERVER_INCLUDE_DIRS} | 14 | ${MIRSERVER_INCLUDE_DIRS} |
1850 | 13 | ${Qt5Quick_PRIVATE_INCLUDE_DIRS} | 15 | ${Qt5Quick_PRIVATE_INCLUDE_DIRS} |
1851 | 14 | ) | 16 | ) |
1852 | 15 | 17 | ||
1853 | === modified file 'miral-qt/tests/modules/SurfaceManager/mirsurface_test.cpp' | |||
1854 | --- miral-qt/tests/modules/SurfaceManager/mirsurface_test.cpp 2016-06-07 20:32:04 +0000 | |||
1855 | +++ miral-qt/tests/modules/SurfaceManager/mirsurface_test.cpp 2016-08-12 12:04:26 +0000 | |||
1856 | @@ -24,22 +24,24 @@ | |||
1857 | 24 | #include <QTest> | 24 | #include <QTest> |
1858 | 25 | #include <QSignalSpy> | 25 | #include <QSignalSpy> |
1859 | 26 | 26 | ||
1860 | 27 | // src/common | ||
1861 | 28 | #include "windowmodelinterface.h" | ||
1862 | 29 | |||
1863 | 27 | // the test subject | 30 | // the test subject |
1864 | 28 | #include <Unity/Application/mirsurface.h> | 31 | #include <Unity/Application/mirsurface.h> |
1865 | 29 | 32 | ||
1866 | 30 | #include <Unity/Application/timer.h> | 33 | #include <Unity/Application/timer.h> |
1867 | 31 | 34 | ||
1868 | 32 | // tests/framework | 35 | // tests/framework |
1869 | 33 | #include <fake_session.h> | ||
1870 | 34 | #include <mock_mir_session.h> | 36 | #include <mock_mir_session.h> |
1871 | 35 | #include <mock_shell.h> | ||
1872 | 36 | #include <mock_surface.h> | 37 | #include <mock_surface.h> |
1873 | 37 | 38 | ||
1874 | 38 | // tests/modules/common | 39 | // tests/modules/common |
1875 | 39 | #include <surfaceobserver.h> | 40 | #include <surfaceobserver.h> |
1876 | 40 | 41 | ||
1879 | 41 | // mirserver | 42 | // miral |
1880 | 42 | #include <creationhints.h> | 43 | #include "window.h" |
1881 | 44 | #include "window_info.h" | ||
1882 | 43 | 45 | ||
1883 | 44 | using namespace qtmir; | 46 | using namespace qtmir; |
1884 | 45 | 47 | ||
1885 | @@ -54,8 +56,6 @@ | |||
1886 | 54 | // We don't want the logging spam cluttering the test results | 56 | // We don't want the logging spam cluttering the test results |
1887 | 55 | QLoggingCategory::setFilterRules(QStringLiteral("qtmir.surfaces=false")); | 57 | QLoggingCategory::setFilterRules(QStringLiteral("qtmir.surfaces=false")); |
1888 | 56 | } | 58 | } |
1889 | 57 | |||
1890 | 58 | NiceMock<mir::shell::MockShell> m_mockShell; | ||
1891 | 59 | }; | 59 | }; |
1892 | 60 | 60 | ||
1893 | 61 | TEST_F(MirSurfaceTest, UpdateTextureBeforeDraw) | 61 | TEST_F(MirSurfaceTest, UpdateTextureBeforeDraw) |
1894 | @@ -64,22 +64,23 @@ | |||
1895 | 64 | char* argv[0]; | 64 | char* argv[0]; |
1896 | 65 | QCoreApplication qtApp(argc, argv); // app for deleteLater event | 65 | QCoreApplication qtApp(argc, argv); // app for deleteLater event |
1897 | 66 | 66 | ||
1899 | 67 | auto fakeSession = new FakeSession(); | 67 | auto const fakeSession = std::make_shared<ms::MockSession>(); |
1900 | 68 | auto mockSurface = std::make_shared<NiceMock<ms::MockSurface>>(); | 68 | auto mockSurface = std::make_shared<NiceMock<ms::MockSurface>>(); |
1901 | 69 | miral::Window mockWindow(fakeSession, mockSurface); | ||
1902 | 70 | miral::WindowInfo mockWindowInfo(mockWindow, {}); | ||
1903 | 71 | QScopedPointer<WindowInfo> windowInfo(new WindowInfo(mockWindowInfo)); | ||
1904 | 72 | |||
1905 | 69 | auto surfaceObserver = std::make_shared<SurfaceObserver>(); | 73 | auto surfaceObserver = std::make_shared<SurfaceObserver>(); |
1906 | 70 | 74 | ||
1907 | 71 | EXPECT_CALL(*mockSurface.get(),buffers_ready_for_compositor(_)) | 75 | EXPECT_CALL(*mockSurface.get(),buffers_ready_for_compositor(_)) |
1908 | 72 | .WillRepeatedly(Return(1)); | 76 | .WillRepeatedly(Return(1)); |
1909 | 73 | 77 | ||
1911 | 74 | MirSurface *surface = new MirSurface(mockSurface, fakeSession, &m_mockShell, surfaceObserver, CreationHints()); | 78 | MirSurface surface(mockWindowInfo, nullptr, surfaceObserver); |
1912 | 75 | surfaceObserver->frame_posted(1, mir::geometry::Size{1,1}); | 79 | surfaceObserver->frame_posted(1, mir::geometry::Size{1,1}); |
1913 | 76 | 80 | ||
1915 | 77 | QSignalSpy spyFrameDropped(surface, SIGNAL(frameDropped())); | 81 | QSignalSpy spyFrameDropped(&surface, SIGNAL(frameDropped())); |
1916 | 78 | QTest::qWait(300); | 82 | QTest::qWait(300); |
1917 | 79 | ASSERT_TRUE(spyFrameDropped.count() > 0); | 83 | ASSERT_TRUE(spyFrameDropped.count() > 0); |
1918 | 80 | |||
1919 | 81 | delete fakeSession; | ||
1920 | 82 | delete surface; | ||
1921 | 83 | } | 84 | } |
1922 | 84 | 85 | ||
1923 | 85 | 86 | ||
1924 | @@ -89,28 +90,31 @@ | |||
1925 | 89 | char* argv[0]; | 90 | char* argv[0]; |
1926 | 90 | QCoreApplication qtApp(argc, argv); // app for deleteLater event | 91 | QCoreApplication qtApp(argc, argv); // app for deleteLater event |
1927 | 91 | 92 | ||
1929 | 92 | auto fakeSession = new FakeSession(); | 93 | auto const fakeSession = std::make_shared<NiceMock<ms::MockSession>>(); |
1930 | 93 | auto mockSurface = std::make_shared<NiceMock<ms::MockSurface>>(); | 94 | auto mockSurface = std::make_shared<NiceMock<ms::MockSurface>>(); |
1933 | 94 | 95 | miral::Window mockWindow(fakeSession, mockSurface); | |
1934 | 95 | MirSurface *surface = new MirSurface(mockSurface, fakeSession, &m_mockShell, nullptr, CreationHints()); | 96 | miral::WindowInfo mockWindowInfo(mockWindow, {}); |
1935 | 97 | QScopedPointer<WindowInfo> windowInfo(new WindowInfo(mockWindowInfo)); | ||
1936 | 98 | auto surfaceObserver = std::make_shared<SurfaceObserver>(); | ||
1937 | 99 | |||
1938 | 100 | MirSurface surface(mockWindowInfo, nullptr, surfaceObserver); | ||
1939 | 101 | |||
1940 | 96 | bool surfaceDeleted = false; | 102 | bool surfaceDeleted = false; |
1942 | 97 | QObject::connect(surface, &QObject::destroyed, surface, [&surfaceDeleted](){ surfaceDeleted = true; }); | 103 | QObject::connect(&surface, &QObject::destroyed, &surface, [&surfaceDeleted](){ surfaceDeleted = true; }); |
1943 | 98 | 104 | ||
1944 | 99 | qintptr view1 = (qintptr)1; | 105 | qintptr view1 = (qintptr)1; |
1945 | 100 | qintptr view2 = (qintptr)2; | 106 | qintptr view2 = (qintptr)2; |
1946 | 101 | 107 | ||
1950 | 102 | surface->registerView(view1); | 108 | surface.registerView(view1); |
1951 | 103 | surface->registerView(view2); | 109 | surface.registerView(view2); |
1952 | 104 | surface->setLive(false); | 110 | surface.setLive(false); |
1953 | 105 | EXPECT_FALSE(surfaceDeleted); | 111 | EXPECT_FALSE(surfaceDeleted); |
1954 | 106 | 112 | ||
1957 | 107 | surface->unregisterView(view1); | 113 | surface.unregisterView(view1); |
1958 | 108 | surface->unregisterView(view2); | 114 | surface.unregisterView(view2); |
1959 | 109 | 115 | ||
1960 | 110 | QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); | 116 | QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
1961 | 111 | EXPECT_TRUE(surfaceDeleted); | 117 | EXPECT_TRUE(surfaceDeleted); |
1962 | 112 | |||
1963 | 113 | delete fakeSession; | ||
1964 | 114 | } | 118 | } |
1965 | 115 | 119 | ||
1966 | 116 | 120 | ||
1967 | @@ -120,62 +124,63 @@ | |||
1968 | 120 | char* argv[0]; | 124 | char* argv[0]; |
1969 | 121 | QCoreApplication qtApp(argc, argv); // app for deleteLater event | 125 | QCoreApplication qtApp(argc, argv); // app for deleteLater event |
1970 | 122 | 126 | ||
1972 | 123 | auto fakeSession = new FakeSession(); | 127 | auto const fakeSession = std::make_shared<ms::MockSession>(); |
1973 | 124 | auto mockSurface = std::make_shared<NiceMock<ms::MockSurface>>(); | 128 | auto mockSurface = std::make_shared<NiceMock<ms::MockSurface>>(); |
1976 | 125 | 129 | miral::Window mockWindow(fakeSession, mockSurface); | |
1977 | 126 | MirSurface *surface = new MirSurface(mockSurface, fakeSession, &m_mockShell, nullptr, CreationHints()); | 130 | miral::WindowInfo mockWindowInfo(mockWindow, {}); |
1978 | 131 | QScopedPointer<WindowInfo> windowInfo(new WindowInfo(mockWindowInfo)); | ||
1979 | 132 | auto surfaceObserver = std::make_shared<SurfaceObserver>(); | ||
1980 | 133 | |||
1981 | 134 | MirSurface surface(mockWindowInfo, nullptr, surfaceObserver); | ||
1982 | 135 | |||
1983 | 127 | bool surfaceDeleted = false; | 136 | bool surfaceDeleted = false; |
1985 | 128 | QObject::connect(surface, &QObject::destroyed, surface, [&surfaceDeleted](){ surfaceDeleted = true; }); | 137 | QObject::connect(&surface, &QObject::destroyed, &surface, [&surfaceDeleted](){ surfaceDeleted = true; }); |
1986 | 129 | 138 | ||
1987 | 130 | qintptr view1 = (qintptr)1; | 139 | qintptr view1 = (qintptr)1; |
1988 | 131 | qintptr view2 = (qintptr)2; | 140 | qintptr view2 = (qintptr)2; |
1989 | 132 | 141 | ||
1992 | 133 | surface->registerView(view1); | 142 | surface.registerView(view1); |
1993 | 134 | surface->registerView(view2); | 143 | surface.registerView(view2); |
1994 | 135 | 144 | ||
1997 | 136 | surface->unregisterView(view1); | 145 | surface.unregisterView(view1); |
1998 | 137 | surface->unregisterView(view2); | 146 | surface.unregisterView(view2); |
1999 | 138 | 147 | ||
2000 | 139 | QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); | 148 | QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
2001 | 140 | EXPECT_FALSE(surfaceDeleted); | 149 | EXPECT_FALSE(surfaceDeleted); |
2002 | 141 | |||
2003 | 142 | delete fakeSession; | ||
2004 | 143 | delete surface; | ||
2005 | 144 | } | 150 | } |
2006 | 145 | 151 | ||
2007 | 146 | /* | 152 | /* |
2008 | 147 | * Test that a surface whose client fails to comply with a close request will eventually get destroyed. | 153 | * Test that a surface whose client fails to comply with a close request will eventually get destroyed. |
2009 | 148 | */ | 154 | */ |
2011 | 149 | TEST_F(MirSurfaceTest, failedSurfaceCloseEventualyDestroysSurface) | 155 | TEST_F(MirSurfaceTest, failedSurfaceCloseEventuallyDestroysSurface) |
2012 | 150 | { | 156 | { |
2013 | 151 | const pid_t pid = 1234; | ||
2014 | 152 | const char appId[] = "test-app"; | ||
2015 | 153 | |||
2016 | 154 | int argc = 0; | 157 | int argc = 0; |
2017 | 155 | char* argv[0]; | 158 | char* argv[0]; |
2018 | 156 | QCoreApplication qtApp(argc, argv); // app for deleteLater event | 159 | QCoreApplication qtApp(argc, argv); // app for deleteLater event |
2019 | 157 | 160 | ||
2024 | 158 | auto fakeSession = new FakeSession(); | 161 | auto const mockSession = std::make_shared<NiceMock<ms::MockSession>>(); |
2021 | 159 | auto mirSession = std::make_shared<mir::scene::MockSession>(appId, pid); | ||
2022 | 160 | fakeSession->setSession(mirSession); | ||
2023 | 161 | |||
2025 | 162 | auto mockSurface = std::make_shared<NiceMock<ms::MockSurface>>(); | 162 | auto mockSurface = std::make_shared<NiceMock<ms::MockSurface>>(); |
2028 | 163 | 163 | miral::Window mockWindow(mockSession, mockSurface); | |
2029 | 164 | MirSurface *surface = new MirSurface(mockSurface, fakeSession, &m_mockShell, nullptr, CreationHints()); | 164 | miral::WindowInfo mockWindowInfo(mockWindow, {}); |
2030 | 165 | QScopedPointer<WindowInfo> windowInfo(new WindowInfo(mockWindowInfo)); | ||
2031 | 166 | auto surfaceObserver = std::make_shared<SurfaceObserver>(); | ||
2032 | 167 | |||
2033 | 168 | MirSurface surface(mockWindowInfo, nullptr, surfaceObserver); | ||
2034 | 169 | |||
2035 | 165 | bool surfaceDeleted = false; | 170 | bool surfaceDeleted = false; |
2037 | 166 | QObject::connect(surface, &QObject::destroyed, surface, [&surfaceDeleted](){ surfaceDeleted = true; }); | 171 | QObject::connect(&surface, &QObject::destroyed, &surface, [&surfaceDeleted](){ surfaceDeleted = true; }); |
2038 | 167 | 172 | ||
2039 | 168 | QSharedPointer<FakeTimeSource> fakeTimeSource(new FakeTimeSource); | 173 | QSharedPointer<FakeTimeSource> fakeTimeSource(new FakeTimeSource); |
2040 | 169 | QPointer<FakeTimer> fakeTimer(new FakeTimer(fakeTimeSource)); | 174 | QPointer<FakeTimer> fakeTimer(new FakeTimer(fakeTimeSource)); |
2042 | 170 | surface->setCloseTimer(fakeTimer.data()); // surface takes ownership of the timer | 175 | surface.setCloseTimer(fakeTimer.data()); // surface takes ownership of the timer |
2043 | 171 | 176 | ||
2044 | 172 | qintptr view = (qintptr)1; | 177 | qintptr view = (qintptr)1; |
2046 | 173 | surface->registerView(view); | 178 | surface.registerView(view); |
2047 | 174 | 179 | ||
2049 | 175 | EXPECT_CALL(*mirSession.get(), destroy_surface(An<const std::weak_ptr<mir::scene::Surface> &>())) | 180 | EXPECT_CALL(*mockSession.get(), destroy_surface(An<const std::weak_ptr<ms::Surface> &>())) |
2050 | 176 | .Times(1); | 181 | .Times(1); |
2051 | 177 | 182 | ||
2053 | 178 | surface->close(); | 183 | surface.close(); |
2054 | 179 | 184 | ||
2055 | 180 | if (fakeTimer->isRunning()) { | 185 | if (fakeTimer->isRunning()) { |
2056 | 181 | // Simulate that closeTimer has timed out. | 186 | // Simulate that closeTimer has timed out. |
2057 | @@ -184,8 +189,6 @@ | |||
2058 | 184 | } | 189 | } |
2059 | 185 | 190 | ||
2060 | 186 | // clean up | 191 | // clean up |
2065 | 187 | surface->setLive(false); | 192 | surface.setLive(false); |
2066 | 188 | surface->unregisterView(view); | 193 | surface.unregisterView(view); |
2063 | 189 | delete surface; | ||
2064 | 190 | delete fakeSession; | ||
2067 | 191 | } | 194 | } |
With Vivid+Overlay/clang I need:
#pragma clang diagnostic push OPERATORS_ FOR_FLAGS( DirtyStates)
#pragma clang diagnostic ignored "-Wunused-function"
Q_DECLARE_
#pragma clang diagnostic pop