Merge lp:~alan-griffiths/mir/surface-states-simplification into lp:~mir-team/mir/trunk
- surface-states-simplification
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Robert Ancell |
Approved revision: | no longer in the source branch. |
Merged at revision: | 636 |
Proposed branch: | lp:~alan-griffiths/mir/surface-states-simplification |
Merge into: | lp:~mir-team/mir/trunk |
Prerequisite: | lp:~vanvugt/mir/surface-states |
Diff against target: |
1924 lines (+334/-253) 62 files modified
examples/demo-inprocess-egl/inprocess_egl_client.cpp (+1/-1) include/server/mir/frontend/protobuf_ipc_factory.h (+4/-2) include/server/mir/frontend/session.h (+0/-3) include/server/mir/frontend/session_mediator.h (+5/-3) include/server/mir/frontend/shell.h (+5/-2) include/server/mir/shell/application_session.h (+11/-5) include/server/mir/shell/organising_surface_factory.h (+4/-1) include/server/mir/shell/session_manager.h (+1/-1) include/server/mir/shell/surface.h (+13/-7) include/server/mir/shell/surface_factory.h (+9/-1) include/server/mir/shell/surface_source.h (+4/-1) include/shared/mir/events/event_sink.h (+6/-5) include/test/mir_test_doubles/mock_session.h (+0/-2) include/test/mir_test_doubles/mock_shell.h (+1/-1) include/test/mir_test_doubles/mock_surface_factory.h (+4/-1) include/test/mir_test_doubles/stub_ipc_factory.h (+1/-1) include/test/mir_test_doubles/stub_session.h (+1/-1) include/test/mir_test_doubles/stub_shell.h (+1/-1) src/client/make_rpc_channel.h (+2/-2) src/client/make_socket_rpc_channel.cpp (+1/-1) src/client/mir_basic_rpc_channel.cpp (+1/-3) src/client/mir_basic_rpc_channel.h (+6/-0) src/client/mir_client_library.cpp (+9/-13) src/client/mir_connection.cpp (+2/-1) src/client/mir_connection.h (+5/-4) src/client/mir_socket_rpc_channel.cpp (+32/-33) src/client/mir_socket_rpc_channel.h (+4/-4) src/server/CMakeLists.txt (+0/-1) src/server/default_server_configuration.cpp (+2/-1) src/server/frontend/CMakeLists.txt (+1/-0) src/server/frontend/event_pipe.cpp (+6/-7) src/server/frontend/event_pipe.h (+12/-10) src/server/frontend/protobuf_message_processor.cpp (+3/-1) src/server/frontend/protobuf_message_processor.h (+2/-2) src/server/frontend/protobuf_socket_communicator.cpp (+4/-5) src/server/frontend/session_mediator.cpp (+2/-3) src/server/shell/application_session.cpp (+14/-12) src/server/shell/organising_surface_factory.cpp (+5/-2) src/server/shell/session_manager.cpp (+4/-2) src/server/shell/surface.cpp (+19/-12) src/server/shell/surface_source.cpp (+7/-2) src/shared/protobuf/mir_protobuf_wire.proto (+3/-1) tests/acceptance-tests/test_focus_management_api.cpp (+4/-4) tests/behavior-tests/session_management_context.cpp (+8/-4) tests/integration-tests/cucumber/test_session_management_context.cpp (+3/-3) tests/integration-tests/shell/test_session_manager.cpp (+8/-7) tests/unit-tests/CMakeLists.txt (+0/-1) tests/unit-tests/client/test_client_mir_surface.cpp (+1/-1) tests/unit-tests/client/test_mir_connection.cpp (+3/-1) tests/unit-tests/event/CMakeLists.txt (+0/-5) tests/unit-tests/frontend/CMakeLists.txt (+1/-0) tests/unit-tests/frontend/test_event_pipe.cpp (+14/-11) tests/unit-tests/frontend/test_session_mediator.cpp (+9/-5) tests/unit-tests/frontend/test_session_mediator_android.cpp (+9/-3) tests/unit-tests/frontend/test_session_mediator_gbm.cpp (+9/-3) tests/unit-tests/shell/test_application_session.cpp (+10/-9) tests/unit-tests/shell/test_organising_surface_factory.cpp (+6/-5) tests/unit-tests/shell/test_registration_order_focus_sequence.cpp (+11/-10) tests/unit-tests/shell/test_session_manager.cpp (+16/-15) tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp (+0/-1) tests/unit-tests/shell/test_surface.cpp (+2/-0) tests/unit-tests/shell/test_the_session_container_implementation.cpp (+3/-4) |
To merge this branch: | bzr merge lp:~alan-griffiths/mir/surface-states-simplification |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Chris Halse Rogers | Approve | ||
Robert Ancell | Approve | ||
Kevin DuBois (community) | Approve | ||
Daniel van Vugt | Pending | ||
Review via email: mp+160583@code.launchpad.net |
This proposal supersedes a proposal from 2013-04-23.
Commit message
frontend, shell, tests: surface-states updated to avoid supplying dependencies through public member functions.
Description of the change
frontend, shell, tests: surface-states updated to avoid supplying dependencies through public member functions.
Where possible, dependencies should be supplied as constructor arguments and held as const members.
(This required updates to a few factory interfaces to supply the dependencies.)
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Also, here's an example use-case for changing the event sink of a surface:
Windows (like the one Flash video uses in a web browser) are implemented using reparenting. If Mir was to support such a thing in future then it would be handy to be able to re-assign a surface to a different session. Hence you'd also need to be able to change a surface's event target (its session).
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal | # |
> Secondly, I disagree with the approach. There are no strong "dependencies" here.
As mentioned in an older comment [1], they are effectively dependencies because of how Mir uses the class. That is, in all cases in production code we need to set both the id and the sink for our features to work properly.
> If Mir was to support such a thing in future then it would be handy to be able to re-assign
> a surface to a different session
The key words are "if ... in the future ...". If we need this in the future, we are free to change the code to suit our needs. Right now the values are meant to be set only once at creation time, and accepting them in the constructor enforces this restriction (and, as mentioned above, also enforces that we always get a fully working object).
[1] https:/
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
There is a difference between a local dependency and a system dependency. On the local scale, the classes do not depend on EventSink to work. So on a local scale, it should not affect the constructor.
A surface can emit events. A surface can have an ID. However those are not required attributes for the surface to be created and work as a surface.
No amount of "modern C++ tradition" supersedes the basic programming ideal of low coupling.
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
> Firstly, needs fixing:
> Text conflict in tests/unit-
> 1 conflicts encountered.
Resolved.
> Secondly, I disagree with the approach. There are no strong "dependencies"
> here. The information in question is all optional to the class receiving it,
> so should not be passed in constructors. The classes can function without
> event sinks or surface IDs. They will work as they already do. Only event
> emission would not happen. So it's optional relative to those classes, and
> therefore not something to enforce in the constructor.
Arguing that a subset of the functionality works without these attributes is an argument that the subset belongs in a class providing just that subset. While we could factor that subset out, I don't think we need to that now.
> Aside from anything else, the degree of coupling introduced here looks very
> high. It's always better to minimize coupling.
I agree that coupling should be reduced - I disagree that this MP increases coupling. For example, the interface used by frontend should not need Session:
> You can't call it a
> simplification if coupling is increased and the diff is "+205/-148".
You can't measure coupling (or other attributes of the resulting code) by diff size.
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
I have stated my opinions strongly. I disagree with this proposal as it significantly decreases readability and maintainability. Those are the traits of high coupling, and things I would like to avoid.
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal | # |
> > Secondly, I disagree with the approach. There are no strong "dependencies"
> > here. The information in question is all optional to the class receiving it,
> > so should not be passed in constructors. The classes can function without
> > event sinks or surface IDs. They will work as they already do. Only event
> > emission would not happen. So it's optional relative to those classes, and
> > therefore not something to enforce in the constructor.
>
> Arguing that a subset of the functionality works without these attributes is
> an argument that the subset belongs in a class providing just that subset.
> While we could factor that subset out, I don't think we need to that now.
I think we're using the term 'coupling' too broadly to make much progress arguing :) I'll propose re-framing the argument, and then give my 2 cents
I think we can agree on this though:
1) Its better if a function call doesn't have any hidden prerequisites, like "you must call function A before you call function B". This is sort of 'coupling of calling requirements".
2) A class with a lot of constructor parameters has a lot of dependencies and might be trying to do too much. This is sort of 'coupling of object dependencies'
my 2cents...
so we have to find a way to balance.
I think that, with regards to notify_
We've tried to mitigate the problem of #2 by having a lot of mocks and stubs and nulls that are easy to plug in and make the object easy to manipulate in test. Since its easier to read a constructor than it is to trace what the call order is, I'd rather plug in mocks/stubs to the constructor than have to trace a call order to figure out if we've fulfilled our usage requirements.
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
You are free to propose and land this directly to lp:mir.
I just don't want code like this landing in a branch with my name on it.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:669
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:670
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal | # |
might be the first time there's been 2 rival reviews going on ;-)
again, seems the biggest point of contention is about 2 phase initialization and what has more or less coupling. maybe a new day will let me rephrase a bit better. :) Seems to me that (for example) in msh::Surface msh::Surface's notify_change function is coupled to having the ID, so whether you put it in the constructor or require a set_ function to be called, both depend on having an id to use notify_change() in a way. I'd rather come down on the side of putting it all dependencies in the constructor, because it allows us to see pretty quickly what a class needs, and gives us an easy-to-read signal about if a class is doing too much and needs to refactor. So, msh::Shell, might just be on the point of needing a refactor. (if its constructor is getting "too bloated" of course)
I know we had a debate similar to this one at an earlier point in the project, I hope we have another one next week :)
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal | # |
This doesn't immediately *look* like a simplification to me.
My understanding is that this is a simplification for clients of this code - ie: consumers of this class no longer have to check if the EventSink or SurfaceID is set.
My question is then - do consumers of this class need to check if the EventSink or SurfaceID is set currently? It looks like consumers of this class generally won't care - if they configure() a surface which doesn't have an EventSink set then nothing will get the event but everything else will work as expected?
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
From a high-level perspective I can see two problems here:
1. It's 1000 lines bigger than my proposal. Even if you agree that's not a simplification, but for other purposes, then I think it's still a bit much to review all in one go.
2. This does not solve the problem of code I disagree with ending up in a commit with my name on it. Because once merged it would just show one commit with both our names as authors.
To keep code reviews smaller and simpler, please propose your changes separately (after) surface-states to lp:mir. I won't agree with them, but I won't block them there either.
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Just further to Kevin's comment:
"We've tried to mitigate the problem of #2 by having a lot of mocks and stubs and nulls that are easy to plug in and make the object easy to manipulate in test. Since its easier to read a constructor than it is to trace what the call order is, I'd rather plug in mocks/stubs to the constructor than have to trace a call order to figure out if we've fulfilled our usage requirements."
This is false: "lot of mocks and stubs and nulls that are easy to plug in and make the object easy to manipulate in test". You define "easy" by how much effort it requires for someone like you guys (who have been at it for over a year) to modify the code. I define "easy" by how much effort a newcomer requires (with no prior knowledge of the code).
This is false: "Since its easier to read a constructor than it is to trace what the call order is". Constructors do not explicitly state what they're doing, unlike "set_id" or "set_event_sink". And if you did make a mistake somewhere and dereference a null shared_ptr, then the trace would be a call stack. Automatically generated and easier to read.
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
If you resubmit and prerequisite the surface-states branch, I will close my eyes and happily Abstain.
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
> My question is then - do consumers of this class need to check if the
> EventSink or SurfaceID is set currently? It looks like consumers of this class
> generally won't care - if they configure() a surface which doesn't have an
> EventSink set then nothing will get the event but everything else will work as
> expected?
On this point is that consumers shouldn't even know about them - they shouldn't see these functions in the interface they use (i.e. they don't belong in frontend::Surface). Unnecessarily exposing these functions *is* increasing coupling.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:671
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alan Griffiths (alan-griffiths) wrote : | # |
"So, msh::Shell, might just be on the point of needing a refactor. (if its constructor is getting "too bloated" of course"
I assume that means msh::Surface?
I too have questioned in the past whether some of the attributes currently being added to shell::Surface are best modeled as member variables. (As opposed to say, their being an event filter that has an associative map from surface to event sink.)
This proposal doesn't address this question.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:671
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:674
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:675
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Kevin DuBois (kdub) wrote : | # |
looks good to me, although a good future improvement might be to consolidate ApplicationSess
Robert Ancell (robert-ancell) : | # |
Chris Halse Rogers (raof) wrote : | # |
It's still not clear to me that this is a simplification, but there's nothing objectionable in here.
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'examples/demo-inprocess-egl/inprocess_egl_client.cpp' |
2 | --- examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-04-24 05:22:20 +0000 |
3 | +++ examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-04-25 09:50:50 +0000 |
4 | @@ -60,7 +60,7 @@ |
5 | .of_size(surface_size) |
6 | .of_buffer_usage(mc::BufferUsage::hardware) |
7 | .of_pixel_format(geom::PixelFormat::argb_8888); |
8 | - auto surface = surface_factory->create_surface(params); |
9 | + auto surface = surface_factory->create_surface(params, mf::SurfaceId(), std::shared_ptr<events::EventSink>()); |
10 | |
11 | surface->advance_client_buffer(); // TODO: What a wart! |
12 | |
13 | |
14 | === modified file 'include/server/mir/frontend/protobuf_ipc_factory.h' |
15 | --- include/server/mir/frontend/protobuf_ipc_factory.h 2013-04-24 05:22:20 +0000 |
16 | +++ include/server/mir/frontend/protobuf_ipc_factory.h 2013-04-25 09:50:50 +0000 |
17 | @@ -23,8 +23,10 @@ |
18 | |
19 | namespace mir |
20 | { |
21 | +namespace events |
22 | +{ |
23 | class EventSink; |
24 | - |
25 | +} |
26 | namespace protobuf |
27 | { |
28 | class DisplayServer; |
29 | @@ -38,7 +40,7 @@ |
30 | { |
31 | public: |
32 | virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server( |
33 | - std::shared_ptr<EventSink> const& sink) = 0; |
34 | + std::shared_ptr<events::EventSink> const& sink) = 0; |
35 | virtual std::shared_ptr<ResourceCache> resource_cache() = 0; |
36 | virtual std::shared_ptr<MessageProcessorReport> report() = 0; |
37 | |
38 | |
39 | === modified file 'include/server/mir/frontend/session.h' |
40 | --- include/server/mir/frontend/session.h 2013-04-24 05:22:20 +0000 |
41 | +++ include/server/mir/frontend/session.h 2013-04-25 09:50:50 +0000 |
42 | @@ -29,7 +29,6 @@ |
43 | |
44 | namespace mir |
45 | { |
46 | -class EventSink; |
47 | |
48 | namespace frontend |
49 | { |
50 | @@ -52,8 +51,6 @@ |
51 | |
52 | virtual int configure_surface(SurfaceId id, MirSurfaceAttrib attrib, int value) = 0; |
53 | |
54 | - virtual void set_event_sink(std::shared_ptr<EventSink> const&) = 0; |
55 | - |
56 | protected: |
57 | Session() = default; |
58 | Session(Session const&) = delete; |
59 | |
60 | === modified file 'include/server/mir/frontend/session_mediator.h' |
61 | --- include/server/mir/frontend/session_mediator.h 2013-04-24 05:22:20 +0000 |
62 | +++ include/server/mir/frontend/session_mediator.h 2013-04-25 09:50:50 +0000 |
63 | @@ -27,8 +27,10 @@ |
64 | |
65 | namespace mir |
66 | { |
67 | +namespace events |
68 | +{ |
69 | class EventSink; |
70 | - |
71 | +} |
72 | namespace graphics |
73 | { |
74 | class Platform; |
75 | @@ -62,7 +64,7 @@ |
76 | std::shared_ptr<graphics::ViewableArea> const& viewable_area, |
77 | std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator, |
78 | std::shared_ptr<SessionMediatorReport> const& report, |
79 | - std::shared_ptr<EventSink> const& event_sink, |
80 | + std::shared_ptr<events::EventSink> const& event_sink, |
81 | std::shared_ptr<ResourceCache> const& resource_cache); |
82 | |
83 | /* Platform independent requests */ |
84 | @@ -119,7 +121,7 @@ |
85 | std::shared_ptr<compositor::GraphicBufferAllocator> const buffer_allocator; |
86 | |
87 | std::shared_ptr<SessionMediatorReport> const report; |
88 | - std::shared_ptr<EventSink> const event_sink; |
89 | + std::shared_ptr<events::EventSink> const event_sink; |
90 | std::shared_ptr<ResourceCache> const resource_cache; |
91 | std::shared_ptr<ClientBufferTracker> const client_tracker; |
92 | |
93 | |
94 | === modified file 'include/server/mir/frontend/shell.h' |
95 | --- include/server/mir/frontend/shell.h 2013-04-24 05:22:20 +0000 |
96 | +++ include/server/mir/frontend/shell.h 2013-04-25 09:50:50 +0000 |
97 | @@ -24,7 +24,10 @@ |
98 | |
99 | namespace mir |
100 | { |
101 | - |
102 | +namespace events |
103 | +{ |
104 | +class EventSink; |
105 | +} |
106 | namespace frontend |
107 | { |
108 | class Session; |
109 | @@ -35,7 +38,7 @@ |
110 | public: |
111 | virtual ~Shell() {} |
112 | |
113 | - virtual std::shared_ptr<Session> open_session(std::string const& name) = 0; |
114 | + virtual std::shared_ptr<Session> open_session(std::string const& name, std::shared_ptr<events::EventSink> const& sink) = 0; |
115 | virtual void close_session(std::shared_ptr<Session> const& session) = 0; |
116 | |
117 | virtual void tag_session_with_lightdm_id(std::shared_ptr<Session> const& session, int id) = 0; |
118 | |
119 | === modified file 'include/server/mir/shell/application_session.h' |
120 | --- include/server/mir/shell/application_session.h 2013-04-24 05:22:20 +0000 |
121 | +++ include/server/mir/shell/application_session.h 2013-04-25 09:50:50 +0000 |
122 | @@ -25,8 +25,10 @@ |
123 | |
124 | namespace mir |
125 | { |
126 | +namespace events |
127 | +{ |
128 | class EventSink; |
129 | - |
130 | +} |
131 | namespace shell |
132 | { |
133 | class SurfaceFactory; |
134 | @@ -38,6 +40,13 @@ |
135 | public: |
136 | explicit ApplicationSession(std::shared_ptr<SurfaceFactory> const& surface_factory, |
137 | std::shared_ptr<InputTargetListener> const& input_target_listener, std::string const& session_name); |
138 | + |
139 | + ApplicationSession( |
140 | + std::shared_ptr<SurfaceFactory> const& surface_factory, |
141 | + std::shared_ptr<InputTargetListener> const& input_target_listener, |
142 | + std::string const& session_name, |
143 | + std::shared_ptr<events::EventSink> const& sink); |
144 | + |
145 | ~ApplicationSession(); |
146 | |
147 | frontend::SurfaceId create_surface(frontend::SurfaceCreationParameters const& params); |
148 | @@ -55,8 +64,6 @@ |
149 | |
150 | int configure_surface(frontend::SurfaceId id, MirSurfaceAttrib attrib, int value); |
151 | |
152 | - void set_event_sink(std::shared_ptr<mir::EventSink> const& sink); |
153 | - |
154 | protected: |
155 | ApplicationSession(ApplicationSession const&) = delete; |
156 | ApplicationSession& operator=(ApplicationSession const&) = delete; |
157 | @@ -65,6 +72,7 @@ |
158 | std::shared_ptr<SurfaceFactory> const surface_factory; |
159 | std::shared_ptr<InputTargetListener> const input_target_listener; |
160 | std::string const session_name; |
161 | + std::shared_ptr<events::EventSink> const event_sink; |
162 | |
163 | frontend::SurfaceId next_id(); |
164 | |
165 | @@ -74,8 +82,6 @@ |
166 | Surfaces::const_iterator checked_find(frontend::SurfaceId id) const; |
167 | std::mutex mutable surfaces_mutex; |
168 | Surfaces surfaces; |
169 | - |
170 | - std::shared_ptr<EventSink> event_sink; |
171 | }; |
172 | |
173 | } |
174 | |
175 | === modified file 'include/server/mir/shell/organising_surface_factory.h' |
176 | --- include/server/mir/shell/organising_surface_factory.h 2013-04-24 05:22:20 +0000 |
177 | +++ include/server/mir/shell/organising_surface_factory.h 2013-04-25 09:50:50 +0000 |
178 | @@ -36,7 +36,10 @@ |
179 | std::shared_ptr<PlacementStrategy> const& placement_strategy); |
180 | virtual ~OrganisingSurfaceFactory(); |
181 | |
182 | - std::shared_ptr<Surface> create_surface(frontend::SurfaceCreationParameters const& params); |
183 | + std::shared_ptr<Surface> create_surface( |
184 | + frontend::SurfaceCreationParameters const& params, |
185 | + frontend::SurfaceId id, |
186 | + std::shared_ptr<events::EventSink> const& sink) override; |
187 | |
188 | protected: |
189 | OrganisingSurfaceFactory(OrganisingSurfaceFactory const&) = delete; |
190 | |
191 | === modified file 'include/server/mir/shell/session_manager.h' |
192 | --- include/server/mir/shell/session_manager.h 2013-04-24 22:14:08 +0000 |
193 | +++ include/server/mir/shell/session_manager.h 2013-04-25 09:50:50 +0000 |
194 | @@ -54,7 +54,7 @@ |
195 | std::shared_ptr<InputTargetListener> const& input_target_listener); |
196 | virtual ~SessionManager(); |
197 | |
198 | - virtual std::shared_ptr<frontend::Session> open_session(std::string const& name); |
199 | + virtual std::shared_ptr<frontend::Session> open_session(std::string const& name, std::shared_ptr<events::EventSink> const& sink); |
200 | virtual void close_session(std::shared_ptr<frontend::Session> const& session); |
201 | |
202 | virtual void tag_session_with_lightdm_id(std::shared_ptr<frontend::Session> const& session, int id); |
203 | |
204 | === modified file 'include/server/mir/shell/surface.h' |
205 | --- include/server/mir/shell/surface.h 2013-04-24 05:22:20 +0000 |
206 | +++ include/server/mir/shell/surface.h 2013-04-25 09:50:50 +0000 |
207 | @@ -31,9 +31,10 @@ |
208 | |
209 | namespace mir |
210 | { |
211 | - |
212 | +namespace events |
213 | +{ |
214 | class EventSink; |
215 | - |
216 | +} |
217 | namespace frontend |
218 | { |
219 | struct SurfaceCreationParameters; |
220 | @@ -54,6 +55,14 @@ |
221 | std::shared_ptr<SurfaceBuilder> const& builder, |
222 | frontend::SurfaceCreationParameters const& params, |
223 | std::shared_ptr<input::InputChannel> const& input_channel); |
224 | + |
225 | + Surface( |
226 | + std::shared_ptr<SurfaceBuilder> const& builder, |
227 | + frontend::SurfaceCreationParameters const& params, |
228 | + std::shared_ptr<input::InputChannel> const& input_channel, |
229 | + frontend::SurfaceId id, |
230 | + std::shared_ptr<events::EventSink> const& sink); |
231 | + |
232 | ~Surface(); |
233 | |
234 | virtual void hide(); |
235 | @@ -82,9 +91,6 @@ |
236 | virtual MirSurfaceType type() const; |
237 | virtual MirSurfaceState state() const; |
238 | |
239 | - void set_id(frontend::SurfaceId i); |
240 | - void set_event_target(std::shared_ptr<EventSink> const& sink); |
241 | - |
242 | private: |
243 | bool set_type(MirSurfaceType t); // Use configure() to make public changes |
244 | bool set_state(MirSurfaceState s); |
245 | @@ -94,8 +100,8 @@ |
246 | std::shared_ptr<mir::input::InputChannel> const input_channel; |
247 | std::weak_ptr<mir::surfaces::Surface> const surface; |
248 | |
249 | - std::shared_ptr<EventSink> event_sink; |
250 | - frontend::SurfaceId id; |
251 | + frontend::SurfaceId const id; |
252 | + std::shared_ptr<events::EventSink> const event_sink; |
253 | |
254 | MirSurfaceType type_value; |
255 | MirSurfaceState state_value; |
256 | |
257 | === modified file 'include/server/mir/shell/surface_factory.h' |
258 | --- include/server/mir/shell/surface_factory.h 2013-04-24 05:22:20 +0000 |
259 | +++ include/server/mir/shell/surface_factory.h 2013-04-25 09:50:50 +0000 |
260 | @@ -19,10 +19,15 @@ |
261 | #ifndef MIR_SHELL_SURFACE_FACTORY_H_ |
262 | #define MIR_SHELL_SURFACE_FACTORY_H_ |
263 | |
264 | +#include "mir/frontend/surface_id.h" |
265 | #include <memory> |
266 | |
267 | namespace mir |
268 | { |
269 | +namespace events |
270 | +{ |
271 | +class EventSink; |
272 | +} |
273 | namespace frontend |
274 | { |
275 | struct SurfaceCreationParameters; |
276 | @@ -34,7 +39,10 @@ |
277 | class SurfaceFactory |
278 | { |
279 | public: |
280 | - virtual std::shared_ptr<Surface> create_surface(const frontend::SurfaceCreationParameters& params) = 0; |
281 | + virtual std::shared_ptr<Surface> create_surface( |
282 | + frontend::SurfaceCreationParameters const& params, |
283 | + frontend::SurfaceId id, |
284 | + std::shared_ptr<events::EventSink> const& sink) = 0; |
285 | |
286 | protected: |
287 | virtual ~SurfaceFactory() {} |
288 | |
289 | === modified file 'include/server/mir/shell/surface_source.h' |
290 | --- include/server/mir/shell/surface_source.h 2013-04-24 05:22:20 +0000 |
291 | +++ include/server/mir/shell/surface_source.h 2013-04-25 09:50:50 +0000 |
292 | @@ -40,7 +40,10 @@ |
293 | explicit SurfaceSource(std::shared_ptr<SurfaceBuilder> const& surface_builder, std::shared_ptr<input::InputChannelFactory> const& input_factory); |
294 | virtual ~SurfaceSource() {} |
295 | |
296 | - std::shared_ptr<Surface> create_surface(const frontend::SurfaceCreationParameters& params); |
297 | + std::shared_ptr<Surface> create_surface( |
298 | + frontend::SurfaceCreationParameters const& params, |
299 | + frontend::SurfaceId id, |
300 | + std::shared_ptr<events::EventSink> const& sink); |
301 | |
302 | protected: |
303 | SurfaceSource(const SurfaceSource&) = delete; |
304 | |
305 | === added directory 'include/shared/mir/events' |
306 | === renamed file 'include/shared/mir/event_sink.h' => 'include/shared/mir/events/event_sink.h' |
307 | --- include/shared/mir/event_sink.h 2013-04-19 04:33:51 +0000 |
308 | +++ include/shared/mir/events/event_sink.h 2013-04-25 09:50:50 +0000 |
309 | @@ -16,13 +16,15 @@ |
310 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
311 | */ |
312 | |
313 | -#ifndef MIR_EVENT_SINK_H_ |
314 | -#define MIR_EVENT_SINK_H_ |
315 | +#ifndef MIR_EVENTS_EVENT_SINK_H_ |
316 | +#define MIR_EVENTS_EVENT_SINK_H_ |
317 | |
318 | #include "mir_toolkit/event.h" |
319 | |
320 | namespace mir |
321 | { |
322 | +namespace events |
323 | +{ |
324 | |
325 | class EventSink |
326 | { |
327 | @@ -36,8 +38,7 @@ |
328 | EventSink(EventSink const&) = delete; |
329 | EventSink& operator=(EventSink const&) = delete; |
330 | }; |
331 | - |
332 | +} |
333 | } // namespace mir |
334 | |
335 | -#endif |
336 | - |
337 | +#endif // MIR_EVENTS_EVENT_SINK_H_ |
338 | |
339 | === modified file 'include/test/mir_test_doubles/mock_session.h' |
340 | --- include/test/mir_test_doubles/mock_session.h 2013-04-24 05:22:20 +0000 |
341 | +++ include/test/mir_test_doubles/mock_session.h 2013-04-25 09:50:50 +0000 |
342 | @@ -43,8 +43,6 @@ |
343 | MOCK_METHOD0(show, void()); |
344 | |
345 | MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int)); |
346 | - |
347 | - MOCK_METHOD1(set_event_sink, void(std::shared_ptr<mir::EventSink> const&)); |
348 | }; |
349 | |
350 | } |
351 | |
352 | === modified file 'include/test/mir_test_doubles/mock_shell.h' |
353 | --- include/test/mir_test_doubles/mock_shell.h 2013-04-24 05:22:20 +0000 |
354 | +++ include/test/mir_test_doubles/mock_shell.h 2013-04-25 09:50:50 +0000 |
355 | @@ -34,7 +34,7 @@ |
356 | |
357 | struct MockShell : public frontend::Shell |
358 | { |
359 | - MOCK_METHOD1(open_session, std::shared_ptr<frontend::Session>(std::string const&)); |
360 | + MOCK_METHOD2(open_session, std::shared_ptr<frontend::Session>(std::string const&, std::shared_ptr<events::EventSink> const&)); |
361 | MOCK_METHOD1(close_session, void(std::shared_ptr<frontend::Session> const&)); |
362 | |
363 | MOCK_METHOD2(tag_session_with_lightdm_id, void(std::shared_ptr<frontend::Session> const&, int)); |
364 | |
365 | === modified file 'include/test/mir_test_doubles/mock_surface_factory.h' |
366 | --- include/test/mir_test_doubles/mock_surface_factory.h 2013-04-24 05:22:20 +0000 |
367 | +++ include/test/mir_test_doubles/mock_surface_factory.h 2013-04-25 09:50:50 +0000 |
368 | @@ -33,7 +33,10 @@ |
369 | |
370 | struct MockSurfaceFactory : public shell::SurfaceFactory |
371 | { |
372 | - MOCK_METHOD1(create_surface, std::shared_ptr<shell::Surface>(const frontend::SurfaceCreationParameters&)); |
373 | + MOCK_METHOD3(create_surface, std::shared_ptr<shell::Surface>( |
374 | + const frontend::SurfaceCreationParameters&, |
375 | + frontend::SurfaceId, |
376 | + std::shared_ptr<events::EventSink> const&)); |
377 | }; |
378 | |
379 | } |
380 | |
381 | === modified file 'include/test/mir_test_doubles/stub_ipc_factory.h' |
382 | --- include/test/mir_test_doubles/stub_ipc_factory.h 2013-04-24 05:22:20 +0000 |
383 | +++ include/test/mir_test_doubles/stub_ipc_factory.h 2013-04-25 09:50:50 +0000 |
384 | @@ -42,7 +42,7 @@ |
385 | } |
386 | |
387 | std::shared_ptr<protobuf::DisplayServer> make_ipc_server( |
388 | - std::shared_ptr<EventSink> const&) |
389 | + std::shared_ptr<events::EventSink> const&) |
390 | { |
391 | return server; |
392 | } |
393 | |
394 | === modified file 'include/test/mir_test_doubles/stub_session.h' |
395 | --- include/test/mir_test_doubles/stub_session.h 2013-04-24 05:22:20 +0000 |
396 | +++ include/test/mir_test_doubles/stub_session.h 2013-04-25 09:50:50 +0000 |
397 | @@ -58,7 +58,7 @@ |
398 | { |
399 | return 0; |
400 | } |
401 | - void set_event_sink(std::shared_ptr<EventSink> const&) |
402 | + void set_event_sink(std::shared_ptr<events::EventSink> const&) |
403 | { |
404 | } |
405 | }; |
406 | |
407 | === modified file 'include/test/mir_test_doubles/stub_shell.h' |
408 | --- include/test/mir_test_doubles/stub_shell.h 2013-04-24 05:22:20 +0000 |
409 | +++ include/test/mir_test_doubles/stub_shell.h 2013-04-25 09:50:50 +0000 |
410 | @@ -31,7 +31,7 @@ |
411 | |
412 | class StubShell : public frontend::Shell |
413 | { |
414 | - std::shared_ptr<frontend::Session> open_session(std::string const& /* name */) |
415 | + std::shared_ptr<frontend::Session> open_session(std::string const& /* name */, std::shared_ptr<events::EventSink> const& /* sink */) |
416 | { |
417 | return std::make_shared<StubSession>(); |
418 | } |
419 | |
420 | === modified file 'src/client/make_rpc_channel.h' |
421 | --- src/client/make_rpc_channel.h 2013-04-24 05:22:20 +0000 |
422 | +++ src/client/make_rpc_channel.h 2013-04-25 09:50:50 +0000 |
423 | @@ -19,7 +19,7 @@ |
424 | #define MIR_CLIENT_MAKE_RPC_CHANNEL_H_ |
425 | |
426 | #include <memory> |
427 | -#include "mir_protobuf.pb.h" |
428 | +#include "mir_basic_rpc_channel.h" |
429 | |
430 | namespace mir |
431 | { |
432 | @@ -27,7 +27,7 @@ |
433 | { |
434 | class Logger; |
435 | |
436 | -std::shared_ptr<google::protobuf::RpcChannel> |
437 | +std::shared_ptr<MirBasicRpcChannel> |
438 | make_rpc_channel(std::string const& name, std::shared_ptr<Logger> const& log); |
439 | } |
440 | } |
441 | |
442 | === modified file 'src/client/make_socket_rpc_channel.cpp' |
443 | --- src/client/make_socket_rpc_channel.cpp 2013-04-24 05:22:20 +0000 |
444 | +++ src/client/make_socket_rpc_channel.cpp 2013-04-25 09:50:50 +0000 |
445 | @@ -21,7 +21,7 @@ |
446 | |
447 | namespace mcl = mir::client; |
448 | |
449 | -std::shared_ptr<google::protobuf::RpcChannel> |
450 | +std::shared_ptr<mcl::MirBasicRpcChannel> |
451 | mcl::make_rpc_channel(std::string const& name, std::shared_ptr<Logger> const& log) |
452 | { |
453 | return std::make_shared<MirSocketRpcChannel>(name, log); |
454 | |
455 | === modified file 'src/client/mir_basic_rpc_channel.cpp' |
456 | --- src/client/mir_basic_rpc_channel.cpp 2013-04-24 05:22:20 +0000 |
457 | +++ src/client/mir_basic_rpc_channel.cpp 2013-04-25 09:50:50 +0000 |
458 | @@ -100,7 +100,5 @@ |
459 | |
460 | int mcl::MirBasicRpcChannel::next_id() |
461 | { |
462 | - int id = next_message_id.load(); |
463 | - while (!next_message_id.compare_exchange_weak(id, id + 1)) std::this_thread::yield(); |
464 | - return id; |
465 | + return next_message_id.fetch_add(1); |
466 | } |
467 | |
468 | === modified file 'src/client/mir_basic_rpc_channel.h' |
469 | --- src/client/mir_basic_rpc_channel.h 2013-04-24 05:22:20 +0000 |
470 | +++ src/client/mir_basic_rpc_channel.h 2013-04-25 09:50:50 +0000 |
471 | @@ -33,6 +33,10 @@ |
472 | |
473 | namespace mir |
474 | { |
475 | +namespace events |
476 | +{ |
477 | +class EventSink; |
478 | +} |
479 | namespace protobuf |
480 | { |
481 | namespace wire |
482 | @@ -92,6 +96,8 @@ |
483 | MirBasicRpcChannel(); |
484 | ~MirBasicRpcChannel(); |
485 | |
486 | + virtual void set_event_handler(events::EventSink *sink) = 0; |
487 | + |
488 | protected: |
489 | mir::protobuf::wire::Invocation invocation_for(const google::protobuf::MethodDescriptor* method, |
490 | const google::protobuf::Message* request); |
491 | |
492 | === modified file 'src/client/mir_client_library.cpp' |
493 | --- src/client/mir_client_library.cpp 2013-04-24 05:22:20 +0000 |
494 | +++ src/client/mir_client_library.cpp 2013-04-25 09:50:50 +0000 |
495 | @@ -26,7 +26,7 @@ |
496 | #include "native_client_platform_factory.h" |
497 | #include "egl_native_display_container.h" |
498 | #include "mir_logger.h" |
499 | -#include "mir_socket_rpc_channel.h" |
500 | +#include "make_rpc_channel.h" |
501 | |
502 | #include <set> |
503 | #include <unordered_set> |
504 | @@ -60,12 +60,10 @@ |
505 | auto log = std::make_shared<mcl::ConsoleLogger>(); |
506 | auto client_platform_factory = std::make_shared<mcl::NativeClientPlatformFactory>(); |
507 | |
508 | - auto rpc = std::make_shared<mcl::MirSocketRpcChannel>(sock, log); |
509 | - |
510 | - MirConnection* connection = new MirConnection(rpc, log, |
511 | - client_platform_factory); |
512 | - |
513 | - rpc->set_event_handler(connection); |
514 | + MirConnection* connection = new MirConnection( |
515 | + mcl::make_rpc_channel(sock, log), |
516 | + log, |
517 | + client_platform_factory); |
518 | |
519 | return connection->connect(name, callback, context); |
520 | } |
521 | @@ -258,12 +256,10 @@ |
522 | auto log = std::make_shared<mcl::ConsoleLogger>(); |
523 | auto client_platform_factory = std::make_shared<mcl::NativeClientPlatformFactory>(); |
524 | |
525 | - auto rpc = std::make_shared<mcl::MirSocketRpcChannel>(server, log); |
526 | - |
527 | - MirConnection* connection = new MirConnection(rpc, log, |
528 | - client_platform_factory); |
529 | - |
530 | - rpc->set_event_handler(connection); |
531 | + MirConnection* connection = new MirConnection( |
532 | + mcl::make_rpc_channel(server, log), |
533 | + log, |
534 | + client_platform_factory); |
535 | |
536 | return connection->connect(lightdm_id, app_name, callback, client_context); |
537 | } |
538 | |
539 | === modified file 'src/client/mir_connection.cpp' |
540 | --- src/client/mir_connection.cpp 2013-04-24 05:22:20 +0000 |
541 | +++ src/client/mir_connection.cpp 2013-04-25 09:50:50 +0000 |
542 | @@ -43,7 +43,7 @@ |
543 | } |
544 | |
545 | MirConnection::MirConnection( |
546 | - std::shared_ptr<google::protobuf::RpcChannel> const& channel, |
547 | + std::shared_ptr<mir::client::MirBasicRpcChannel> const& channel, |
548 | std::shared_ptr<mcl::Logger> const & log, |
549 | std::shared_ptr<mcl::ClientPlatformFactory> const& client_platform_factory) : |
550 | channel(channel), |
551 | @@ -52,6 +52,7 @@ |
552 | client_platform_factory(client_platform_factory), |
553 | input_platform(mcli::InputPlatform::create()) |
554 | { |
555 | + channel->set_event_handler(this); |
556 | { |
557 | std::lock_guard<std::mutex> lock(connection_guard); |
558 | valid_connections.insert(this); |
559 | |
560 | === modified file 'src/client/mir_connection.h' |
561 | --- src/client/mir_connection.h 2013-04-24 05:22:20 +0000 |
562 | +++ src/client/mir_connection.h 2013-04-25 09:50:50 +0000 |
563 | @@ -34,7 +34,7 @@ |
564 | #include "client_context.h" |
565 | |
566 | #include "mir_wait_handle.h" |
567 | -#include "mir/event_sink.h" |
568 | +#include "mir/events/event_sink.h" |
569 | |
570 | namespace mir |
571 | { |
572 | @@ -44,6 +44,8 @@ |
573 | class Logger; |
574 | class ClientBufferDepository; |
575 | class ClientPlatformFactory; |
576 | +class MirBasicRpcChannel; |
577 | + |
578 | namespace input |
579 | { |
580 | class InputPlatform; |
581 | @@ -51,13 +53,12 @@ |
582 | } |
583 | } |
584 | |
585 | -struct MirConnection : public mir::client::ClientContext, |
586 | - public mir::EventSink |
587 | +struct MirConnection : mir::client::ClientContext, private mir::events::EventSink |
588 | { |
589 | public: |
590 | MirConnection(); |
591 | |
592 | - MirConnection(std::shared_ptr<google::protobuf::RpcChannel> const& channel, |
593 | + MirConnection(std::shared_ptr<mir::client::MirBasicRpcChannel> const& channel, |
594 | std::shared_ptr<mir::client::Logger> const & log, |
595 | std::shared_ptr<mir::client::ClientPlatformFactory> const& client_platform_factory); |
596 | ~MirConnection() noexcept; |
597 | |
598 | === modified file 'src/client/mir_socket_rpc_channel.cpp' |
599 | --- src/client/mir_socket_rpc_channel.cpp 2013-04-24 05:22:20 +0000 |
600 | +++ src/client/mir_socket_rpc_channel.cpp 2013-04-25 09:50:50 +0000 |
601 | @@ -253,11 +253,12 @@ |
602 | |
603 | log->debug() << __PRETTY_FUNCTION__ << " result.id():" << result.id() << std::endl; |
604 | |
605 | - if (!result.has_id()) // It's an event sequence |
606 | + for (int i = 0; i != result.events_size(); ++i) |
607 | { |
608 | - process_event_sequence(result); |
609 | + process_event_sequence(result.events(i)); |
610 | } |
611 | - else |
612 | + |
613 | + if (result.has_id()) |
614 | { |
615 | pending_calls.complete_response(result); |
616 | } |
617 | @@ -269,44 +270,42 @@ |
618 | } |
619 | } |
620 | |
621 | -void mcl::MirSocketRpcChannel::process_event_sequence( |
622 | - mir::protobuf::wire::Result const& result) |
623 | +void mcl::MirSocketRpcChannel::process_event_sequence(std::string const& event) |
624 | { |
625 | if (!event_handler) |
626 | return; |
627 | |
628 | mir::protobuf::EventSequence seq; |
629 | - if (seq.ParseFromString(result.response())) |
630 | + |
631 | + seq.ParseFromString(event); |
632 | + int const nevents = seq.event_size(); |
633 | + for (int i = 0; i != nevents; ++i) |
634 | { |
635 | - int const nevents = seq.event_size(); |
636 | - for (int i = 0; i < nevents; i++) |
637 | + mir::protobuf::Event const& event = seq.event(i); |
638 | + if (event.has_raw()) |
639 | { |
640 | - mir::protobuf::Event const& event = seq.event(i); |
641 | - if (event.has_raw()) |
642 | - { |
643 | - std::string const& raw_event = event.raw(); |
644 | - |
645 | - // In future, events might be compressed where possible. |
646 | - // But that's a job for later... |
647 | - if (raw_event.size() == sizeof(MirEvent)) |
648 | - { |
649 | - MirEvent e; |
650 | - |
651 | - // Make a copy to ensure integer fields get correct memory |
652 | - // alignment, which is critical on many non-x86 |
653 | - // architectures. |
654 | - memcpy(&e, raw_event.data(), sizeof e); |
655 | - event_handler->handle_event(e); |
656 | - } |
657 | - else |
658 | - { |
659 | - log->error() << __PRETTY_FUNCTION__ |
660 | - << " Received MirEvent of an unexpected size." |
661 | - << std::endl; |
662 | - } |
663 | + std::string const& raw_event = event.raw(); |
664 | + |
665 | + // In future, events might be compressed where possible. |
666 | + // But that's a job for later... |
667 | + if (raw_event.size() == sizeof(MirEvent)) |
668 | + { |
669 | + MirEvent e; |
670 | + |
671 | + // Make a copy to ensure integer fields get correct memory |
672 | + // alignment, which is critical on many non-x86 |
673 | + // architectures. |
674 | + memcpy(&e, raw_event.data(), sizeof e); |
675 | + event_handler->handle_event(e); |
676 | + } |
677 | + else |
678 | + { |
679 | + log->error() << __PRETTY_FUNCTION__ |
680 | + << " Received MirEvent of an unexpected size." |
681 | + << std::endl; |
682 | } |
683 | } |
684 | - } // else protobuf will log an error |
685 | + } |
686 | } |
687 | |
688 | size_t mcl::MirSocketRpcChannel::read_message_header() |
689 | @@ -331,7 +330,7 @@ |
690 | return result; |
691 | } |
692 | |
693 | -void mcl::MirSocketRpcChannel::set_event_handler(mir::EventSink *sink) |
694 | +void mcl::MirSocketRpcChannel::set_event_handler(events::EventSink *sink) |
695 | { |
696 | /* |
697 | * Yes, these have to be regular pointers. Because ownership of the object |
698 | |
699 | === modified file 'src/client/mir_socket_rpc_channel.h' |
700 | --- src/client/mir_socket_rpc_channel.h 2013-04-24 05:22:20 +0000 |
701 | +++ src/client/mir_socket_rpc_channel.h 2013-04-25 09:50:50 +0000 |
702 | @@ -22,7 +22,7 @@ |
703 | |
704 | #include "mir_basic_rpc_channel.h" |
705 | #include "mir_logger.h" |
706 | -#include "mir/event_sink.h" |
707 | +#include "mir/events/event_sink.h" |
708 | |
709 | #include <boost/asio.hpp> |
710 | |
711 | @@ -52,7 +52,7 @@ |
712 | MirSocketRpcChannel(const std::string& endpoint, const std::shared_ptr<Logger>& log); |
713 | ~MirSocketRpcChannel(); |
714 | |
715 | - void set_event_handler(EventSink *sink); |
716 | + void set_event_handler(events::EventSink *sink); |
717 | |
718 | private: |
719 | virtual void CallMethod(const google::protobuf::MethodDescriptor* method, google::protobuf::RpcController*, |
720 | @@ -75,13 +75,13 @@ |
721 | void on_header_read(const boost::system::error_code& error); |
722 | |
723 | void read_message(); |
724 | - void process_event_sequence(mir::protobuf::wire::Result const& result); |
725 | + void process_event_sequence(std::string const& event); |
726 | |
727 | size_t read_message_header(); |
728 | |
729 | mir::protobuf::wire::Result read_message_body(const size_t body_size); |
730 | |
731 | - EventSink *event_handler; |
732 | + events::EventSink *event_handler; |
733 | }; |
734 | |
735 | } |
736 | |
737 | === modified file 'src/server/CMakeLists.txt' |
738 | --- src/server/CMakeLists.txt 2013-04-24 05:22:20 +0000 |
739 | +++ src/server/CMakeLists.txt 2013-04-25 09:50:50 +0000 |
740 | @@ -26,7 +26,6 @@ |
741 | display_server.cpp |
742 | default_server_configuration.cpp |
743 | asio_main_loop.cpp |
744 | - event_queue.cpp |
745 | ) |
746 | |
747 | set(MIRSERVER_LINKAGE SHARED) |
748 | |
749 | === modified file 'src/server/default_server_configuration.cpp' |
750 | --- src/server/default_server_configuration.cpp 2013-04-24 22:14:08 +0000 |
751 | +++ src/server/default_server_configuration.cpp 2013-04-25 09:50:50 +0000 |
752 | @@ -63,6 +63,7 @@ |
753 | #include "mir/default_configuration.h" |
754 | |
755 | namespace mc = mir::compositor; |
756 | +namespace me = mir::events; |
757 | namespace geom = mir::geometry; |
758 | namespace mf = mir::frontend; |
759 | namespace mg = mir::graphics; |
760 | @@ -109,7 +110,7 @@ |
761 | std::shared_ptr<mc::GraphicBufferAllocator> const buffer_allocator; |
762 | |
763 | virtual std::shared_ptr<mir::protobuf::DisplayServer> make_ipc_server( |
764 | - std::shared_ptr<mir::EventSink> const& sink) |
765 | + std::shared_ptr<me::EventSink> const& sink) |
766 | { |
767 | return std::make_shared<mf::SessionMediator>( |
768 | shell, |
769 | |
770 | === modified file 'src/server/frontend/CMakeLists.txt' |
771 | --- src/server/frontend/CMakeLists.txt 2013-04-24 05:22:20 +0000 |
772 | +++ src/server/frontend/CMakeLists.txt 2013-04-25 09:50:50 +0000 |
773 | @@ -8,6 +8,7 @@ |
774 | protobuf_message_processor.cpp |
775 | null_message_processor.cpp |
776 | surface_creation_parameters.cpp |
777 | + event_pipe.cpp |
778 | |
779 | resource_cache.cpp |
780 | ${PROTO_HDRS} |
781 | |
782 | === renamed file 'src/server/event_queue.cpp' => 'src/server/frontend/event_pipe.cpp' |
783 | --- src/server/event_queue.cpp 2013-04-24 03:44:27 +0000 |
784 | +++ src/server/frontend/event_pipe.cpp 2013-04-25 09:50:50 +0000 |
785 | @@ -16,17 +16,16 @@ |
786 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
787 | */ |
788 | |
789 | -#include "mir/event_queue.h" |
790 | -#include "mir/event_sink.h" |
791 | - |
792 | -using namespace mir; |
793 | - |
794 | -void EventQueue::set_target(std::weak_ptr<EventSink> const& s) |
795 | +#include "event_pipe.h" |
796 | + |
797 | +namespace mf = mir::frontend; |
798 | + |
799 | +void mf::EventPipe::set_target(std::weak_ptr<EventSink> const& s) |
800 | { |
801 | target = s; |
802 | } |
803 | |
804 | -void EventQueue::handle_event(MirEvent const& e) |
805 | +void mf::EventPipe::handle_event(MirEvent const& e) |
806 | { |
807 | // In future, we might put e on a queue and wait for some background |
808 | // thread to push it through to target. But that's not required right now. |
809 | |
810 | === renamed file 'include/server/mir/event_queue.h' => 'src/server/frontend/event_pipe.h' |
811 | --- include/server/mir/event_queue.h 2013-04-16 05:46:28 +0000 |
812 | +++ src/server/frontend/event_pipe.h 2013-04-25 09:50:50 +0000 |
813 | @@ -16,25 +16,27 @@ |
814 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
815 | */ |
816 | |
817 | -#ifndef MIR_EVENT_QUEUE_H_ |
818 | -#define MIR_EVENT_QUEUE_H_ |
819 | +#ifndef MIR_FRONTEND_EVENT_PIPE_H_ |
820 | +#define MIR_FRONTEND_EVENT_PIPE_H_ |
821 | |
822 | #include "mir_toolkit/event.h" |
823 | -#include "mir/event_sink.h" |
824 | +#include "mir/events/event_sink.h" |
825 | #include <memory> |
826 | |
827 | namespace mir |
828 | { |
829 | -class EventQueue : public EventSink |
830 | +namespace frontend |
831 | +{ |
832 | +class EventPipe : public events::EventSink |
833 | { |
834 | public: |
835 | - void set_target(std::weak_ptr<EventSink> const& s); |
836 | + void set_target(std::weak_ptr<events::EventSink> const& s); |
837 | void handle_event(MirEvent const& e) override; |
838 | |
839 | private: |
840 | - std::weak_ptr<EventSink> target; |
841 | + std::weak_ptr<events::EventSink> target; |
842 | }; |
843 | - |
844 | -} // namespace mir |
845 | - |
846 | -#endif |
847 | +} |
848 | +} |
849 | + |
850 | +#endif // MIR_FRONTEND_EVENT_PIPE_H_ |
851 | |
852 | === modified file 'src/server/frontend/protobuf_message_processor.cpp' |
853 | --- src/server/frontend/protobuf_message_processor.cpp 2013-04-24 05:22:20 +0000 |
854 | +++ src/server/frontend/protobuf_message_processor.cpp 2013-04-25 09:50:50 +0000 |
855 | @@ -138,6 +138,8 @@ |
856 | |
857 | void mfd::ProtobufMessageProcessor::send_event(MirEvent const& e) |
858 | { |
859 | + // In future we might send multiple events, or insert them into messages |
860 | + // containing other responses, but for now we send them individually. |
861 | mir::protobuf::EventSequence seq; |
862 | mir::protobuf::Event *ev = seq.add_event(); |
863 | ev->set_raw(&e, sizeof(MirEvent)); |
864 | @@ -146,7 +148,7 @@ |
865 | seq.SerializeToString(&buffer); |
866 | |
867 | mir::protobuf::wire::Result result; |
868 | - result.set_response(buffer); |
869 | + result.add_events(buffer); |
870 | |
871 | result.SerializeToString(&buffer); |
872 | |
873 | |
874 | === modified file 'src/server/frontend/protobuf_message_processor.h' |
875 | --- src/server/frontend/protobuf_message_processor.h 2013-04-24 05:22:20 +0000 |
876 | +++ src/server/frontend/protobuf_message_processor.h 2013-04-25 09:50:50 +0000 |
877 | @@ -24,7 +24,7 @@ |
878 | |
879 | #include "mir_protobuf.pb.h" |
880 | #include "mir_protobuf_wire.pb.h" |
881 | -#include "mir/event_sink.h" |
882 | +#include "mir/events/event_sink.h" |
883 | |
884 | #include <vector> |
885 | #include <memory> |
886 | @@ -44,7 +44,7 @@ |
887 | { |
888 | |
889 | struct ProtobufMessageProcessor : MessageProcessor, |
890 | - public EventSink |
891 | + public events::EventSink |
892 | { |
893 | ProtobufMessageProcessor( |
894 | MessageSender* sender, |
895 | |
896 | === modified file 'src/server/frontend/protobuf_socket_communicator.cpp' |
897 | --- src/server/frontend/protobuf_socket_communicator.cpp 2013-04-24 05:22:20 +0000 |
898 | +++ src/server/frontend/protobuf_socket_communicator.cpp 2013-04-25 09:50:50 +0000 |
899 | @@ -22,8 +22,7 @@ |
900 | |
901 | #include "mir/frontend/protobuf_ipc_factory.h" |
902 | #include "mir/protobuf/google_protobuf_guard.h" |
903 | -#include "mir/event_sink.h" |
904 | -#include "mir/event_queue.h" |
905 | +#include "event_pipe.h" |
906 | |
907 | #include <boost/signals2.hpp> |
908 | |
909 | @@ -51,7 +50,7 @@ |
910 | |
911 | void mf::ProtobufSocketCommunicator::start_accept() |
912 | { |
913 | - std::shared_ptr<EventQueue> event_queue = std::make_shared<EventQueue>(); |
914 | + auto const& event_pipe = std::make_shared<EventPipe>(); |
915 | |
916 | auto const& socket_session = std::make_shared<mfd::SocketSession>( |
917 | io_service, |
918 | @@ -60,11 +59,11 @@ |
919 | |
920 | auto session = std::make_shared<detail::ProtobufMessageProcessor>( |
921 | socket_session.get(), |
922 | - ipc_factory->make_ipc_server(event_queue), |
923 | + ipc_factory->make_ipc_server(event_pipe), |
924 | ipc_factory->resource_cache(), |
925 | ipc_factory->report()); |
926 | |
927 | - event_queue->set_target(session); |
928 | + event_pipe->set_target(session); |
929 | socket_session->set_processor(session); |
930 | |
931 | acceptor.async_accept( |
932 | |
933 | === modified file 'src/server/frontend/session_mediator.cpp' |
934 | --- src/server/frontend/session_mediator.cpp 2013-04-24 05:22:20 +0000 |
935 | +++ src/server/frontend/session_mediator.cpp 2013-04-25 09:50:50 +0000 |
936 | @@ -44,7 +44,7 @@ |
937 | std::shared_ptr<graphics::ViewableArea> const& viewable_area, |
938 | std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator, |
939 | std::shared_ptr<SessionMediatorReport> const& report, |
940 | - std::shared_ptr<EventSink> const& event_sink, |
941 | + std::shared_ptr<events::EventSink> const& event_sink, |
942 | std::shared_ptr<ResourceCache> const& resource_cache) : |
943 | shell(shell), |
944 | graphics_platform(graphics_platform), |
945 | @@ -65,8 +65,7 @@ |
946 | { |
947 | report->session_connect_called(request->application_name()); |
948 | |
949 | - session = shell->open_session(request->application_name()); |
950 | - session->set_event_sink(event_sink); |
951 | + session = shell->open_session(request->application_name(), event_sink); |
952 | |
953 | auto ipc_package = graphics_platform->get_ipc_package(); |
954 | auto platform = response->mutable_platform(); |
955 | |
956 | === modified file 'src/server/shell/application_session.cpp' |
957 | --- src/server/shell/application_session.cpp 2013-04-24 05:22:20 +0000 |
958 | +++ src/server/shell/application_session.cpp 2013-04-25 09:50:50 +0000 |
959 | @@ -28,21 +28,32 @@ |
960 | #include <cassert> |
961 | #include <algorithm> |
962 | |
963 | +namespace me = mir::events; |
964 | namespace mf = mir::frontend; |
965 | namespace msh = mir::shell; |
966 | |
967 | msh::ApplicationSession::ApplicationSession( |
968 | - std::shared_ptr<msh::SurfaceFactory> const& surface_factory, |
969 | + std::shared_ptr<SurfaceFactory> const& surface_factory, |
970 | std::shared_ptr<msh::InputTargetListener> const& input_target_listener, |
971 | - std::string const& session_name) : |
972 | + std::string const& session_name, |
973 | + std::shared_ptr<me::EventSink> const& sink) : |
974 | surface_factory(surface_factory), |
975 | input_target_listener(input_target_listener), |
976 | session_name(session_name), |
977 | + event_sink(sink), |
978 | next_surface_id(0) |
979 | { |
980 | assert(surface_factory); |
981 | } |
982 | |
983 | +msh::ApplicationSession::ApplicationSession( |
984 | + std::shared_ptr<SurfaceFactory> const& surface_factory, |
985 | + std::shared_ptr<msh::InputTargetListener> const& input_target_listener, |
986 | + std::string const& session_name) : |
987 | + ApplicationSession(surface_factory, input_target_listener, session_name, std::shared_ptr<me::EventSink>()) |
988 | +{ |
989 | +} |
990 | + |
991 | msh::ApplicationSession::~ApplicationSession() |
992 | { |
993 | std::unique_lock<std::mutex> lock(surfaces_mutex); |
994 | @@ -53,12 +64,6 @@ |
995 | } |
996 | } |
997 | |
998 | -void msh::ApplicationSession::set_event_sink( |
999 | - std::shared_ptr<mir::EventSink> const& sink) |
1000 | -{ |
1001 | - event_sink = sink; |
1002 | -} |
1003 | - |
1004 | mf::SurfaceId msh::ApplicationSession::next_id() |
1005 | { |
1006 | return mf::SurfaceId(next_surface_id.fetch_add(1)); |
1007 | @@ -66,11 +71,8 @@ |
1008 | |
1009 | mf::SurfaceId msh::ApplicationSession::create_surface(const mf::SurfaceCreationParameters& params) |
1010 | { |
1011 | - auto surf = surface_factory->create_surface(params); |
1012 | auto const id = next_id(); |
1013 | - |
1014 | - surf->set_id(id); |
1015 | - surf->set_event_target(event_sink); |
1016 | + auto surf = surface_factory->create_surface(params, id, event_sink); |
1017 | |
1018 | std::unique_lock<std::mutex> lock(surfaces_mutex); |
1019 | surfaces[id] = surf; |
1020 | |
1021 | === modified file 'src/server/shell/organising_surface_factory.cpp' |
1022 | --- src/server/shell/organising_surface_factory.cpp 2013-04-24 05:22:20 +0000 |
1023 | +++ src/server/shell/organising_surface_factory.cpp 2013-04-25 09:50:50 +0000 |
1024 | @@ -34,10 +34,13 @@ |
1025 | { |
1026 | } |
1027 | |
1028 | -std::shared_ptr<msh::Surface> msh::OrganisingSurfaceFactory::create_surface(const mf::SurfaceCreationParameters& params) |
1029 | +std::shared_ptr<msh::Surface> msh::OrganisingSurfaceFactory::create_surface( |
1030 | + frontend::SurfaceCreationParameters const& params, |
1031 | + frontend::SurfaceId id, |
1032 | + std::shared_ptr<events::EventSink> const& sink) |
1033 | { |
1034 | auto placed_params = placement_strategy->place(params); |
1035 | |
1036 | - return underlying_factory->create_surface(placed_params); |
1037 | + return underlying_factory->create_surface(placed_params, id, sink); |
1038 | } |
1039 | |
1040 | |
1041 | === modified file 'src/server/shell/session_manager.cpp' |
1042 | --- src/server/shell/session_manager.cpp 2013-04-24 05:22:20 +0000 |
1043 | +++ src/server/shell/session_manager.cpp 2013-04-25 09:50:50 +0000 |
1044 | @@ -55,9 +55,11 @@ |
1045 | { |
1046 | } |
1047 | |
1048 | -std::shared_ptr<mf::Session> msh::SessionManager::open_session(std::string const& name) |
1049 | +std::shared_ptr<mf::Session> msh::SessionManager::open_session( |
1050 | + std::string const& name, |
1051 | + std::shared_ptr<events::EventSink> const& sink) |
1052 | { |
1053 | - auto new_session = std::make_shared<msh::ApplicationSession>(surface_factory, input_target_listener, name); |
1054 | + auto new_session = std::make_shared<msh::ApplicationSession>(surface_factory, input_target_listener, name, sink); |
1055 | |
1056 | app_container->insert_session(new_session); |
1057 | |
1058 | |
1059 | === modified file 'src/server/shell/surface.cpp' |
1060 | --- src/server/shell/surface.cpp 2013-04-24 05:22:20 +0000 |
1061 | +++ src/server/shell/surface.cpp 2013-04-25 09:50:50 +0000 |
1062 | @@ -20,7 +20,7 @@ |
1063 | #include "mir/shell/surface_builder.h" |
1064 | #include "mir/input/input_channel.h" |
1065 | #include "mir_toolkit/event.h" |
1066 | -#include "mir/event_sink.h" |
1067 | +#include "mir/events/event_sink.h" |
1068 | |
1069 | #include <boost/throw_exception.hpp> |
1070 | |
1071 | @@ -34,11 +34,28 @@ |
1072 | msh::Surface::Surface( |
1073 | std::shared_ptr<SurfaceBuilder> const& builder, |
1074 | frontend::SurfaceCreationParameters const& params, |
1075 | + std::shared_ptr<input::InputChannel> const& input_channel, |
1076 | + frontend::SurfaceId id, |
1077 | + std::shared_ptr<events::EventSink> const& sink) |
1078 | + : builder(builder), |
1079 | + input_channel(input_channel), |
1080 | + surface(builder->create_surface(params)), |
1081 | + id(id), |
1082 | + event_sink(sink), |
1083 | + type_value(mir_surface_type_normal), |
1084 | + state_value(mir_surface_state_restored) |
1085 | +{ |
1086 | +} |
1087 | + |
1088 | +msh::Surface::Surface( |
1089 | + std::shared_ptr<SurfaceBuilder> const& builder, |
1090 | + frontend::SurfaceCreationParameters const& params, |
1091 | std::shared_ptr<input::InputChannel> const& input_channel) |
1092 | : builder(builder), |
1093 | input_channel(input_channel), |
1094 | surface(builder->create_surface(params)), |
1095 | - id(0), |
1096 | + id(), |
1097 | + event_sink(), |
1098 | type_value(mir_surface_type_normal), |
1099 | state_value(mir_surface_state_restored) |
1100 | { |
1101 | @@ -52,16 +69,6 @@ |
1102 | } |
1103 | } |
1104 | |
1105 | -void msh::Surface::set_id(mir::frontend::SurfaceId i) |
1106 | -{ |
1107 | - id = i; |
1108 | -} |
1109 | - |
1110 | -void msh::Surface::set_event_target(std::shared_ptr<EventSink> const& sink) |
1111 | -{ |
1112 | - event_sink = sink; |
1113 | -} |
1114 | - |
1115 | void msh::Surface::hide() |
1116 | { |
1117 | if (auto const& s = surface.lock()) |
1118 | |
1119 | === modified file 'src/server/shell/surface_source.cpp' |
1120 | --- src/server/shell/surface_source.cpp 2013-04-24 05:22:20 +0000 |
1121 | +++ src/server/shell/surface_source.cpp 2013-04-25 09:50:50 +0000 |
1122 | @@ -39,11 +39,16 @@ |
1123 | assert(surface_builder); |
1124 | } |
1125 | |
1126 | -std::shared_ptr<msh::Surface> msh::SurfaceSource::create_surface(const mf::SurfaceCreationParameters& params) |
1127 | +std::shared_ptr<msh::Surface> msh::SurfaceSource::create_surface( |
1128 | + frontend::SurfaceCreationParameters const& params, |
1129 | + frontend::SurfaceId id, |
1130 | + std::shared_ptr<events::EventSink> const& sink) |
1131 | { |
1132 | return std::make_shared<Surface>( |
1133 | surface_builder, |
1134 | params, |
1135 | - input_factory->make_input_channel()); |
1136 | + input_factory->make_input_channel(), |
1137 | + id, |
1138 | + sink); |
1139 | } |
1140 | |
1141 | |
1142 | === modified file 'src/shared/protobuf/mir_protobuf_wire.proto' |
1143 | --- src/shared/protobuf/mir_protobuf_wire.proto 2013-04-24 05:22:20 +0000 |
1144 | +++ src/shared/protobuf/mir_protobuf_wire.proto 2013-04-25 09:50:50 +0000 |
1145 | @@ -7,7 +7,9 @@ |
1146 | } |
1147 | |
1148 | message Result { |
1149 | - // Invocation results have id and response. Events only have response. |
1150 | + // Invocation results have id and response. |
1151 | optional uint32 id = 1; |
1152 | optional bytes response = 2; |
1153 | + // Events are in events. |
1154 | + repeated bytes events = 3; |
1155 | } |
1156 | |
1157 | === modified file 'tests/acceptance-tests/test_focus_management_api.cpp' |
1158 | --- tests/acceptance-tests/test_focus_management_api.cpp 2013-04-24 22:14:08 +0000 |
1159 | +++ tests/acceptance-tests/test_focus_management_api.cpp 2013-04-25 09:50:50 +0000 |
1160 | @@ -126,7 +126,7 @@ |
1161 | { |
1162 | using namespace ::testing; |
1163 | using frontend::Shell; |
1164 | - ON_CALL(*this, open_session(_)).WillByDefault(Invoke(impl.get(), &Shell::open_session)); |
1165 | + ON_CALL(*this, open_session(_, _)).WillByDefault(Invoke(impl.get(), &Shell::open_session)); |
1166 | ON_CALL(*this, close_session(_)).WillByDefault(Invoke(impl.get(), &Shell::close_session)); |
1167 | |
1168 | ON_CALL(*this, tag_session_with_lightdm_id(_, _)).WillByDefault(Invoke(impl.get(), &Shell::tag_session_with_lightdm_id)); |
1169 | @@ -135,7 +135,7 @@ |
1170 | ON_CALL(*this, create_surface_for(_, _)).WillByDefault(Invoke(impl.get(), &Shell::create_surface_for)); |
1171 | } |
1172 | |
1173 | - MOCK_METHOD1(open_session, std::shared_ptr<mf::Session> (std::string const& name)); |
1174 | + MOCK_METHOD2(open_session, std::shared_ptr<mf::Session> (std::string const& name, std::shared_ptr<mir::events::EventSink> const&)); |
1175 | MOCK_METHOD1(close_session, void (std::shared_ptr<mf::Session> const& session)); |
1176 | |
1177 | MOCK_METHOD2(tag_session_with_lightdm_id, void (std::shared_ptr<mf::Session> const& session, int id)); |
1178 | @@ -167,13 +167,13 @@ |
1179 | |
1180 | Sequence s1, s2; |
1181 | |
1182 | - EXPECT_CALL(*mock_shell, open_session(_)) |
1183 | + EXPECT_CALL(*mock_shell, open_session(_, _)) |
1184 | .InSequence(s1, s2); |
1185 | |
1186 | EXPECT_CALL(*mock_shell, create_surface_for(_,_)) |
1187 | .InSequence(s1); |
1188 | |
1189 | - EXPECT_CALL(*mock_shell, open_session(_)) |
1190 | + EXPECT_CALL(*mock_shell, open_session(_, _)) |
1191 | .InSequence(s2); |
1192 | |
1193 | EXPECT_CALL(*mock_shell, close_session(_)) |
1194 | |
1195 | === modified file 'tests/behavior-tests/session_management_context.cpp' |
1196 | --- tests/behavior-tests/session_management_context.cpp 2013-04-24 05:22:20 +0000 |
1197 | +++ tests/behavior-tests/session_management_context.cpp 2013-04-25 09:50:50 +0000 |
1198 | @@ -66,12 +66,16 @@ |
1199 | { |
1200 | } |
1201 | |
1202 | - std::shared_ptr<msh::Surface> create_surface(const mf::SurfaceCreationParameters& params) |
1203 | + std::shared_ptr<msh::Surface> create_surface(const mf::SurfaceCreationParameters& params, |
1204 | + frontend::SurfaceId id, |
1205 | + std::shared_ptr<events::EventSink> const& sink) override |
1206 | { |
1207 | return std::make_shared<msh::Surface>( |
1208 | mt::fake_shared(surface_builder), |
1209 | params, |
1210 | - std::shared_ptr<mir::input::InputChannel>()); |
1211 | + std::shared_ptr<mir::input::InputChannel>(), |
1212 | + id, |
1213 | + sink); |
1214 | } |
1215 | |
1216 | mtd::StubSurfaceBuilder surface_builder; |
1217 | @@ -152,7 +156,7 @@ |
1218 | bool mtc::SessionManagementContext::open_window_consuming(std::string const& window_name) |
1219 | { |
1220 | auto const params = mf::a_surface().of_name(window_name); |
1221 | - auto session = shell->open_session(window_name); |
1222 | + auto session = shell->open_session(window_name, std::shared_ptr<mir::events::EventSink>()); |
1223 | auto const surface_id = session->create_surface(params); |
1224 | |
1225 | open_windows[window_name] = std::make_tuple(session, surface_id); |
1226 | @@ -164,7 +168,7 @@ |
1227 | geom::Size const& size) |
1228 | { |
1229 | auto const params = mf::a_surface().of_name(window_name).of_size(size); |
1230 | - auto session = shell->open_session(window_name); |
1231 | + auto session = shell->open_session(window_name, std::shared_ptr<mir::events::EventSink>()); |
1232 | auto const surface_id = session->create_surface(params); |
1233 | |
1234 | open_windows[window_name] = std::make_tuple(session, surface_id); |
1235 | |
1236 | === modified file 'tests/integration-tests/cucumber/test_session_management_context.cpp' |
1237 | --- tests/integration-tests/cucumber/test_session_management_context.cpp 2013-04-24 05:22:20 +0000 |
1238 | +++ tests/integration-tests/cucumber/test_session_management_context.cpp 2013-04-25 09:50:50 +0000 |
1239 | @@ -106,7 +106,7 @@ |
1240 | |
1241 | mtd::MockSession session; |
1242 | |
1243 | - EXPECT_CALL(shell, open_session(test_window_name)).Times(1) |
1244 | + EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1) |
1245 | .WillOnce(Return(mt::fake_shared<mf::Session>(session))); |
1246 | |
1247 | // As consuming mode is the default, omiting geometry is sufficient to request it. |
1248 | @@ -122,7 +122,7 @@ |
1249 | |
1250 | mtd::MockSession session; |
1251 | |
1252 | - EXPECT_CALL(shell, open_session(test_window_name)).Times(1) |
1253 | + EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1) |
1254 | .WillOnce(Return(mt::fake_shared<mf::Session>(session))); |
1255 | |
1256 | EXPECT_CALL(session, create_surface(NamedWindowWithGeometry(test_window_name, test_window_size))).Times(1) |
1257 | @@ -138,7 +138,7 @@ |
1258 | mtd::MockSession session; |
1259 | mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); |
1260 | |
1261 | - EXPECT_CALL(shell, open_session(test_window_name)).Times(1) |
1262 | + EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1) |
1263 | .WillOnce(Return(mt::fake_shared<mf::Session>(session))); |
1264 | |
1265 | EXPECT_CALL(session, create_surface(NamedWindowWithGeometry(test_window_name, test_window_size))).Times(1) |
1266 | |
1267 | === modified file 'tests/integration-tests/shell/test_session_manager.cpp' |
1268 | --- tests/integration-tests/shell/test_session_manager.cpp 2013-04-24 05:22:20 +0000 |
1269 | +++ tests/integration-tests/shell/test_session_manager.cpp 2013-04-25 09:50:50 +0000 |
1270 | @@ -36,6 +36,7 @@ |
1271 | #include "mir_test_doubles/stub_input_target_listener.h" |
1272 | |
1273 | namespace mc = mir::compositor; |
1274 | +namespace me = mir::events; |
1275 | namespace mf = mir::frontend; |
1276 | namespace msh = mir::shell; |
1277 | namespace ms = mir::surfaces; |
1278 | @@ -59,12 +60,12 @@ |
1279 | mt::fake_shared(sequence), |
1280 | mt::fake_shared(focus_setter), |
1281 | mt::fake_shared(input_target_listener)); |
1282 | - |
1283 | + |
1284 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3); |
1285 | |
1286 | - auto session1 = session_manager.open_session("Visual Basic Studio"); |
1287 | - auto session2 = session_manager.open_session("Microsoft Access"); |
1288 | - auto session3 = session_manager.open_session("WordPerfect"); |
1289 | + auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1290 | + auto session2 = session_manager.open_session("Microsoft Access", std::shared_ptr<me::EventSink>()); |
1291 | + auto session3 = session_manager.open_session("WordPerfect", std::shared_ptr<me::EventSink>()); |
1292 | |
1293 | { |
1294 | InSequence seq; |
1295 | @@ -98,9 +99,9 @@ |
1296 | |
1297 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3); |
1298 | |
1299 | - auto session1 = session_manager.open_session("Visual Basic Studio"); |
1300 | - auto session2 = session_manager.open_session("Microsoft Access"); |
1301 | - auto session3 = session_manager.open_session("WordPerfect"); |
1302 | + auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1303 | + auto session2 = session_manager.open_session("Microsoft Access", std::shared_ptr<me::EventSink>()); |
1304 | + auto session3 = session_manager.open_session("WordPerfect", std::shared_ptr<me::EventSink>()); |
1305 | |
1306 | { |
1307 | InSequence seq; |
1308 | |
1309 | === modified file 'tests/unit-tests/CMakeLists.txt' |
1310 | --- tests/unit-tests/CMakeLists.txt 2013-04-24 05:22:20 +0000 |
1311 | +++ tests/unit-tests/CMakeLists.txt 2013-04-25 09:50:50 +0000 |
1312 | @@ -20,7 +20,6 @@ |
1313 | add_subdirectory(android_input/) |
1314 | add_subdirectory(surfaces/) |
1315 | add_subdirectory(draw/) |
1316 | -add_subdirectory(event/) |
1317 | |
1318 | add_executable(unit-tests ${UNIT_TEST_SOURCES}) |
1319 | uses_android_input(unit-tests) |
1320 | |
1321 | === modified file 'tests/unit-tests/client/test_client_mir_surface.cpp' |
1322 | --- tests/unit-tests/client/test_client_mir_surface.cpp 2013-04-24 05:22:20 +0000 |
1323 | +++ tests/unit-tests/client/test_client_mir_surface.cpp 2013-04-25 09:50:50 +0000 |
1324 | @@ -298,7 +298,7 @@ |
1325 | test_server.reset(); |
1326 | } |
1327 | |
1328 | - std::shared_ptr<google::protobuf::RpcChannel> channel; |
1329 | + std::shared_ptr<mcl::MirBasicRpcChannel> channel; |
1330 | std::shared_ptr<mcl::Logger> logger; |
1331 | std::shared_ptr<mcl::ClientPlatformFactory> platform_factory; |
1332 | std::shared_ptr<MirConnection> connection; |
1333 | |
1334 | === modified file 'tests/unit-tests/client/test_mir_connection.cpp' |
1335 | --- tests/unit-tests/client/test_mir_connection.cpp 2013-04-24 05:22:20 +0000 |
1336 | +++ tests/unit-tests/client/test_mir_connection.cpp 2013-04-25 09:50:50 +0000 |
1337 | @@ -39,7 +39,7 @@ |
1338 | namespace |
1339 | { |
1340 | |
1341 | -struct MockRpcChannel : public google::protobuf::RpcChannel |
1342 | +struct MockRpcChannel : public mir::client::MirBasicRpcChannel |
1343 | { |
1344 | void CallMethod(const google::protobuf::MethodDescriptor* method, |
1345 | google::protobuf::RpcController*, |
1346 | @@ -63,6 +63,8 @@ |
1347 | |
1348 | MOCK_METHOD1(drm_auth_magic, void(const mp::DRMMagic*)); |
1349 | MOCK_METHOD2(connect, void(mp::ConnectParameters const*,mp::Connection*)); |
1350 | + |
1351 | + void set_event_handler(mir::events::EventSink *) {} |
1352 | }; |
1353 | |
1354 | struct MockClientPlatform : public mcl::ClientPlatform |
1355 | |
1356 | === removed directory 'tests/unit-tests/event' |
1357 | === removed file 'tests/unit-tests/event/CMakeLists.txt' |
1358 | --- tests/unit-tests/event/CMakeLists.txt 2013-04-09 08:23:32 +0000 |
1359 | +++ tests/unit-tests/event/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1360 | @@ -1,5 +0,0 @@ |
1361 | -set (UNIT_TEST_SOURCES |
1362 | - ${UNIT_TEST_SOURCES} |
1363 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_event_queue.cpp |
1364 | - PARENT_SCOPE |
1365 | -) |
1366 | |
1367 | === modified file 'tests/unit-tests/frontend/CMakeLists.txt' |
1368 | --- tests/unit-tests/frontend/CMakeLists.txt 2013-04-24 05:22:20 +0000 |
1369 | +++ tests/unit-tests/frontend/CMakeLists.txt 2013-04-25 09:50:50 +0000 |
1370 | @@ -6,6 +6,7 @@ |
1371 | ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_reports_errors.cpp |
1372 | ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_cache.cpp |
1373 | ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator.cpp |
1374 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_event_pipe.cpp |
1375 | ) |
1376 | |
1377 | # TODO this test is a mess - something better is needed. |
1378 | |
1379 | === renamed file 'tests/unit-tests/event/test_event_queue.cpp' => 'tests/unit-tests/frontend/test_event_pipe.cpp' |
1380 | --- tests/unit-tests/event/test_event_queue.cpp 2013-04-22 03:37:28 +0000 |
1381 | +++ tests/unit-tests/frontend/test_event_pipe.cpp 2013-04-25 09:50:50 +0000 |
1382 | @@ -16,14 +16,17 @@ |
1383 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1384 | */ |
1385 | |
1386 | +#include "src/server/frontend/event_pipe.h" |
1387 | +#include <cstring> |
1388 | + |
1389 | #include <gtest/gtest.h> |
1390 | -#include "mir/event_queue.h" |
1391 | -#include "mir/event_sink.h" |
1392 | -#include <cstring> |
1393 | - |
1394 | -TEST(EventQueue, no_sink) |
1395 | + |
1396 | +using mir::frontend::EventPipe; |
1397 | + |
1398 | + |
1399 | +TEST(EventPipe, no_sink) |
1400 | { |
1401 | - mir::EventQueue q; |
1402 | + EventPipe q; |
1403 | MirEvent e; |
1404 | |
1405 | e.type = mir_event_type_key; |
1406 | @@ -38,7 +41,7 @@ |
1407 | |
1408 | namespace |
1409 | { |
1410 | - class TestSink : public mir::EventSink |
1411 | + class TestSink : public mir::events::EventSink |
1412 | { |
1413 | public: |
1414 | TestSink() |
1415 | @@ -61,9 +64,9 @@ |
1416 | }; |
1417 | } |
1418 | |
1419 | -TEST(EventQueue, events_get_handled) |
1420 | +TEST(EventPipe, events_get_handled) |
1421 | { |
1422 | - mir::EventQueue q; |
1423 | + EventPipe q; |
1424 | std::shared_ptr<TestSink> s(new TestSink); |
1425 | |
1426 | q.set_target(s); |
1427 | @@ -84,9 +87,9 @@ |
1428 | EXPECT_EQ(mir_event_type_surface, s->last_event_handled().type); |
1429 | } |
1430 | |
1431 | -TEST(EventQueue, sink_is_changeable) |
1432 | +TEST(EventPipe, sink_is_changeable) |
1433 | { |
1434 | - mir::EventQueue q; |
1435 | + EventPipe q; |
1436 | std::shared_ptr<TestSink> a(new TestSink); |
1437 | std::shared_ptr<TestSink> b(new TestSink); |
1438 | |
1439 | |
1440 | === modified file 'tests/unit-tests/frontend/test_session_mediator.cpp' |
1441 | --- tests/unit-tests/frontend/test_session_mediator.cpp 2013-04-24 05:22:20 +0000 |
1442 | +++ tests/unit-tests/frontend/test_session_mediator.cpp 2013-04-25 09:50:50 +0000 |
1443 | @@ -34,7 +34,7 @@ |
1444 | #include "mir_test_doubles/stub_session.h" |
1445 | #include "mir_test_doubles/stub_surface_builder.h" |
1446 | #include "mir_test/fake_shared.h" |
1447 | -#include "mir/event_queue.h" |
1448 | +#include "mir/events/event_sink.h" |
1449 | #include "mir/shell/surface.h" |
1450 | |
1451 | #include <gtest/gtest.h> |
1452 | @@ -129,7 +129,11 @@ |
1453 | } |
1454 | }; |
1455 | |
1456 | -} |
1457 | +class NullEventSink : public mir::events::EventSink |
1458 | +{ |
1459 | +public: |
1460 | + void handle_event(MirEvent const& ) override {} |
1461 | +}; |
1462 | |
1463 | struct SessionMediatorTest : public ::testing::Test |
1464 | { |
1465 | @@ -142,14 +146,14 @@ |
1466 | resource_cache{std::make_shared<mf::ResourceCache>()}, |
1467 | mediator{shell, graphics_platform, graphics_display, |
1468 | buffer_allocator, report, |
1469 | - std::make_shared<mir::EventQueue>(), |
1470 | + std::make_shared<NullEventSink>(), |
1471 | resource_cache}, |
1472 | stubbed_session{std::make_shared<StubbedSession>()}, |
1473 | null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} |
1474 | { |
1475 | using namespace ::testing; |
1476 | |
1477 | - ON_CALL(*shell, open_session(_)).WillByDefault(Return(stubbed_session)); |
1478 | + ON_CALL(*shell, open_session(_, _)).WillByDefault(Return(stubbed_session)); |
1479 | ON_CALL(*shell, create_surface_for(_, _)).WillByDefault(Return(mf::SurfaceId{1})); |
1480 | } |
1481 | |
1482 | @@ -164,7 +168,7 @@ |
1483 | |
1484 | std::unique_ptr<google::protobuf::Closure> null_callback; |
1485 | }; |
1486 | - |
1487 | +} |
1488 | |
1489 | TEST_F(SessionMediatorTest, disconnect_releases_session) |
1490 | { |
1491 | |
1492 | === modified file 'tests/unit-tests/frontend/test_session_mediator_android.cpp' |
1493 | --- tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-04-24 05:22:20 +0000 |
1494 | +++ tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-04-25 09:50:50 +0000 |
1495 | @@ -31,7 +31,7 @@ |
1496 | #include "mir_test_doubles/mock_session.h" |
1497 | #include "mir_test_doubles/stub_shell.h" |
1498 | |
1499 | -#include "mir/event_queue.h" |
1500 | +#include "mir/events/event_sink.h" |
1501 | |
1502 | #include <gtest/gtest.h> |
1503 | |
1504 | @@ -87,7 +87,11 @@ |
1505 | } |
1506 | }; |
1507 | |
1508 | -} |
1509 | +class NullEventSink : public mir::events::EventSink |
1510 | +{ |
1511 | +public: |
1512 | + void handle_event(MirEvent const& ) override {} |
1513 | +}; |
1514 | |
1515 | struct SessionMediatorAndroidTest : public ::testing::Test |
1516 | { |
1517 | @@ -100,7 +104,7 @@ |
1518 | resource_cache{std::make_shared<mf::ResourceCache>()}, |
1519 | mediator{shell, graphics_platform, graphics_display, |
1520 | buffer_allocator, report, |
1521 | - std::make_shared<mir::EventQueue>(), |
1522 | + std::make_shared<NullEventSink>(), |
1523 | resource_cache}, |
1524 | null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} |
1525 | { |
1526 | @@ -117,6 +121,8 @@ |
1527 | std::unique_ptr<google::protobuf::Closure> null_callback; |
1528 | }; |
1529 | |
1530 | +} |
1531 | + |
1532 | TEST_F(SessionMediatorAndroidTest, drm_auth_magic_throws) |
1533 | { |
1534 | mp::ConnectParameters connect_parameters; |
1535 | |
1536 | === modified file 'tests/unit-tests/frontend/test_session_mediator_gbm.cpp' |
1537 | --- tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-04-24 05:22:20 +0000 |
1538 | +++ tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-04-25 09:50:50 +0000 |
1539 | @@ -27,7 +27,7 @@ |
1540 | #include "mir/graphics/drm_authenticator.h" |
1541 | #include "mir/graphics/platform.h" |
1542 | #include "mir/graphics/platform_ipc_package.h" |
1543 | -#include "mir/event_queue.h" |
1544 | +#include "mir/events/event_sink.h" |
1545 | |
1546 | #include <boost/exception/errinfo_errno.hpp> |
1547 | #include <boost/throw_exception.hpp> |
1548 | @@ -91,7 +91,11 @@ |
1549 | MOCK_METHOD1(drm_auth_magic, void(drm_magic_t)); |
1550 | }; |
1551 | |
1552 | -} |
1553 | +class NullEventSink : public mir::events::EventSink |
1554 | +{ |
1555 | +public: |
1556 | + void handle_event(MirEvent const& ) override {} |
1557 | +}; |
1558 | |
1559 | struct SessionMediatorGBMTest : public ::testing::Test |
1560 | { |
1561 | @@ -104,7 +108,7 @@ |
1562 | resource_cache{std::make_shared<mf::ResourceCache>()}, |
1563 | mediator{shell, mock_platform, graphics_display, |
1564 | buffer_allocator, report, |
1565 | - std::make_shared<mir::EventQueue>(), |
1566 | + std::make_shared<NullEventSink>(), |
1567 | resource_cache}, |
1568 | null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} |
1569 | { |
1570 | @@ -121,6 +125,8 @@ |
1571 | std::unique_ptr<google::protobuf::Closure> null_callback; |
1572 | }; |
1573 | |
1574 | +} |
1575 | + |
1576 | TEST_F(SessionMediatorGBMTest, drm_auth_magic_uses_drm_authenticator) |
1577 | { |
1578 | mp::ConnectParameters connect_parameters; |
1579 | |
1580 | === modified file 'tests/unit-tests/shell/test_application_session.cpp' |
1581 | --- tests/unit-tests/shell/test_application_session.cpp 2013-04-24 05:22:20 +0000 |
1582 | +++ tests/unit-tests/shell/test_application_session.cpp 2013-04-25 09:50:50 +0000 |
1583 | @@ -32,6 +32,7 @@ |
1584 | #include <gtest/gtest.h> |
1585 | |
1586 | namespace mc = mir::compositor; |
1587 | +namespace me = mir::events; |
1588 | namespace mf = mir::frontend; |
1589 | namespace msh = mir::shell; |
1590 | namespace ms = mir::surfaces; |
1591 | @@ -47,9 +48,9 @@ |
1592 | auto const mock_surface = std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder)); |
1593 | |
1594 | mtd::MockSurfaceFactory surface_factory; |
1595 | - ON_CALL(surface_factory, create_surface(_)).WillByDefault(Return(mock_surface)); |
1596 | + ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(Return(mock_surface)); |
1597 | |
1598 | - EXPECT_CALL(surface_factory, create_surface(_)); |
1599 | + EXPECT_CALL(surface_factory, create_surface(_, _, _)); |
1600 | EXPECT_CALL(*mock_surface, destroy()); |
1601 | |
1602 | mtd::StubInputTargetListener input_listener; |
1603 | @@ -69,11 +70,11 @@ |
1604 | mtd::StubSurfaceBuilder surface_builder; |
1605 | { |
1606 | InSequence seq; |
1607 | - EXPECT_CALL(surface_factory, create_surface(_)).Times(1) |
1608 | - .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); |
1609 | - EXPECT_CALL(surface_factory, create_surface(_)).Times(1) |
1610 | - .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); |
1611 | - EXPECT_CALL(surface_factory, create_surface(_)).Times(1) |
1612 | + EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1) |
1613 | + .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); |
1614 | + EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1) |
1615 | + .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); |
1616 | + EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1) |
1617 | .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); |
1618 | } |
1619 | |
1620 | @@ -106,12 +107,12 @@ |
1621 | auto const mock_surface = std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder)); |
1622 | |
1623 | mtd::MockSurfaceFactory surface_factory; |
1624 | - ON_CALL(surface_factory, create_surface(_)).WillByDefault(Return(mock_surface)); |
1625 | + ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(Return(mock_surface)); |
1626 | |
1627 | mtd::StubInputTargetListener input_listener; |
1628 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo"); |
1629 | |
1630 | - EXPECT_CALL(surface_factory, create_surface(_)); |
1631 | + EXPECT_CALL(surface_factory, create_surface(_, _, _)); |
1632 | |
1633 | { |
1634 | InSequence seq; |
1635 | |
1636 | === modified file 'tests/unit-tests/shell/test_organising_surface_factory.cpp' |
1637 | --- tests/unit-tests/shell/test_organising_surface_factory.cpp 2013-04-24 05:22:20 +0000 |
1638 | +++ tests/unit-tests/shell/test_organising_surface_factory.cpp 2013-04-25 09:50:50 +0000 |
1639 | @@ -25,6 +25,7 @@ |
1640 | #include <gtest/gtest.h> |
1641 | #include <gmock/gmock.h> |
1642 | |
1643 | +namespace me = mir::events; |
1644 | namespace mf = mir::frontend; |
1645 | namespace msh = mir::shell; |
1646 | namespace geom = mir::geometry; |
1647 | @@ -45,7 +46,7 @@ |
1648 | using namespace ::testing; |
1649 | |
1650 | underlying_surface_factory = std::make_shared<mtd::MockSurfaceFactory>(); |
1651 | - ON_CALL(*underlying_surface_factory, create_surface(_)).WillByDefault(Return(null_surface)); |
1652 | + ON_CALL(*underlying_surface_factory, create_surface(_, _, _)).WillByDefault(Return(null_surface)); |
1653 | |
1654 | placement_strategy = std::make_shared<MockPlacementStrategy>(); |
1655 | } |
1656 | @@ -62,13 +63,13 @@ |
1657 | |
1658 | msh::OrganisingSurfaceFactory factory(underlying_surface_factory, placement_strategy); |
1659 | |
1660 | - EXPECT_CALL(*underlying_surface_factory, create_surface(_)).Times(1); |
1661 | + EXPECT_CALL(*underlying_surface_factory, create_surface(_, _, _)).Times(1); |
1662 | |
1663 | auto params = mf::a_surface(); |
1664 | EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1) |
1665 | .WillOnce(Return(mf::a_surface())); |
1666 | |
1667 | - factory.create_surface(params); |
1668 | + factory.create_surface(params, mf::SurfaceId(), std::shared_ptr<me::EventSink>()); |
1669 | } |
1670 | |
1671 | TEST_F(OrganisingSurfaceFactorySetup, forwards_create_surface_parameters_from_placement_strategy_to_underlying_factory) |
1672 | @@ -83,8 +84,8 @@ |
1673 | |
1674 | EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1) |
1675 | .WillOnce(Return(placed_params)); |
1676 | - EXPECT_CALL(*underlying_surface_factory, create_surface(placed_params)); |
1677 | + EXPECT_CALL(*underlying_surface_factory, create_surface(placed_params, mf::SurfaceId(), std::shared_ptr<me::EventSink>())); |
1678 | |
1679 | - factory.create_surface(params); |
1680 | + factory.create_surface(params, mf::SurfaceId(), std::shared_ptr<me::EventSink>()); |
1681 | } |
1682 | |
1683 | |
1684 | === modified file 'tests/unit-tests/shell/test_registration_order_focus_sequence.cpp' |
1685 | --- tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-04-24 05:22:20 +0000 |
1686 | +++ tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-04-25 09:50:50 +0000 |
1687 | @@ -33,6 +33,7 @@ |
1688 | #include <string> |
1689 | |
1690 | namespace mc = mir::compositor; |
1691 | +namespace me = mir::events; |
1692 | namespace msh = mir::shell; |
1693 | namespace ms = mir::surfaces; |
1694 | namespace mt = mir::test; |
1695 | @@ -65,9 +66,9 @@ |
1696 | { |
1697 | using namespace ::testing; |
1698 | |
1699 | - auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); |
1700 | - auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2); |
1701 | - auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3); |
1702 | + auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>()); |
1703 | + auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2, std::shared_ptr<me::EventSink>()); |
1704 | + auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3, std::shared_ptr<me::EventSink>()); |
1705 | |
1706 | container->insert_session(app1); |
1707 | container->insert_session(app2); |
1708 | @@ -83,9 +84,9 @@ |
1709 | { |
1710 | using namespace ::testing; |
1711 | |
1712 | - auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); |
1713 | - auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2); |
1714 | - auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3); |
1715 | + auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>()); |
1716 | + auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2, std::shared_ptr<me::EventSink>()); |
1717 | + auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3, std::shared_ptr<me::EventSink>()); |
1718 | container->insert_session(app1); |
1719 | container->insert_session(app2); |
1720 | container->insert_session(app3); |
1721 | @@ -100,7 +101,7 @@ |
1722 | { |
1723 | using namespace ::testing; |
1724 | |
1725 | - auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); |
1726 | + auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>()); |
1727 | container->insert_session(app1); |
1728 | |
1729 | msh::RegistrationOrderFocusSequence focus_sequence(container); |
1730 | @@ -112,8 +113,8 @@ |
1731 | { |
1732 | using namespace ::testing; |
1733 | |
1734 | - auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); |
1735 | - auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2); |
1736 | + auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>()); |
1737 | + auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2, std::shared_ptr<me::EventSink>()); |
1738 | auto null_session = std::shared_ptr<msh::ApplicationSession>(); |
1739 | |
1740 | msh::RegistrationOrderFocusSequence focus_sequence(container); |
1741 | @@ -129,7 +130,7 @@ |
1742 | { |
1743 | using namespace ::testing; |
1744 | |
1745 | - auto invalid_session = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); |
1746 | + auto invalid_session = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>()); |
1747 | auto null_session = std::shared_ptr<msh::ApplicationSession>(); |
1748 | |
1749 | msh::RegistrationOrderFocusSequence focus_sequence(container); |
1750 | |
1751 | === modified file 'tests/unit-tests/shell/test_session_manager.cpp' |
1752 | --- tests/unit-tests/shell/test_session_manager.cpp 2013-04-24 05:22:20 +0000 |
1753 | +++ tests/unit-tests/shell/test_session_manager.cpp 2013-04-25 09:50:50 +0000 |
1754 | @@ -41,6 +41,7 @@ |
1755 | #include <gtest/gtest.h> |
1756 | |
1757 | namespace mc = mir::compositor; |
1758 | +namespace me = mir::events; |
1759 | namespace mf = mir::frontend; |
1760 | namespace msh = mir::shell; |
1761 | namespace ms = mir::surfaces; |
1762 | @@ -101,7 +102,7 @@ |
1763 | |
1764 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); |
1765 | |
1766 | - auto session = session_manager.open_session("Visual Basic Studio"); |
1767 | + auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1768 | session_manager.close_session(session); |
1769 | } |
1770 | |
1771 | @@ -109,10 +110,10 @@ |
1772 | { |
1773 | using namespace ::testing; |
1774 | |
1775 | - EXPECT_CALL(surface_factory, create_surface(_)).Times(1); |
1776 | + EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1); |
1777 | |
1778 | std::shared_ptr<mi::InputChannel> null_input_channel; |
1779 | - ON_CALL(surface_factory, create_surface(_)).WillByDefault( |
1780 | + ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault( |
1781 | Return(std::make_shared<msh::Surface>( |
1782 | mt::fake_shared(surface_builder), |
1783 | mf::a_surface(), |
1784 | @@ -126,7 +127,7 @@ |
1785 | |
1786 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); |
1787 | |
1788 | - auto session = session_manager.open_session("Visual Basic Studio"); |
1789 | + auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1790 | session->create_surface(mf::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}})); |
1791 | |
1792 | session_manager.close_session(session); |
1793 | @@ -140,7 +141,7 @@ |
1794 | EXPECT_CALL(container, insert_session(_)).Times(1); |
1795 | EXPECT_CALL(focus_setter, set_focus_to(_)).WillOnce(SaveArg<0>(&new_session)); |
1796 | |
1797 | - auto session = session_manager.open_session("Visual Basic Studio"); |
1798 | + auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1799 | EXPECT_EQ(session, new_session); |
1800 | } |
1801 | |
1802 | @@ -148,8 +149,8 @@ |
1803 | { |
1804 | using namespace ::testing; |
1805 | |
1806 | - auto session1 = session_manager.open_session("Visual Basic Studio"); |
1807 | - auto session2 = session_manager.open_session("IntelliJ IDEA"); |
1808 | + auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1809 | + auto session2 = session_manager.open_session("IntelliJ IDEA", std::shared_ptr<me::EventSink>()); |
1810 | |
1811 | session_manager.tag_session_with_lightdm_id(session1, 1); |
1812 | |
1813 | @@ -161,8 +162,8 @@ |
1814 | { |
1815 | using namespace ::testing; |
1816 | |
1817 | - auto session1 = session_manager.open_session("Visual Basic Studio"); |
1818 | - auto session2 = session_manager.open_session("IntelliJ IDEA"); |
1819 | + auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1820 | + auto session2 = session_manager.open_session("IntelliJ IDEA", std::shared_ptr<me::EventSink>()); |
1821 | |
1822 | auto shell_session1 = std::dynamic_pointer_cast<msh::Session>(session1); |
1823 | auto shell_session2 = std::dynamic_pointer_cast<msh::Session>(session2); |
1824 | @@ -180,7 +181,7 @@ |
1825 | { |
1826 | using namespace ::testing; |
1827 | std::shared_ptr<mi::InputChannel> null_input_channel; |
1828 | - ON_CALL(surface_factory, create_surface(_)).WillByDefault( |
1829 | + ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault( |
1830 | Return(std::make_shared<msh::Surface>( |
1831 | mt::fake_shared(surface_builder), |
1832 | mf::a_surface(), |
1833 | @@ -191,11 +192,11 @@ |
1834 | InSequence seq; |
1835 | |
1836 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Session creation |
1837 | - EXPECT_CALL(surface_factory, create_surface(_)).Times(1); |
1838 | + EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1); |
1839 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation |
1840 | } |
1841 | |
1842 | - auto session1 = session_manager.open_session("Weather Report"); |
1843 | + auto session1 = session_manager.open_session("Weather Report", std::shared_ptr<me::EventSink>()); |
1844 | session_manager.create_surface_for(session1, mf::a_surface()); |
1845 | } |
1846 | |
1847 | @@ -230,12 +231,12 @@ |
1848 | using namespace ::testing; |
1849 | |
1850 | std::shared_ptr<mi::InputChannel> null_input_channel; |
1851 | - ON_CALL(surface_factory, create_surface(_)).WillByDefault( |
1852 | + ON_CALL(surface_factory, create_surface(_,_,_)).WillByDefault( |
1853 | Return(std::make_shared<msh::Surface>( |
1854 | mt::fake_shared(surface_builder), |
1855 | mf::a_surface(), |
1856 | null_input_channel))); |
1857 | - EXPECT_CALL(surface_factory, create_surface(_)).Times(1); |
1858 | + EXPECT_CALL(surface_factory, create_surface(_,_,_)).Times(1); |
1859 | |
1860 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); |
1861 | { |
1862 | @@ -252,7 +253,7 @@ |
1863 | } |
1864 | |
1865 | { |
1866 | - auto session = session_manager.open_session("test"); |
1867 | + auto session = session_manager.open_session("test", std::shared_ptr<me::EventSink>()); |
1868 | auto surf = session_manager.create_surface_for(session, mf::a_surface()); |
1869 | session->destroy_surface(surf); |
1870 | session_manager.close_session(session); |
1871 | |
1872 | === modified file 'tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp' |
1873 | --- tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-04-24 05:22:20 +0000 |
1874 | +++ tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-04-25 09:50:50 +0000 |
1875 | @@ -57,7 +57,6 @@ |
1876 | MOCK_METHOD0(show, void()); |
1877 | |
1878 | MOCK_METHOD3(configure_surface, int(mf::SurfaceId, MirSurfaceAttrib, int)); |
1879 | - MOCK_METHOD1(set_event_sink, void(std::shared_ptr<mir::EventSink> const&)); |
1880 | }; |
1881 | |
1882 | TEST(SingleVisibilityFocusMechanism, mechanism_sets_visibility) |
1883 | |
1884 | === modified file 'tests/unit-tests/shell/test_surface.cpp' |
1885 | --- tests/unit-tests/shell/test_surface.cpp 2013-04-24 05:22:20 +0000 |
1886 | +++ tests/unit-tests/shell/test_surface.cpp 2013-04-25 09:50:50 +0000 |
1887 | @@ -33,6 +33,7 @@ |
1888 | #include <gmock/gmock.h> |
1889 | #include <gtest/gtest.h> |
1890 | |
1891 | +namespace me = mir::events; |
1892 | namespace ms = mir::surfaces; |
1893 | namespace msh = mir::shell; |
1894 | namespace mf = mir::frontend; |
1895 | @@ -450,3 +451,4 @@ |
1896 | mir_surface_state_fullscreen)); |
1897 | EXPECT_EQ(mir_surface_state_fullscreen, surf.state()); |
1898 | } |
1899 | + |
1900 | |
1901 | === modified file 'tests/unit-tests/shell/test_the_session_container_implementation.cpp' |
1902 | --- tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-04-24 05:22:20 +0000 |
1903 | +++ tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-04-25 09:50:50 +0000 |
1904 | @@ -29,6 +29,7 @@ |
1905 | #include <gtest/gtest.h> |
1906 | #include <string> |
1907 | |
1908 | +namespace me = mir::events; |
1909 | namespace mf = mir::frontend; |
1910 | namespace msh = mir::shell; |
1911 | namespace mtd = mir::test::doubles; |
1912 | @@ -39,10 +40,8 @@ |
1913 | auto factory = std::make_shared<mtd::MockSurfaceFactory>(); |
1914 | msh::DefaultSessionContainer container; |
1915 | |
1916 | - container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), |
1917 | - "Visual Studio 7")); |
1918 | - container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), |
1919 | - "Visual Studio 8")); |
1920 | + container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), "Visual Studio 7")); |
1921 | + container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), "Visual Studio 8")); |
1922 | |
1923 | struct local |
1924 | { |
Firstly, needs fixing: tests/shell/ test_applicatio n_session. cpp
Text conflict in tests/unit-
1 conflicts encountered.
Secondly, I disagree with the approach. There are no strong "dependencies" here. The information in question is all optional to the class receiving it, so should not be passed in constructors. The classes can function without event sinks or surface IDs. They will work as they already do. Only event emission would not happen. So it's optional relative to those classes, and therefore not something to enforce in the constructor.
Aside from anything else, the degree of coupling introduced here looks very high. It's always better to minimize coupling. You can't call it a simplification if coupling is increased and the diff is "+205/-148".