Merge lp:~andreas-pokorny/mir/override-orientation into lp:mir/0.13
- override-orientation
- Merge into 0.13
Proposed by
Andreas Pokorny
Status: | Work in progress |
---|---|
Proposed branch: | lp:~andreas-pokorny/mir/override-orientation |
Merge into: | lp:mir/0.13 |
Diff against target: |
1333 lines (+523/-78) 35 files modified
3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp (+1/-1) 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp (+29/-34) debian/changelog (+11/-0) include/common/mir/geometry/overrides.h (+92/-0) include/platform/mir/graphics/cursor.h (+2/-0) include/server/mir/input/input_region.h (+6/-0) include/server/mir/server.h (+4/-1) src/include/server/mir/display_changer.h (+1/-0) src/platforms/mesa/server/cursor.cpp (+14/-1) src/platforms/mesa/server/cursor.h (+3/-0) src/server/graphics/default_configuration.cpp (+3/-1) src/server/graphics/nested/cursor.cpp (+5/-0) src/server/graphics/nested/cursor.h (+1/-0) src/server/graphics/software_cursor.cpp (+135/-3) src/server/graphics/software_cursor.h (+11/-0) src/server/input/android/android_input_reader_policy.cpp (+16/-2) src/server/input/android/android_pointer_controller.cpp (+20/-0) src/server/input/android/android_pointer_controller.h (+1/-0) src/server/input/default_configuration.cpp (+3/-1) src/server/input/display_input_region.cpp (+45/-27) src/server/input/display_input_region.h (+13/-3) src/server/scene/mediating_display_changer.cpp (+17/-0) src/server/scene/mediating_display_changer.h (+5/-0) src/server/server.cpp (+1/-0) src/server/symbols.map (+2/-0) tests/acceptance-tests/throwback/test_client_cursor_api.cpp (+1/-0) tests/include/mir_test_doubles/mock_input_region.h (+2/-0) tests/include/mir_test_doubles/stub_cursor.h (+1/-0) tests/include/mir_test_doubles/stub_display_changer.h (+52/-0) tests/mir_test_doubles/fake_event_hub.cpp (+3/-1) tests/mir_test_framework/stubbed_server_configuration.cpp (+1/-0) tests/unit-tests/graphics/test_software_cursor.cpp (+13/-0) tests/unit-tests/input/android/test_android_pointer_controller.cpp (+3/-1) tests/unit-tests/input/test_cursor_controller.cpp (+1/-0) tests/unit-tests/input/test_display_input_region.cpp (+5/-2) |
To merge this branch: | bzr merge lp:~andreas-pokorny/mir/override-orientation |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+263638@code.launchpad.net |
Commit message
Overrides the configured orientation in mir for moving and displaying the cursor
Description of the change
Updated orientation override for mir-0.13
To post a comment you must log in.
- 2291. By Andreas Pokorny
-
changelog entry
- 2292. By Andreas Pokorny
-
guessing a better version
Unmerged revisions
- 2292. By Andreas Pokorny
-
guessing a better version
- 2291. By Andreas Pokorny
-
changelog entry
- 2290. By Andreas Pokorny
-
switch to mir 0.13.0
- 2289. By Andreas Pokorny
-
add orientation override
- 2288. By Andreas Pokorny
-
merge mir-0.12 and pointer acceleration enablement
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp' |
2 | --- 3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp 2015-03-31 02:35:42 +0000 |
3 | +++ 3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp 2015-07-02 11:48:27 +0000 |
4 | @@ -70,7 +70,7 @@ |
5 | |
6 | float vx, vy; |
7 | float scale = mParameters.scale; |
8 | - if (mVelocityTracker.getVelocity(0, &vx, &vy)) { |
9 | + if (mVelocityTracker.getVelocity(1, &vx, &vy)) { |
10 | float speed = hypotf(vx, vy) * scale; |
11 | if (speed >= mParameters.highThreshold) { |
12 | // Apply full acceleration above the high speed threshold. |
13 | |
14 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp' |
15 | --- 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp 2015-03-31 02:35:42 +0000 |
16 | +++ 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp 2015-07-02 11:48:27 +0000 |
17 | @@ -65,36 +65,31 @@ |
18 | |
19 | #if DEBUG_STRATEGY || DEBUG_VELOCITY |
20 | static String8 vectorToString(const float* a, uint32_t m) { |
21 | - String8 str; |
22 | - str.append("["); |
23 | + std::stringstream str; |
24 | + str << '['; |
25 | while (m--) { |
26 | - str.appendFormat(" %f", *(a++)); |
27 | - if (m) { |
28 | - str.append(","); |
29 | - } |
30 | + str << *a++; |
31 | + if (m) |
32 | + str << ','; |
33 | } |
34 | - str.append(" ]"); |
35 | - return str; |
36 | + str << ']'; |
37 | + return str.str(); |
38 | } |
39 | |
40 | static String8 matrixToString(const float* a, uint32_t m, uint32_t n, bool rowMajor) { |
41 | - String8 str; |
42 | - str.append("["); |
43 | + std::stringstream str; |
44 | + str << '['; |
45 | for (size_t i = 0; i < m; i++) { |
46 | - if (i) { |
47 | - str.append(","); |
48 | - } |
49 | - str.append(" ["); |
50 | + if (i) str << ','; |
51 | + str << " ["; |
52 | for (size_t j = 0; j < n; j++) { |
53 | - if (j) { |
54 | - str.append(","); |
55 | - } |
56 | - str.appendFormat(" %f", a[rowMajor ? i * n + j : j * m + i]); |
57 | + if (j) str << ','; |
58 | + str << ' ' << a[rowMajor ? i * n + j : j * m + i]; |
59 | } |
60 | - str.append(" ]"); |
61 | + str << " ]"; |
62 | } |
63 | - str.append(" ]"); |
64 | - return str; |
65 | + str << " ]"; |
66 | + return str.str(); |
67 | } |
68 | #endif |
69 | |
70 | @@ -249,11 +244,11 @@ |
71 | "estimator (degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f)", |
72 | id, positions[index].x, positions[index].y, |
73 | int(estimator.degree), |
74 | - vectorToString(estimator.xCoeff, estimator.degree + 1).string(), |
75 | - vectorToString(estimator.yCoeff, estimator.degree + 1).string(), |
76 | + vectorToString(estimator.xCoeff, estimator.degree + 1).c_str(), |
77 | + vectorToString(estimator.yCoeff, estimator.degree + 1).c_str(), |
78 | estimator.confidence); |
79 | ++index; |
80 | - } |
81 | + }); |
82 | #endif |
83 | } |
84 | |
85 | @@ -436,8 +431,8 @@ |
86 | const float* w, uint32_t m, uint32_t n, float* outB, float* outDet) { |
87 | #if DEBUG_STRATEGY |
88 | ALOGD("solveLeastSquares: m=%d, n=%d, x=%s, y=%s, w=%s", int(m), int(n), |
89 | - vectorToString(x, m).string(), vectorToString(y, m).string(), |
90 | - vectorToString(w, m).string()); |
91 | + vectorToString(x, m).c_str(), vectorToString(y, m).c_str(), |
92 | + vectorToString(w, m).c_str()); |
93 | #endif |
94 | |
95 | // Expand the X vector to a matrix A, pre-multiplied by the weights. |
96 | @@ -449,7 +444,7 @@ |
97 | } |
98 | } |
99 | #if DEBUG_STRATEGY |
100 | - ALOGD(" - a=%s", matrixToString(&a[0][0], m, n, false /*rowMajor*/).string()); |
101 | + ALOGD(" - a=%s", matrixToString(&a[0][0], m, n, false /*rowMajor*/).c_str()); |
102 | #endif |
103 | |
104 | // Apply the Gram-Schmidt process to A to obtain its QR decomposition. |
105 | @@ -484,8 +479,8 @@ |
106 | } |
107 | } |
108 | #if DEBUG_STRATEGY |
109 | - ALOGD(" - q=%s", matrixToString(&q[0][0], m, n, false /*rowMajor*/).string()); |
110 | - ALOGD(" - r=%s", matrixToString(&r[0][0], n, n, true /*rowMajor*/).string()); |
111 | + ALOGD(" - q=%s", matrixToString(&q[0][0], m, n, false /*rowMajor*/).c_str()); |
112 | + ALOGD(" - r=%s", matrixToString(&r[0][0], n, n, true /*rowMajor*/).c_str()); |
113 | |
114 | // calculate QR, if we factored A correctly then QR should equal A |
115 | float qr[n][m]; |
116 | @@ -497,7 +492,7 @@ |
117 | } |
118 | } |
119 | } |
120 | - ALOGD(" - qr=%s", matrixToString(&qr[0][0], m, n, false /*rowMajor*/).string()); |
121 | + ALOGD(" - qr=%s", matrixToString(&qr[0][0], m, n, false /*rowMajor*/).c_str()); |
122 | #endif |
123 | |
124 | // Solve R B = Qt W Y to find B. This is easy because R is upper triangular. |
125 | @@ -514,7 +509,7 @@ |
126 | outB[i] /= r[i][i]; |
127 | } |
128 | #if DEBUG_STRATEGY |
129 | - ALOGD(" - b=%s", vectorToString(outB, n).string()); |
130 | + ALOGD(" - b=%s", vectorToString(outB, n).c_str()); |
131 | #endif |
132 | |
133 | // Calculate the coefficient of determination as 1 - (SSerr / SStot) where |
134 | @@ -598,10 +593,10 @@ |
135 | outEstimator->degree = degree; |
136 | outEstimator->confidence = xdet * ydet; |
137 | #if DEBUG_STRATEGY |
138 | - ALOGD("estimate: degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f", |
139 | + ALOGD("estimate : degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f", |
140 | int(outEstimator->degree), |
141 | - vectorToString(outEstimator->xCoeff, n).string(), |
142 | - vectorToString(outEstimator->yCoeff, n).string(), |
143 | + vectorToString(outEstimator->xCoeff, n).c_str(), |
144 | + vectorToString(outEstimator->yCoeff, n).c_str(), |
145 | outEstimator->confidence); |
146 | #endif |
147 | return true; |
148 | |
149 | === modified file 'debian/changelog' |
150 | --- debian/changelog 2015-06-17 20:02:15 +0000 |
151 | +++ debian/changelog 2015-07-02 11:48:27 +0000 |
152 | @@ -1,3 +1,14 @@ |
153 | +mir (0.13.3+15.04.20150617-0ubuntu1) UNRELEASED; urgency=medium |
154 | + |
155 | + * Orientation override and pointer acceleration |
156 | + - Improvements: |
157 | + . activates pointer acceleration path in android input stack |
158 | + - Features: |
159 | + . adds an interface to override the orienation of displays |
160 | + . rotates the cursor according to the changed orientation |
161 | + |
162 | + -- Andreas Pokorny <andreas.pokorny@canonical.com> Thu, 02 Jul 2015 13:33:06 +0200 |
163 | + |
164 | mir (0.13.3+15.10.20150617-0ubuntu1) wily; urgency=medium |
165 | |
166 | [ Alberto Aguirre ] |
167 | |
168 | === added file 'include/common/mir/geometry/overrides.h' |
169 | --- include/common/mir/geometry/overrides.h 1970-01-01 00:00:00 +0000 |
170 | +++ include/common/mir/geometry/overrides.h 2015-07-02 11:48:27 +0000 |
171 | @@ -0,0 +1,92 @@ |
172 | +/* |
173 | + * Copyright © 2015 Canonical Ltd. |
174 | + * |
175 | + * This program is free software: you can redistribute it and/or modify it |
176 | + * under the terms of the GNU Lesser General Public License version 3, |
177 | + * as published by the Free Software Foundation. |
178 | + * |
179 | + * This program is distributed in the hope that it will be useful, |
180 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
181 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
182 | + * GNU Lesser General Public License for more details. |
183 | + * |
184 | + * You should have received a copy of the GNU Lesser General Public License |
185 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
186 | + * |
187 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
188 | + */ |
189 | + |
190 | +#ifndef MIR_GEOMETRY_OVERRIDES_H_ |
191 | +#define MIR_GEOMETRY_OVERRIDES_H_ |
192 | + |
193 | +#include "mir_toolkit/common.h" |
194 | + |
195 | +#include "mir/geometry/rectangle.h" |
196 | + |
197 | +#include <map> |
198 | + |
199 | +namespace mir |
200 | +{ |
201 | +namespace geometry |
202 | +{ |
203 | +struct Overrides |
204 | +{ |
205 | + inline MirOrientation get_orientation(uint32_t display_id, MirOrientation original) |
206 | + { |
207 | + if (end(overrides) == overrides.find(display_id)) |
208 | + return original; |
209 | + return overrides[display_id]; |
210 | + } |
211 | + inline Rectangle transform_rectangle(uint32_t display_id, Rectangle const& rect, MirOrientation original) |
212 | + { |
213 | + if (end(overrides) == overrides.find(display_id)) |
214 | + return rect; |
215 | + if (original == overrides[display_id]) |
216 | + return rect; |
217 | + |
218 | + switch(original) |
219 | + { |
220 | + case mir_orientation_left: |
221 | + case mir_orientation_right: |
222 | + switch(overrides[display_id]) |
223 | + { |
224 | + case mir_orientation_left: |
225 | + case mir_orientation_right: |
226 | + default: |
227 | + return rect; |
228 | + case mir_orientation_inverted: |
229 | + case mir_orientation_normal: |
230 | + return swap_width_height(rect); |
231 | + } |
232 | + case mir_orientation_normal: |
233 | + case mir_orientation_inverted: |
234 | + switch(overrides[display_id]) |
235 | + { |
236 | + case mir_orientation_left: |
237 | + case mir_orientation_right: |
238 | + return swap_width_height(rect); |
239 | + case mir_orientation_inverted: |
240 | + case mir_orientation_normal: |
241 | + default: |
242 | + return rect; |
243 | + } |
244 | + default: |
245 | + return rect; |
246 | + } |
247 | + } |
248 | + |
249 | + inline Rectangle swap_width_height(Rectangle rect) |
250 | + { |
251 | + return Rectangle{rect.top_left, Size{rect.size.height.as_int(), rect.size.width.as_int()}}; |
252 | + } |
253 | + |
254 | + inline void add_override(uint32_t display, MirOrientation orientation) |
255 | + { |
256 | + overrides[display] = orientation; |
257 | + } |
258 | + std::map<uint32_t, MirOrientation> overrides; |
259 | +}; |
260 | +} |
261 | +} |
262 | + |
263 | +#endif |
264 | |
265 | === modified file 'include/platform/mir/graphics/cursor.h' |
266 | --- include/platform/mir/graphics/cursor.h 2015-03-31 02:35:42 +0000 |
267 | +++ include/platform/mir/graphics/cursor.h 2015-07-02 11:48:27 +0000 |
268 | @@ -23,6 +23,7 @@ |
269 | #include "mir/geometry/size.h" |
270 | #include "mir/geometry/point.h" |
271 | |
272 | +#include "mir_toolkit/common.h" |
273 | #include <memory> |
274 | |
275 | namespace mir |
276 | @@ -38,6 +39,7 @@ |
277 | virtual void hide() = 0; |
278 | |
279 | virtual void move_to(geometry::Point position) = 0; |
280 | + virtual void override_orientation(uint32_t screen, MirOrientation orientation) = 0; |
281 | |
282 | protected: |
283 | Cursor() = default; |
284 | |
285 | === renamed file 'src/include/server/mir/input/input_region.h' => 'include/server/mir/input/input_region.h' |
286 | --- src/include/server/mir/input/input_region.h 2015-01-21 07:34:50 +0000 |
287 | +++ include/server/mir/input/input_region.h 2015-07-02 11:48:27 +0000 |
288 | @@ -19,6 +19,9 @@ |
289 | #ifndef MIR_INPUT_INPUT_REGION_H_ |
290 | #define MIR_INPUT_INPUT_REGION_H_ |
291 | |
292 | +#include <mir_toolkit/common.h> |
293 | +#include <cstdint> |
294 | + |
295 | namespace mir |
296 | { |
297 | namespace geometry |
298 | @@ -51,6 +54,9 @@ |
299 | */ |
300 | virtual void confine(geometry::Point& point) = 0; |
301 | |
302 | + virtual void override_orientation(uint32_t display_id, MirOrientation orientation) = 0; |
303 | + virtual MirOrientation get_orientation(geometry::Point const& point) = 0; |
304 | + |
305 | protected: |
306 | InputRegion() = default; |
307 | InputRegion(InputRegion const&) = delete; |
308 | |
309 | === modified file 'include/server/mir/server.h' |
310 | --- include/server/mir/server.h 2015-04-09 06:20:31 +0000 |
311 | +++ include/server/mir/server.h 2015-07-02 11:48:27 +0000 |
312 | @@ -31,7 +31,7 @@ |
313 | namespace compositor { class Compositor; class DisplayBufferCompositorFactory; } |
314 | namespace frontend { class SessionAuthorizer; class Session; class SessionMediatorReport; } |
315 | namespace graphics { class Cursor; class Platform; class Display; class GLConfig; class DisplayConfigurationPolicy; } |
316 | -namespace input { class CompositeEventFilter; class InputDispatcher; class CursorListener; class TouchVisualizer; class InputDeviceHub;} |
317 | +namespace input { class InputRegion; class CompositeEventFilter; class InputDispatcher; class CursorListener; class TouchVisualizer; class InputDeviceHub;} |
318 | namespace logging { class Logger; } |
319 | namespace options { class Option; } |
320 | namespace shell |
321 | @@ -300,6 +300,9 @@ |
322 | /// \return the input targeter. |
323 | auto the_input_targeter() const -> std::shared_ptr<shell::InputTargeter>; |
324 | |
325 | + /// Sets an override functor for creating the input region. |
326 | + auto the_input_region() const -> std::shared_ptr<input::InputRegion>; |
327 | + |
328 | /// \return the logger. |
329 | auto the_logger() const -> std::shared_ptr<logging::Logger>; |
330 | |
331 | |
332 | === modified file 'src/include/server/mir/display_changer.h' |
333 | --- src/include/server/mir/display_changer.h 2015-01-21 07:34:50 +0000 |
334 | +++ src/include/server/mir/display_changer.h 2015-07-02 11:48:27 +0000 |
335 | @@ -41,6 +41,7 @@ |
336 | |
337 | virtual void pause_display_config_processing() = 0; |
338 | virtual void resume_display_config_processing() = 0; |
339 | + virtual void register_change_callback(std::function<void(graphics::DisplayConfiguration const&)> const& change_callback) = 0; |
340 | |
341 | protected: |
342 | DisplayChanger() = default; |
343 | |
344 | === modified file 'src/platforms/mesa/server/cursor.cpp' |
345 | --- src/platforms/mesa/server/cursor.cpp 2015-04-30 11:36:36 +0000 |
346 | +++ src/platforms/mesa/server/cursor.cpp 2015-07-02 11:48:27 +0000 |
347 | @@ -262,11 +262,17 @@ |
348 | if (!visible) |
349 | return; |
350 | |
351 | + uint32_t override_id = 0; |
352 | + |
353 | for_each_used_output([&](KMSOutput& output, geom::Rectangle const& output_rect, MirOrientation orientation) |
354 | { |
355 | if (output_rect.contains(position)) |
356 | { |
357 | - auto dp = transform(output_rect, position - output_rect.top_left, orientation); |
358 | + MirOrientation overridden = orientation; |
359 | + if (end(overrides) != overrides.find(override_id)) |
360 | + overridden = overrides[override_id]; |
361 | + |
362 | + auto dp = transform(output_rect, position - output_rect.top_left, overridden); |
363 | |
364 | // It's a little strange that we implement hotspot this way as there is |
365 | // drmModeSetCursor2 with hotspot support. However it appears to not actually |
366 | @@ -285,5 +291,12 @@ |
367 | output.clear_cursor(); |
368 | } |
369 | } |
370 | + ++override_id; |
371 | }); |
372 | } |
373 | + |
374 | +void mgm::Cursor::override_orientation(uint32_t screen, MirOrientation orientation) |
375 | +{ |
376 | + // there is no cache invalidation in this hack |
377 | + overrides[screen] = orientation; |
378 | +} |
379 | |
380 | === modified file 'src/platforms/mesa/server/cursor.h' |
381 | --- src/platforms/mesa/server/cursor.h 2015-03-31 02:35:42 +0000 |
382 | +++ src/platforms/mesa/server/cursor.h 2015-07-02 11:48:27 +0000 |
383 | @@ -28,6 +28,7 @@ |
384 | |
385 | #include <gbm.h> |
386 | |
387 | +#include <map> |
388 | #include <memory> |
389 | #include <mutex> |
390 | |
391 | @@ -76,6 +77,7 @@ |
392 | void show() override; |
393 | void show(CursorImage const& cursor_image) override; |
394 | void hide() override; |
395 | + void override_orientation(uint32_t screen, MirOrientation) override; |
396 | |
397 | void move_to(geometry::Point position) override; |
398 | |
399 | @@ -113,6 +115,7 @@ |
400 | uint32_t buffer_height; |
401 | |
402 | std::shared_ptr<CurrentConfiguration> const current_configuration; |
403 | + std::map<uint32_t, MirOrientation> overrides; |
404 | }; |
405 | } |
406 | } |
407 | |
408 | === modified file 'src/server/graphics/default_configuration.cpp' |
409 | --- src/server/graphics/default_configuration.cpp 2015-04-23 20:17:52 +0000 |
410 | +++ src/server/graphics/default_configuration.cpp 2015-07-02 11:48:27 +0000 |
411 | @@ -30,6 +30,7 @@ |
412 | #include "mir/graphics/gl_config.h" |
413 | #include "mir/graphics/platform.h" |
414 | #include "mir/graphics/cursor.h" |
415 | +#include "mir/graphics/display.h" |
416 | #include "mir/graphics/platform_probe.h" |
417 | #include "program_factory.h" |
418 | |
419 | @@ -172,7 +173,6 @@ |
420 | { |
421 | if (the_options()->is_set(options::host_socket_opt)) |
422 | return std::make_shared<mgn::Cursor>(the_host_connection(), the_default_cursor_image()); |
423 | - |
424 | // We try to create a hardware cursor, if this fails we use a software cursor |
425 | auto hardware_cursor = the_display()->create_hardware_cursor(the_default_cursor_image()); |
426 | if (hardware_cursor) |
427 | @@ -185,6 +185,8 @@ |
428 | mir::log_info("Using software cursor"); |
429 | |
430 | auto const cursor = std::make_shared<mg::SoftwareCursor>( |
431 | + *the_display()->configuration(), // hack |
432 | + the_display_changer(), // hack |
433 | the_buffer_allocator(), |
434 | the_input_scene()); |
435 | |
436 | |
437 | === modified file 'src/server/graphics/nested/cursor.cpp' |
438 | --- src/server/graphics/nested/cursor.cpp 2015-04-13 17:55:51 +0000 |
439 | +++ src/server/graphics/nested/cursor.cpp 2015-07-02 11:48:27 +0000 |
440 | @@ -50,3 +50,8 @@ |
441 | { |
442 | connection->hide_cursor(); |
443 | } |
444 | + |
445 | +void mgn::Cursor::override_orientation(uint32_t, MirOrientation) |
446 | +{ |
447 | + // not going to be used. |
448 | +} |
449 | |
450 | === modified file 'src/server/graphics/nested/cursor.h' |
451 | --- src/server/graphics/nested/cursor.h 2015-04-13 17:43:08 +0000 |
452 | +++ src/server/graphics/nested/cursor.h 2015-07-02 11:48:27 +0000 |
453 | @@ -40,6 +40,7 @@ |
454 | void hide() override; |
455 | |
456 | void move_to(geometry::Point position) override; |
457 | + void override_orientation(uint32_t screen, MirOrientation orientation) override; |
458 | private: |
459 | std::shared_ptr<HostConnection> const connection; |
460 | std::shared_ptr<CursorImage> const default_image; |
461 | |
462 | === modified file 'src/server/graphics/software_cursor.cpp' |
463 | --- src/server/graphics/software_cursor.cpp 2015-04-30 11:36:36 +0000 |
464 | +++ src/server/graphics/software_cursor.cpp 2015-07-02 11:48:27 +0000 |
465 | @@ -21,10 +21,13 @@ |
466 | #include "mir/graphics/graphic_buffer_allocator.h" |
467 | #include "mir/graphics/pixel_format_utils.h" |
468 | #include "mir/graphics/renderable.h" |
469 | +#include "mir/display_changer.h" |
470 | +#include "mir/graphics/display_configuration.h" |
471 | #include "mir/graphics/buffer_properties.h" |
472 | #include "mir/input/scene.h" |
473 | |
474 | #include <mutex> |
475 | +#include <sstream> |
476 | |
477 | namespace mg = mir::graphics; |
478 | namespace mi = mir::input; |
479 | @@ -32,6 +35,47 @@ |
480 | |
481 | namespace |
482 | { |
483 | +void update_rectangles(mg::DisplayConfiguration const& conf, geom::Rectangles& rectangles) |
484 | +{ |
485 | + conf.for_each_output( |
486 | + [&rectangles](mg::DisplayConfigurationOutput const& output) |
487 | + { |
488 | + if (output.power_mode == mir_power_mode_on && |
489 | + output.current_mode_index < output.modes.size()) |
490 | + rectangles.add({output.top_left, output.modes[output.current_mode_index].size}); |
491 | + }); |
492 | +} |
493 | +geom::Point transform(float scale, |
494 | + geom::Displacement const& vector, |
495 | + geom::Displacement const& hotspot, |
496 | + geom::Size const& buffer_size, |
497 | + MirOrientation orientation) |
498 | +{ |
499 | + auto center = geom::Displacement{buffer_size.width.as_int(), buffer_size.height.as_int()}*0.5f; |
500 | + auto scaled_center = scale*center; |
501 | + auto scaled_hotspot = scale*hotspot; |
502 | + |
503 | + switch(orientation) |
504 | + { |
505 | + case mir_orientation_right: |
506 | + scaled_hotspot = geom::Displacement{-scaled_hotspot.dy.as_int(), scaled_hotspot.dx.as_int()}; |
507 | + scaled_center = geom::Displacement{-scaled_center.dy.as_int(), scaled_center.dx.as_int()}; |
508 | + break; |
509 | + case mir_orientation_left: |
510 | + scaled_hotspot = geom::Displacement{scaled_hotspot.dy.as_int(), -scaled_hotspot.dx.as_int()}; |
511 | + scaled_center = geom::Displacement{scaled_center.dy.as_int(), -scaled_center.dx.as_int()}; |
512 | + break; |
513 | + case mir_orientation_inverted: |
514 | + scaled_center = -1.0f*scaled_center; |
515 | + scaled_hotspot = -1.0f*scaled_hotspot; |
516 | + break; |
517 | + default: |
518 | + break; |
519 | + } |
520 | + |
521 | + auto position = vector + scaled_center - scaled_hotspot - center; |
522 | + return {position.dx.as_int(), position.dy.as_int()}; |
523 | +} |
524 | |
525 | MirPixelFormat get_8888_format(std::vector<MirPixelFormat> const& formats) |
526 | { |
527 | @@ -59,6 +103,14 @@ |
528 | : buffer_{buffer}, |
529 | position{position} |
530 | { |
531 | + auto const* env = getenv("GRID_UNIT_PX"); |
532 | + if (env) |
533 | + { |
534 | + std::stringstream gu_parse(std::string{env}); |
535 | + float value; |
536 | + if (gu_parse >> value) |
537 | + scale = value/8.0f; // guess to transform gu into a scale that turns 32x32 icon into a readable size |
538 | + } |
539 | } |
540 | |
541 | mg::Renderable::ID id() const override |
542 | @@ -82,9 +134,47 @@ |
543 | return 1.0; |
544 | } |
545 | |
546 | + |
547 | + float get_scale() |
548 | + { |
549 | + return this->scale; |
550 | + } |
551 | + void set_scale(float scale) |
552 | + { |
553 | + this->scale = scale; |
554 | + } |
555 | + |
556 | + void set_orientation(MirOrientation orientation) |
557 | + { |
558 | + this->orientation = orientation; |
559 | + } |
560 | + |
561 | glm::mat4 transformation() const override |
562 | { |
563 | - return glm::mat4(); |
564 | + switch(orientation) |
565 | + { |
566 | + case mir_orientation_left: |
567 | + return glm::mat4( 0, -scale, 0, 0, |
568 | + scale, 0, 0, 0, |
569 | + 0, 0, 1, 0, |
570 | + 0, 0, 0, 1); |
571 | + case mir_orientation_inverted: |
572 | + return glm::mat4(-scale, 0, 0, 0, |
573 | + 0, -scale, 0, 0, |
574 | + 0, 0, 1, 0, |
575 | + 0, 0, 0, 1); |
576 | + case mir_orientation_right: |
577 | + return glm::mat4( 0,scale, 0, 0, |
578 | + -scale, 0, 0, 0, |
579 | + 0, 0, 1, 0, |
580 | + 0, 0, 0, 1); |
581 | + default: |
582 | + case mir_orientation_normal: |
583 | + return glm::mat4(scale, 0, 0, 0, |
584 | + 0, scale, 0, 0, |
585 | + 0, 0, 1, 0, |
586 | + 0, 0, 0, 1); |
587 | + } |
588 | } |
589 | |
590 | bool shaped() const override |
591 | @@ -102,9 +192,13 @@ |
592 | std::shared_ptr<mg::Buffer> const buffer_; |
593 | mutable std::mutex position_mutex; |
594 | geom::Point position; |
595 | + float scale{1.0f}; |
596 | + MirOrientation orientation{mir_orientation_normal}; |
597 | }; |
598 | |
599 | mg::SoftwareCursor::SoftwareCursor( |
600 | + mg::DisplayConfiguration const& intial_configuration, |
601 | + std::shared_ptr<mir::DisplayChanger> const& display_changer, |
602 | std::shared_ptr<mg::GraphicBufferAllocator> const& allocator, |
603 | std::shared_ptr<mi::Scene> const& scene) |
604 | : allocator{allocator}, |
605 | @@ -113,6 +207,13 @@ |
606 | visible(false), |
607 | hotspot{0,0} |
608 | { |
609 | + update_rectangles(intial_configuration, bounding_rectangle); |
610 | + display_changer->register_change_callback( |
611 | + [this](mg::DisplayConfiguration const& conf) |
612 | + { |
613 | + std::unique_lock<std::mutex> lock(guard); |
614 | + update_rectangles(conf, bounding_rectangle); |
615 | + }); |
616 | } |
617 | |
618 | mg::SoftwareCursor::~SoftwareCursor() |
619 | @@ -129,7 +230,28 @@ |
620 | visible = needs_scene_change = true; |
621 | } |
622 | if (needs_scene_change && renderable) |
623 | + { |
624 | + update_visualization(renderable); |
625 | scene->add_input_visualization(renderable); |
626 | + } |
627 | +} |
628 | + |
629 | +void mg::SoftwareCursor::update_visualization(std::shared_ptr<detail::CursorRenderable> cursor) |
630 | +{ |
631 | + if (!cursor) |
632 | + return; |
633 | + uint32_t display_id = 0; |
634 | + MirOrientation overridden = overrides.get_orientation(display_id, mir_orientation_normal); |
635 | + geom::Rectangle area = bounding_rectangle.bounding_rectangle(); |
636 | + |
637 | + auto displacement = transform(cursor->get_scale(), |
638 | + position - area.top_left, |
639 | + hotspot, |
640 | + cursor->buffer()->size(), |
641 | + overridden); |
642 | + |
643 | + cursor->move_to(displacement); |
644 | + cursor->set_orientation(overridden); |
645 | } |
646 | |
647 | void mg::SoftwareCursor::show(CursorImage const& cursor_image) |
648 | @@ -142,10 +264,10 @@ |
649 | { |
650 | geom::Point position{0,0}; |
651 | std::lock_guard<std::mutex> lg{guard}; |
652 | + visible = true; |
653 | if (renderable) |
654 | position = renderable->screen_position().top_left; |
655 | new_renderable = create_renderable_for(cursor_image, position); |
656 | - visible = true; |
657 | } |
658 | |
659 | // Add the new renderable first, then remove the old one to avoid |
660 | @@ -159,6 +281,7 @@ |
661 | renderable = new_renderable; |
662 | hotspot = cursor_image.hotspot(); |
663 | } |
664 | + update_visualization(new_renderable); |
665 | |
666 | if (old_renderable) |
667 | scene->remove_input_visualization(old_renderable); |
668 | @@ -206,11 +329,20 @@ |
669 | { |
670 | std::lock_guard<std::mutex> lg{guard}; |
671 | |
672 | + this->position = position; |
673 | + |
674 | if (!renderable) |
675 | return; |
676 | |
677 | - renderable->move_to(position - hotspot); |
678 | + update_visualization(renderable); |
679 | } |
680 | |
681 | scene->emit_scene_changed(); |
682 | } |
683 | + |
684 | +void mg::SoftwareCursor::override_orientation(uint32_t screen, MirOrientation orientation) |
685 | +{ |
686 | + // there is no cache invalidation in this hack |
687 | + overrides.add_override(screen, orientation); |
688 | + scene->emit_scene_changed(); |
689 | +} |
690 | |
691 | === modified file 'src/server/graphics/software_cursor.h' |
692 | --- src/server/graphics/software_cursor.h 2015-04-30 11:36:36 +0000 |
693 | +++ src/server/graphics/software_cursor.h 2015-07-02 11:48:27 +0000 |
694 | @@ -22,13 +22,17 @@ |
695 | #include "mir/graphics/cursor.h" |
696 | #include "mir_toolkit/client_types.h" |
697 | #include "mir/geometry/displacement.h" |
698 | +#include "mir/geometry/overrides.h" |
699 | +#include "mir/geometry/rectangles.h" |
700 | #include <mutex> |
701 | |
702 | namespace mir |
703 | { |
704 | +class DisplayChanger; |
705 | namespace input { class Scene; } |
706 | namespace graphics |
707 | { |
708 | +class DisplayConfiguration; |
709 | class GraphicBufferAllocator; |
710 | class Renderable; |
711 | |
712 | @@ -41,6 +45,8 @@ |
713 | { |
714 | public: |
715 | SoftwareCursor( |
716 | + mir::graphics::DisplayConfiguration const& inital_configuration, |
717 | + std::shared_ptr<mir::DisplayChanger> const& display_changer, |
718 | std::shared_ptr<GraphicBufferAllocator> const& allocator, |
719 | std::shared_ptr<input::Scene> const& scene); |
720 | ~SoftwareCursor(); |
721 | @@ -49,10 +55,12 @@ |
722 | void show(CursorImage const& cursor_image) override; |
723 | void hide() override; |
724 | void move_to(geometry::Point position) override; |
725 | + void override_orientation(uint32_t screen, MirOrientation) override; |
726 | |
727 | private: |
728 | std::shared_ptr<detail::CursorRenderable> create_renderable_for( |
729 | CursorImage const& cursor_image, geometry::Point position); |
730 | + void update_visualization(std::shared_ptr<detail::CursorRenderable> renderable); |
731 | |
732 | std::shared_ptr<GraphicBufferAllocator> const allocator; |
733 | std::shared_ptr<input::Scene> const scene; |
734 | @@ -60,7 +68,10 @@ |
735 | std::mutex guard; |
736 | std::shared_ptr<detail::CursorRenderable> renderable; |
737 | bool visible; |
738 | + geometry::Point position; |
739 | geometry::Displacement hotspot; |
740 | + geometry::Overrides overrides; |
741 | + geometry::Rectangles bounding_rectangle; |
742 | }; |
743 | |
744 | } |
745 | |
746 | === modified file 'src/server/input/android/android_input_reader_policy.cpp' |
747 | --- src/server/input/android/android_input_reader_policy.cpp 2015-01-21 07:34:50 +0000 |
748 | +++ src/server/input/android/android_input_reader_policy.cpp 2015-07-02 11:48:27 +0000 |
749 | @@ -22,6 +22,8 @@ |
750 | #include "mir/input/input_region.h" |
751 | #include "mir/geometry/rectangle.h" |
752 | |
753 | +#include <sstream> |
754 | + |
755 | namespace mi = mir::input; |
756 | namespace mia = mir::input::android; |
757 | |
758 | @@ -50,8 +52,20 @@ |
759 | height, |
760 | default_display_orientation); |
761 | |
762 | - out_config->pointerVelocityControlParameters.acceleration = 1.0; |
763 | - |
764 | + auto gu_scale = 16.0f; |
765 | + auto gu_env = getenv("GRID_UNIT_PX"); |
766 | + |
767 | + if (gu_env) |
768 | + { |
769 | + std::istringstream in(gu_env); |
770 | + in >> gu_scale; |
771 | + } |
772 | + |
773 | + out_config->pointerVelocityControlParameters.lowThreshold = 150.0f; |
774 | + out_config->pointerVelocityControlParameters.highThreshold = 500.0f; |
775 | + out_config->pointerVelocityControlParameters.acceleration = 3.0f + gu_scale/16.0f; |
776 | + out_config->wheelVelocityControlParameters.acceleration = 4.0f + gu_scale/16.0f; |
777 | + |
778 | // This only enables passing through the touch coordinates from the InputReader to the TouchVisualizer |
779 | // the touch visualizer still decides whether or not to render anything. |
780 | out_config->showTouches = true; |
781 | |
782 | === modified file 'src/server/input/android/android_pointer_controller.cpp' |
783 | --- src/server/input/android/android_pointer_controller.cpp 2015-01-21 07:34:50 +0000 |
784 | +++ src/server/input/android/android_pointer_controller.cpp 2015-07-02 11:48:27 +0000 |
785 | @@ -77,6 +77,25 @@ |
786 | { |
787 | auto new_x = x + delta_x; |
788 | auto new_y = y + delta_y; |
789 | + auto old_orientation = input_region->get_orientation(geom::Point{x, y}); |
790 | + switch (old_orientation) |
791 | + { |
792 | + default: |
793 | + case mir_orientation_normal: |
794 | + break; |
795 | + case mir_orientation_inverted: |
796 | + new_x = x - delta_x; |
797 | + new_y = y - delta_y; |
798 | + break; |
799 | + case mir_orientation_left: |
800 | + new_x = x + delta_y; |
801 | + new_y = y - delta_x; |
802 | + break; |
803 | + case mir_orientation_right: |
804 | + new_x = x - delta_y; |
805 | + new_y = y + delta_x; |
806 | + break; |
807 | + } |
808 | setPosition(new_x, new_y); |
809 | } |
810 | void mia::PointerController::setButtonState(int32_t button_state) |
811 | @@ -103,6 +122,7 @@ |
812 | // to prevent the InputReader from getting ahead of rendering. This may need to be thought about later. |
813 | notify_listener(); |
814 | } |
815 | + |
816 | void mia::PointerController::getPosition(float *out_x, float *out_y) const |
817 | { |
818 | std::lock_guard<std::mutex> lg(guard); |
819 | |
820 | === modified file 'src/server/input/android/android_pointer_controller.h' |
821 | --- src/server/input/android/android_pointer_controller.h 2015-01-21 07:34:50 +0000 |
822 | +++ src/server/input/android/android_pointer_controller.h 2015-07-02 11:48:27 +0000 |
823 | @@ -54,6 +54,7 @@ |
824 | |
825 | private: |
826 | bool get_bounds_locked(float *out_min_x, float* out_min_y, float* out_max_x, float* out_max_y) const; |
827 | + void update_positions(float& new_x, float& new_y); |
828 | void notify_listener(); |
829 | // Could be a read/write mutex as this is a latency sensitive class. |
830 | mutable std::mutex guard; |
831 | |
832 | === modified file 'src/server/input/default_configuration.cpp' |
833 | --- src/server/input/default_configuration.cpp 2015-04-28 12:28:05 +0000 |
834 | +++ src/server/input/default_configuration.cpp 2015-07-02 11:48:27 +0000 |
835 | @@ -48,6 +48,8 @@ |
836 | #include "mir/input/platform.h" |
837 | #include "mir/options/configuration.h" |
838 | #include "mir/options/option.h" |
839 | +#include "mir/graphics/display.h" |
840 | +#include "mir/graphics/display_configuration.h" |
841 | #include "mir/dispatch/multiplexing_dispatchable.h" |
842 | #include "mir/compositor/scene.h" |
843 | #include "mir/emergency_cleanup.h" |
844 | @@ -75,7 +77,7 @@ |
845 | return input_region( |
846 | [this]() |
847 | { |
848 | - return std::make_shared<mi::DisplayInputRegion>(the_display()); |
849 | + return std::make_shared<mi::DisplayInputRegion>(*the_display()->configuration(), the_display_changer()); |
850 | }); |
851 | } |
852 | |
853 | |
854 | === modified file 'src/server/input/display_input_region.cpp' |
855 | --- src/server/input/display_input_region.cpp 2015-03-31 02:35:42 +0000 |
856 | +++ src/server/input/display_input_region.cpp 2015-07-02 11:48:27 +0000 |
857 | @@ -17,50 +17,68 @@ |
858 | */ |
859 | |
860 | #include "display_input_region.h" |
861 | -#include "mir/graphics/display.h" |
862 | -#include "mir/graphics/display_buffer.h" |
863 | +#include "mir/graphics/display_configuration.h" |
864 | +#include "mir/display_changer.h" |
865 | |
866 | #include "mir/geometry/rectangle.h" |
867 | #include "mir/geometry/rectangles.h" |
868 | |
869 | +#include <iostream> |
870 | + |
871 | namespace mi = mir::input; |
872 | namespace mg = mir::graphics; |
873 | namespace geom = mir::geometry; |
874 | |
875 | +namespace |
876 | +{ |
877 | +void update_rectangles(mg::DisplayConfiguration const& conf, geom::Rectangles& rectangles) |
878 | +{ |
879 | + conf.for_each_output( |
880 | + [&rectangles](mg::DisplayConfigurationOutput const& output) |
881 | + { |
882 | + if (output.power_mode == mir_power_mode_on && |
883 | + output.current_mode_index < output.modes.size()) |
884 | + rectangles.add({output.top_left, output.modes[output.current_mode_index].size}); |
885 | + }); |
886 | +} |
887 | +} |
888 | + |
889 | mi::DisplayInputRegion::DisplayInputRegion( |
890 | - std::shared_ptr<mg::Display> const& display) |
891 | - : display{display} |
892 | -{ |
893 | + mg::DisplayConfiguration const& initial_conf, |
894 | + std::shared_ptr<mir::DisplayChanger> const& display_changer) |
895 | +{ |
896 | + update_rectangles(initial_conf, rectangles); |
897 | + display_changer->register_change_callback( |
898 | + [this](mg::DisplayConfiguration const& conf) |
899 | + { |
900 | + std::unique_lock<std::mutex> lock(rectangles_lock); |
901 | + update_rectangles(conf, rectangles); |
902 | + }); |
903 | +} |
904 | + |
905 | +void mi::DisplayInputRegion::override_orientation(uint32_t display_id, MirOrientation orientation) |
906 | +{ |
907 | + std::unique_lock<std::mutex> lock(rectangles_lock); |
908 | + overrides.add_override(display_id, orientation); |
909 | +} |
910 | + |
911 | +MirOrientation mi::DisplayInputRegion::get_orientation(geometry::Point const& /*point*/) |
912 | +{ |
913 | + std::unique_lock<std::mutex> lock(rectangles_lock); |
914 | + uint32_t display_id = 0; |
915 | + MirOrientation orientation = mir_orientation_normal; |
916 | + |
917 | + return overrides.get_orientation(display_id, orientation); |
918 | } |
919 | |
920 | geom::Rectangle mi::DisplayInputRegion::bounding_rectangle() |
921 | { |
922 | - geom::Rectangles rectangles; |
923 | - |
924 | - display->for_each_display_sync_group([&rectangles](mg::DisplaySyncGroup& group) |
925 | - { |
926 | - group.for_each_display_buffer( |
927 | - [&rectangles](mg::DisplayBuffer const& buffer) |
928 | - { |
929 | - rectangles.add(buffer.view_area()); |
930 | - }); |
931 | - }); |
932 | - |
933 | + std::unique_lock<std::mutex> lock(rectangles_lock); |
934 | return rectangles.bounding_rectangle(); |
935 | } |
936 | |
937 | void mi::DisplayInputRegion::confine(geom::Point& point) |
938 | { |
939 | - geom::Rectangles rectangles; |
940 | - |
941 | - display->for_each_display_sync_group([&rectangles](mg::DisplaySyncGroup& group) |
942 | - { |
943 | - group.for_each_display_buffer( |
944 | - [&rectangles](mg::DisplayBuffer const& buffer) |
945 | - { |
946 | - rectangles.add(buffer.view_area()); |
947 | - }); |
948 | - }); |
949 | - |
950 | + std::unique_lock<std::mutex> lock(rectangles_lock); |
951 | rectangles.confine(point); |
952 | } |
953 | |
954 | === modified file 'src/server/input/display_input_region.h' |
955 | --- src/server/input/display_input_region.h 2014-03-06 06:05:17 +0000 |
956 | +++ src/server/input/display_input_region.h 2015-07-02 11:48:27 +0000 |
957 | @@ -20,14 +20,18 @@ |
958 | #define MIR_INPUT_DISPLAY_INPUT_REGION_H_ |
959 | |
960 | #include "mir/input/input_region.h" |
961 | +#include "mir/geometry/overrides.h" |
962 | +#include "mir/geometry/rectangles.h" |
963 | |
964 | #include <memory> |
965 | +#include <mutex> |
966 | |
967 | namespace mir |
968 | { |
969 | +class DisplayChanger; |
970 | namespace graphics |
971 | { |
972 | -class Display; |
973 | +class DisplayConfiguration; |
974 | } |
975 | namespace input |
976 | { |
977 | @@ -35,13 +39,19 @@ |
978 | class DisplayInputRegion : public InputRegion |
979 | { |
980 | public: |
981 | - DisplayInputRegion(std::shared_ptr<graphics::Display> const& display); |
982 | + DisplayInputRegion(mir::graphics::DisplayConfiguration const& initial_conf, |
983 | + std::shared_ptr<mir::DisplayChanger> const& display_changer); |
984 | |
985 | + void override_orientation(uint32_t display_id, MirOrientation orientation) override; |
986 | + MirOrientation get_orientation(geometry::Point const& point) override; |
987 | geometry::Rectangle bounding_rectangle(); |
988 | void confine(geometry::Point& point); |
989 | |
990 | private: |
991 | - std::shared_ptr<graphics::Display> const display; |
992 | + std::mutex rectangles_lock; |
993 | + mir::geometry::Overrides overrides; |
994 | + mir::geometry::Rectangles rectangles; |
995 | + |
996 | }; |
997 | |
998 | } |
999 | |
1000 | === modified file 'src/server/scene/mediating_display_changer.cpp' |
1001 | --- src/server/scene/mediating_display_changer.cpp 2015-01-21 07:34:50 +0000 |
1002 | +++ src/server/scene/mediating_display_changer.cpp 2015-07-02 11:48:27 +0000 |
1003 | @@ -160,9 +160,16 @@ |
1004 | |
1005 | /* Send the new configuration to all the sessions */ |
1006 | send_config_to_all_sessions(conf); |
1007 | + |
1008 | + send_config_to_all_callbacks(conf); |
1009 | }); |
1010 | } |
1011 | |
1012 | +void ms::MediatingDisplayChanger::register_change_callback(std::function<void(mg::DisplayConfiguration const&)> const& callback) |
1013 | +{ |
1014 | + callbacks.push_back(callback); |
1015 | +} |
1016 | + |
1017 | void ms::MediatingDisplayChanger::pause_display_config_processing() |
1018 | { |
1019 | server_action_queue->pause_processing_for(this); |
1020 | @@ -210,6 +217,16 @@ |
1021 | }); |
1022 | } |
1023 | |
1024 | + |
1025 | +void ms::MediatingDisplayChanger::send_config_to_all_callbacks( |
1026 | + std::shared_ptr<mg::DisplayConfiguration> const& conf) |
1027 | +{ |
1028 | + for (auto const& callback : callbacks) |
1029 | + { |
1030 | + callback(*conf); |
1031 | + } |
1032 | +} |
1033 | + |
1034 | void ms::MediatingDisplayChanger::focus_change_handler( |
1035 | std::shared_ptr<ms::Session> const& session) |
1036 | { |
1037 | |
1038 | === modified file 'src/server/scene/mediating_display_changer.h' |
1039 | --- src/server/scene/mediating_display_changer.h 2015-01-21 07:34:50 +0000 |
1040 | +++ src/server/scene/mediating_display_changer.h 2015-07-02 11:48:27 +0000 |
1041 | @@ -24,6 +24,7 @@ |
1042 | |
1043 | #include <mutex> |
1044 | #include <map> |
1045 | +#include <vector> |
1046 | |
1047 | namespace mir |
1048 | { |
1049 | @@ -65,6 +66,7 @@ |
1050 | |
1051 | void pause_display_config_processing() override; |
1052 | void resume_display_config_processing() override; |
1053 | + void register_change_callback(std::function<void(graphics::DisplayConfiguration const&)> const& change_callback) override; |
1054 | |
1055 | private: |
1056 | void focus_change_handler(std::shared_ptr<Session> const& session); |
1057 | @@ -76,6 +78,8 @@ |
1058 | void apply_base_config(SystemStateHandling pause_resume_system); |
1059 | void send_config_to_all_sessions( |
1060 | std::shared_ptr<graphics::DisplayConfiguration> const& conf); |
1061 | + void send_config_to_all_callbacks( |
1062 | + std::shared_ptr<graphics::DisplayConfiguration> const& conf); |
1063 | |
1064 | std::shared_ptr<graphics::Display> const display; |
1065 | std::shared_ptr<compositor::Compositor> const compositor; |
1066 | @@ -90,6 +94,7 @@ |
1067 | std::weak_ptr<frontend::Session> focused_session; |
1068 | std::shared_ptr<graphics::DisplayConfiguration> base_configuration; |
1069 | bool base_configuration_applied; |
1070 | + std::vector<std::function<void(graphics::DisplayConfiguration const&)>> callbacks; |
1071 | }; |
1072 | |
1073 | } |
1074 | |
1075 | === modified file 'src/server/server.cpp' |
1076 | --- src/server/server.cpp 2015-04-09 06:20:31 +0000 |
1077 | +++ src/server/server.cpp 2015-07-02 11:48:27 +0000 |
1078 | @@ -67,6 +67,7 @@ |
1079 | MACRO(the_cursor_listener)\ |
1080 | MACRO(the_cursor)\ |
1081 | MACRO(the_display)\ |
1082 | + MACRO(the_input_region)\ |
1083 | MACRO(the_focus_controller)\ |
1084 | MACRO(the_gl_config)\ |
1085 | MACRO(the_graphics_platform)\ |
1086 | |
1087 | === modified file 'src/server/symbols.map' |
1088 | --- src/server/symbols.map 2015-05-01 13:49:42 +0000 |
1089 | +++ src/server/symbols.map 2015-07-02 11:48:27 +0000 |
1090 | @@ -182,6 +182,7 @@ |
1091 | mir::Server::the_graphics_platform*; |
1092 | mir::Server::the_input_device_hub*; |
1093 | mir::Server::the_input_targeter*; |
1094 | + mir::Server::the_input_region*; |
1095 | mir::Server::the_logger*; |
1096 | mir::Server::the_main_loop*; |
1097 | mir::Server::the_prompt_session_listener*; |
1098 | @@ -424,6 +425,7 @@ |
1099 | vtable?for?mir::input::InputDeviceObserver; |
1100 | vtable?for?mir::input::InputDispatcher; |
1101 | vtable?for?mir::input::InputManager; |
1102 | + vtable?for?mir::input::InputRegion; |
1103 | vtable?for?mir::input::Surface; |
1104 | vtable?for?mir::input::TouchVisualizer; |
1105 | vtable?for?mir::input::TouchVisualizer::Spot; |
1106 | |
1107 | === modified file 'tests/acceptance-tests/throwback/test_client_cursor_api.cpp' |
1108 | --- tests/acceptance-tests/throwback/test_client_cursor_api.cpp 2015-04-23 20:17:52 +0000 |
1109 | +++ tests/acceptance-tests/throwback/test_client_cursor_api.cpp 2015-07-02 11:48:27 +0000 |
1110 | @@ -55,6 +55,7 @@ |
1111 | { |
1112 | MOCK_METHOD0(show, void()); |
1113 | MOCK_METHOD1(show, void(mg::CursorImage const&)); |
1114 | + MOCK_METHOD2(override_orientation, void(uint32_t, MirOrientation)); |
1115 | MOCK_METHOD0(hide, void()); |
1116 | |
1117 | // We are not interested in mocking the motion in these tests as we |
1118 | |
1119 | === modified file 'tests/include/mir_test_doubles/mock_input_region.h' |
1120 | --- tests/include/mir_test_doubles/mock_input_region.h 2013-07-19 14:12:57 +0000 |
1121 | +++ tests/include/mir_test_doubles/mock_input_region.h 2015-07-02 11:48:27 +0000 |
1122 | @@ -35,6 +35,8 @@ |
1123 | class MockInputRegion : public input::InputRegion |
1124 | { |
1125 | public: |
1126 | + MOCK_METHOD2(override_orientation, void(uint32_t, MirOrientation)); |
1127 | + MOCK_METHOD1(get_orientation, MirOrientation(mir::geometry::Point const&)); |
1128 | MOCK_METHOD0(bounding_rectangle, geometry::Rectangle()); |
1129 | MOCK_METHOD1(confine, void(geometry::Point&)); |
1130 | }; |
1131 | |
1132 | === modified file 'tests/include/mir_test_doubles/stub_cursor.h' |
1133 | --- tests/include/mir_test_doubles/stub_cursor.h 2015-04-01 22:06:05 +0000 |
1134 | +++ tests/include/mir_test_doubles/stub_cursor.h 2015-07-02 11:48:27 +0000 |
1135 | @@ -34,6 +34,7 @@ |
1136 | void show(graphics::CursorImage const&) override {} |
1137 | void hide() override {} |
1138 | void move_to(geometry::Point) override {} |
1139 | + void override_orientation(uint32_t, MirOrientation) override {} |
1140 | }; |
1141 | |
1142 | } |
1143 | |
1144 | === added file 'tests/include/mir_test_doubles/stub_display_changer.h' |
1145 | --- tests/include/mir_test_doubles/stub_display_changer.h 1970-01-01 00:00:00 +0000 |
1146 | +++ tests/include/mir_test_doubles/stub_display_changer.h 2015-07-02 11:48:27 +0000 |
1147 | @@ -0,0 +1,52 @@ |
1148 | +/* |
1149 | + * Copyright © 2015 Canonical Ltd. |
1150 | + * |
1151 | + * This program is free software: you can redistribute it and/or modify it |
1152 | + * under the terms of the GNU General Public License version 3, |
1153 | + * as published by the Free Software Foundation. |
1154 | + * |
1155 | + * This program is distributed in the hope that it will be useful, |
1156 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1157 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1158 | + * GNU General Public License for more details. |
1159 | + * |
1160 | + * You should have received a copy of the GNU General Public License |
1161 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1162 | + * |
1163 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
1164 | + */ |
1165 | + |
1166 | +#ifndef MIR_TEST_DOUBLES_STUB_DISPLAY_CHANGER_H_ |
1167 | +#define MIR_TEST_DOUBLES_STUB_DISPLAY_CHANGER_H_ |
1168 | + |
1169 | +#include "mir/display_changer.h" |
1170 | + |
1171 | +namespace mir |
1172 | +{ |
1173 | +namespace test |
1174 | +{ |
1175 | +namespace doubles |
1176 | +{ |
1177 | + |
1178 | +struct StubDisplayChanger : public mir::DisplayChanger |
1179 | +{ |
1180 | + void configure_for_hardware_change( |
1181 | + std::shared_ptr<graphics::DisplayConfiguration> const& , |
1182 | + SystemStateHandling) override |
1183 | + {} |
1184 | + |
1185 | + void pause_display_config_processing() override |
1186 | + {} |
1187 | + |
1188 | + void resume_display_config_processing() override |
1189 | + {} |
1190 | + void register_change_callback(std::function<void(graphics::DisplayConfiguration const&)> const&) override |
1191 | + {} |
1192 | + |
1193 | +}; |
1194 | + |
1195 | +} |
1196 | +} |
1197 | +} |
1198 | + |
1199 | +#endif |
1200 | |
1201 | === modified file 'tests/mir_test_doubles/fake_event_hub.cpp' |
1202 | --- tests/mir_test_doubles/fake_event_hub.cpp 2015-04-16 08:42:38 +0000 |
1203 | +++ tests/mir_test_doubles/fake_event_hub.cpp 2015-07-02 11:48:27 +0000 |
1204 | @@ -558,7 +558,9 @@ |
1205 | void FakeEventHub::synthesize_event(const mis::MotionParameters ¶meters) |
1206 | { |
1207 | RawEvent event; |
1208 | - event.when = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch()); |
1209 | + static auto time = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch()); |
1210 | + time += std::chrono::seconds(1); |
1211 | + event.when = time; |
1212 | event.type = EV_REL; |
1213 | if (parameters.device_id) |
1214 | event.deviceId = parameters.device_id; |
1215 | |
1216 | === modified file 'tests/mir_test_framework/stubbed_server_configuration.cpp' |
1217 | --- tests/mir_test_framework/stubbed_server_configuration.cpp 2015-04-23 20:17:52 +0000 |
1218 | +++ tests/mir_test_framework/stubbed_server_configuration.cpp 2015-07-02 11:48:27 +0000 |
1219 | @@ -47,6 +47,7 @@ |
1220 | |
1221 | namespace |
1222 | { |
1223 | + |
1224 | class StubRendererFactory : public mc::RendererFactory |
1225 | { |
1226 | public: |
1227 | |
1228 | === modified file 'tests/unit-tests/graphics/test_software_cursor.cpp' |
1229 | --- tests/unit-tests/graphics/test_software_cursor.cpp 2015-04-30 11:36:36 +0000 |
1230 | +++ tests/unit-tests/graphics/test_software_cursor.cpp 2015-07-02 11:48:27 +0000 |
1231 | @@ -22,6 +22,8 @@ |
1232 | |
1233 | #include "mir_test_doubles/stub_buffer_allocator.h" |
1234 | #include "mir_test_doubles/stub_input_scene.h" |
1235 | +#include "mir_test_doubles/stub_display.h" |
1236 | +#include "mir_test_doubles/stub_display_changer.h" |
1237 | |
1238 | #include "mir_test/fake_shared.h" |
1239 | |
1240 | @@ -80,12 +82,21 @@ |
1241 | |
1242 | struct SoftwareCursor : testing::Test |
1243 | { |
1244 | + std::vector<mir::geometry::Rectangle> regs{ |
1245 | + mir::geometry::Rectangle{ |
1246 | + mir::geometry::Point{0,0}, |
1247 | + mir::geometry::Size{1024,768} |
1248 | + }}; |
1249 | + mtd::StubDisplay stub_display{regs}; |
1250 | + mtd::StubDisplayChanger stub_display_changer; |
1251 | StubCursorImage stub_cursor_image{{3,4}}; |
1252 | StubCursorImage another_stub_cursor_image{{10,9}}; |
1253 | mtd::StubBufferAllocator stub_buffer_allocator; |
1254 | testing::NiceMock<MockInputScene> mock_input_scene; |
1255 | |
1256 | mg::SoftwareCursor cursor{ |
1257 | + *stub_display.configuration(), |
1258 | + mt::fake_shared(stub_display_changer), |
1259 | mt::fake_shared(stub_buffer_allocator), |
1260 | mt::fake_shared(mock_input_scene)}; |
1261 | }; |
1262 | @@ -307,6 +318,8 @@ |
1263 | .Times(3) |
1264 | .WillRepeatedly(testing::Return(std::make_shared<mtd::StubBuffer>()));; |
1265 | mg::SoftwareCursor cursor{ |
1266 | + *stub_display.configuration(), |
1267 | + mt::fake_shared(stub_display_changer), |
1268 | mt::fake_shared(mock_allocator), |
1269 | mt::fake_shared(mock_input_scene)}; |
1270 | cursor.show(another_stub_cursor_image); |
1271 | |
1272 | === modified file 'tests/unit-tests/input/android/test_android_pointer_controller.cpp' |
1273 | --- tests/unit-tests/input/android/test_android_pointer_controller.cpp 2015-01-21 07:34:50 +0000 |
1274 | +++ tests/unit-tests/input/android/test_android_pointer_controller.cpp 2015-07-02 11:48:27 +0000 |
1275 | @@ -48,9 +48,11 @@ |
1276 | { |
1277 | controller = std::make_shared<mia::PointerController>(mt::fake_shared(input_region), std::shared_ptr<mi::CursorListener>(), |
1278 | std::make_shared<mtd::StubTouchVisualizer>()); |
1279 | + using namespace ::testing; |
1280 | + ON_CALL(input_region,get_orientation(_)).WillByDefault(Return(mir_orientation_normal)); |
1281 | } |
1282 | protected: |
1283 | - mtd::MockInputRegion input_region; |
1284 | + ::testing::NiceMock<mtd::MockInputRegion> input_region; |
1285 | std::shared_ptr<mia::PointerController> controller; |
1286 | }; |
1287 | |
1288 | |
1289 | === modified file 'tests/unit-tests/input/test_cursor_controller.cpp' |
1290 | --- tests/unit-tests/input/test_cursor_controller.cpp 2015-03-31 02:35:42 +0000 |
1291 | +++ tests/unit-tests/input/test_cursor_controller.cpp 2015-07-02 11:48:27 +0000 |
1292 | @@ -86,6 +86,7 @@ |
1293 | |
1294 | struct MockCursor : public mg::Cursor |
1295 | { |
1296 | + MOCK_METHOD2(override_orientation, void(uint32_t, MirOrientation)); |
1297 | MOCK_METHOD0(show, void()); |
1298 | MOCK_METHOD1(show, void(mg::CursorImage const&)); |
1299 | MOCK_METHOD0(hide, void()); |
1300 | |
1301 | === modified file 'tests/unit-tests/input/test_display_input_region.cpp' |
1302 | --- tests/unit-tests/input/test_display_input_region.cpp 2015-03-31 02:35:42 +0000 |
1303 | +++ tests/unit-tests/input/test_display_input_region.cpp 2015-07-02 11:48:27 +0000 |
1304 | @@ -20,6 +20,7 @@ |
1305 | |
1306 | #include "mir_test_doubles/null_display.h" |
1307 | #include "mir_test_doubles/stub_display.h" |
1308 | +#include "mir_test_doubles/stub_display_changer.h" |
1309 | |
1310 | #include <vector> |
1311 | #include <tuple> |
1312 | @@ -44,8 +45,9 @@ |
1313 | { |
1314 | geom::Rectangle const expected_bounding_rect{geom::Point{0,0}, geom::Size{900,700}}; |
1315 | auto stub_display = std::make_shared<mtd::StubDisplay>(rects); |
1316 | + auto stub_display_changer = std::make_shared<mtd::StubDisplayChanger>(); |
1317 | |
1318 | - mi::DisplayInputRegion input_region{stub_display}; |
1319 | + mi::DisplayInputRegion input_region{*stub_display->configuration(), stub_display_changer}; |
1320 | |
1321 | auto rect = input_region.bounding_rectangle(); |
1322 | EXPECT_EQ(expected_bounding_rect, rect); |
1323 | @@ -54,8 +56,9 @@ |
1324 | TEST(DisplayInputRegionTest, confines_point_to_closest_valid_position) |
1325 | { |
1326 | auto stub_display = std::make_shared<mtd::StubDisplay>(rects); |
1327 | + auto stub_display_changer = std::make_shared<mtd::StubDisplayChanger>(); |
1328 | |
1329 | - mi::DisplayInputRegion input_region{stub_display}; |
1330 | + mi::DisplayInputRegion input_region{*stub_display->configuration(), stub_display_changer}; |
1331 | |
1332 | std::vector<std::tuple<geom::Point,geom::Point>> point_tuples{ |
1333 | std::make_tuple(geom::Point{0,0}, geom::Point{0,0}), |