Merge lp:~kdub/unity-system-compositor/unblock-silo0 into lp:~mir-team/unity-system-compositor/silo0

Proposed by Kevin DuBois
Status: Superseded
Proposed branch: lp:~kdub/unity-system-compositor/unblock-silo0
Merge into: lp:~mir-team/unity-system-compositor/silo0
Diff against target: 908 lines (+489/-32) (has conflicts)
21 files modified
debian/changelog (+34/-3)
debian/control (+2/-2)
src/CMakeLists.txt (+6/-1)
src/clone_display_configuration_policy.cpp (+46/-0)
src/clone_display_configuration_policy.h (+34/-0)
src/com.canonical.Unity.Screen.xml (+4/-0)
src/cursor_enabler.cpp (+72/-0)
src/cursor_enabler.h (+58/-0)
src/mir_screen.cpp (+4/-0)
src/mir_screen.h (+3/-1)
src/server.cpp (+15/-13)
src/server.h (+11/-5)
src/system_compositor.cpp (+10/-0)
src/system_compositor.h (+3/-0)
src/window_manager.cpp (+58/-5)
src/window_manager.h (+16/-2)
tests/integration-tests/test_unity_screen_service.cpp (+1/-0)
tests/unit-tests/CMakeLists.txt (+1/-0)
tests/unit-tests/test_cursor_enabler.cpp (+97/-0)
tests/unit-tests/test_mir_screen.cpp (+13/-0)
tests/unit-tests/test_screen_event_handler.cpp (+1/-0)
Text conflict in src/CMakeLists.txt
Conflict adding file src/clone_display_configuration_policy.cpp.  Moved existing file to src/clone_display_configuration_policy.cpp.moved.
Conflict adding file src/clone_display_configuration_policy.h.  Moved existing file to src/clone_display_configuration_policy.h.moved.
Text conflict in src/server.cpp
To merge this branch: bzr merge lp:~kdub/unity-system-compositor/unblock-silo0
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+266934@code.launchpad.net

Commit message

upon Display changes, use information from WindowManager system to figure out the new dimensions. Also scan through the list of surfaces differently, as surface_after() will never return nullptr.

Description of the change

upon Display changes, use information from WindowManager system to figure out the new dimensions. Also scan through the list of surfaces differently, as surface_after() will never return nullptr.

To post a comment you must log in.

Unmerged revisions

226. By Kevin DuBois

configure the display differently on screen changes

225. By Andreas Pokorny

fix changelog

224. By Andreas Pokorny

update to recent unity-system-compositor changes

223. By Gerry Boland

Merge fix-1461476-display-off-ubuntu

222. By Gerry Boland

Try a release

221. By Gerry Boland

WindowManager: attempt to resize surfaces to fil the smallest available display - deadlocks

220. By Gerry Boland

Update display rotation at runtime

219. By Gerry Boland

Attempt at rotating the non-primary display by default

218. By Gerry Boland

Update comment to reflect hardware cursor enabled by default

217. By Gerry Boland

Enable hardware cursor by default

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-07-16 21:45:22 +0000
3+++ debian/changelog 2015-08-04 17:52:54 +0000
4@@ -1,8 +1,39 @@
5-unity-system-compositor (0.0.5+15.10.20150506.2-0ubuntu1) UNRELEASED; urgency=medium
6-
7+unity-system-compositor (0.1.1) UNRELEASED; urgency=medium
8+
9+ * Demo USC with cursor override and special clone ability
10+
11+ -- Gerry Boland <gerry.boland@canonical.com> Tue, 07 Jul 2015 10:50:27 +0100
12+
13+unity-system-compositor (0.1.0+15.10.20150728.1-0ubuntu1) wily; urgency=medium
14+
15+ [ Alexandros Frantzis ]
16+ * Support different screen timeout values for notifications
17+ (LP: #1426115)
18+ * Enable and handle proximity events properly (LP: #1291455)
19+ * Don't force gcc 4.9 when building the package (LP: #1478926)
20+ * Introduce new versioning scheme
21+
22+ [ Alan Griffiths ]
23+ * Port to mir SystemCompositorWindowManager
24+
25+ [ Robert Ancell ]
26+ * Depend on the new xmir package instead of the obsolete
27+ xserver-xorg-xmir (LP: #1204505)
28+
29+ [ CI Train Bot ]
30+ * New rebuild forced.
31+
32+ -- CI Train Bot <ci-train-bot@canonical.com> Tue, 28 Jul 2015 18:55:28 +0000
33+
34+unity-system-compositor (0.0.5+15.10.20150722-0ubuntu1) wily; urgency=medium
35+
36+ [ Kevin Gunn ]
37 * Release in step with Mir 0.14
38
39- -- Kevin Gunn <kevin.gunn@canonical.com> Thu, 16 Jul 2015 15:14:22 -0500
40+ [ CI Train Bot ]
41+ * New rebuild forced.
42+
43+ -- CI Train Bot <ci-train-bot@canonical.com> Wed, 22 Jul 2015 14:49:58 +0000
44
45 unity-system-compositor (0.0.5+15.04.20150713-0ubuntu1) vivid; urgency=medium
46
47
48=== modified file 'debian/control'
49--- debian/control 2015-07-27 10:29:16 +0000
50+++ debian/control 2015-08-04 17:52:54 +0000
51@@ -13,8 +13,8 @@
52 libdbus-1-dev,
53 libglib2.0-dev,
54 libgles2-mesa-dev,
55- libmirclient-dev (>= 0.13.0),
56- libmirserver-dev (>= 0.13.0),
57+ libmirclient-dev (>= 0.13.4),
58+ libmirserver-dev (>= 0.13.4),
59 libprotobuf-dev,
60 pkg-config,
61 python:any (>= 2.7),
62
63=== modified file 'src/CMakeLists.txt'
64--- src/CMakeLists.txt 2015-08-04 17:05:31 +0000
65+++ src/CMakeLists.txt 2015-08-04 17:52:54 +0000
66@@ -16,7 +16,12 @@
67
68 set(USC_SRCS
69 asio_dm_connection.cpp
70- clone_display_configuration_policy.cpp
71+<<<<<<< TREE
72+ clone_display_configuration_policy.cpp
73+=======
74+ clone_display_configuration_policy.cpp
75+ cursor_enabler.cpp
76+>>>>>>> MERGE-SOURCE
77 dbus_connection_handle.cpp
78 dbus_event_loop.cpp
79 dbus_message_handle.cpp
80
81=== added file 'src/clone_display_configuration_policy.cpp'
82--- src/clone_display_configuration_policy.cpp 1970-01-01 00:00:00 +0000
83+++ src/clone_display_configuration_policy.cpp 2015-08-04 17:52:54 +0000
84@@ -0,0 +1,46 @@
85+/*
86+ * Copyright (C) 2015 Canonical, Ltd.
87+ *
88+ * This program is free software: you can redistribute it and/or modify it under
89+ * the terms of the GNU Lesser General Public License version 3, as published by
90+ * the Free Software Foundation.
91+ *
92+ * This program is distributed in the hope that it will be useful, but WITHOUT
93+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
94+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
95+ * Lesser General Public License for more details.
96+ *
97+ * You should have received a copy of the GNU Lesser General Public License
98+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
99+ */
100+
101+#include "clone_display_configuration_policy.h"
102+
103+#include <mir/graphics/display_configuration.h>
104+#include <cstdio>
105+namespace mg = mir::graphics;
106+
107+CloneDisplayConfigurationPolicy::CloneDisplayConfigurationPolicy(
108+ const std::shared_ptr<mir::graphics::DisplayConfigurationPolicy> &wrapped)
109+ : wrapped{wrapped}
110+{
111+}
112+
113+void CloneDisplayConfigurationPolicy::apply_to(mir::graphics::DisplayConfiguration& conf)
114+{
115+ wrapped->apply_to(conf);
116+
117+ conf.for_each_output(
118+ [&](mg::UserDisplayConfigurationOutput& displayConfigOutput) {
119+ if (displayConfigOutput.id.as_value() > 0) { printf("Here\n");
120+ displayConfigOutput.orientation = mir_orientation_left;
121+ }
122+ }
123+ );
124+
125+ conf.for_each_output(
126+ [&](const mg::DisplayConfigurationOutput displayConfigOutput) {
127+ printf("Output %d: Orientation %d\n", displayConfigOutput.id.as_value(), displayConfigOutput.orientation);
128+ }
129+ );
130+}
131
132=== renamed file 'src/clone_display_configuration_policy.cpp' => 'src/clone_display_configuration_policy.cpp.moved'
133=== added file 'src/clone_display_configuration_policy.h'
134--- src/clone_display_configuration_policy.h 1970-01-01 00:00:00 +0000
135+++ src/clone_display_configuration_policy.h 2015-08-04 17:52:54 +0000
136@@ -0,0 +1,34 @@
137+/*
138+ * Copyright (C) 2015 Canonical, Ltd.
139+ *
140+ * This program is free software: you can redistribute it and/or modify it under
141+ * the terms of the GNU Lesser General Public License version 3, as published by
142+ * the Free Software Foundation.
143+ *
144+ * This program is distributed in the hope that it will be useful, but WITHOUT
145+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
146+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
147+ * Lesser General Public License for more details.
148+ *
149+ * You should have received a copy of the GNU Lesser General Public License
150+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
151+ */
152+
153+#ifndef CLONEDISPLAYCONFIGURATIONPOLICY_H
154+#define CLONEDISPLAYCONFIGURATIONPOLICY_H
155+
156+#include <mir/graphics/display_configuration_policy.h>
157+#include <memory>
158+
159+class CloneDisplayConfigurationPolicy : public mir::graphics::DisplayConfigurationPolicy
160+{
161+public:
162+ CloneDisplayConfigurationPolicy(const std::shared_ptr<mir::graphics::DisplayConfigurationPolicy> &wrapped);
163+
164+ void apply_to(mir::graphics::DisplayConfiguration& conf) override;
165+
166+private:
167+ const std::shared_ptr<mir::graphics::DisplayConfigurationPolicy> wrapped;
168+};
169+
170+#endif // CLONEDISPLAYCONFIGURATIONPOLICY_H
171
172=== renamed file 'src/clone_display_configuration_policy.h' => 'src/clone_display_configuration_policy.h.moved'
173=== modified file 'src/com.canonical.Unity.Screen.xml'
174--- src/com.canonical.Unity.Screen.xml 2015-03-18 13:06:10 +0000
175+++ src/com.canonical.Unity.Screen.xml 2015-08-04 17:52:54 +0000
176@@ -25,5 +25,9 @@
177 <method name='setTouchVisualizationEnabled'>
178 <arg name='enabled' type='b' direction='in'/>
179 </method>
180+ <method name='overrideOrientation'>
181+ <arg name='display_id' type='u' direction='in'/>
182+ <arg name='orientation' type='i' direction='in'/>
183+ </method>
184 </interface>
185 </node>
186
187=== added file 'src/cursor_enabler.cpp'
188--- src/cursor_enabler.cpp 1970-01-01 00:00:00 +0000
189+++ src/cursor_enabler.cpp 2015-08-04 17:52:54 +0000
190@@ -0,0 +1,72 @@
191+/*
192+ * Copyright © 2015 Canonical Ltd.
193+ *
194+ * This program is free software: you can redistribute it and/or modify
195+ * it under the terms of the GNU General Public License version 3 as
196+ * published by the Free Software Foundation.
197+ *
198+ * This program is distributed in the hope that it will be useful,
199+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
200+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
201+ * GNU General Public License for more details.
202+ *
203+ * You should have received a copy of the GNU General Public License
204+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
205+ */
206+
207+#include "cursor_enabler.h"
208+
209+#include "mir/graphics/cursor.h"
210+#include "mir_toolkit/event.h"
211+
212+namespace mi = mir::input;
213+
214+CursorEnabler::CursorEnabler(
215+ std::shared_ptr<mir::graphics::Cursor> const& cursor,
216+ std::chrono::milliseconds remove_pointer_timeout)
217+ : cursor_shown(false), remove_delay{static_cast<uint32_t>(remove_pointer_timeout.count())}, last_cursor_movement(0),
218+ cursor(cursor)
219+{
220+ cursor->hide();
221+}
222+
223+CursorEnabler::~CursorEnabler() = default;
224+
225+bool CursorEnabler::handle(MirEvent const& event)
226+{
227+ if (mir_event_get_type(&event) != mir_event_type_input)
228+ {
229+ return false;
230+ }
231+ auto const* ev = mir_event_get_input_event(&event);
232+ if (mir_input_event_type_pointer == mir_input_event_get_type(ev))
233+ {
234+ enable_cursor();
235+ last_cursor_movement = mir_input_event_get_event_time(ev);
236+ }
237+ else if (remove_delay &&
238+ mir_input_event_type_touch == mir_input_event_get_type(ev) &&
239+ (mir_input_event_get_event_time(ev) - last_cursor_movement > remove_delay))
240+ {
241+ disable_cursor();
242+ }
243+ return false;
244+}
245+
246+void CursorEnabler::enable_cursor()
247+{
248+ if (!cursor_shown)
249+ {
250+ cursor->show();
251+ cursor_shown = true;
252+ }
253+}
254+
255+void CursorEnabler::disable_cursor()
256+{
257+ if (cursor_shown)
258+ {
259+ cursor->hide();
260+ cursor_shown = false;
261+ }
262+}
263
264=== added file 'src/cursor_enabler.h'
265--- src/cursor_enabler.h 1970-01-01 00:00:00 +0000
266+++ src/cursor_enabler.h 2015-08-04 17:52:54 +0000
267@@ -0,0 +1,58 @@
268+/*
269+ * Copyright © 2015 Canonical Ltd.
270+ *
271+ * This program is free software: you can redistribute it and/or modify
272+ * it under the terms of the GNU General Public License version 3 as
273+ * published by the Free Software Foundation.
274+ *
275+ * This program is distributed in the hope that it will be useful,
276+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
277+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
278+ * GNU General Public License for more details.
279+ *
280+ * You should have received a copy of the GNU General Public License
281+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
282+ */
283+
284+#ifndef USC_CURSOR_IMAGE_ENABLER_H_
285+#define USC_CURSOR_IMAGE_ENABLER_H_
286+
287+#include "mir/input/event_filter.h"
288+
289+#include <memory>
290+#include <chrono>
291+
292+namespace mir
293+{
294+namespace graphics
295+{
296+class Cursor;
297+class CursorImage;
298+}
299+}
300+
301+/*
302+ * Disables the cursor on construction and waits for the first mir pointer/cursor
303+ * event to come by for enabling the cursor again.
304+ */
305+class CursorEnabler : public mir::input::EventFilter
306+{
307+public:
308+ CursorEnabler(std::shared_ptr<mir::graphics::Cursor> const& cursor,
309+ std::chrono::milliseconds remove_pointer_timeout);
310+
311+ ~CursorEnabler();
312+
313+ bool handle(MirEvent const& event) override;
314+
315+private:
316+ void enable_cursor();
317+ void disable_cursor();
318+
319+ bool cursor_shown;
320+ uint32_t remove_delay;
321+ uint32_t last_cursor_movement;
322+ std::shared_ptr<mir::graphics::Cursor> const cursor;
323+};
324+
325+#endif
326
327=== modified file 'src/mir_screen.cpp'
328--- src/mir_screen.cpp 2015-07-27 17:01:28 +0000
329+++ src/mir_screen.cpp 2015-08-04 17:52:54 +0000
330@@ -23,6 +23,7 @@
331 #include <mir/graphics/display.h>
332 #include <mir/graphics/display_configuration.h>
333 #include <mir/input/touch_visualizer.h>
334+#include <mir/graphics/cursor.h>
335
336 #include <cstdio>
337 #include "screen_hardware.h"
338@@ -39,6 +40,7 @@
339 std::shared_ptr<mir::input::TouchVisualizer> const& touch_visualizer,
340 std::shared_ptr<mir::time::AlarmFactory> const& alarm_factory,
341 std::shared_ptr<usc::Clock> const& clock,
342+ std::shared_ptr<mir::graphics::Cursor> const& cursor,
343 Timeouts inactivity_timeouts,
344 Timeouts notification_timeouts)
345 : screen_hardware{screen_hardware},
346@@ -47,6 +49,7 @@
347 touch_visualizer{touch_visualizer},
348 alarm_factory{alarm_factory},
349 clock{clock},
350+ cursor{cursor},
351 power_off_alarm{alarm_factory->create_alarm(
352 std::bind(&usc::MirScreen::power_off_alarm_notification, this))},
353 dimmer_alarm{alarm_factory->create_alarm(
354@@ -328,3 +331,4 @@
355
356 power_state_change_handler = handler;
357 }
358+
359
360=== modified file 'src/mir_screen.h'
361--- src/mir_screen.h 2015-07-17 12:43:46 +0000
362+++ src/mir_screen.h 2015-08-04 17:52:54 +0000
363@@ -29,7 +29,7 @@
364 namespace mir
365 {
366 namespace compositor { class Compositor; }
367-namespace graphics {class Display;}
368+namespace graphics {class Display; class Cursor;}
369 namespace input { class TouchVisualizer; }
370 namespace time { class AlarmFactory; class Alarm; }
371 }
372@@ -55,6 +55,7 @@
373 std::shared_ptr<mir::input::TouchVisualizer> const& touch_visualizer,
374 std::shared_ptr<mir::time::AlarmFactory> const& alarm_factory,
375 std::shared_ptr<usc::Clock> const& clock,
376+ std::shared_ptr<mir::graphics::Cursor> const& cursor,
377 Timeouts inactivity_timeouts,
378 Timeouts notification_timeouts);
379 ~MirScreen();
380@@ -94,6 +95,7 @@
381 std::shared_ptr<mir::input::TouchVisualizer> const touch_visualizer;
382 std::shared_ptr<mir::time::AlarmFactory> const alarm_factory;
383 std::shared_ptr<usc::Clock> const clock;
384+ std::shared_ptr<mir::graphics::Cursor> const cursor;
385 std::unique_ptr<mir::time::Alarm> const power_off_alarm;
386 std::unique_ptr<mir::time::Alarm> const dimmer_alarm;
387
388
389=== modified file 'src/server.cpp'
390--- src/server.cpp 2015-08-04 17:05:31 +0000
391+++ src/server.cpp 2015-08-04 17:52:54 +0000
392@@ -25,6 +25,7 @@
393 #include "screen_event_handler.h"
394 #include "powerd_mediator.h"
395 #include "unity_screen_service.h"
396+#include "clone_display_configuration_policy.h"
397 #include "steady_clock.h"
398 #include "clone_display_configuration_policy.h"
399
400@@ -114,12 +115,13 @@
401 add_configuration_option("version", "Show version of Unity System Compositor", mir::OptionType::null);
402 add_configuration_option("spinner", "Path to spinner executable", mir::OptionType::string);
403 add_configuration_option("public-socket", "Make the socket file publicly writable", mir::OptionType::boolean);
404- add_configuration_option("enable-hardware-cursor", "Enable the hardware cursor (disabled by default)", mir::OptionType::boolean);
405+ add_configuration_option("enable-hardware-cursor", "Enable the hardware cursor (enabled by default)", mir::OptionType::boolean);
406 add_configuration_option("inactivity-display-off-timeout", "The time in seconds before the screen is turned off when there are no active sessions", mir::OptionType::integer);
407 add_configuration_option("inactivity-display-dim-timeout", "The time in seconds before the screen is dimmed when there are no active sessions", mir::OptionType::integer);
408 add_configuration_option("shutdown-timeout", "The time in milli-seconds the power key must be held to initiate a clean system shutdown", mir::OptionType::integer);
409 add_configuration_option("power-key-ignore-timeout", "The time in milli-seconds the power key must be held to ignore - must be less than shutdown-timeout", mir::OptionType::integer);
410 add_configuration_option("disable-inactivity-policy", "Disables handling user inactivity and power key", mir::OptionType::boolean);
411+ add_configuration_option("remove_pointer_timeout", "The time in milli-seconds the cursor image stays visible after touch screen is used again - by default the cursor image stays visible", mir::OptionType::integer);
412 add_configuration_option("notification-display-off-timeout", "The time in seconds before the screen is turned off after a notification arrives", mir::OptionType::integer);
413 add_configuration_option("notification-display-dim-timeout", "The time in seconds before the screen is dimmed after a notification arrives", mir::OptionType::integer);
414
415@@ -127,18 +129,6 @@
416
417 set_command_line_handler(&ignore_unknown_arguments);
418
419- wrap_cursor_listener([this](std::shared_ptr<mir::input::CursorListener> const& default_)
420- -> std::shared_ptr<mir::input::CursorListener>
421- {
422- // This is a workaround for u8 desktop preview in 14.04 for the lack of client cursor API.
423- // We need to disable the cursor for XMir but leave it on for the desktop preview.
424- // Luckily as it stands they run inside seperate instances of USC. ~racarr
425- if (enable_hardware_cursor())
426- return default_;
427- else
428- return std::make_shared<NullCursorListener>();
429- });
430-
431 override_the_server_status_listener([this]()
432 -> std::shared_ptr<mir::ServerStatusListener>
433 {
434@@ -154,6 +144,7 @@
435 the_session_switcher());
436 });
437
438+<<<<<<< TREE
439 wrap_display_configuration_policy(
440 [](const std::shared_ptr<mg::DisplayConfigurationPolicy> &wrapped)
441 -> std::shared_ptr<mg::DisplayConfigurationPolicy>
442@@ -161,6 +152,16 @@
443 return std::make_shared<CloneDisplayConfigurationPolicy>(wrapped);
444 });
445
446+=======
447+ wrap_display_configuration_policy(
448+ [](const std::shared_ptr<mg::DisplayConfigurationPolicy> &wrapped)
449+ -> std::shared_ptr<mg::DisplayConfigurationPolicy>
450+ {
451+ return std::make_shared<CloneDisplayConfigurationPolicy>(wrapped);
452+ });
453+
454+
455+>>>>>>> MERGE-SOURCE
456 set_config_filename("unity-system-compositor.conf");
457
458 apply_settings();
459@@ -250,6 +251,7 @@
460 the_touch_visualizer(),
461 the_main_loop(),
462 the_clock(),
463+ the_cursor(),
464 MirScreen::Timeouts{
465 inactivity_display_off_timeout(),
466 inactivity_display_dim_timeout()},
467
468=== modified file 'src/server.h'
469--- src/server.h 2015-07-15 13:48:31 +0000
470+++ src/server.h 2015-08-04 17:52:54 +0000
471@@ -51,6 +51,7 @@
472
473 using mir::Server::add_init_callback;
474 using mir::Server::run;
475+ using mir::Server::the_cursor;
476 using mir::Server::the_main_loop;
477 using mir::Server::the_composite_event_filter;
478 using mir::Server::the_display;
479@@ -93,6 +94,16 @@
480 return the_options()->get("file", "/tmp/mir_socket");
481 }
482
483+ int remove_pointer_timeout()
484+ {
485+ return the_options()->get("remove-pointer-timeout", 0);
486+ }
487+
488+ bool enable_hardware_cursor()
489+ {
490+ return the_options()->get("enable-hardware-cursor", true);
491+ }
492+
493 private:
494 inline auto the_options()
495 -> decltype(mir::Server::get_options())
496@@ -138,11 +149,6 @@
497 the_options()->get("power-key-ignore-timeout", 2000)};
498 }
499
500- bool enable_hardware_cursor()
501- {
502- return the_options()->get("enable-hardware-cursor", false);
503- }
504-
505 std::string spinner_executable()
506 {
507 // TODO: once our default spinner is ready for use everywhere, replace
508
509=== modified file 'src/system_compositor.cpp'
510--- src/system_compositor.cpp 2015-04-07 13:36:48 +0000
511+++ src/system_compositor.cpp 2015-08-04 17:52:54 +0000
512@@ -20,6 +20,7 @@
513 #include "system_compositor.h"
514 #include "server.h"
515 #include "dm_connection.h"
516+#include "cursor_enabler.h"
517
518 #include <mir/input/composite_event_filter.h>
519 #include <mir/abnormal_exit.h>
520@@ -87,6 +88,8 @@
521 return;
522 }
523
524+ std::chrono::milliseconds remove_pointer_timeout{server->remove_pointer_timeout()};
525+
526 server->add_init_callback([&]
527 {
528 auto vendor = (char *) glGetString(GL_VENDOR);
529@@ -118,9 +121,16 @@
530 screen = server->the_screen();
531 screen_event_handler = server->the_screen_event_handler();
532
533+ cursor_enabler = std::make_shared<CursorEnabler>(
534+ server->the_cursor(),
535+ remove_pointer_timeout);
536+
537 auto composite_filter = server->the_composite_event_filter();
538 composite_filter->append(screen_event_handler);
539
540+ if (server->enable_hardware_cursor())
541+ composite_filter->append(cursor_enabler);
542+
543 unity_screen_service = server->the_unity_screen_service();
544 }
545 });
546
547=== modified file 'src/system_compositor.h'
548--- src/system_compositor.h 2015-04-07 13:36:48 +0000
549+++ src/system_compositor.h 2015-08-04 17:52:54 +0000
550@@ -30,6 +30,8 @@
551 }
552 }
553
554+class CursorEnabler;
555+
556 namespace usc
557 {
558
559@@ -53,6 +55,7 @@
560 std::shared_ptr<Screen> screen;
561 std::shared_ptr<mir::input::EventFilter> screen_event_handler;
562 std::shared_ptr<UnityScreenService> unity_screen_service;
563+ std::shared_ptr<CursorEnabler> cursor_enabler;
564 };
565
566 }
567
568=== modified file 'src/window_manager.cpp'
569--- src/window_manager.cpp 2015-06-11 16:55:36 +0000
570+++ src/window_manager.cpp 2015-08-04 17:52:54 +0000
571@@ -20,23 +20,23 @@
572
573 #include "session_monitor.h"
574
575+#include "mir/graphics/display.h"
576+#include "mir/graphics/display_configuration.h"
577 #include "mir/geometry/rectangle.h"
578-#include "mir/shell/surface_ready_observer.h"
579 #include "mir/scene/session.h"
580-#include "mir/scene/session_coordinator.h"
581 #include "mir/scene/surface.h"
582-#include "mir/scene/surface_creation_parameters.h"
583 #include "mir/shell/display_layout.h"
584 #include "mir/shell/focus_controller.h"
585-#include "mir/shell/surface_specification.h"
586
587 #include "mir_toolkit/client_types.h"
588
589 #include <iostream>
590+#include <algorithm>
591
592 namespace mf = mir::frontend;
593 namespace ms = mir::scene;
594 namespace msh = mir::shell;
595+namespace mg = mir::graphics;
596
597 namespace
598 {
599@@ -93,9 +93,11 @@
600 focus_controller,
601 display_layout,
602 session_coordinator},
603- session_monitor{session_monitor}
604+ session_monitor{session_monitor},
605+ display_layout{display_layout}
606 {
607 }
608+
609 void usc::WindowManager::on_session_added(std::shared_ptr<mir::scene::Session> const& session) const
610 {
611 std::cerr << "Opening session " << session->name() << std::endl;
612@@ -103,6 +105,7 @@
613 auto const usc_session = std::make_shared<UscSession>(session, *focus_controller);
614
615 session_monitor->add(usc_session, session->process_id());
616+ sessions.push_back(session);
617 }
618
619 void usc::WindowManager::on_session_removed(std::shared_ptr<mir::scene::Session> const& session) const
620@@ -110,9 +113,59 @@
621 std::cerr << "Closing session " << session->name() << std::endl;
622
623 session_monitor->remove(session);
624+
625+ sessions.erase( std::remove(begin(sessions), end(sessions), session), end(sessions));
626 }
627
628 void usc::WindowManager::on_session_ready(std::shared_ptr<mir::scene::Session> const& session) const
629 {
630 session_monitor->mark_ready(session.get());
631 }
632+
633+void usc::WindowManager::add_display(mir::geometry::Rectangle const& area)
634+{
635+ rects.push_back(area);
636+ resize_scene_to_cloned_display_intersection();
637+}
638+
639+void usc::WindowManager::remove_display(mir::geometry::Rectangle const& area)
640+{
641+ for(auto it = rects.begin(); it != rects.end();)
642+ {
643+ if (*it == area)
644+ it = rects.erase(it);
645+ else
646+ it++;
647+ }
648+
649+ resize_scene_to_cloned_display_intersection();
650+}
651+
652+void usc::WindowManager::resize_scene_to_cloned_display_intersection()
653+{
654+ using namespace mir::geometry;
655+ // Determine display intersection geometry - they should already be cloned and have
656+ // orientation (i.e. both landscape)
657+
658+ if (rects.empty())
659+ return;
660+
661+ auto intersection = rects.front();
662+ for (auto const& rect : rects)
663+ intersection = intersection.intersection_with(rect);
664+
665+ std::cout << "Intersection: " << intersection << std::endl;
666+
667+ // Now resize all surfaces in scene to this value
668+ for (auto &session : sessions)
669+ {
670+ auto first = session->default_surface();
671+ first->resize(intersection.size);
672+ auto next = session->surface_after(first);
673+ while (next != first)
674+ {
675+ next->resize(intersection.size);
676+ next = session->surface_after(next);
677+ }
678+ }
679+}
680
681=== modified file 'src/window_manager.h'
682--- src/window_manager.h 2015-06-11 16:51:42 +0000
683+++ src/window_manager.h 2015-08-04 17:52:54 +0000
684@@ -20,11 +20,15 @@
685 #define USC_WINDOW_MANAGER_H_
686
687 #include <mir/shell/system_compositor_window_manager.h>
688+#include "mir/geometry/rectangle.h"
689 #include "session_monitor.h"
690+#include <vector>
691+#include <set>
692
693 namespace mir
694 {
695-namespace scene { class PlacementStrategy; class SessionCoordinator; }
696+namespace graphics { class Display; }
697+namespace scene { class SessionCoordinator; }
698 namespace shell { class FocusController; class DisplayLayout; }
699 }
700
701@@ -39,14 +43,24 @@
702 mir::shell::FocusController* focus_controller,
703 std::shared_ptr<mir::shell::DisplayLayout> const& display_layout,
704 std::shared_ptr<mir::scene::SessionCoordinator> const& session_coordinator,
705- std::shared_ptr<SessionMonitor> const& session_switcher);
706+ std::shared_ptr<SessionMonitor> const& session_monitor);
707
708 private:
709+ void resize_scene_to_cloned_display_intersection();
710 std::shared_ptr<SessionMonitor> const session_monitor;
711
712+ std::shared_ptr<mir::graphics::Display> display;
713+ std::shared_ptr<mir::shell::DisplayLayout> const display_layout;
714+ mutable std::vector<std::shared_ptr<mir::scene::Session>> sessions;
715+
716+ void add_display(mir::geometry::Rectangle const& area);
717+ void remove_display(mir::geometry::Rectangle const& area);
718 virtual void on_session_added(std::shared_ptr<mir::scene::Session> const& session) const;
719 virtual void on_session_removed(std::shared_ptr<mir::scene::Session> const& session) const;
720 virtual void on_session_ready(std::shared_ptr<mir::scene::Session> const& session) const;
721+ std::vector<mir::geometry::Rectangle> rects;
722+ mir::geometry::Size surface_size;
723+ std::vector<std::shared_ptr<mir::scene::Surface>> mutable surfaces;
724 };
725 }
726
727
728=== modified file 'tests/integration-tests/test_unity_screen_service.cpp'
729--- tests/integration-tests/test_unity_screen_service.cpp 2015-07-16 06:14:32 +0000
730+++ tests/integration-tests/test_unity_screen_service.cpp 2015-08-04 17:52:54 +0000
731@@ -50,6 +50,7 @@
732 MOCK_METHOD2(set_inactivity_timeouts, void(int power_off_timeout, int dimmer_timeout));
733
734 MOCK_METHOD1(set_touch_visualization_enabled, void(bool enabled));
735+ MOCK_METHOD2(override_orientation, void(unsigned int, int));
736
737 void register_power_state_change_handler(
738 usc::PowerStateChangeHandler const& handler)
739
740=== modified file 'tests/unit-tests/CMakeLists.txt'
741--- tests/unit-tests/CMakeLists.txt 2015-02-18 14:40:29 +0000
742+++ tests/unit-tests/CMakeLists.txt 2015-08-04 17:52:54 +0000
743@@ -22,6 +22,7 @@
744 add_executable(
745 usc_unit_tests
746
747+ test_cursor_enabler.cpp
748 test_session_switcher.cpp
749 test_screen_event_handler.cpp
750 test_mir_screen.cpp
751
752=== added file 'tests/unit-tests/test_cursor_enabler.cpp'
753--- tests/unit-tests/test_cursor_enabler.cpp 1970-01-01 00:00:00 +0000
754+++ tests/unit-tests/test_cursor_enabler.cpp 2015-08-04 17:52:54 +0000
755@@ -0,0 +1,97 @@
756+/*
757+ * Copyright © 2015 Canonical Ltd.
758+ *
759+ * This program is free software: you can redistribute it and/or modify
760+ * it under the terms of the GNU General Public License version 3 as
761+ * published by the Free Software Foundation.
762+ *
763+ * This program is distributed in the hope that it will be useful,
764+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
765+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
766+ * GNU General Public License for more details.
767+ *
768+ * You should have received a copy of the GNU General Public License
769+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
770+ *
771+ * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
772+ */
773+
774+#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
775+
776+#include "src/cursor_enabler.h"
777+
778+#include "mir_toolkit/event.h"
779+#include "mir/events/event_builders.h"
780+#include "mir/graphics/cursor.h"
781+#include "mir/graphics/cursor_image.h"
782+#include "mir_toolkit/events/input/input_event.h"
783+
784+#include <gtest/gtest.h>
785+#include <gmock/gmock.h>
786+
787+#include <memory>
788+#include <vector>
789+#include <tuple>
790+#include <cstring>
791+#include <chrono>
792+
793+namespace mev = mir::events;
794+
795+namespace
796+{
797+struct MockCursor : mir::graphics::Cursor
798+{
799+ MOCK_METHOD0(show, void());
800+ MOCK_METHOD1(show, void(mir::graphics::CursorImage const&));
801+ MOCK_METHOD0(hide, void());
802+ MOCK_METHOD1(move_to, void(mir::geometry::Point));
803+ MOCK_METHOD2(override_orientation, void(uint32_t, MirOrientation));
804+};
805+
806+struct TestCursorEnabler : ::testing::Test
807+{
808+ std::shared_ptr<::testing::NiceMock<MockCursor>> mock_cursor = std::make_shared<::testing::NiceMock<MockCursor>>();
809+ std::chrono::milliseconds never_remove_pointer{0};
810+ std::chrono::milliseconds remove_after_five_seconds_of_non_pointing_events{5000};
811+
812+ mir::EventUPtr mouse_event{ mev::make_event(MirInputDeviceId{1}, std::chrono::nanoseconds(10), mir_input_event_modifier_none, mir_pointer_action_motion, 0, 1.0f, 1.0f, 0.0f, 0.0f) };
813+ mir::EventUPtr touch_event{ mev::make_event(MirInputDeviceId{2}, std::chrono::nanoseconds(6000), mir_input_event_modifier_none) };
814+ mir::EventUPtr key_event{ mev::make_event(MirInputDeviceId{3}, std::chrono::nanoseconds(6000), mir_keyboard_action_up, 0, 0, mir_input_event_modifier_none) };
815+ TestCursorEnabler()
816+ {
817+ mev::add_touch(*touch_event, 0, mir_touch_action_change, mir_touch_tooltype_unknown, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);
818+ }
819+};
820+}
821+
822+TEST_F(TestCursorEnabler, disables_cursor_on_start)
823+{
824+ using namespace testing;
825+ EXPECT_CALL(*mock_cursor, hide());
826+
827+ CursorEnabler enabler(mock_cursor, never_remove_pointer);
828+}
829+
830+TEST_F(TestCursorEnabler, enable_cursor_on_mouse_event)
831+{
832+ using namespace testing;
833+ EXPECT_CALL(*mock_cursor, hide());
834+ EXPECT_CALL(*mock_cursor, show());
835+
836+ CursorEnabler enabler(mock_cursor, never_remove_pointer);
837+ enabler.handle(*mouse_event);
838+}
839+
840+TEST_F(TestCursorEnabler, disable_cursor_on_touch_event)
841+{
842+ using namespace testing;
843+ InSequence seq;
844+ EXPECT_CALL(*mock_cursor, hide());
845+ EXPECT_CALL(*mock_cursor, show());
846+ EXPECT_CALL(*mock_cursor, hide());
847+
848+ CursorEnabler enabler(mock_cursor, remove_after_five_seconds_of_non_pointing_events);
849+ enabler.handle(*mouse_event);
850+ enabler.handle(*touch_event);
851+}
852+
853
854=== modified file 'tests/unit-tests/test_mir_screen.cpp'
855--- tests/unit-tests/test_mir_screen.cpp 2015-07-27 17:01:28 +0000
856+++ tests/unit-tests/test_mir_screen.cpp 2015-08-04 17:52:54 +0000
857@@ -26,6 +26,7 @@
858 #include <mir/graphics/display_configuration.h>
859 #include <mir/graphics/gl_context.h>
860 #include <mir/input/touch_visualizer.h>
861+#include <mir/graphics/cursor.h>
862
863 #include <gtest/gtest.h>
864 #include <gmock/gmock.h>
865@@ -146,6 +147,15 @@
866 void visualize_touches(std::vector<Spot> const& touches) override {}
867 };
868
869+struct MockCursor : mir::graphics::Cursor
870+{
871+ void show() {}
872+ void show(mg::CursorImage const& ) {}
873+ void hide() {}
874+ void move_to(mir::geometry::Point) {}
875+ void override_orientation(uint32_t, MirOrientation) {}
876+};
877+
878 struct AMirScreen : testing::Test
879 {
880 AMirScreen()
881@@ -272,6 +282,8 @@
882 std::make_shared<testing::NiceMock<MockTouchVisualizer>>()};
883 std::shared_ptr<AdvanceableTimer> timer{
884 std::make_shared<AdvanceableTimer>()};
885+ std::shared_ptr<MockCursor> cursor{
886+ std::make_shared<testing::NiceMock<MockCursor>>()};
887
888 usc::MirScreen mir_screen{
889 screen_hardware,
890@@ -280,6 +292,7 @@
891 touch_visualizer,
892 timer,
893 timer,
894+ cursor,
895 {power_off_timeout, dimmer_timeout},
896 {notification_power_off_timeout, notification_dimmer_timeout}};
897 };
898
899=== modified file 'tests/unit-tests/test_screen_event_handler.cpp'
900--- tests/unit-tests/test_screen_event_handler.cpp 2015-07-13 12:35:41 +0000
901+++ tests/unit-tests/test_screen_event_handler.cpp 2015-08-04 17:52:54 +0000
902@@ -46,6 +46,7 @@
903 MOCK_METHOD2(set_inactivity_timeouts, void(int power_off_timeout, int dimmer_timeout));
904
905 MOCK_METHOD1(set_touch_visualization_enabled, void(bool enabled));
906+ MOCK_METHOD2(override_orientation, void(unsigned int, int));
907 MOCK_METHOD1(register_power_state_change_handler, void(
908 usc::PowerStateChangeHandler const& handler));
909

Subscribers

People subscribed via source and target branches