Mir

Merge lp:~alan-griffiths/mir/test-without-ABI-bump-libmirserver into lp:mir

Proposed by Alan Griffiths
Status: Rejected
Rejected by: Alan Griffiths
Proposed branch: lp:~alan-griffiths/mir/test-without-ABI-bump-libmirserver
Merge into: lp:mir
Diff against target: 234 lines (+109/-1)
10 files modified
include/server/mir/scene/surface_coordinator.h (+4/-0)
src/server/scene/surface_controller.cpp (+6/-0)
src/server/scene/surface_controller.h (+2/-0)
src/server/scene/surface_stack.cpp (+37/-0)
src/server/scene/surface_stack.h (+2/-0)
src/server/scene/surface_stack_model.h (+5/-1)
tests/include/mir_test_doubles/mock_surface_coordinator.h (+1/-0)
tests/unit-tests/scene/test_application_session.cpp (+4/-0)
tests/unit-tests/scene/test_surface_controller.cpp (+1/-0)
tests/unit-tests/scene/test_surface_stack.cpp (+47/-0)
To merge this branch: bzr merge lp:~alan-griffiths/mir/test-without-ABI-bump-libmirserver
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Disapprove
Review via email: mp+250179@code.launchpad.net

Commit message

*Test MP*

It looks as though bumping the mir server ABI breaks the maki when installed. This is just the other changes to see what happens.

Description of the change

*Test MP*

It looks as though bumping the mir server ABI breaks the maki when installed. This is just the other changes to see what happens.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Not intended to land

review: Disapprove
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

2328. By Alan Griffiths

Not the libmirserver ABI bump

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/server/mir/scene/surface_coordinator.h'
2--- include/server/mir/scene/surface_coordinator.h 2015-01-21 07:34:50 +0000
3+++ include/server/mir/scene/surface_coordinator.h 2015-02-18 17:45:38 +0000
4@@ -24,6 +24,7 @@
5
6 namespace mir
7 {
8+namespace geometry { class Point; }
9 namespace scene
10 {
11 class Surface;
12@@ -41,6 +42,9 @@
13 virtual void raise(std::weak_ptr<Surface> const& surface) = 0;
14
15 virtual void remove_surface(std::weak_ptr<Surface> const& surface) = 0;
16+
17+ virtual auto surface_at(geometry::Point) const -> std::shared_ptr<Surface> = 0;
18+
19 protected:
20 SurfaceCoordinator() = default;
21 virtual ~SurfaceCoordinator() = default;
22
23=== modified file 'src/server/scene/surface_controller.cpp'
24--- src/server/scene/surface_controller.cpp 2015-02-13 06:12:34 +0000
25+++ src/server/scene/surface_controller.cpp 2015-02-18 17:45:38 +0000
26@@ -49,3 +49,9 @@
27 {
28 surface_stack->raise(surface);
29 }
30+
31+auto ms::SurfaceController::surface_at(geometry::Point cursor) const
32+-> std::shared_ptr<Surface>
33+{
34+ return surface_stack->surface_at(cursor);
35+}
36
37=== modified file 'src/server/scene/surface_controller.h'
38--- src/server/scene/surface_controller.h 2015-02-13 06:12:34 +0000
39+++ src/server/scene/surface_controller.h 2015-02-18 17:45:38 +0000
40@@ -46,6 +46,8 @@
41
42 void raise(std::weak_ptr<Surface> const& surface) override;
43
44+ auto surface_at(geometry::Point) const -> std::shared_ptr<Surface> override;
45+
46 private:
47 std::shared_ptr<SurfaceFactory> const surface_factory;
48 std::shared_ptr<SurfaceStackModel> const surface_stack;
49
50=== modified file 'src/server/scene/surface_stack.cpp'
51--- src/server/scene/surface_stack.cpp 2015-02-13 06:12:34 +0000
52+++ src/server/scene/surface_stack.cpp 2015-02-18 17:45:38 +0000
53@@ -277,6 +277,43 @@
54 // TODO: error logging when surface not found
55 }
56
57+namespace
58+{
59+template <typename Container>
60+struct InReverse {
61+ Container& container;
62+ auto begin() -> decltype(container.rbegin()) { return container.rbegin(); }
63+ auto end() -> decltype(container.rend()) { return container.rend(); }
64+};
65+
66+template <typename Container>
67+InReverse<Container> in_reverse(Container& container) { return InReverse<Container>{container}; }
68+}
69+
70+auto ms::SurfaceStack::surface_at(geometry::Point cursor) const
71+-> std::shared_ptr<Surface>
72+{
73+ std::lock_guard<decltype(guard)> lg(guard);
74+ for (auto &layer : in_reverse(layers_by_depth))
75+ {
76+ for (auto const& surface : in_reverse(layer.second))
77+ {
78+ // TODO this implementation is probably simplistic as the client area may,
79+ // TODO in principle, have transparency. I don't think we have a mechanism
80+ // TODO to track this yet.
81+ // TODO Daniel has suggested using "surface->input_area_contains(cursor)"
82+ // TODO here but has also (in the code that uses this) pointed out that
83+ // TODO "the input area the client has designated is probably irrelevant.
84+ // TODO Instead you want to consider the whole surface rectangle..."
85+ if (surface->visible() &&
86+ geom::Rectangle{surface->top_left(), surface->size()}.contains(cursor))
87+ return surface;
88+ }
89+ }
90+
91+ return {};
92+}
93+
94 void ms::SurfaceStack::for_each(std::function<void(std::shared_ptr<mi::Surface> const&)> const& callback)
95 {
96 std::lock_guard<decltype(guard)> lg(guard);
97
98=== modified file 'src/server/scene/surface_stack.h'
99--- src/server/scene/surface_stack.h 2015-01-21 09:51:37 +0000
100+++ src/server/scene/surface_stack.h 2015-02-18 17:45:38 +0000
101@@ -89,6 +89,8 @@
102 DepthId depth,
103 input::InputReceptionMode input_mode) override;
104
105+ auto surface_at(geometry::Point) const -> std::shared_ptr<Surface> override;
106+
107 void add_observer(std::shared_ptr<Observer> const& observer) override;
108 void remove_observer(std::weak_ptr<Observer> const& observer) override;
109
110
111=== modified file 'src/server/scene/surface_stack_model.h'
112--- src/server/scene/surface_stack_model.h 2015-01-21 07:34:50 +0000
113+++ src/server/scene/surface_stack_model.h 2015-02-18 17:45:38 +0000
114@@ -27,6 +27,8 @@
115
116 namespace mir
117 {
118+namespace geometry { class Point; }
119+
120 namespace scene
121 {
122 class Surface;
123@@ -34,7 +36,7 @@
124 class SurfaceStackModel
125 {
126 public:
127- virtual ~SurfaceStackModel() {}
128+ virtual ~SurfaceStackModel() = default;
129
130 virtual void add_surface(
131 std::shared_ptr<Surface> const& surface,
132@@ -45,6 +47,8 @@
133
134 virtual void raise(std::weak_ptr<Surface> const& surface) = 0;
135
136+ virtual auto surface_at(geometry::Point) const -> std::shared_ptr<Surface> = 0;
137+
138 protected:
139 SurfaceStackModel() = default;
140 SurfaceStackModel(const SurfaceStackModel&) = delete;
141
142=== modified file 'tests/include/mir_test_doubles/mock_surface_coordinator.h'
143--- tests/include/mir_test_doubles/mock_surface_coordinator.h 2015-02-13 06:12:34 +0000
144+++ tests/include/mir_test_doubles/mock_surface_coordinator.h 2015-02-18 17:45:38 +0000
145@@ -41,6 +41,7 @@
146 scene::Session* session));
147
148 MOCK_METHOD1(remove_surface, void(std::weak_ptr<scene::Surface> const& surface));
149+ MOCK_CONST_METHOD1(surface_at, std::shared_ptr<scene::Surface>(geometry::Point));
150 };
151
152 }
153
154=== modified file 'tests/unit-tests/scene/test_application_session.cpp'
155--- tests/unit-tests/scene/test_application_session.cpp 2015-02-13 06:12:34 +0000
156+++ tests/unit-tests/scene/test_application_session.cpp 2015-02-18 17:45:38 +0000
157@@ -97,6 +97,10 @@
158 void remove_surface(std::weak_ptr<ms::Surface> const&) override
159 {
160 }
161+ auto surface_at(mir::geometry::Point) const -> std::shared_ptr<ms::Surface>
162+ {
163+ return std::shared_ptr<ms::Surface>{};
164+ }
165 };
166
167 struct ApplicationSession : public testing::Test
168
169=== modified file 'tests/unit-tests/scene/test_surface_controller.cpp'
170--- tests/unit-tests/scene/test_surface_controller.cpp 2015-02-13 06:12:34 +0000
171+++ tests/unit-tests/scene/test_surface_controller.cpp 2015-02-18 17:45:38 +0000
172@@ -52,6 +52,7 @@
173 mir::input::InputReceptionMode input_mode));
174 MOCK_METHOD1(remove_surface, void(std::weak_ptr<ms::Surface> const&));
175 MOCK_METHOD1(raise, void(std::weak_ptr<ms::Surface> const&));
176+ MOCK_CONST_METHOD1(surface_at, std::shared_ptr<ms::Surface>(geom::Point));
177 };
178
179 struct SurfaceController : testing::Test
180
181=== modified file 'tests/unit-tests/scene/test_surface_stack.cpp'
182--- tests/unit-tests/scene/test_surface_stack.cpp 2015-02-13 06:12:34 +0000
183+++ tests/unit-tests/scene/test_surface_stack.cpp 2015-02-18 17:45:38 +0000
184@@ -882,3 +882,50 @@
185 stack.for_each(count_exposed_surfaces);
186 EXPECT_THAT(num_exposed_surfaces, Eq(1));
187 }
188+
189+using namespace ::testing;
190+
191+TEST_F(SurfaceStack, returns_top_surface_under_cursor)
192+{
193+ geom::Point const cursor_over_all {100, 100};
194+ geom::Point const cursor_over_12 {200, 100};
195+ geom::Point const cursor_over_1 {600, 600};
196+ geom::Point const cursor_over_none{999, 999};
197+
198+ stack.add_surface(stub_surface1, default_params.depth, default_params.input_mode);
199+ stack.add_surface(stub_surface2, default_params.depth, default_params.input_mode);
200+ stack.add_surface(stub_surface3, default_params.depth, default_params.input_mode);
201+
202+ stub_surface1->resize({900, 900});
203+ stub_surface2->resize({500, 200});
204+ stub_surface3->resize({200, 500});
205+
206+ EXPECT_THAT(stack.surface_at(cursor_over_all), Eq(stub_surface3));
207+ EXPECT_THAT(stack.surface_at(cursor_over_12), Eq(stub_surface2));
208+ EXPECT_THAT(stack.surface_at(cursor_over_1), Eq(stub_surface1));
209+ EXPECT_THAT(stack.surface_at(cursor_over_none).get(), IsNull());
210+}
211+
212+TEST_F(SurfaceStack, returns_top_visible_surface_under_cursor)
213+{
214+ geom::Point const cursor_over_all {100, 100};
215+ geom::Point const cursor_over_12 {200, 100};
216+ geom::Point const cursor_over_1 {600, 600};
217+ geom::Point const cursor_over_none{999, 999};
218+
219+ stack.add_surface(stub_surface1, default_params.depth, default_params.input_mode);
220+ stack.add_surface(stub_surface2, default_params.depth, default_params.input_mode);
221+ stack.add_surface(stub_surface3, default_params.depth, default_params.input_mode);
222+ stack.add_surface(invisible_stub_surface, default_params.depth, default_params.input_mode);
223+
224+ stub_surface1->resize({900, 900});
225+ stub_surface2->resize({500, 200});
226+ stub_surface3->resize({200, 500});
227+ invisible_stub_surface->resize({999, 999});
228+
229+ EXPECT_THAT(stack.surface_at(cursor_over_all), Eq(stub_surface3));
230+ EXPECT_THAT(stack.surface_at(cursor_over_12), Eq(stub_surface2));
231+ EXPECT_THAT(stack.surface_at(cursor_over_1), Eq(stub_surface1));
232+ EXPECT_THAT(stack.surface_at(cursor_over_none).get(), IsNull());
233+}
234+

Subscribers

People subscribed via source and target branches