Mir

Merge lp:~robertcarr/mir/improve-cursor-configuration into lp:~mir-team/mir/trunk

Proposed by Robert Carr
Status: Merged
Approved by: Robert Carr
Approved revision: no longer in the source branch.
Merged at revision: 850
Proposed branch: lp:~robertcarr/mir/improve-cursor-configuration
Merge into: lp:~mir-team/mir/trunk
Diff against target: 95 lines (+31/-19)
2 files modified
include/server/mir/default_server_configuration.h (+3/-0)
src/server/default_server_configuration.cpp (+28/-19)
To merge this branch: bzr merge lp:~robertcarr/mir/improve-cursor-configuration
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
Robert Ancell Approve
Review via email: mp+174003@code.launchpad.net

Commit message

Extract DefaultServerConfiguration::the_cursor_listener from DefaultServerConfiguration::the_input_configuration

Description of the change

Make it easy to override the cursor listener for unity-system-compositor

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Robert Ancell (robert-ancell) wrote :

I don't know what needs to access this but the code makes sense.

review: Approve
Revision history for this message
Robert Ancell (robert-ancell) wrote :

There seems to be some additional indentation around lines 48-52 of the diff.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Oh, from the bug I guess this is so we ignore the cursor moving and don't move the cursor overlay? I would have thought we'd just turn the whole cursor off somewhere so we don't use a layer and the input system isn't running (for mouse inputs).

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

Looks good.

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

As Robert mentioned the braces are indented too deeply:

48 + if (auto c = cursor.lock())
49 + {
50 + c->move_to(geom::Point{geom::X(abs_x), geom::Y(abs_y)});
51 + }

Also since geom::Point now has a new constructor, we can now just use geom::Point{abs_x, abs_y}

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Would be OK, except it trivially conflicts with trunk

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/server/mir/default_server_configuration.h'
2--- include/server/mir/default_server_configuration.h 2013-07-10 08:50:53 +0000
3+++ include/server/mir/default_server_configuration.h 2013-07-12 20:53:27 +0000
4@@ -90,6 +90,7 @@
5 class EventFilter;
6 class InputChannelFactory;
7 class InputConfiguration;
8+class CursorListener;
9 }
10
11 namespace logging
12@@ -192,6 +193,7 @@
13 virtual std::initializer_list<std::shared_ptr<input::EventFilter> const> the_event_filters();
14 virtual std::shared_ptr<surfaces::InputRegistrar> the_input_registrar();
15 virtual std::shared_ptr<shell::InputTargeter> the_input_targeter();
16+ virtual std::shared_ptr<input::CursorListener> the_cursor_listener();
17 /** @} */
18
19 /** @name logging configuration - customization
20@@ -224,6 +226,7 @@
21 CachedPtr<input::InputManager> input_manager;
22 CachedPtr<surfaces::InputRegistrar> input_registrar;
23 CachedPtr<shell::InputTargeter> input_targeter;
24+ CachedPtr<input::CursorListener> cursor_listener;
25 CachedPtr<graphics::Platform> graphics_platform;
26 CachedPtr<graphics::BufferInitializer> buffer_initializer;
27 CachedPtr<compositor::GraphicBufferAllocator> buffer_allocator;
28
29=== modified file 'src/server/default_server_configuration.cpp'
30--- src/server/default_server_configuration.cpp 2013-07-11 09:51:41 +0000
31+++ src/server/default_server_configuration.cpp 2013-07-12 20:53:27 +0000
32@@ -466,35 +466,44 @@
33 });
34 }
35
36+std::shared_ptr<mi::CursorListener>
37+mir::DefaultServerConfiguration::the_cursor_listener()
38+{
39+ struct DefaultCursorListener : mi::CursorListener
40+ {
41+ DefaultCursorListener(std::weak_ptr<mg::Cursor> const& cursor) :
42+ cursor(cursor)
43+ {
44+ }
45+
46+ void cursor_moved_to(float abs_x, float abs_y)
47+ {
48+ if (auto c = cursor.lock())
49+ {
50+ c->move_to(geom::Point{abs_x, abs_y});
51+ }
52+ }
53+
54+ std::weak_ptr<mg::Cursor> const cursor;
55+ };
56+ return cursor_listener(
57+ [this]() -> std::shared_ptr<mi::CursorListener>
58+ {
59+ return std::make_shared<DefaultCursorListener>(the_display()->the_cursor());
60+ });
61+}
62+
63 std::shared_ptr<mi::InputConfiguration>
64 mir::DefaultServerConfiguration::the_input_configuration()
65 {
66 if (!input_configuration)
67 {
68- struct DefaultCursorListener : mi::CursorListener
69- {
70- DefaultCursorListener(std::weak_ptr<mg::Cursor> const& cursor) :
71- cursor(cursor)
72- {
73- }
74-
75- void cursor_moved_to(float abs_x, float abs_y)
76- {
77- if (auto c = cursor.lock())
78- {
79- c->move_to(geom::Point{abs_x, abs_y});
80- }
81- }
82-
83- std::weak_ptr<mg::Cursor> const cursor;
84- };
85-
86 if (the_options()->get("enable-input", enable_input_default))
87 {
88 input_configuration = std::make_shared<mia::DefaultInputConfiguration>(
89 the_event_filters(),
90 the_display(),
91- std::make_shared<DefaultCursorListener>(the_display()->the_cursor()),
92+ the_cursor_listener(),
93 the_input_report());
94 }
95 else

Subscribers

People subscribed via source and target branches