Merge lp:~alan-griffiths/mir/surface-states-simplification into lp:~mir-team/mir/trunk
- surface-states-simplification
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~alan-griffiths/mir/surface-states-simplification |
Merge into: | lp:~mir-team/mir/trunk |
Diff against target: |
2159 lines (+389/-285) 63 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 (+9/-7) 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 (+8/-8) 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.h (+6/-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 (+6/-12) src/server/shell/organising_surface_factory.cpp (+5/-2) src/server/shell/session_manager.cpp (+4/-2) src/server/shell/surface.cpp (+6/-13) 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 (+15/-14) 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 (+25/-18) tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp (+0/-1) tests/unit-tests/shell/test_surface.cpp (+60/-17) tests/unit-tests/shell/test_the_session_container_implementation.cpp (+8/-6) |
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 | |
Daniel van Vugt | Needs Resubmitting | ||
Chris Halse Rogers | Needs Information | ||
Review via email: mp+160361@code.launchpad.net |
This proposal supersedes a proposal from 2013-04-19.
This proposal has been superseded by a proposal from 2013-04-24.
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 : | # |
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 : | # |
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 : | # |
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 : | # |
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 : | # |
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 : | # |
If you resubmit and prerequisite the surface-states branch, I will close my eyes and happily Abstain.
Alan Griffiths (alan-griffiths) wrote : | # |
> 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 : | # |
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://
Preview Diff
1 | === modified file 'examples/demo-inprocess-egl/inprocess_egl_client.cpp' | |||
2 | --- examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-04-23 01:40:52 +0000 | |||
3 | +++ examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-04-24 09:03:32 +0000 | |||
4 | @@ -60,7 +60,7 @@ | |||
5 | 60 | .of_size(surface_size) | 60 | .of_size(surface_size) |
6 | 61 | .of_buffer_usage(mc::BufferUsage::hardware) | 61 | .of_buffer_usage(mc::BufferUsage::hardware) |
7 | 62 | .of_pixel_format(geom::PixelFormat::argb_8888); | 62 | .of_pixel_format(geom::PixelFormat::argb_8888); |
9 | 63 | auto surface = surface_factory->create_surface(params); | 63 | auto surface = surface_factory->create_surface(params, mf::SurfaceId(), std::shared_ptr<events::EventSink>()); |
10 | 64 | 64 | ||
11 | 65 | surface->advance_client_buffer(); // TODO: What a wart! | 65 | surface->advance_client_buffer(); // TODO: What a wart! |
12 | 66 | 66 | ||
13 | 67 | 67 | ||
14 | === modified file 'include/server/mir/frontend/protobuf_ipc_factory.h' | |||
15 | --- include/server/mir/frontend/protobuf_ipc_factory.h 2013-04-19 07:45:44 +0000 | |||
16 | +++ include/server/mir/frontend/protobuf_ipc_factory.h 2013-04-24 09:03:32 +0000 | |||
17 | @@ -23,8 +23,10 @@ | |||
18 | 23 | 23 | ||
19 | 24 | namespace mir | 24 | namespace mir |
20 | 25 | { | 25 | { |
21 | 26 | namespace events | ||
22 | 27 | { | ||
23 | 26 | class EventSink; | 28 | class EventSink; |
25 | 27 | 29 | } | |
26 | 28 | namespace protobuf | 30 | namespace protobuf |
27 | 29 | { | 31 | { |
28 | 30 | class DisplayServer; | 32 | class DisplayServer; |
29 | @@ -38,7 +40,7 @@ | |||
30 | 38 | { | 40 | { |
31 | 39 | public: | 41 | public: |
32 | 40 | virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server( | 42 | virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server( |
34 | 41 | std::shared_ptr<EventSink> const& sink) = 0; | 43 | std::shared_ptr<events::EventSink> const& sink) = 0; |
35 | 42 | virtual std::shared_ptr<ResourceCache> resource_cache() = 0; | 44 | virtual std::shared_ptr<ResourceCache> resource_cache() = 0; |
36 | 43 | virtual std::shared_ptr<MessageProcessorReport> report() = 0; | 45 | virtual std::shared_ptr<MessageProcessorReport> report() = 0; |
37 | 44 | 46 | ||
38 | 45 | 47 | ||
39 | === modified file 'include/server/mir/frontend/session.h' | |||
40 | --- include/server/mir/frontend/session.h 2013-04-22 03:24:56 +0000 | |||
41 | +++ include/server/mir/frontend/session.h 2013-04-24 09:03:32 +0000 | |||
42 | @@ -29,7 +29,6 @@ | |||
43 | 29 | 29 | ||
44 | 30 | namespace mir | 30 | namespace mir |
45 | 31 | { | 31 | { |
46 | 32 | class EventSink; | ||
47 | 33 | 32 | ||
48 | 34 | namespace frontend | 33 | namespace frontend |
49 | 35 | { | 34 | { |
50 | @@ -52,8 +51,6 @@ | |||
51 | 52 | 51 | ||
52 | 53 | virtual int configure_surface(SurfaceId id, MirSurfaceAttrib attrib, int value) = 0; | 52 | virtual int configure_surface(SurfaceId id, MirSurfaceAttrib attrib, int value) = 0; |
53 | 54 | 53 | ||
54 | 55 | virtual void set_event_sink(std::shared_ptr<EventSink> const&) = 0; | ||
55 | 56 | |||
56 | 57 | protected: | 54 | protected: |
57 | 58 | Session() = default; | 55 | Session() = default; |
58 | 59 | Session(Session const&) = delete; | 56 | Session(Session const&) = delete; |
59 | 60 | 57 | ||
60 | === modified file 'include/server/mir/frontend/session_mediator.h' | |||
61 | --- include/server/mir/frontend/session_mediator.h 2013-04-19 07:45:44 +0000 | |||
62 | +++ include/server/mir/frontend/session_mediator.h 2013-04-24 09:03:32 +0000 | |||
63 | @@ -27,8 +27,10 @@ | |||
64 | 27 | 27 | ||
65 | 28 | namespace mir | 28 | namespace mir |
66 | 29 | { | 29 | { |
67 | 30 | namespace events | ||
68 | 31 | { | ||
69 | 30 | class EventSink; | 32 | class EventSink; |
71 | 31 | 33 | } | |
72 | 32 | namespace graphics | 34 | namespace graphics |
73 | 33 | { | 35 | { |
74 | 34 | class Platform; | 36 | class Platform; |
75 | @@ -62,7 +64,7 @@ | |||
76 | 62 | std::shared_ptr<graphics::ViewableArea> const& viewable_area, | 64 | std::shared_ptr<graphics::ViewableArea> const& viewable_area, |
77 | 63 | std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator, | 65 | std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator, |
78 | 64 | std::shared_ptr<SessionMediatorReport> const& report, | 66 | std::shared_ptr<SessionMediatorReport> const& report, |
80 | 65 | std::shared_ptr<EventSink> const& event_sink, | 67 | std::shared_ptr<events::EventSink> const& event_sink, |
81 | 66 | std::shared_ptr<ResourceCache> const& resource_cache); | 68 | std::shared_ptr<ResourceCache> const& resource_cache); |
82 | 67 | 69 | ||
83 | 68 | /* Platform independent requests */ | 70 | /* Platform independent requests */ |
84 | @@ -119,7 +121,7 @@ | |||
85 | 119 | std::shared_ptr<compositor::GraphicBufferAllocator> const buffer_allocator; | 121 | std::shared_ptr<compositor::GraphicBufferAllocator> const buffer_allocator; |
86 | 120 | 122 | ||
87 | 121 | std::shared_ptr<SessionMediatorReport> const report; | 123 | std::shared_ptr<SessionMediatorReport> const report; |
89 | 122 | std::shared_ptr<EventSink> const event_sink; | 124 | std::shared_ptr<events::EventSink> const event_sink; |
90 | 123 | std::shared_ptr<ResourceCache> const resource_cache; | 125 | std::shared_ptr<ResourceCache> const resource_cache; |
91 | 124 | std::shared_ptr<ClientBufferTracker> const client_tracker; | 126 | std::shared_ptr<ClientBufferTracker> const client_tracker; |
92 | 125 | 127 | ||
93 | 126 | 128 | ||
94 | === modified file 'include/server/mir/frontend/shell.h' | |||
95 | --- include/server/mir/frontend/shell.h 2013-04-22 03:24:56 +0000 | |||
96 | +++ include/server/mir/frontend/shell.h 2013-04-24 09:03:32 +0000 | |||
97 | @@ -24,7 +24,10 @@ | |||
98 | 24 | 24 | ||
99 | 25 | namespace mir | 25 | namespace mir |
100 | 26 | { | 26 | { |
102 | 27 | 27 | namespace events | |
103 | 28 | { | ||
104 | 29 | class EventSink; | ||
105 | 30 | } | ||
106 | 28 | namespace frontend | 31 | namespace frontend |
107 | 29 | { | 32 | { |
108 | 30 | class Session; | 33 | class Session; |
109 | @@ -35,7 +38,7 @@ | |||
110 | 35 | public: | 38 | public: |
111 | 36 | virtual ~Shell() {} | 39 | virtual ~Shell() {} |
112 | 37 | 40 | ||
114 | 38 | virtual std::shared_ptr<Session> open_session(std::string const& name) = 0; | 41 | virtual std::shared_ptr<Session> open_session(std::string const& name, std::shared_ptr<events::EventSink> const& sink) = 0; |
115 | 39 | virtual void close_session(std::shared_ptr<Session> const& session) = 0; | 42 | virtual void close_session(std::shared_ptr<Session> const& session) = 0; |
116 | 40 | 43 | ||
117 | 41 | virtual void tag_session_with_lightdm_id(std::shared_ptr<Session> const& session, int id) = 0; | 44 | virtual void tag_session_with_lightdm_id(std::shared_ptr<Session> const& session, int id) = 0; |
118 | 42 | 45 | ||
119 | === modified file 'include/server/mir/shell/application_session.h' | |||
120 | --- include/server/mir/shell/application_session.h 2013-04-23 01:40:52 +0000 | |||
121 | +++ include/server/mir/shell/application_session.h 2013-04-24 09:03:32 +0000 | |||
122 | @@ -25,8 +25,10 @@ | |||
123 | 25 | 25 | ||
124 | 26 | namespace mir | 26 | namespace mir |
125 | 27 | { | 27 | { |
126 | 28 | namespace events | ||
127 | 29 | { | ||
128 | 28 | class EventSink; | 30 | class EventSink; |
130 | 29 | 31 | } | |
131 | 30 | namespace shell | 32 | namespace shell |
132 | 31 | { | 33 | { |
133 | 32 | class SurfaceFactory; | 34 | class SurfaceFactory; |
134 | @@ -36,8 +38,11 @@ | |||
135 | 36 | class ApplicationSession : public Session | 38 | class ApplicationSession : public Session |
136 | 37 | { | 39 | { |
137 | 38 | public: | 40 | public: |
140 | 39 | explicit ApplicationSession(std::shared_ptr<SurfaceFactory> const& surface_factory, | 41 | explicit ApplicationSession( |
141 | 40 | std::shared_ptr<InputTargetListener> const& input_target_listener, std::string const& session_name); | 42 | std::shared_ptr<SurfaceFactory> const& surface_factory, |
142 | 43 | std::shared_ptr<InputTargetListener> const& input_target_listener, | ||
143 | 44 | std::string const& session_name, | ||
144 | 45 | std::shared_ptr<events::EventSink> const& sink); | ||
145 | 41 | ~ApplicationSession(); | 46 | ~ApplicationSession(); |
146 | 42 | 47 | ||
147 | 43 | frontend::SurfaceId create_surface(frontend::SurfaceCreationParameters const& params); | 48 | frontend::SurfaceId create_surface(frontend::SurfaceCreationParameters const& params); |
148 | @@ -55,8 +60,6 @@ | |||
149 | 55 | 60 | ||
150 | 56 | int configure_surface(frontend::SurfaceId id, MirSurfaceAttrib attrib, int value); | 61 | int configure_surface(frontend::SurfaceId id, MirSurfaceAttrib attrib, int value); |
151 | 57 | 62 | ||
152 | 58 | void set_event_sink(std::shared_ptr<mir::EventSink> const& sink); | ||
153 | 59 | |||
154 | 60 | protected: | 63 | protected: |
155 | 61 | ApplicationSession(ApplicationSession const&) = delete; | 64 | ApplicationSession(ApplicationSession const&) = delete; |
156 | 62 | ApplicationSession& operator=(ApplicationSession const&) = delete; | 65 | ApplicationSession& operator=(ApplicationSession const&) = delete; |
157 | @@ -65,6 +68,7 @@ | |||
158 | 65 | std::shared_ptr<SurfaceFactory> const surface_factory; | 68 | std::shared_ptr<SurfaceFactory> const surface_factory; |
159 | 66 | std::shared_ptr<InputTargetListener> const input_target_listener; | 69 | std::shared_ptr<InputTargetListener> const input_target_listener; |
160 | 67 | std::string const session_name; | 70 | std::string const session_name; |
161 | 71 | std::shared_ptr<events::EventSink> const event_sink; | ||
162 | 68 | 72 | ||
163 | 69 | frontend::SurfaceId next_id(); | 73 | frontend::SurfaceId next_id(); |
164 | 70 | 74 | ||
165 | @@ -74,8 +78,6 @@ | |||
166 | 74 | Surfaces::const_iterator checked_find(frontend::SurfaceId id) const; | 78 | Surfaces::const_iterator checked_find(frontend::SurfaceId id) const; |
167 | 75 | std::mutex mutable surfaces_mutex; | 79 | std::mutex mutable surfaces_mutex; |
168 | 76 | Surfaces surfaces; | 80 | Surfaces surfaces; |
169 | 77 | |||
170 | 78 | std::shared_ptr<EventSink> event_sink; | ||
171 | 79 | }; | 81 | }; |
172 | 80 | 82 | ||
173 | 81 | } | 83 | } |
174 | 82 | 84 | ||
175 | === modified file 'include/server/mir/shell/organising_surface_factory.h' | |||
176 | --- include/server/mir/shell/organising_surface_factory.h 2013-04-16 09:16:38 +0000 | |||
177 | +++ include/server/mir/shell/organising_surface_factory.h 2013-04-24 09:03:32 +0000 | |||
178 | @@ -36,7 +36,10 @@ | |||
179 | 36 | std::shared_ptr<PlacementStrategy> const& placement_strategy); | 36 | std::shared_ptr<PlacementStrategy> const& placement_strategy); |
180 | 37 | virtual ~OrganisingSurfaceFactory(); | 37 | virtual ~OrganisingSurfaceFactory(); |
181 | 38 | 38 | ||
183 | 39 | std::shared_ptr<Surface> create_surface(frontend::SurfaceCreationParameters const& params); | 39 | std::shared_ptr<Surface> create_surface( |
184 | 40 | frontend::SurfaceCreationParameters const& params, | ||
185 | 41 | frontend::SurfaceId id, | ||
186 | 42 | std::shared_ptr<events::EventSink> const& sink) override; | ||
187 | 40 | 43 | ||
188 | 41 | protected: | 44 | protected: |
189 | 42 | OrganisingSurfaceFactory(OrganisingSurfaceFactory const&) = delete; | 45 | OrganisingSurfaceFactory(OrganisingSurfaceFactory const&) = delete; |
190 | 43 | 46 | ||
191 | === modified file 'include/server/mir/shell/session_manager.h' | |||
192 | --- include/server/mir/shell/session_manager.h 2013-04-23 01:40:52 +0000 | |||
193 | +++ include/server/mir/shell/session_manager.h 2013-04-24 09:03:32 +0000 | |||
194 | @@ -53,7 +53,7 @@ | |||
195 | 53 | std::shared_ptr<InputTargetListener> const& input_target_listener); | 53 | std::shared_ptr<InputTargetListener> const& input_target_listener); |
196 | 54 | virtual ~SessionManager(); | 54 | virtual ~SessionManager(); |
197 | 55 | 55 | ||
199 | 56 | virtual std::shared_ptr<frontend::Session> open_session(std::string const& name); | 56 | virtual std::shared_ptr<frontend::Session> open_session(std::string const& name, std::shared_ptr<events::EventSink> const& sink); |
200 | 57 | virtual void close_session(std::shared_ptr<frontend::Session> const& session); | 57 | virtual void close_session(std::shared_ptr<frontend::Session> const& session); |
201 | 58 | 58 | ||
202 | 59 | virtual void tag_session_with_lightdm_id(std::shared_ptr<frontend::Session> const& session, int id); | 59 | virtual void tag_session_with_lightdm_id(std::shared_ptr<frontend::Session> const& session, int id); |
203 | 60 | 60 | ||
204 | === modified file 'include/server/mir/shell/surface.h' | |||
205 | --- include/server/mir/shell/surface.h 2013-04-19 03:20:05 +0000 | |||
206 | +++ include/server/mir/shell/surface.h 2013-04-24 09:03:32 +0000 | |||
207 | @@ -31,9 +31,10 @@ | |||
208 | 31 | 31 | ||
209 | 32 | namespace mir | 32 | namespace mir |
210 | 33 | { | 33 | { |
212 | 34 | 34 | namespace events | |
213 | 35 | { | ||
214 | 35 | class EventSink; | 36 | class EventSink; |
216 | 36 | 37 | } | |
217 | 37 | namespace frontend | 38 | namespace frontend |
218 | 38 | { | 39 | { |
219 | 39 | struct SurfaceCreationParameters; | 40 | struct SurfaceCreationParameters; |
220 | @@ -53,7 +54,9 @@ | |||
221 | 53 | Surface( | 54 | Surface( |
222 | 54 | std::shared_ptr<SurfaceBuilder> const& builder, | 55 | std::shared_ptr<SurfaceBuilder> const& builder, |
223 | 55 | frontend::SurfaceCreationParameters const& params, | 56 | frontend::SurfaceCreationParameters const& params, |
225 | 56 | std::shared_ptr<input::InputChannel> const& input_channel); | 57 | std::shared_ptr<input::InputChannel> const& input_channel, |
226 | 58 | frontend::SurfaceId id, | ||
227 | 59 | std::shared_ptr<events::EventSink> const& sink); | ||
228 | 57 | ~Surface(); | 60 | ~Surface(); |
229 | 58 | 61 | ||
230 | 59 | virtual void hide(); | 62 | virtual void hide(); |
231 | @@ -82,9 +85,6 @@ | |||
232 | 82 | virtual MirSurfaceType type() const; | 85 | virtual MirSurfaceType type() const; |
233 | 83 | virtual MirSurfaceState state() const; | 86 | virtual MirSurfaceState state() const; |
234 | 84 | 87 | ||
235 | 85 | void set_id(frontend::SurfaceId i); | ||
236 | 86 | void set_event_target(std::shared_ptr<EventSink> const& sink); | ||
237 | 87 | |||
238 | 88 | private: | 88 | private: |
239 | 89 | bool set_type(MirSurfaceType t); // Use configure() to make public changes | 89 | bool set_type(MirSurfaceType t); // Use configure() to make public changes |
240 | 90 | bool set_state(MirSurfaceState s); | 90 | bool set_state(MirSurfaceState s); |
241 | @@ -94,8 +94,8 @@ | |||
242 | 94 | std::shared_ptr<mir::input::InputChannel> const input_channel; | 94 | std::shared_ptr<mir::input::InputChannel> const input_channel; |
243 | 95 | std::weak_ptr<mir::surfaces::Surface> const surface; | 95 | std::weak_ptr<mir::surfaces::Surface> const surface; |
244 | 96 | 96 | ||
247 | 97 | std::shared_ptr<EventSink> event_sink; | 97 | frontend::SurfaceId const id; |
248 | 98 | frontend::SurfaceId id; | 98 | std::shared_ptr<events::EventSink> const event_sink; |
249 | 99 | 99 | ||
250 | 100 | MirSurfaceType type_value; | 100 | MirSurfaceType type_value; |
251 | 101 | MirSurfaceState state_value; | 101 | MirSurfaceState state_value; |
252 | 102 | 102 | ||
253 | === modified file 'include/server/mir/shell/surface_factory.h' | |||
254 | --- include/server/mir/shell/surface_factory.h 2013-04-19 03:20:05 +0000 | |||
255 | +++ include/server/mir/shell/surface_factory.h 2013-04-24 09:03:32 +0000 | |||
256 | @@ -19,10 +19,15 @@ | |||
257 | 19 | #ifndef MIR_SHELL_SURFACE_FACTORY_H_ | 19 | #ifndef MIR_SHELL_SURFACE_FACTORY_H_ |
258 | 20 | #define MIR_SHELL_SURFACE_FACTORY_H_ | 20 | #define MIR_SHELL_SURFACE_FACTORY_H_ |
259 | 21 | 21 | ||
260 | 22 | #include "mir/frontend/surface_id.h" | ||
261 | 22 | #include <memory> | 23 | #include <memory> |
262 | 23 | 24 | ||
263 | 24 | namespace mir | 25 | namespace mir |
264 | 25 | { | 26 | { |
265 | 27 | namespace events | ||
266 | 28 | { | ||
267 | 29 | class EventSink; | ||
268 | 30 | } | ||
269 | 26 | namespace frontend | 31 | namespace frontend |
270 | 27 | { | 32 | { |
271 | 28 | struct SurfaceCreationParameters; | 33 | struct SurfaceCreationParameters; |
272 | @@ -34,7 +39,10 @@ | |||
273 | 34 | class SurfaceFactory | 39 | class SurfaceFactory |
274 | 35 | { | 40 | { |
275 | 36 | public: | 41 | public: |
277 | 37 | virtual std::shared_ptr<Surface> create_surface(const frontend::SurfaceCreationParameters& params) = 0; | 42 | virtual std::shared_ptr<Surface> create_surface( |
278 | 43 | frontend::SurfaceCreationParameters const& params, | ||
279 | 44 | frontend::SurfaceId id, | ||
280 | 45 | std::shared_ptr<events::EventSink> const& sink) = 0; | ||
281 | 38 | 46 | ||
282 | 39 | protected: | 47 | protected: |
283 | 40 | virtual ~SurfaceFactory() {} | 48 | virtual ~SurfaceFactory() {} |
284 | 41 | 49 | ||
285 | === modified file 'include/server/mir/shell/surface_source.h' | |||
286 | --- include/server/mir/shell/surface_source.h 2013-04-16 09:16:38 +0000 | |||
287 | +++ include/server/mir/shell/surface_source.h 2013-04-24 09:03:32 +0000 | |||
288 | @@ -40,7 +40,10 @@ | |||
289 | 40 | explicit SurfaceSource(std::shared_ptr<SurfaceBuilder> const& surface_builder, std::shared_ptr<input::InputChannelFactory> const& input_factory); | 40 | explicit SurfaceSource(std::shared_ptr<SurfaceBuilder> const& surface_builder, std::shared_ptr<input::InputChannelFactory> const& input_factory); |
290 | 41 | virtual ~SurfaceSource() {} | 41 | virtual ~SurfaceSource() {} |
291 | 42 | 42 | ||
293 | 43 | std::shared_ptr<Surface> create_surface(const frontend::SurfaceCreationParameters& params); | 43 | std::shared_ptr<Surface> create_surface( |
294 | 44 | frontend::SurfaceCreationParameters const& params, | ||
295 | 45 | frontend::SurfaceId id, | ||
296 | 46 | std::shared_ptr<events::EventSink> const& sink); | ||
297 | 44 | 47 | ||
298 | 45 | protected: | 48 | protected: |
299 | 46 | SurfaceSource(const SurfaceSource&) = delete; | 49 | SurfaceSource(const SurfaceSource&) = delete; |
300 | 47 | 50 | ||
301 | === added directory 'include/shared/mir/events' | |||
302 | === renamed file 'include/shared/mir/event_sink.h' => 'include/shared/mir/events/event_sink.h' | |||
303 | --- include/shared/mir/event_sink.h 2013-04-19 04:33:51 +0000 | |||
304 | +++ include/shared/mir/events/event_sink.h 2013-04-24 09:03:32 +0000 | |||
305 | @@ -16,13 +16,15 @@ | |||
306 | 16 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> | 16 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
307 | 17 | */ | 17 | */ |
308 | 18 | 18 | ||
311 | 19 | #ifndef MIR_EVENT_SINK_H_ | 19 | #ifndef MIR_EVENTS_EVENT_SINK_H_ |
312 | 20 | #define MIR_EVENT_SINK_H_ | 20 | #define MIR_EVENTS_EVENT_SINK_H_ |
313 | 21 | 21 | ||
314 | 22 | #include "mir_toolkit/event.h" | 22 | #include "mir_toolkit/event.h" |
315 | 23 | 23 | ||
316 | 24 | namespace mir | 24 | namespace mir |
317 | 25 | { | 25 | { |
318 | 26 | namespace events | ||
319 | 27 | { | ||
320 | 26 | 28 | ||
321 | 27 | class EventSink | 29 | class EventSink |
322 | 28 | { | 30 | { |
323 | @@ -36,8 +38,7 @@ | |||
324 | 36 | EventSink(EventSink const&) = delete; | 38 | EventSink(EventSink const&) = delete; |
325 | 37 | EventSink& operator=(EventSink const&) = delete; | 39 | EventSink& operator=(EventSink const&) = delete; |
326 | 38 | }; | 40 | }; |
328 | 39 | 41 | } | |
329 | 40 | } // namespace mir | 42 | } // namespace mir |
330 | 41 | 43 | ||
333 | 42 | #endif | 44 | #endif // MIR_EVENTS_EVENT_SINK_H_ |
332 | 43 | |||
334 | 44 | 45 | ||
335 | === modified file 'include/test/mir_test_doubles/mock_session.h' | |||
336 | --- include/test/mir_test_doubles/mock_session.h 2013-04-19 08:03:57 +0000 | |||
337 | +++ include/test/mir_test_doubles/mock_session.h 2013-04-24 09:03:32 +0000 | |||
338 | @@ -43,8 +43,6 @@ | |||
339 | 43 | MOCK_METHOD0(show, void()); | 43 | MOCK_METHOD0(show, void()); |
340 | 44 | 44 | ||
341 | 45 | MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int)); | 45 | MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int)); |
342 | 46 | |||
343 | 47 | MOCK_METHOD1(set_event_sink, void(std::shared_ptr<mir::EventSink> const&)); | ||
344 | 48 | }; | 46 | }; |
345 | 49 | 47 | ||
346 | 50 | } | 48 | } |
347 | 51 | 49 | ||
348 | === modified file 'include/test/mir_test_doubles/mock_shell.h' | |||
349 | --- include/test/mir_test_doubles/mock_shell.h 2013-04-19 03:20:05 +0000 | |||
350 | +++ include/test/mir_test_doubles/mock_shell.h 2013-04-24 09:03:32 +0000 | |||
351 | @@ -34,7 +34,7 @@ | |||
352 | 34 | 34 | ||
353 | 35 | struct MockShell : public frontend::Shell | 35 | struct MockShell : public frontend::Shell |
354 | 36 | { | 36 | { |
356 | 37 | MOCK_METHOD1(open_session, std::shared_ptr<frontend::Session>(std::string const&)); | 37 | MOCK_METHOD2(open_session, std::shared_ptr<frontend::Session>(std::string const&, std::shared_ptr<events::EventSink> const&)); |
357 | 38 | MOCK_METHOD1(close_session, void(std::shared_ptr<frontend::Session> const&)); | 38 | MOCK_METHOD1(close_session, void(std::shared_ptr<frontend::Session> const&)); |
358 | 39 | 39 | ||
359 | 40 | MOCK_METHOD2(tag_session_with_lightdm_id, void(std::shared_ptr<frontend::Session> const&, int)); | 40 | MOCK_METHOD2(tag_session_with_lightdm_id, void(std::shared_ptr<frontend::Session> const&, int)); |
360 | 41 | 41 | ||
361 | === modified file 'include/test/mir_test_doubles/mock_surface.h' | |||
362 | --- include/test/mir_test_doubles/mock_surface.h 2013-04-19 03:20:05 +0000 | |||
363 | +++ include/test/mir_test_doubles/mock_surface.h 2013-04-24 09:03:32 +0000 | |||
364 | @@ -37,7 +37,12 @@ | |||
365 | 37 | struct MockSurface : public shell::Surface | 37 | struct MockSurface : public shell::Surface |
366 | 38 | { | 38 | { |
367 | 39 | MockSurface(std::shared_ptr<shell::SurfaceBuilder> const& builder) : | 39 | MockSurface(std::shared_ptr<shell::SurfaceBuilder> const& builder) : |
369 | 40 | shell::Surface(builder, frontend::a_surface(), std::shared_ptr<input::InputChannel>()) | 40 | shell::Surface( |
370 | 41 | builder, | ||
371 | 42 | frontend::a_surface(), | ||
372 | 43 | std::shared_ptr<input::InputChannel>(), | ||
373 | 44 | frontend::SurfaceId(), | ||
374 | 45 | std::shared_ptr<events::EventSink>()) | ||
375 | 41 | { | 46 | { |
376 | 42 | } | 47 | } |
377 | 43 | 48 | ||
378 | 44 | 49 | ||
379 | === modified file 'include/test/mir_test_doubles/mock_surface_factory.h' | |||
380 | --- include/test/mir_test_doubles/mock_surface_factory.h 2013-04-16 09:16:38 +0000 | |||
381 | +++ include/test/mir_test_doubles/mock_surface_factory.h 2013-04-24 09:03:32 +0000 | |||
382 | @@ -33,7 +33,10 @@ | |||
383 | 33 | 33 | ||
384 | 34 | struct MockSurfaceFactory : public shell::SurfaceFactory | 34 | struct MockSurfaceFactory : public shell::SurfaceFactory |
385 | 35 | { | 35 | { |
387 | 36 | MOCK_METHOD1(create_surface, std::shared_ptr<shell::Surface>(const frontend::SurfaceCreationParameters&)); | 36 | MOCK_METHOD3(create_surface, std::shared_ptr<shell::Surface>( |
388 | 37 | const frontend::SurfaceCreationParameters&, | ||
389 | 38 | frontend::SurfaceId, | ||
390 | 39 | std::shared_ptr<events::EventSink> const&)); | ||
391 | 37 | }; | 40 | }; |
392 | 38 | 41 | ||
393 | 39 | } | 42 | } |
394 | 40 | 43 | ||
395 | === modified file 'include/test/mir_test_doubles/stub_ipc_factory.h' | |||
396 | --- include/test/mir_test_doubles/stub_ipc_factory.h 2013-04-19 07:45:44 +0000 | |||
397 | +++ include/test/mir_test_doubles/stub_ipc_factory.h 2013-04-24 09:03:32 +0000 | |||
398 | @@ -42,7 +42,7 @@ | |||
399 | 42 | } | 42 | } |
400 | 43 | 43 | ||
401 | 44 | std::shared_ptr<protobuf::DisplayServer> make_ipc_server( | 44 | std::shared_ptr<protobuf::DisplayServer> make_ipc_server( |
403 | 45 | std::shared_ptr<EventSink> const&) | 45 | std::shared_ptr<events::EventSink> const&) |
404 | 46 | { | 46 | { |
405 | 47 | return server; | 47 | return server; |
406 | 48 | } | 48 | } |
407 | 49 | 49 | ||
408 | === modified file 'include/test/mir_test_doubles/stub_session.h' | |||
409 | --- include/test/mir_test_doubles/stub_session.h 2013-04-19 08:03:57 +0000 | |||
410 | +++ include/test/mir_test_doubles/stub_session.h 2013-04-24 09:03:32 +0000 | |||
411 | @@ -58,7 +58,7 @@ | |||
412 | 58 | { | 58 | { |
413 | 59 | return 0; | 59 | return 0; |
414 | 60 | } | 60 | } |
416 | 61 | void set_event_sink(std::shared_ptr<EventSink> const&) | 61 | void set_event_sink(std::shared_ptr<events::EventSink> const&) |
417 | 62 | { | 62 | { |
418 | 63 | } | 63 | } |
419 | 64 | }; | 64 | }; |
420 | 65 | 65 | ||
421 | === modified file 'include/test/mir_test_doubles/stub_shell.h' | |||
422 | --- include/test/mir_test_doubles/stub_shell.h 2013-04-19 03:20:05 +0000 | |||
423 | +++ include/test/mir_test_doubles/stub_shell.h 2013-04-24 09:03:32 +0000 | |||
424 | @@ -31,7 +31,7 @@ | |||
425 | 31 | 31 | ||
426 | 32 | class StubShell : public frontend::Shell | 32 | class StubShell : public frontend::Shell |
427 | 33 | { | 33 | { |
429 | 34 | std::shared_ptr<frontend::Session> open_session(std::string const& /* name */) | 34 | std::shared_ptr<frontend::Session> open_session(std::string const& /* name */, std::shared_ptr<events::EventSink> const& /* sink */) |
430 | 35 | { | 35 | { |
431 | 36 | return std::make_shared<StubSession>(); | 36 | return std::make_shared<StubSession>(); |
432 | 37 | } | 37 | } |
433 | 38 | 38 | ||
434 | === modified file 'src/client/make_rpc_channel.h' | |||
435 | --- src/client/make_rpc_channel.h 2013-04-12 03:36:28 +0000 | |||
436 | +++ src/client/make_rpc_channel.h 2013-04-24 09:03:32 +0000 | |||
437 | @@ -19,7 +19,7 @@ | |||
438 | 19 | #define MIR_CLIENT_MAKE_RPC_CHANNEL_H_ | 19 | #define MIR_CLIENT_MAKE_RPC_CHANNEL_H_ |
439 | 20 | 20 | ||
440 | 21 | #include <memory> | 21 | #include <memory> |
442 | 22 | #include "mir_protobuf.pb.h" | 22 | #include "mir_basic_rpc_channel.h" |
443 | 23 | 23 | ||
444 | 24 | namespace mir | 24 | namespace mir |
445 | 25 | { | 25 | { |
446 | @@ -27,7 +27,7 @@ | |||
447 | 27 | { | 27 | { |
448 | 28 | class Logger; | 28 | class Logger; |
449 | 29 | 29 | ||
451 | 30 | std::shared_ptr<google::protobuf::RpcChannel> | 30 | std::shared_ptr<MirBasicRpcChannel> |
452 | 31 | make_rpc_channel(std::string const& name, std::shared_ptr<Logger> const& log); | 31 | make_rpc_channel(std::string const& name, std::shared_ptr<Logger> const& log); |
453 | 32 | } | 32 | } |
454 | 33 | } | 33 | } |
455 | 34 | 34 | ||
456 | === modified file 'src/client/make_socket_rpc_channel.cpp' | |||
457 | --- src/client/make_socket_rpc_channel.cpp 2013-04-12 03:36:28 +0000 | |||
458 | +++ src/client/make_socket_rpc_channel.cpp 2013-04-24 09:03:32 +0000 | |||
459 | @@ -21,7 +21,7 @@ | |||
460 | 21 | 21 | ||
461 | 22 | namespace mcl = mir::client; | 22 | namespace mcl = mir::client; |
462 | 23 | 23 | ||
464 | 24 | std::shared_ptr<google::protobuf::RpcChannel> | 24 | std::shared_ptr<mcl::MirBasicRpcChannel> |
465 | 25 | mcl::make_rpc_channel(std::string const& name, std::shared_ptr<Logger> const& log) | 25 | mcl::make_rpc_channel(std::string const& name, std::shared_ptr<Logger> const& log) |
466 | 26 | { | 26 | { |
467 | 27 | return std::make_shared<MirSocketRpcChannel>(name, log); | 27 | return std::make_shared<MirSocketRpcChannel>(name, log); |
468 | 28 | 28 | ||
469 | === modified file 'src/client/mir_basic_rpc_channel.cpp' | |||
470 | --- src/client/mir_basic_rpc_channel.cpp 2013-04-18 04:15:05 +0000 | |||
471 | +++ src/client/mir_basic_rpc_channel.cpp 2013-04-24 09:03:32 +0000 | |||
472 | @@ -100,7 +100,5 @@ | |||
473 | 100 | 100 | ||
474 | 101 | int mcl::MirBasicRpcChannel::next_id() | 101 | int mcl::MirBasicRpcChannel::next_id() |
475 | 102 | { | 102 | { |
479 | 103 | int id = next_message_id.load(); | 103 | return next_message_id.fetch_add(1); |
477 | 104 | while (!next_message_id.compare_exchange_weak(id, id + 1)) std::this_thread::yield(); | ||
478 | 105 | return id; | ||
480 | 106 | } | 104 | } |
481 | 107 | 105 | ||
482 | === modified file 'src/client/mir_basic_rpc_channel.h' | |||
483 | --- src/client/mir_basic_rpc_channel.h 2013-04-12 03:36:28 +0000 | |||
484 | +++ src/client/mir_basic_rpc_channel.h 2013-04-24 09:03:32 +0000 | |||
485 | @@ -33,6 +33,10 @@ | |||
486 | 33 | 33 | ||
487 | 34 | namespace mir | 34 | namespace mir |
488 | 35 | { | 35 | { |
489 | 36 | namespace events | ||
490 | 37 | { | ||
491 | 38 | class EventSink; | ||
492 | 39 | } | ||
493 | 36 | namespace protobuf | 40 | namespace protobuf |
494 | 37 | { | 41 | { |
495 | 38 | namespace wire | 42 | namespace wire |
496 | @@ -92,6 +96,8 @@ | |||
497 | 92 | MirBasicRpcChannel(); | 96 | MirBasicRpcChannel(); |
498 | 93 | ~MirBasicRpcChannel(); | 97 | ~MirBasicRpcChannel(); |
499 | 94 | 98 | ||
500 | 99 | virtual void set_event_handler(events::EventSink *sink) = 0; | ||
501 | 100 | |||
502 | 95 | protected: | 101 | protected: |
503 | 96 | mir::protobuf::wire::Invocation invocation_for(const google::protobuf::MethodDescriptor* method, | 102 | mir::protobuf::wire::Invocation invocation_for(const google::protobuf::MethodDescriptor* method, |
504 | 97 | const google::protobuf::Message* request); | 103 | const google::protobuf::Message* request); |
505 | 98 | 104 | ||
506 | === modified file 'src/client/mir_client_library.cpp' | |||
507 | --- src/client/mir_client_library.cpp 2013-04-24 03:02:59 +0000 | |||
508 | +++ src/client/mir_client_library.cpp 2013-04-24 09:03:32 +0000 | |||
509 | @@ -26,7 +26,7 @@ | |||
510 | 26 | #include "native_client_platform_factory.h" | 26 | #include "native_client_platform_factory.h" |
511 | 27 | #include "egl_native_display_container.h" | 27 | #include "egl_native_display_container.h" |
512 | 28 | #include "mir_logger.h" | 28 | #include "mir_logger.h" |
514 | 29 | #include "mir_socket_rpc_channel.h" | 29 | #include "make_rpc_channel.h" |
515 | 30 | 30 | ||
516 | 31 | #include <set> | 31 | #include <set> |
517 | 32 | #include <unordered_set> | 32 | #include <unordered_set> |
518 | @@ -60,12 +60,10 @@ | |||
519 | 60 | auto log = std::make_shared<mcl::ConsoleLogger>(); | 60 | auto log = std::make_shared<mcl::ConsoleLogger>(); |
520 | 61 | auto client_platform_factory = std::make_shared<mcl::NativeClientPlatformFactory>(); | 61 | auto client_platform_factory = std::make_shared<mcl::NativeClientPlatformFactory>(); |
521 | 62 | 62 | ||
528 | 63 | auto rpc = std::make_shared<mcl::MirSocketRpcChannel>(sock, log); | 63 | MirConnection* connection = new MirConnection( |
529 | 64 | 64 | mcl::make_rpc_channel(sock, log), | |
530 | 65 | MirConnection* connection = new MirConnection(rpc, log, | 65 | log, |
531 | 66 | client_platform_factory); | 66 | client_platform_factory); |
526 | 67 | |||
527 | 68 | rpc->set_event_handler(connection); | ||
532 | 69 | 67 | ||
533 | 70 | return connection->connect(name, callback, context); | 68 | return connection->connect(name, callback, context); |
534 | 71 | } | 69 | } |
535 | @@ -258,12 +256,10 @@ | |||
536 | 258 | auto log = std::make_shared<mcl::ConsoleLogger>(); | 256 | auto log = std::make_shared<mcl::ConsoleLogger>(); |
537 | 259 | auto client_platform_factory = std::make_shared<mcl::NativeClientPlatformFactory>(); | 257 | auto client_platform_factory = std::make_shared<mcl::NativeClientPlatformFactory>(); |
538 | 260 | 258 | ||
545 | 261 | auto rpc = std::make_shared<mcl::MirSocketRpcChannel>(server, log); | 259 | MirConnection* connection = new MirConnection( |
546 | 262 | 260 | mcl::make_rpc_channel(server, log), | |
547 | 263 | MirConnection* connection = new MirConnection(rpc, log, | 261 | log, |
548 | 264 | client_platform_factory); | 262 | client_platform_factory); |
543 | 265 | |||
544 | 266 | rpc->set_event_handler(connection); | ||
549 | 267 | 263 | ||
550 | 268 | return connection->connect(lightdm_id, app_name, callback, client_context); | 264 | return connection->connect(lightdm_id, app_name, callback, client_context); |
551 | 269 | } | 265 | } |
552 | 270 | 266 | ||
553 | === modified file 'src/client/mir_connection.cpp' | |||
554 | --- src/client/mir_connection.cpp 2013-04-16 09:42:50 +0000 | |||
555 | +++ src/client/mir_connection.cpp 2013-04-24 09:03:32 +0000 | |||
556 | @@ -43,7 +43,7 @@ | |||
557 | 43 | } | 43 | } |
558 | 44 | 44 | ||
559 | 45 | MirConnection::MirConnection( | 45 | MirConnection::MirConnection( |
561 | 46 | std::shared_ptr<google::protobuf::RpcChannel> const& channel, | 46 | std::shared_ptr<mir::client::MirBasicRpcChannel> const& channel, |
562 | 47 | std::shared_ptr<mcl::Logger> const & log, | 47 | std::shared_ptr<mcl::Logger> const & log, |
563 | 48 | std::shared_ptr<mcl::ClientPlatformFactory> const& client_platform_factory) : | 48 | std::shared_ptr<mcl::ClientPlatformFactory> const& client_platform_factory) : |
564 | 49 | channel(channel), | 49 | channel(channel), |
565 | @@ -52,6 +52,7 @@ | |||
566 | 52 | client_platform_factory(client_platform_factory), | 52 | client_platform_factory(client_platform_factory), |
567 | 53 | input_platform(mcli::InputPlatform::create()) | 53 | input_platform(mcli::InputPlatform::create()) |
568 | 54 | { | 54 | { |
569 | 55 | channel->set_event_handler(this); | ||
570 | 55 | { | 56 | { |
571 | 56 | std::lock_guard<std::mutex> lock(connection_guard); | 57 | std::lock_guard<std::mutex> lock(connection_guard); |
572 | 57 | valid_connections.insert(this); | 58 | valid_connections.insert(this); |
573 | 58 | 59 | ||
574 | === modified file 'src/client/mir_connection.h' | |||
575 | --- src/client/mir_connection.h 2013-04-16 09:42:50 +0000 | |||
576 | +++ src/client/mir_connection.h 2013-04-24 09:03:32 +0000 | |||
577 | @@ -34,7 +34,7 @@ | |||
578 | 34 | #include "client_context.h" | 34 | #include "client_context.h" |
579 | 35 | 35 | ||
580 | 36 | #include "mir_wait_handle.h" | 36 | #include "mir_wait_handle.h" |
582 | 37 | #include "mir/event_sink.h" | 37 | #include "mir/events/event_sink.h" |
583 | 38 | 38 | ||
584 | 39 | namespace mir | 39 | namespace mir |
585 | 40 | { | 40 | { |
586 | @@ -44,6 +44,8 @@ | |||
587 | 44 | class Logger; | 44 | class Logger; |
588 | 45 | class ClientBufferDepository; | 45 | class ClientBufferDepository; |
589 | 46 | class ClientPlatformFactory; | 46 | class ClientPlatformFactory; |
590 | 47 | class MirBasicRpcChannel; | ||
591 | 48 | |||
592 | 47 | namespace input | 49 | namespace input |
593 | 48 | { | 50 | { |
594 | 49 | class InputPlatform; | 51 | class InputPlatform; |
595 | @@ -51,13 +53,12 @@ | |||
596 | 51 | } | 53 | } |
597 | 52 | } | 54 | } |
598 | 53 | 55 | ||
601 | 54 | struct MirConnection : public mir::client::ClientContext, | 56 | struct MirConnection : mir::client::ClientContext, private mir::events::EventSink |
600 | 55 | public mir::EventSink | ||
602 | 56 | { | 57 | { |
603 | 57 | public: | 58 | public: |
604 | 58 | MirConnection(); | 59 | MirConnection(); |
605 | 59 | 60 | ||
607 | 60 | MirConnection(std::shared_ptr<google::protobuf::RpcChannel> const& channel, | 61 | MirConnection(std::shared_ptr<mir::client::MirBasicRpcChannel> const& channel, |
608 | 61 | std::shared_ptr<mir::client::Logger> const & log, | 62 | std::shared_ptr<mir::client::Logger> const & log, |
609 | 62 | std::shared_ptr<mir::client::ClientPlatformFactory> const& client_platform_factory); | 63 | std::shared_ptr<mir::client::ClientPlatformFactory> const& client_platform_factory); |
610 | 63 | ~MirConnection() noexcept; | 64 | ~MirConnection() noexcept; |
611 | 64 | 65 | ||
612 | === modified file 'src/client/mir_socket_rpc_channel.cpp' | |||
613 | --- src/client/mir_socket_rpc_channel.cpp 2013-04-18 04:15:05 +0000 | |||
614 | +++ src/client/mir_socket_rpc_channel.cpp 2013-04-24 09:03:32 +0000 | |||
615 | @@ -253,11 +253,12 @@ | |||
616 | 253 | 253 | ||
617 | 254 | log->debug() << __PRETTY_FUNCTION__ << " result.id():" << result.id() << std::endl; | 254 | log->debug() << __PRETTY_FUNCTION__ << " result.id():" << result.id() << std::endl; |
618 | 255 | 255 | ||
620 | 256 | if (!result.has_id()) // It's an event sequence | 256 | for (int i = 0; i != result.events_size(); ++i) |
621 | 257 | { | 257 | { |
623 | 258 | process_event_sequence(result); | 258 | process_event_sequence(result.events(i)); |
624 | 259 | } | 259 | } |
626 | 260 | else | 260 | |
627 | 261 | if (result.has_id()) | ||
628 | 261 | { | 262 | { |
629 | 262 | pending_calls.complete_response(result); | 263 | pending_calls.complete_response(result); |
630 | 263 | } | 264 | } |
631 | @@ -269,44 +270,42 @@ | |||
632 | 269 | } | 270 | } |
633 | 270 | } | 271 | } |
634 | 271 | 272 | ||
637 | 272 | void mcl::MirSocketRpcChannel::process_event_sequence( | 273 | void mcl::MirSocketRpcChannel::process_event_sequence(std::string const& event) |
636 | 273 | mir::protobuf::wire::Result const& result) | ||
638 | 274 | { | 274 | { |
639 | 275 | if (!event_handler) | 275 | if (!event_handler) |
640 | 276 | return; | 276 | return; |
641 | 277 | 277 | ||
642 | 278 | mir::protobuf::EventSequence seq; | 278 | mir::protobuf::EventSequence seq; |
644 | 279 | if (seq.ParseFromString(result.response())) | 279 | |
645 | 280 | seq.ParseFromString(event); | ||
646 | 281 | int const nevents = seq.event_size(); | ||
647 | 282 | for (int i = 0; i != nevents; ++i) | ||
648 | 280 | { | 283 | { |
651 | 281 | int const nevents = seq.event_size(); | 284 | mir::protobuf::Event const& event = seq.event(i); |
652 | 282 | for (int i = 0; i < nevents; i++) | 285 | if (event.has_raw()) |
653 | 283 | { | 286 | { |
677 | 284 | mir::protobuf::Event const& event = seq.event(i); | 287 | std::string const& raw_event = event.raw(); |
678 | 285 | if (event.has_raw()) | 288 | |
679 | 286 | { | 289 | // In future, events might be compressed where possible. |
680 | 287 | std::string const& raw_event = event.raw(); | 290 | // But that's a job for later... |
681 | 288 | 291 | if (raw_event.size() == sizeof(MirEvent)) | |
682 | 289 | // In future, events might be compressed where possible. | 292 | { |
683 | 290 | // But that's a job for later... | 293 | MirEvent e; |
684 | 291 | if (raw_event.size() == sizeof(MirEvent)) | 294 | |
685 | 292 | { | 295 | // Make a copy to ensure integer fields get correct memory |
686 | 293 | MirEvent e; | 296 | // alignment, which is critical on many non-x86 |
687 | 294 | 297 | // architectures. | |
688 | 295 | // Make a copy to ensure integer fields get correct memory | 298 | memcpy(&e, raw_event.data(), sizeof e); |
689 | 296 | // alignment, which is critical on many non-x86 | 299 | event_handler->handle_event(e); |
690 | 297 | // architectures. | 300 | } |
691 | 298 | memcpy(&e, raw_event.data(), sizeof e); | 301 | else |
692 | 299 | event_handler->handle_event(e); | 302 | { |
693 | 300 | } | 303 | log->error() << __PRETTY_FUNCTION__ |
694 | 301 | else | 304 | << " Received MirEvent of an unexpected size." |
695 | 302 | { | 305 | << std::endl; |
673 | 303 | log->error() << __PRETTY_FUNCTION__ | ||
674 | 304 | << " Received MirEvent of an unexpected size." | ||
675 | 305 | << std::endl; | ||
676 | 306 | } | ||
696 | 307 | } | 306 | } |
697 | 308 | } | 307 | } |
699 | 309 | } // else protobuf will log an error | 308 | } |
700 | 310 | } | 309 | } |
701 | 311 | 310 | ||
702 | 312 | size_t mcl::MirSocketRpcChannel::read_message_header() | 311 | size_t mcl::MirSocketRpcChannel::read_message_header() |
703 | @@ -331,7 +330,7 @@ | |||
704 | 331 | return result; | 330 | return result; |
705 | 332 | } | 331 | } |
706 | 333 | 332 | ||
708 | 334 | void mcl::MirSocketRpcChannel::set_event_handler(mir::EventSink *sink) | 333 | void mcl::MirSocketRpcChannel::set_event_handler(events::EventSink *sink) |
709 | 335 | { | 334 | { |
710 | 336 | /* | 335 | /* |
711 | 337 | * Yes, these have to be regular pointers. Because ownership of the object | 336 | * Yes, these have to be regular pointers. Because ownership of the object |
712 | 338 | 337 | ||
713 | === modified file 'src/client/mir_socket_rpc_channel.h' | |||
714 | --- src/client/mir_socket_rpc_channel.h 2013-04-18 03:54:19 +0000 | |||
715 | +++ src/client/mir_socket_rpc_channel.h 2013-04-24 09:03:32 +0000 | |||
716 | @@ -22,7 +22,7 @@ | |||
717 | 22 | 22 | ||
718 | 23 | #include "mir_basic_rpc_channel.h" | 23 | #include "mir_basic_rpc_channel.h" |
719 | 24 | #include "mir_logger.h" | 24 | #include "mir_logger.h" |
721 | 25 | #include "mir/event_sink.h" | 25 | #include "mir/events/event_sink.h" |
722 | 26 | 26 | ||
723 | 27 | #include <boost/asio.hpp> | 27 | #include <boost/asio.hpp> |
724 | 28 | 28 | ||
725 | @@ -52,7 +52,7 @@ | |||
726 | 52 | MirSocketRpcChannel(const std::string& endpoint, const std::shared_ptr<Logger>& log); | 52 | MirSocketRpcChannel(const std::string& endpoint, const std::shared_ptr<Logger>& log); |
727 | 53 | ~MirSocketRpcChannel(); | 53 | ~MirSocketRpcChannel(); |
728 | 54 | 54 | ||
730 | 55 | void set_event_handler(EventSink *sink); | 55 | void set_event_handler(events::EventSink *sink); |
731 | 56 | 56 | ||
732 | 57 | private: | 57 | private: |
733 | 58 | virtual void CallMethod(const google::protobuf::MethodDescriptor* method, google::protobuf::RpcController*, | 58 | virtual void CallMethod(const google::protobuf::MethodDescriptor* method, google::protobuf::RpcController*, |
734 | @@ -75,13 +75,13 @@ | |||
735 | 75 | void on_header_read(const boost::system::error_code& error); | 75 | void on_header_read(const boost::system::error_code& error); |
736 | 76 | 76 | ||
737 | 77 | void read_message(); | 77 | void read_message(); |
739 | 78 | void process_event_sequence(mir::protobuf::wire::Result const& result); | 78 | void process_event_sequence(std::string const& event); |
740 | 79 | 79 | ||
741 | 80 | size_t read_message_header(); | 80 | size_t read_message_header(); |
742 | 81 | 81 | ||
743 | 82 | mir::protobuf::wire::Result read_message_body(const size_t body_size); | 82 | mir::protobuf::wire::Result read_message_body(const size_t body_size); |
744 | 83 | 83 | ||
746 | 84 | EventSink *event_handler; | 84 | events::EventSink *event_handler; |
747 | 85 | }; | 85 | }; |
748 | 86 | 86 | ||
749 | 87 | } | 87 | } |
750 | 88 | 88 | ||
751 | === modified file 'src/server/CMakeLists.txt' | |||
752 | --- src/server/CMakeLists.txt 2013-04-24 03:31:07 +0000 | |||
753 | +++ src/server/CMakeLists.txt 2013-04-24 09:03:32 +0000 | |||
754 | @@ -26,7 +26,6 @@ | |||
755 | 26 | display_server.cpp | 26 | display_server.cpp |
756 | 27 | default_server_configuration.cpp | 27 | default_server_configuration.cpp |
757 | 28 | asio_main_loop.cpp | 28 | asio_main_loop.cpp |
758 | 29 | event_queue.cpp | ||
759 | 30 | ) | 29 | ) |
760 | 31 | 30 | ||
761 | 32 | set(MIRSERVER_LINKAGE SHARED) | 31 | set(MIRSERVER_LINKAGE SHARED) |
762 | 33 | 32 | ||
763 | === modified file 'src/server/default_server_configuration.cpp' | |||
764 | --- src/server/default_server_configuration.cpp 2013-04-24 05:19:54 +0000 | |||
765 | +++ src/server/default_server_configuration.cpp 2013-04-24 09:03:32 +0000 | |||
766 | @@ -63,6 +63,7 @@ | |||
767 | 63 | #include "mir/default_configuration.h" | 63 | #include "mir/default_configuration.h" |
768 | 64 | 64 | ||
769 | 65 | namespace mc = mir::compositor; | 65 | namespace mc = mir::compositor; |
770 | 66 | namespace me = mir::events; | ||
771 | 66 | namespace geom = mir::geometry; | 67 | namespace geom = mir::geometry; |
772 | 67 | namespace mf = mir::frontend; | 68 | namespace mf = mir::frontend; |
773 | 68 | namespace mg = mir::graphics; | 69 | namespace mg = mir::graphics; |
774 | @@ -109,7 +110,7 @@ | |||
775 | 109 | std::shared_ptr<mc::GraphicBufferAllocator> const buffer_allocator; | 110 | std::shared_ptr<mc::GraphicBufferAllocator> const buffer_allocator; |
776 | 110 | 111 | ||
777 | 111 | virtual std::shared_ptr<mir::protobuf::DisplayServer> make_ipc_server( | 112 | virtual std::shared_ptr<mir::protobuf::DisplayServer> make_ipc_server( |
779 | 112 | std::shared_ptr<mir::EventSink> const& sink) | 113 | std::shared_ptr<me::EventSink> const& sink) |
780 | 113 | { | 114 | { |
781 | 114 | return std::make_shared<mf::SessionMediator>( | 115 | return std::make_shared<mf::SessionMediator>( |
782 | 115 | shell, | 116 | shell, |
783 | 116 | 117 | ||
784 | === modified file 'src/server/frontend/CMakeLists.txt' | |||
785 | --- src/server/frontend/CMakeLists.txt 2013-04-19 04:00:32 +0000 | |||
786 | +++ src/server/frontend/CMakeLists.txt 2013-04-24 09:03:32 +0000 | |||
787 | @@ -8,6 +8,7 @@ | |||
788 | 8 | protobuf_message_processor.cpp | 8 | protobuf_message_processor.cpp |
789 | 9 | null_message_processor.cpp | 9 | null_message_processor.cpp |
790 | 10 | surface_creation_parameters.cpp | 10 | surface_creation_parameters.cpp |
791 | 11 | event_pipe.cpp | ||
792 | 11 | 12 | ||
793 | 12 | resource_cache.cpp | 13 | resource_cache.cpp |
794 | 13 | ${PROTO_HDRS} | 14 | ${PROTO_HDRS} |
795 | 14 | 15 | ||
796 | === renamed file 'src/server/event_queue.cpp' => 'src/server/frontend/event_pipe.cpp' | |||
797 | --- src/server/event_queue.cpp 2013-04-24 03:44:27 +0000 | |||
798 | +++ src/server/frontend/event_pipe.cpp 2013-04-24 09:03:32 +0000 | |||
799 | @@ -16,17 +16,16 @@ | |||
800 | 16 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> | 16 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
801 | 17 | */ | 17 | */ |
802 | 18 | 18 | ||
809 | 19 | #include "mir/event_queue.h" | 19 | #include "event_pipe.h" |
810 | 20 | #include "mir/event_sink.h" | 20 | |
811 | 21 | 21 | namespace mf = mir::frontend; | |
812 | 22 | using namespace mir; | 22 | |
813 | 23 | 23 | void mf::EventPipe::set_target(std::weak_ptr<EventSink> const& s) | |
808 | 24 | void EventQueue::set_target(std::weak_ptr<EventSink> const& s) | ||
814 | 25 | { | 24 | { |
815 | 26 | target = s; | 25 | target = s; |
816 | 27 | } | 26 | } |
817 | 28 | 27 | ||
819 | 29 | void EventQueue::handle_event(MirEvent const& e) | 28 | void mf::EventPipe::handle_event(MirEvent const& e) |
820 | 30 | { | 29 | { |
821 | 31 | // In future, we might put e on a queue and wait for some background | 30 | // In future, we might put e on a queue and wait for some background |
822 | 32 | // thread to push it through to target. But that's not required right now. | 31 | // thread to push it through to target. But that's not required right now. |
823 | 33 | 32 | ||
824 | === renamed file 'include/server/mir/event_queue.h' => 'src/server/frontend/event_pipe.h' | |||
825 | --- include/server/mir/event_queue.h 2013-04-16 05:46:28 +0000 | |||
826 | +++ src/server/frontend/event_pipe.h 2013-04-24 09:03:32 +0000 | |||
827 | @@ -16,25 +16,27 @@ | |||
828 | 16 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> | 16 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
829 | 17 | */ | 17 | */ |
830 | 18 | 18 | ||
833 | 19 | #ifndef MIR_EVENT_QUEUE_H_ | 19 | #ifndef MIR_FRONTEND_EVENT_PIPE_H_ |
834 | 20 | #define MIR_EVENT_QUEUE_H_ | 20 | #define MIR_FRONTEND_EVENT_PIPE_H_ |
835 | 21 | 21 | ||
836 | 22 | #include "mir_toolkit/event.h" | 22 | #include "mir_toolkit/event.h" |
838 | 23 | #include "mir/event_sink.h" | 23 | #include "mir/events/event_sink.h" |
839 | 24 | #include <memory> | 24 | #include <memory> |
840 | 25 | 25 | ||
841 | 26 | namespace mir | 26 | namespace mir |
842 | 27 | { | 27 | { |
844 | 28 | class EventQueue : public EventSink | 28 | namespace frontend |
845 | 29 | { | ||
846 | 30 | class EventPipe : public events::EventSink | ||
847 | 29 | { | 31 | { |
848 | 30 | public: | 32 | public: |
850 | 31 | void set_target(std::weak_ptr<EventSink> const& s); | 33 | void set_target(std::weak_ptr<events::EventSink> const& s); |
851 | 32 | void handle_event(MirEvent const& e) override; | 34 | void handle_event(MirEvent const& e) override; |
852 | 33 | 35 | ||
853 | 34 | private: | 36 | private: |
855 | 35 | std::weak_ptr<EventSink> target; | 37 | std::weak_ptr<events::EventSink> target; |
856 | 36 | }; | 38 | }; |
861 | 37 | 39 | } | |
862 | 38 | } // namespace mir | 40 | } |
863 | 39 | 41 | ||
864 | 40 | #endif | 42 | #endif // MIR_FRONTEND_EVENT_PIPE_H_ |
865 | 41 | 43 | ||
866 | === modified file 'src/server/frontend/protobuf_message_processor.cpp' | |||
867 | --- src/server/frontend/protobuf_message_processor.cpp 2013-04-24 03:02:59 +0000 | |||
868 | +++ src/server/frontend/protobuf_message_processor.cpp 2013-04-24 09:03:32 +0000 | |||
869 | @@ -138,6 +138,8 @@ | |||
870 | 138 | 138 | ||
871 | 139 | void mfd::ProtobufMessageProcessor::send_event(MirEvent const& e) | 139 | void mfd::ProtobufMessageProcessor::send_event(MirEvent const& e) |
872 | 140 | { | 140 | { |
873 | 141 | // In future we might send multiple events, or insert them into messages | ||
874 | 142 | // containing other responses, but for now we send them individually. | ||
875 | 141 | mir::protobuf::EventSequence seq; | 143 | mir::protobuf::EventSequence seq; |
876 | 142 | mir::protobuf::Event *ev = seq.add_event(); | 144 | mir::protobuf::Event *ev = seq.add_event(); |
877 | 143 | ev->set_raw(&e, sizeof(MirEvent)); | 145 | ev->set_raw(&e, sizeof(MirEvent)); |
878 | @@ -146,7 +148,7 @@ | |||
879 | 146 | seq.SerializeToString(&buffer); | 148 | seq.SerializeToString(&buffer); |
880 | 147 | 149 | ||
881 | 148 | mir::protobuf::wire::Result result; | 150 | mir::protobuf::wire::Result result; |
883 | 149 | result.set_response(buffer); | 151 | result.add_events(buffer); |
884 | 150 | 152 | ||
885 | 151 | result.SerializeToString(&buffer); | 153 | result.SerializeToString(&buffer); |
886 | 152 | 154 | ||
887 | 153 | 155 | ||
888 | === modified file 'src/server/frontend/protobuf_message_processor.h' | |||
889 | --- src/server/frontend/protobuf_message_processor.h 2013-04-24 03:02:59 +0000 | |||
890 | +++ src/server/frontend/protobuf_message_processor.h 2013-04-24 09:03:32 +0000 | |||
891 | @@ -24,7 +24,7 @@ | |||
892 | 24 | 24 | ||
893 | 25 | #include "mir_protobuf.pb.h" | 25 | #include "mir_protobuf.pb.h" |
894 | 26 | #include "mir_protobuf_wire.pb.h" | 26 | #include "mir_protobuf_wire.pb.h" |
896 | 27 | #include "mir/event_sink.h" | 27 | #include "mir/events/event_sink.h" |
897 | 28 | 28 | ||
898 | 29 | #include <vector> | 29 | #include <vector> |
899 | 30 | #include <memory> | 30 | #include <memory> |
900 | @@ -44,7 +44,7 @@ | |||
901 | 44 | { | 44 | { |
902 | 45 | 45 | ||
903 | 46 | struct ProtobufMessageProcessor : MessageProcessor, | 46 | struct ProtobufMessageProcessor : MessageProcessor, |
905 | 47 | public EventSink | 47 | public events::EventSink |
906 | 48 | { | 48 | { |
907 | 49 | ProtobufMessageProcessor( | 49 | ProtobufMessageProcessor( |
908 | 50 | MessageSender* sender, | 50 | MessageSender* sender, |
909 | 51 | 51 | ||
910 | === modified file 'src/server/frontend/protobuf_socket_communicator.cpp' | |||
911 | --- src/server/frontend/protobuf_socket_communicator.cpp 2013-04-22 09:54:07 +0000 | |||
912 | +++ src/server/frontend/protobuf_socket_communicator.cpp 2013-04-24 09:03:32 +0000 | |||
913 | @@ -22,8 +22,7 @@ | |||
914 | 22 | 22 | ||
915 | 23 | #include "mir/frontend/protobuf_ipc_factory.h" | 23 | #include "mir/frontend/protobuf_ipc_factory.h" |
916 | 24 | #include "mir/protobuf/google_protobuf_guard.h" | 24 | #include "mir/protobuf/google_protobuf_guard.h" |
919 | 25 | #include "mir/event_sink.h" | 25 | #include "event_pipe.h" |
918 | 26 | #include "mir/event_queue.h" | ||
920 | 27 | 26 | ||
921 | 28 | #include <boost/signals2.hpp> | 27 | #include <boost/signals2.hpp> |
922 | 29 | 28 | ||
923 | @@ -51,7 +50,7 @@ | |||
924 | 51 | 50 | ||
925 | 52 | void mf::ProtobufSocketCommunicator::start_accept() | 51 | void mf::ProtobufSocketCommunicator::start_accept() |
926 | 53 | { | 52 | { |
928 | 54 | std::shared_ptr<EventQueue> event_queue = std::make_shared<EventQueue>(); | 53 | auto const& event_pipe = std::make_shared<EventPipe>(); |
929 | 55 | 54 | ||
930 | 56 | auto const& socket_session = std::make_shared<mfd::SocketSession>( | 55 | auto const& socket_session = std::make_shared<mfd::SocketSession>( |
931 | 57 | io_service, | 56 | io_service, |
932 | @@ -60,11 +59,11 @@ | |||
933 | 60 | 59 | ||
934 | 61 | auto session = std::make_shared<detail::ProtobufMessageProcessor>( | 60 | auto session = std::make_shared<detail::ProtobufMessageProcessor>( |
935 | 62 | socket_session.get(), | 61 | socket_session.get(), |
937 | 63 | ipc_factory->make_ipc_server(event_queue), | 62 | ipc_factory->make_ipc_server(event_pipe), |
938 | 64 | ipc_factory->resource_cache(), | 63 | ipc_factory->resource_cache(), |
939 | 65 | ipc_factory->report()); | 64 | ipc_factory->report()); |
940 | 66 | 65 | ||
942 | 67 | event_queue->set_target(session); | 66 | event_pipe->set_target(session); |
943 | 68 | socket_session->set_processor(session); | 67 | socket_session->set_processor(session); |
944 | 69 | 68 | ||
945 | 70 | acceptor.async_accept( | 69 | acceptor.async_accept( |
946 | 71 | 70 | ||
947 | === modified file 'src/server/frontend/session_mediator.cpp' | |||
948 | --- src/server/frontend/session_mediator.cpp 2013-04-19 07:45:44 +0000 | |||
949 | +++ src/server/frontend/session_mediator.cpp 2013-04-24 09:03:32 +0000 | |||
950 | @@ -44,7 +44,7 @@ | |||
951 | 44 | std::shared_ptr<graphics::ViewableArea> const& viewable_area, | 44 | std::shared_ptr<graphics::ViewableArea> const& viewable_area, |
952 | 45 | std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator, | 45 | std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator, |
953 | 46 | std::shared_ptr<SessionMediatorReport> const& report, | 46 | std::shared_ptr<SessionMediatorReport> const& report, |
955 | 47 | std::shared_ptr<EventSink> const& event_sink, | 47 | std::shared_ptr<events::EventSink> const& event_sink, |
956 | 48 | std::shared_ptr<ResourceCache> const& resource_cache) : | 48 | std::shared_ptr<ResourceCache> const& resource_cache) : |
957 | 49 | shell(shell), | 49 | shell(shell), |
958 | 50 | graphics_platform(graphics_platform), | 50 | graphics_platform(graphics_platform), |
959 | @@ -65,8 +65,7 @@ | |||
960 | 65 | { | 65 | { |
961 | 66 | report->session_connect_called(request->application_name()); | 66 | report->session_connect_called(request->application_name()); |
962 | 67 | 67 | ||
965 | 68 | session = shell->open_session(request->application_name()); | 68 | session = shell->open_session(request->application_name(), event_sink); |
964 | 69 | session->set_event_sink(event_sink); | ||
966 | 70 | 69 | ||
967 | 71 | auto ipc_package = graphics_platform->get_ipc_package(); | 70 | auto ipc_package = graphics_platform->get_ipc_package(); |
968 | 72 | auto platform = response->mutable_platform(); | 71 | auto platform = response->mutable_platform(); |
969 | 73 | 72 | ||
970 | === modified file 'src/server/shell/application_session.cpp' | |||
971 | --- src/server/shell/application_session.cpp 2013-04-23 01:40:52 +0000 | |||
972 | +++ src/server/shell/application_session.cpp 2013-04-24 09:03:32 +0000 | |||
973 | @@ -28,16 +28,19 @@ | |||
974 | 28 | #include <cassert> | 28 | #include <cassert> |
975 | 29 | #include <algorithm> | 29 | #include <algorithm> |
976 | 30 | 30 | ||
977 | 31 | namespace me = mir::events; | ||
978 | 31 | namespace mf = mir::frontend; | 32 | namespace mf = mir::frontend; |
979 | 32 | namespace msh = mir::shell; | 33 | namespace msh = mir::shell; |
980 | 33 | 34 | ||
981 | 34 | msh::ApplicationSession::ApplicationSession( | 35 | msh::ApplicationSession::ApplicationSession( |
983 | 35 | std::shared_ptr<msh::SurfaceFactory> const& surface_factory, | 36 | std::shared_ptr<SurfaceFactory> const& surface_factory, |
984 | 36 | std::shared_ptr<msh::InputTargetListener> const& input_target_listener, | 37 | std::shared_ptr<msh::InputTargetListener> const& input_target_listener, |
986 | 37 | std::string const& session_name) : | 38 | std::string const& session_name, |
987 | 39 | std::shared_ptr<me::EventSink> const& sink) : | ||
988 | 38 | surface_factory(surface_factory), | 40 | surface_factory(surface_factory), |
989 | 39 | input_target_listener(input_target_listener), | 41 | input_target_listener(input_target_listener), |
990 | 40 | session_name(session_name), | 42 | session_name(session_name), |
991 | 43 | event_sink(sink), | ||
992 | 41 | next_surface_id(0) | 44 | next_surface_id(0) |
993 | 42 | { | 45 | { |
994 | 43 | assert(surface_factory); | 46 | assert(surface_factory); |
995 | @@ -53,12 +56,6 @@ | |||
996 | 53 | } | 56 | } |
997 | 54 | } | 57 | } |
998 | 55 | 58 | ||
999 | 56 | void msh::ApplicationSession::set_event_sink( | ||
1000 | 57 | std::shared_ptr<mir::EventSink> const& sink) | ||
1001 | 58 | { | ||
1002 | 59 | event_sink = sink; | ||
1003 | 60 | } | ||
1004 | 61 | |||
1005 | 62 | mf::SurfaceId msh::ApplicationSession::next_id() | 59 | mf::SurfaceId msh::ApplicationSession::next_id() |
1006 | 63 | { | 60 | { |
1007 | 64 | return mf::SurfaceId(next_surface_id.fetch_add(1)); | 61 | return mf::SurfaceId(next_surface_id.fetch_add(1)); |
1008 | @@ -66,11 +63,8 @@ | |||
1009 | 66 | 63 | ||
1010 | 67 | mf::SurfaceId msh::ApplicationSession::create_surface(const mf::SurfaceCreationParameters& params) | 64 | mf::SurfaceId msh::ApplicationSession::create_surface(const mf::SurfaceCreationParameters& params) |
1011 | 68 | { | 65 | { |
1012 | 69 | auto surf = surface_factory->create_surface(params); | ||
1013 | 70 | auto const id = next_id(); | 66 | auto const id = next_id(); |
1017 | 71 | 67 | auto surf = surface_factory->create_surface(params, id, event_sink); | |
1015 | 72 | surf->set_id(id); | ||
1016 | 73 | surf->set_event_target(event_sink); | ||
1018 | 74 | 68 | ||
1019 | 75 | std::unique_lock<std::mutex> lock(surfaces_mutex); | 69 | std::unique_lock<std::mutex> lock(surfaces_mutex); |
1020 | 76 | surfaces[id] = surf; | 70 | surfaces[id] = surf; |
1021 | 77 | 71 | ||
1022 | === modified file 'src/server/shell/organising_surface_factory.cpp' | |||
1023 | --- src/server/shell/organising_surface_factory.cpp 2013-04-16 09:16:38 +0000 | |||
1024 | +++ src/server/shell/organising_surface_factory.cpp 2013-04-24 09:03:32 +0000 | |||
1025 | @@ -34,10 +34,13 @@ | |||
1026 | 34 | { | 34 | { |
1027 | 35 | } | 35 | } |
1028 | 36 | 36 | ||
1030 | 37 | std::shared_ptr<msh::Surface> msh::OrganisingSurfaceFactory::create_surface(const mf::SurfaceCreationParameters& params) | 37 | std::shared_ptr<msh::Surface> msh::OrganisingSurfaceFactory::create_surface( |
1031 | 38 | frontend::SurfaceCreationParameters const& params, | ||
1032 | 39 | frontend::SurfaceId id, | ||
1033 | 40 | std::shared_ptr<events::EventSink> const& sink) | ||
1034 | 38 | { | 41 | { |
1035 | 39 | auto placed_params = placement_strategy->place(params); | 42 | auto placed_params = placement_strategy->place(params); |
1036 | 40 | 43 | ||
1038 | 41 | return underlying_factory->create_surface(placed_params); | 44 | return underlying_factory->create_surface(placed_params, id, sink); |
1039 | 42 | } | 45 | } |
1040 | 43 | 46 | ||
1041 | 44 | 47 | ||
1042 | === modified file 'src/server/shell/session_manager.cpp' | |||
1043 | --- src/server/shell/session_manager.cpp 2013-04-23 01:40:52 +0000 | |||
1044 | +++ src/server/shell/session_manager.cpp 2013-04-24 09:03:32 +0000 | |||
1045 | @@ -55,9 +55,11 @@ | |||
1046 | 55 | { | 55 | { |
1047 | 56 | } | 56 | } |
1048 | 57 | 57 | ||
1050 | 58 | std::shared_ptr<mf::Session> msh::SessionManager::open_session(std::string const& name) | 58 | std::shared_ptr<mf::Session> msh::SessionManager::open_session( |
1051 | 59 | std::string const& name, | ||
1052 | 60 | std::shared_ptr<events::EventSink> const& sink) | ||
1053 | 59 | { | 61 | { |
1055 | 60 | auto new_session = std::make_shared<msh::ApplicationSession>(surface_factory, input_target_listener, name); | 62 | auto new_session = std::make_shared<msh::ApplicationSession>(surface_factory, input_target_listener, name, sink); |
1056 | 61 | 63 | ||
1057 | 62 | app_container->insert_session(new_session); | 64 | app_container->insert_session(new_session); |
1058 | 63 | 65 | ||
1059 | 64 | 66 | ||
1060 | === modified file 'src/server/shell/surface.cpp' | |||
1061 | --- src/server/shell/surface.cpp 2013-04-19 03:20:05 +0000 | |||
1062 | +++ src/server/shell/surface.cpp 2013-04-24 09:03:32 +0000 | |||
1063 | @@ -20,7 +20,7 @@ | |||
1064 | 20 | #include "mir/shell/surface_builder.h" | 20 | #include "mir/shell/surface_builder.h" |
1065 | 21 | #include "mir/input/input_channel.h" | 21 | #include "mir/input/input_channel.h" |
1066 | 22 | #include "mir_toolkit/event.h" | 22 | #include "mir_toolkit/event.h" |
1068 | 23 | #include "mir/event_sink.h" | 23 | #include "mir/events/event_sink.h" |
1069 | 24 | 24 | ||
1070 | 25 | #include <boost/throw_exception.hpp> | 25 | #include <boost/throw_exception.hpp> |
1071 | 26 | 26 | ||
1072 | @@ -34,11 +34,14 @@ | |||
1073 | 34 | msh::Surface::Surface( | 34 | msh::Surface::Surface( |
1074 | 35 | std::shared_ptr<SurfaceBuilder> const& builder, | 35 | std::shared_ptr<SurfaceBuilder> const& builder, |
1075 | 36 | frontend::SurfaceCreationParameters const& params, | 36 | frontend::SurfaceCreationParameters const& params, |
1077 | 37 | std::shared_ptr<input::InputChannel> const& input_channel) | 37 | std::shared_ptr<input::InputChannel> const& input_channel, |
1078 | 38 | frontend::SurfaceId id, | ||
1079 | 39 | std::shared_ptr<events::EventSink> const& sink) | ||
1080 | 38 | : builder(builder), | 40 | : builder(builder), |
1081 | 39 | input_channel(input_channel), | 41 | input_channel(input_channel), |
1082 | 40 | surface(builder->create_surface(params)), | 42 | surface(builder->create_surface(params)), |
1084 | 41 | id(0), | 43 | id(id), |
1085 | 44 | event_sink(sink), | ||
1086 | 42 | type_value(mir_surface_type_normal), | 45 | type_value(mir_surface_type_normal), |
1087 | 43 | state_value(mir_surface_state_restored) | 46 | state_value(mir_surface_state_restored) |
1088 | 44 | { | 47 | { |
1089 | @@ -52,16 +55,6 @@ | |||
1090 | 52 | } | 55 | } |
1091 | 53 | } | 56 | } |
1092 | 54 | 57 | ||
1093 | 55 | void msh::Surface::set_id(mir::frontend::SurfaceId i) | ||
1094 | 56 | { | ||
1095 | 57 | id = i; | ||
1096 | 58 | } | ||
1097 | 59 | |||
1098 | 60 | void msh::Surface::set_event_target(std::shared_ptr<EventSink> const& sink) | ||
1099 | 61 | { | ||
1100 | 62 | event_sink = sink; | ||
1101 | 63 | } | ||
1102 | 64 | |||
1103 | 65 | void msh::Surface::hide() | 58 | void msh::Surface::hide() |
1104 | 66 | { | 59 | { |
1105 | 67 | if (auto const& s = surface.lock()) | 60 | if (auto const& s = surface.lock()) |
1106 | 68 | 61 | ||
1107 | === modified file 'src/server/shell/surface_source.cpp' | |||
1108 | --- src/server/shell/surface_source.cpp 2013-04-16 09:16:38 +0000 | |||
1109 | +++ src/server/shell/surface_source.cpp 2013-04-24 09:03:32 +0000 | |||
1110 | @@ -39,11 +39,16 @@ | |||
1111 | 39 | assert(surface_builder); | 39 | assert(surface_builder); |
1112 | 40 | } | 40 | } |
1113 | 41 | 41 | ||
1115 | 42 | std::shared_ptr<msh::Surface> msh::SurfaceSource::create_surface(const mf::SurfaceCreationParameters& params) | 42 | std::shared_ptr<msh::Surface> msh::SurfaceSource::create_surface( |
1116 | 43 | frontend::SurfaceCreationParameters const& params, | ||
1117 | 44 | frontend::SurfaceId id, | ||
1118 | 45 | std::shared_ptr<events::EventSink> const& sink) | ||
1119 | 43 | { | 46 | { |
1120 | 44 | return std::make_shared<Surface>( | 47 | return std::make_shared<Surface>( |
1121 | 45 | surface_builder, | 48 | surface_builder, |
1122 | 46 | params, | 49 | params, |
1124 | 47 | input_factory->make_input_channel()); | 50 | input_factory->make_input_channel(), |
1125 | 51 | id, | ||
1126 | 52 | sink); | ||
1127 | 48 | } | 53 | } |
1128 | 49 | 54 | ||
1129 | 50 | 55 | ||
1130 | === modified file 'src/shared/protobuf/mir_protobuf_wire.proto' | |||
1131 | --- src/shared/protobuf/mir_protobuf_wire.proto 2013-04-18 04:15:05 +0000 | |||
1132 | +++ src/shared/protobuf/mir_protobuf_wire.proto 2013-04-24 09:03:32 +0000 | |||
1133 | @@ -7,7 +7,9 @@ | |||
1134 | 7 | } | 7 | } |
1135 | 8 | 8 | ||
1136 | 9 | message Result { | 9 | message Result { |
1138 | 10 | // Invocation results have id and response. Events only have response. | 10 | // Invocation results have id and response. |
1139 | 11 | optional uint32 id = 1; | 11 | optional uint32 id = 1; |
1140 | 12 | optional bytes response = 2; | 12 | optional bytes response = 2; |
1141 | 13 | // Events are in events. | ||
1142 | 14 | repeated bytes events = 3; | ||
1143 | 13 | } | 15 | } |
1144 | 14 | 16 | ||
1145 | === modified file 'tests/acceptance-tests/test_focus_management_api.cpp' | |||
1146 | --- tests/acceptance-tests/test_focus_management_api.cpp 2013-04-22 03:24:56 +0000 | |||
1147 | +++ tests/acceptance-tests/test_focus_management_api.cpp 2013-04-24 09:03:32 +0000 | |||
1148 | @@ -126,7 +126,7 @@ | |||
1149 | 126 | { | 126 | { |
1150 | 127 | using namespace ::testing; | 127 | using namespace ::testing; |
1151 | 128 | using frontend::Shell; | 128 | using frontend::Shell; |
1153 | 129 | ON_CALL(*this, open_session(_)).WillByDefault(Invoke(impl.get(), &Shell::open_session)); | 129 | ON_CALL(*this, open_session(_, _)).WillByDefault(Invoke(impl.get(), &Shell::open_session)); |
1154 | 130 | ON_CALL(*this, close_session(_)).WillByDefault(Invoke(impl.get(), &Shell::close_session)); | 130 | ON_CALL(*this, close_session(_)).WillByDefault(Invoke(impl.get(), &Shell::close_session)); |
1155 | 131 | 131 | ||
1156 | 132 | ON_CALL(*this, tag_session_with_lightdm_id(_, _)).WillByDefault(Invoke(impl.get(), &Shell::tag_session_with_lightdm_id)); | 132 | ON_CALL(*this, tag_session_with_lightdm_id(_, _)).WillByDefault(Invoke(impl.get(), &Shell::tag_session_with_lightdm_id)); |
1157 | @@ -135,7 +135,7 @@ | |||
1158 | 135 | ON_CALL(*this, create_surface_for(_, _)).WillByDefault(Invoke(impl.get(), &Shell::create_surface_for)); | 135 | ON_CALL(*this, create_surface_for(_, _)).WillByDefault(Invoke(impl.get(), &Shell::create_surface_for)); |
1159 | 136 | } | 136 | } |
1160 | 137 | 137 | ||
1162 | 138 | MOCK_METHOD1(open_session, std::shared_ptr<mf::Session> (std::string const& name)); | 138 | MOCK_METHOD2(open_session, std::shared_ptr<mf::Session> (std::string const& name, std::shared_ptr<mir::events::EventSink> const&)); |
1163 | 139 | MOCK_METHOD1(close_session, void (std::shared_ptr<mf::Session> const& session)); | 139 | MOCK_METHOD1(close_session, void (std::shared_ptr<mf::Session> const& session)); |
1164 | 140 | 140 | ||
1165 | 141 | MOCK_METHOD2(tag_session_with_lightdm_id, void (std::shared_ptr<mf::Session> const& session, int id)); | 141 | MOCK_METHOD2(tag_session_with_lightdm_id, void (std::shared_ptr<mf::Session> const& session, int id)); |
1166 | @@ -165,13 +165,13 @@ | |||
1167 | 165 | 165 | ||
1168 | 166 | Sequence s1, s2; | 166 | Sequence s1, s2; |
1169 | 167 | 167 | ||
1171 | 168 | EXPECT_CALL(*mock_shell, open_session(_)) | 168 | EXPECT_CALL(*mock_shell, open_session(_, _)) |
1172 | 169 | .InSequence(s1, s2); | 169 | .InSequence(s1, s2); |
1173 | 170 | 170 | ||
1174 | 171 | EXPECT_CALL(*mock_shell, create_surface_for(_,_)) | 171 | EXPECT_CALL(*mock_shell, create_surface_for(_,_)) |
1175 | 172 | .InSequence(s1); | 172 | .InSequence(s1); |
1176 | 173 | 173 | ||
1178 | 174 | EXPECT_CALL(*mock_shell, open_session(_)) | 174 | EXPECT_CALL(*mock_shell, open_session(_, _)) |
1179 | 175 | .InSequence(s2); | 175 | .InSequence(s2); |
1180 | 176 | 176 | ||
1181 | 177 | EXPECT_CALL(*mock_shell, close_session(_)) | 177 | EXPECT_CALL(*mock_shell, close_session(_)) |
1182 | 178 | 178 | ||
1183 | === modified file 'tests/behavior-tests/session_management_context.cpp' | |||
1184 | --- tests/behavior-tests/session_management_context.cpp 2013-04-22 03:24:56 +0000 | |||
1185 | +++ tests/behavior-tests/session_management_context.cpp 2013-04-24 09:03:32 +0000 | |||
1186 | @@ -66,12 +66,16 @@ | |||
1187 | 66 | { | 66 | { |
1188 | 67 | } | 67 | } |
1189 | 68 | 68 | ||
1191 | 69 | std::shared_ptr<msh::Surface> create_surface(const mf::SurfaceCreationParameters& params) | 69 | std::shared_ptr<msh::Surface> create_surface(const mf::SurfaceCreationParameters& params, |
1192 | 70 | frontend::SurfaceId id, | ||
1193 | 71 | std::shared_ptr<events::EventSink> const& sink) override | ||
1194 | 70 | { | 72 | { |
1195 | 71 | return std::make_shared<msh::Surface>( | 73 | return std::make_shared<msh::Surface>( |
1196 | 72 | mt::fake_shared(surface_builder), | 74 | mt::fake_shared(surface_builder), |
1197 | 73 | params, | 75 | params, |
1199 | 74 | std::shared_ptr<mir::input::InputChannel>()); | 76 | std::shared_ptr<mir::input::InputChannel>(), |
1200 | 77 | id, | ||
1201 | 78 | sink); | ||
1202 | 75 | } | 79 | } |
1203 | 76 | 80 | ||
1204 | 77 | mtd::StubSurfaceBuilder surface_builder; | 81 | mtd::StubSurfaceBuilder surface_builder; |
1205 | @@ -152,7 +156,7 @@ | |||
1206 | 152 | bool mtc::SessionManagementContext::open_window_consuming(std::string const& window_name) | 156 | bool mtc::SessionManagementContext::open_window_consuming(std::string const& window_name) |
1207 | 153 | { | 157 | { |
1208 | 154 | auto const params = mf::a_surface().of_name(window_name); | 158 | auto const params = mf::a_surface().of_name(window_name); |
1210 | 155 | auto session = shell->open_session(window_name); | 159 | auto session = shell->open_session(window_name, std::shared_ptr<mir::events::EventSink>()); |
1211 | 156 | auto const surface_id = session->create_surface(params); | 160 | auto const surface_id = session->create_surface(params); |
1212 | 157 | 161 | ||
1213 | 158 | open_windows[window_name] = std::make_tuple(session, surface_id); | 162 | open_windows[window_name] = std::make_tuple(session, surface_id); |
1214 | @@ -164,7 +168,7 @@ | |||
1215 | 164 | geom::Size const& size) | 168 | geom::Size const& size) |
1216 | 165 | { | 169 | { |
1217 | 166 | auto const params = mf::a_surface().of_name(window_name).of_size(size); | 170 | auto const params = mf::a_surface().of_name(window_name).of_size(size); |
1219 | 167 | auto session = shell->open_session(window_name); | 171 | auto session = shell->open_session(window_name, std::shared_ptr<mir::events::EventSink>()); |
1220 | 168 | auto const surface_id = session->create_surface(params); | 172 | auto const surface_id = session->create_surface(params); |
1221 | 169 | 173 | ||
1222 | 170 | open_windows[window_name] = std::make_tuple(session, surface_id); | 174 | open_windows[window_name] = std::make_tuple(session, surface_id); |
1223 | 171 | 175 | ||
1224 | === modified file 'tests/integration-tests/cucumber/test_session_management_context.cpp' | |||
1225 | --- tests/integration-tests/cucumber/test_session_management_context.cpp 2013-04-22 03:24:56 +0000 | |||
1226 | +++ tests/integration-tests/cucumber/test_session_management_context.cpp 2013-04-24 09:03:32 +0000 | |||
1227 | @@ -106,7 +106,7 @@ | |||
1228 | 106 | 106 | ||
1229 | 107 | mtd::MockSession session; | 107 | mtd::MockSession session; |
1230 | 108 | 108 | ||
1232 | 109 | EXPECT_CALL(shell, open_session(test_window_name)).Times(1) | 109 | EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1) |
1233 | 110 | .WillOnce(Return(mt::fake_shared<mf::Session>(session))); | 110 | .WillOnce(Return(mt::fake_shared<mf::Session>(session))); |
1234 | 111 | 111 | ||
1235 | 112 | // As consuming mode is the default, omiting geometry is sufficient to request it. | 112 | // As consuming mode is the default, omiting geometry is sufficient to request it. |
1236 | @@ -122,7 +122,7 @@ | |||
1237 | 122 | 122 | ||
1238 | 123 | mtd::MockSession session; | 123 | mtd::MockSession session; |
1239 | 124 | 124 | ||
1241 | 125 | EXPECT_CALL(shell, open_session(test_window_name)).Times(1) | 125 | EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1) |
1242 | 126 | .WillOnce(Return(mt::fake_shared<mf::Session>(session))); | 126 | .WillOnce(Return(mt::fake_shared<mf::Session>(session))); |
1243 | 127 | 127 | ||
1244 | 128 | EXPECT_CALL(session, create_surface(NamedWindowWithGeometry(test_window_name, test_window_size))).Times(1) | 128 | EXPECT_CALL(session, create_surface(NamedWindowWithGeometry(test_window_name, test_window_size))).Times(1) |
1245 | @@ -138,7 +138,7 @@ | |||
1246 | 138 | mtd::MockSession session; | 138 | mtd::MockSession session; |
1247 | 139 | mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); | 139 | mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); |
1248 | 140 | 140 | ||
1250 | 141 | EXPECT_CALL(shell, open_session(test_window_name)).Times(1) | 141 | EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1) |
1251 | 142 | .WillOnce(Return(mt::fake_shared<mf::Session>(session))); | 142 | .WillOnce(Return(mt::fake_shared<mf::Session>(session))); |
1252 | 143 | 143 | ||
1253 | 144 | EXPECT_CALL(session, create_surface(NamedWindowWithGeometry(test_window_name, test_window_size))).Times(1) | 144 | EXPECT_CALL(session, create_surface(NamedWindowWithGeometry(test_window_name, test_window_size))).Times(1) |
1254 | 145 | 145 | ||
1255 | === modified file 'tests/integration-tests/shell/test_session_manager.cpp' | |||
1256 | --- tests/integration-tests/shell/test_session_manager.cpp 2013-04-23 01:40:52 +0000 | |||
1257 | +++ tests/integration-tests/shell/test_session_manager.cpp 2013-04-24 09:03:32 +0000 | |||
1258 | @@ -36,6 +36,7 @@ | |||
1259 | 36 | #include "mir_test_doubles/stub_input_target_listener.h" | 36 | #include "mir_test_doubles/stub_input_target_listener.h" |
1260 | 37 | 37 | ||
1261 | 38 | namespace mc = mir::compositor; | 38 | namespace mc = mir::compositor; |
1262 | 39 | namespace me = mir::events; | ||
1263 | 39 | namespace mf = mir::frontend; | 40 | namespace mf = mir::frontend; |
1264 | 40 | namespace msh = mir::shell; | 41 | namespace msh = mir::shell; |
1265 | 41 | namespace ms = mir::surfaces; | 42 | namespace ms = mir::surfaces; |
1266 | @@ -59,12 +60,12 @@ | |||
1267 | 59 | mt::fake_shared(sequence), | 60 | mt::fake_shared(sequence), |
1268 | 60 | mt::fake_shared(focus_setter), | 61 | mt::fake_shared(focus_setter), |
1269 | 61 | mt::fake_shared(input_target_listener)); | 62 | mt::fake_shared(input_target_listener)); |
1271 | 62 | 63 | ||
1272 | 63 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3); | 64 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3); |
1273 | 64 | 65 | ||
1277 | 65 | auto session1 = session_manager.open_session("Visual Basic Studio"); | 66 | auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1278 | 66 | auto session2 = session_manager.open_session("Microsoft Access"); | 67 | auto session2 = session_manager.open_session("Microsoft Access", std::shared_ptr<me::EventSink>()); |
1279 | 67 | auto session3 = session_manager.open_session("WordPerfect"); | 68 | auto session3 = session_manager.open_session("WordPerfect", std::shared_ptr<me::EventSink>()); |
1280 | 68 | 69 | ||
1281 | 69 | { | 70 | { |
1282 | 70 | InSequence seq; | 71 | InSequence seq; |
1283 | @@ -98,9 +99,9 @@ | |||
1284 | 98 | 99 | ||
1285 | 99 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3); | 100 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3); |
1286 | 100 | 101 | ||
1290 | 101 | auto session1 = session_manager.open_session("Visual Basic Studio"); | 102 | auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1291 | 102 | auto session2 = session_manager.open_session("Microsoft Access"); | 103 | auto session2 = session_manager.open_session("Microsoft Access", std::shared_ptr<me::EventSink>()); |
1292 | 103 | auto session3 = session_manager.open_session("WordPerfect"); | 104 | auto session3 = session_manager.open_session("WordPerfect", std::shared_ptr<me::EventSink>()); |
1293 | 104 | 105 | ||
1294 | 105 | { | 106 | { |
1295 | 106 | InSequence seq; | 107 | InSequence seq; |
1296 | 107 | 108 | ||
1297 | === modified file 'tests/unit-tests/CMakeLists.txt' | |||
1298 | --- tests/unit-tests/CMakeLists.txt 2013-04-10 02:48:51 +0000 | |||
1299 | +++ tests/unit-tests/CMakeLists.txt 2013-04-24 09:03:32 +0000 | |||
1300 | @@ -20,7 +20,6 @@ | |||
1301 | 20 | add_subdirectory(android_input/) | 20 | add_subdirectory(android_input/) |
1302 | 21 | add_subdirectory(surfaces/) | 21 | add_subdirectory(surfaces/) |
1303 | 22 | add_subdirectory(draw/) | 22 | add_subdirectory(draw/) |
1304 | 23 | add_subdirectory(event/) | ||
1305 | 24 | 23 | ||
1306 | 25 | add_executable(unit-tests ${UNIT_TEST_SOURCES}) | 24 | add_executable(unit-tests ${UNIT_TEST_SOURCES}) |
1307 | 26 | uses_android_input(unit-tests) | 25 | uses_android_input(unit-tests) |
1308 | 27 | 26 | ||
1309 | === modified file 'tests/unit-tests/client/test_client_mir_surface.cpp' | |||
1310 | --- tests/unit-tests/client/test_client_mir_surface.cpp 2013-04-22 03:24:56 +0000 | |||
1311 | +++ tests/unit-tests/client/test_client_mir_surface.cpp 2013-04-24 09:03:32 +0000 | |||
1312 | @@ -298,7 +298,7 @@ | |||
1313 | 298 | test_server.reset(); | 298 | test_server.reset(); |
1314 | 299 | } | 299 | } |
1315 | 300 | 300 | ||
1317 | 301 | std::shared_ptr<google::protobuf::RpcChannel> channel; | 301 | std::shared_ptr<mcl::MirBasicRpcChannel> channel; |
1318 | 302 | std::shared_ptr<mcl::Logger> logger; | 302 | std::shared_ptr<mcl::Logger> logger; |
1319 | 303 | std::shared_ptr<mcl::ClientPlatformFactory> platform_factory; | 303 | std::shared_ptr<mcl::ClientPlatformFactory> platform_factory; |
1320 | 304 | std::shared_ptr<MirConnection> connection; | 304 | std::shared_ptr<MirConnection> connection; |
1321 | 305 | 305 | ||
1322 | === modified file 'tests/unit-tests/client/test_mir_connection.cpp' | |||
1323 | --- tests/unit-tests/client/test_mir_connection.cpp 2013-03-26 05:28:14 +0000 | |||
1324 | +++ tests/unit-tests/client/test_mir_connection.cpp 2013-04-24 09:03:32 +0000 | |||
1325 | @@ -39,7 +39,7 @@ | |||
1326 | 39 | namespace | 39 | namespace |
1327 | 40 | { | 40 | { |
1328 | 41 | 41 | ||
1330 | 42 | struct MockRpcChannel : public google::protobuf::RpcChannel | 42 | struct MockRpcChannel : public mir::client::MirBasicRpcChannel |
1331 | 43 | { | 43 | { |
1332 | 44 | void CallMethod(const google::protobuf::MethodDescriptor* method, | 44 | void CallMethod(const google::protobuf::MethodDescriptor* method, |
1333 | 45 | google::protobuf::RpcController*, | 45 | google::protobuf::RpcController*, |
1334 | @@ -63,6 +63,8 @@ | |||
1335 | 63 | 63 | ||
1336 | 64 | MOCK_METHOD1(drm_auth_magic, void(const mp::DRMMagic*)); | 64 | MOCK_METHOD1(drm_auth_magic, void(const mp::DRMMagic*)); |
1337 | 65 | MOCK_METHOD2(connect, void(mp::ConnectParameters const*,mp::Connection*)); | 65 | MOCK_METHOD2(connect, void(mp::ConnectParameters const*,mp::Connection*)); |
1338 | 66 | |||
1339 | 67 | void set_event_handler(mir::events::EventSink *) {} | ||
1340 | 66 | }; | 68 | }; |
1341 | 67 | 69 | ||
1342 | 68 | struct MockClientPlatform : public mcl::ClientPlatform | 70 | struct MockClientPlatform : public mcl::ClientPlatform |
1343 | 69 | 71 | ||
1344 | === removed directory 'tests/unit-tests/event' | |||
1345 | === removed file 'tests/unit-tests/event/CMakeLists.txt' | |||
1346 | --- tests/unit-tests/event/CMakeLists.txt 2013-04-09 08:23:32 +0000 | |||
1347 | +++ tests/unit-tests/event/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1348 | @@ -1,5 +0,0 @@ | |||
1349 | 1 | set (UNIT_TEST_SOURCES | ||
1350 | 2 | ${UNIT_TEST_SOURCES} | ||
1351 | 3 | ${CMAKE_CURRENT_SOURCE_DIR}/test_event_queue.cpp | ||
1352 | 4 | PARENT_SCOPE | ||
1353 | 5 | ) | ||
1354 | 6 | 0 | ||
1355 | === modified file 'tests/unit-tests/frontend/CMakeLists.txt' | |||
1356 | --- tests/unit-tests/frontend/CMakeLists.txt 2013-04-11 03:54:01 +0000 | |||
1357 | +++ tests/unit-tests/frontend/CMakeLists.txt 2013-04-24 09:03:32 +0000 | |||
1358 | @@ -6,6 +6,7 @@ | |||
1359 | 6 | ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_reports_errors.cpp | 6 | ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_reports_errors.cpp |
1360 | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_cache.cpp | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_cache.cpp |
1361 | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator.cpp | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator.cpp |
1362 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/test_event_pipe.cpp | ||
1363 | 9 | ) | 10 | ) |
1364 | 10 | 11 | ||
1365 | 11 | # TODO this test is a mess - something better is needed. | 12 | # TODO this test is a mess - something better is needed. |
1366 | 12 | 13 | ||
1367 | === renamed file 'tests/unit-tests/event/test_event_queue.cpp' => 'tests/unit-tests/frontend/test_event_pipe.cpp' | |||
1368 | --- tests/unit-tests/event/test_event_queue.cpp 2013-04-22 03:37:28 +0000 | |||
1369 | +++ tests/unit-tests/frontend/test_event_pipe.cpp 2013-04-24 09:03:32 +0000 | |||
1370 | @@ -16,14 +16,17 @@ | |||
1371 | 16 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> | 16 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1372 | 17 | */ | 17 | */ |
1373 | 18 | 18 | ||
1374 | 19 | #include "src/server/frontend/event_pipe.h" | ||
1375 | 20 | #include <cstring> | ||
1376 | 21 | |||
1377 | 19 | #include <gtest/gtest.h> | 22 | #include <gtest/gtest.h> |
1383 | 20 | #include "mir/event_queue.h" | 23 | |
1384 | 21 | #include "mir/event_sink.h" | 24 | using mir::frontend::EventPipe; |
1385 | 22 | #include <cstring> | 25 | |
1386 | 23 | 26 | ||
1387 | 24 | TEST(EventQueue, no_sink) | 27 | TEST(EventPipe, no_sink) |
1388 | 25 | { | 28 | { |
1390 | 26 | mir::EventQueue q; | 29 | EventPipe q; |
1391 | 27 | MirEvent e; | 30 | MirEvent e; |
1392 | 28 | 31 | ||
1393 | 29 | e.type = mir_event_type_key; | 32 | e.type = mir_event_type_key; |
1394 | @@ -38,7 +41,7 @@ | |||
1395 | 38 | 41 | ||
1396 | 39 | namespace | 42 | namespace |
1397 | 40 | { | 43 | { |
1399 | 41 | class TestSink : public mir::EventSink | 44 | class TestSink : public mir::events::EventSink |
1400 | 42 | { | 45 | { |
1401 | 43 | public: | 46 | public: |
1402 | 44 | TestSink() | 47 | TestSink() |
1403 | @@ -61,9 +64,9 @@ | |||
1404 | 61 | }; | 64 | }; |
1405 | 62 | } | 65 | } |
1406 | 63 | 66 | ||
1408 | 64 | TEST(EventQueue, events_get_handled) | 67 | TEST(EventPipe, events_get_handled) |
1409 | 65 | { | 68 | { |
1411 | 66 | mir::EventQueue q; | 69 | EventPipe q; |
1412 | 67 | std::shared_ptr<TestSink> s(new TestSink); | 70 | std::shared_ptr<TestSink> s(new TestSink); |
1413 | 68 | 71 | ||
1414 | 69 | q.set_target(s); | 72 | q.set_target(s); |
1415 | @@ -84,9 +87,9 @@ | |||
1416 | 84 | EXPECT_EQ(mir_event_type_surface, s->last_event_handled().type); | 87 | EXPECT_EQ(mir_event_type_surface, s->last_event_handled().type); |
1417 | 85 | } | 88 | } |
1418 | 86 | 89 | ||
1420 | 87 | TEST(EventQueue, sink_is_changeable) | 90 | TEST(EventPipe, sink_is_changeable) |
1421 | 88 | { | 91 | { |
1423 | 89 | mir::EventQueue q; | 92 | EventPipe q; |
1424 | 90 | std::shared_ptr<TestSink> a(new TestSink); | 93 | std::shared_ptr<TestSink> a(new TestSink); |
1425 | 91 | std::shared_ptr<TestSink> b(new TestSink); | 94 | std::shared_ptr<TestSink> b(new TestSink); |
1426 | 92 | 95 | ||
1427 | 93 | 96 | ||
1428 | === modified file 'tests/unit-tests/frontend/test_session_mediator.cpp' | |||
1429 | --- tests/unit-tests/frontend/test_session_mediator.cpp 2013-04-19 08:03:57 +0000 | |||
1430 | +++ tests/unit-tests/frontend/test_session_mediator.cpp 2013-04-24 09:03:32 +0000 | |||
1431 | @@ -34,7 +34,7 @@ | |||
1432 | 34 | #include "mir_test_doubles/stub_session.h" | 34 | #include "mir_test_doubles/stub_session.h" |
1433 | 35 | #include "mir_test_doubles/stub_surface_builder.h" | 35 | #include "mir_test_doubles/stub_surface_builder.h" |
1434 | 36 | #include "mir_test/fake_shared.h" | 36 | #include "mir_test/fake_shared.h" |
1436 | 37 | #include "mir/event_queue.h" | 37 | #include "mir/events/event_sink.h" |
1437 | 38 | #include "mir/shell/surface.h" | 38 | #include "mir/shell/surface.h" |
1438 | 39 | 39 | ||
1439 | 40 | #include <gtest/gtest.h> | 40 | #include <gtest/gtest.h> |
1440 | @@ -129,7 +129,11 @@ | |||
1441 | 129 | } | 129 | } |
1442 | 130 | }; | 130 | }; |
1443 | 131 | 131 | ||
1445 | 132 | } | 132 | class NullEventSink : public mir::events::EventSink |
1446 | 133 | { | ||
1447 | 134 | public: | ||
1448 | 135 | void handle_event(MirEvent const& ) override {} | ||
1449 | 136 | }; | ||
1450 | 133 | 137 | ||
1451 | 134 | struct SessionMediatorTest : public ::testing::Test | 138 | struct SessionMediatorTest : public ::testing::Test |
1452 | 135 | { | 139 | { |
1453 | @@ -142,14 +146,14 @@ | |||
1454 | 142 | resource_cache{std::make_shared<mf::ResourceCache>()}, | 146 | resource_cache{std::make_shared<mf::ResourceCache>()}, |
1455 | 143 | mediator{shell, graphics_platform, graphics_display, | 147 | mediator{shell, graphics_platform, graphics_display, |
1456 | 144 | buffer_allocator, report, | 148 | buffer_allocator, report, |
1458 | 145 | std::make_shared<mir::EventQueue>(), | 149 | std::make_shared<NullEventSink>(), |
1459 | 146 | resource_cache}, | 150 | resource_cache}, |
1460 | 147 | stubbed_session{std::make_shared<StubbedSession>()}, | 151 | stubbed_session{std::make_shared<StubbedSession>()}, |
1461 | 148 | null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} | 152 | null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} |
1462 | 149 | { | 153 | { |
1463 | 150 | using namespace ::testing; | 154 | using namespace ::testing; |
1464 | 151 | 155 | ||
1466 | 152 | ON_CALL(*shell, open_session(_)).WillByDefault(Return(stubbed_session)); | 156 | ON_CALL(*shell, open_session(_, _)).WillByDefault(Return(stubbed_session)); |
1467 | 153 | ON_CALL(*shell, create_surface_for(_, _)).WillByDefault(Return(mf::SurfaceId{1})); | 157 | ON_CALL(*shell, create_surface_for(_, _)).WillByDefault(Return(mf::SurfaceId{1})); |
1468 | 154 | } | 158 | } |
1469 | 155 | 159 | ||
1470 | @@ -164,7 +168,7 @@ | |||
1471 | 164 | 168 | ||
1472 | 165 | std::unique_ptr<google::protobuf::Closure> null_callback; | 169 | std::unique_ptr<google::protobuf::Closure> null_callback; |
1473 | 166 | }; | 170 | }; |
1475 | 167 | 171 | } | |
1476 | 168 | 172 | ||
1477 | 169 | TEST_F(SessionMediatorTest, disconnect_releases_session) | 173 | TEST_F(SessionMediatorTest, disconnect_releases_session) |
1478 | 170 | { | 174 | { |
1479 | 171 | 175 | ||
1480 | === modified file 'tests/unit-tests/frontend/test_session_mediator_android.cpp' | |||
1481 | --- tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-04-22 03:35:08 +0000 | |||
1482 | +++ tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-04-24 09:03:32 +0000 | |||
1483 | @@ -31,7 +31,7 @@ | |||
1484 | 31 | #include "mir_test_doubles/mock_session.h" | 31 | #include "mir_test_doubles/mock_session.h" |
1485 | 32 | #include "mir_test_doubles/stub_shell.h" | 32 | #include "mir_test_doubles/stub_shell.h" |
1486 | 33 | 33 | ||
1488 | 34 | #include "mir/event_queue.h" | 34 | #include "mir/events/event_sink.h" |
1489 | 35 | 35 | ||
1490 | 36 | #include <gtest/gtest.h> | 36 | #include <gtest/gtest.h> |
1491 | 37 | 37 | ||
1492 | @@ -87,7 +87,11 @@ | |||
1493 | 87 | } | 87 | } |
1494 | 88 | }; | 88 | }; |
1495 | 89 | 89 | ||
1497 | 90 | } | 90 | class NullEventSink : public mir::events::EventSink |
1498 | 91 | { | ||
1499 | 92 | public: | ||
1500 | 93 | void handle_event(MirEvent const& ) override {} | ||
1501 | 94 | }; | ||
1502 | 91 | 95 | ||
1503 | 92 | struct SessionMediatorAndroidTest : public ::testing::Test | 96 | struct SessionMediatorAndroidTest : public ::testing::Test |
1504 | 93 | { | 97 | { |
1505 | @@ -100,7 +104,7 @@ | |||
1506 | 100 | resource_cache{std::make_shared<mf::ResourceCache>()}, | 104 | resource_cache{std::make_shared<mf::ResourceCache>()}, |
1507 | 101 | mediator{shell, graphics_platform, graphics_display, | 105 | mediator{shell, graphics_platform, graphics_display, |
1508 | 102 | buffer_allocator, report, | 106 | buffer_allocator, report, |
1510 | 103 | std::make_shared<mir::EventQueue>(), | 107 | std::make_shared<NullEventSink>(), |
1511 | 104 | resource_cache}, | 108 | resource_cache}, |
1512 | 105 | null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} | 109 | null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} |
1513 | 106 | { | 110 | { |
1514 | @@ -117,6 +121,8 @@ | |||
1515 | 117 | std::unique_ptr<google::protobuf::Closure> null_callback; | 121 | std::unique_ptr<google::protobuf::Closure> null_callback; |
1516 | 118 | }; | 122 | }; |
1517 | 119 | 123 | ||
1518 | 124 | } | ||
1519 | 125 | |||
1520 | 120 | TEST_F(SessionMediatorAndroidTest, drm_auth_magic_throws) | 126 | TEST_F(SessionMediatorAndroidTest, drm_auth_magic_throws) |
1521 | 121 | { | 127 | { |
1522 | 122 | mp::ConnectParameters connect_parameters; | 128 | mp::ConnectParameters connect_parameters; |
1523 | 123 | 129 | ||
1524 | === modified file 'tests/unit-tests/frontend/test_session_mediator_gbm.cpp' | |||
1525 | --- tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-04-19 08:03:57 +0000 | |||
1526 | +++ tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-04-24 09:03:32 +0000 | |||
1527 | @@ -27,7 +27,7 @@ | |||
1528 | 27 | #include "mir/graphics/drm_authenticator.h" | 27 | #include "mir/graphics/drm_authenticator.h" |
1529 | 28 | #include "mir/graphics/platform.h" | 28 | #include "mir/graphics/platform.h" |
1530 | 29 | #include "mir/graphics/platform_ipc_package.h" | 29 | #include "mir/graphics/platform_ipc_package.h" |
1532 | 30 | #include "mir/event_queue.h" | 30 | #include "mir/events/event_sink.h" |
1533 | 31 | 31 | ||
1534 | 32 | #include <boost/exception/errinfo_errno.hpp> | 32 | #include <boost/exception/errinfo_errno.hpp> |
1535 | 33 | #include <boost/throw_exception.hpp> | 33 | #include <boost/throw_exception.hpp> |
1536 | @@ -91,7 +91,11 @@ | |||
1537 | 91 | MOCK_METHOD1(drm_auth_magic, void(drm_magic_t)); | 91 | MOCK_METHOD1(drm_auth_magic, void(drm_magic_t)); |
1538 | 92 | }; | 92 | }; |
1539 | 93 | 93 | ||
1541 | 94 | } | 94 | class NullEventSink : public mir::events::EventSink |
1542 | 95 | { | ||
1543 | 96 | public: | ||
1544 | 97 | void handle_event(MirEvent const& ) override {} | ||
1545 | 98 | }; | ||
1546 | 95 | 99 | ||
1547 | 96 | struct SessionMediatorGBMTest : public ::testing::Test | 100 | struct SessionMediatorGBMTest : public ::testing::Test |
1548 | 97 | { | 101 | { |
1549 | @@ -104,7 +108,7 @@ | |||
1550 | 104 | resource_cache{std::make_shared<mf::ResourceCache>()}, | 108 | resource_cache{std::make_shared<mf::ResourceCache>()}, |
1551 | 105 | mediator{shell, mock_platform, graphics_display, | 109 | mediator{shell, mock_platform, graphics_display, |
1552 | 106 | buffer_allocator, report, | 110 | buffer_allocator, report, |
1554 | 107 | std::make_shared<mir::EventQueue>(), | 111 | std::make_shared<NullEventSink>(), |
1555 | 108 | resource_cache}, | 112 | resource_cache}, |
1556 | 109 | null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} | 113 | null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} |
1557 | 110 | { | 114 | { |
1558 | @@ -121,6 +125,8 @@ | |||
1559 | 121 | std::unique_ptr<google::protobuf::Closure> null_callback; | 125 | std::unique_ptr<google::protobuf::Closure> null_callback; |
1560 | 122 | }; | 126 | }; |
1561 | 123 | 127 | ||
1562 | 128 | } | ||
1563 | 129 | |||
1564 | 124 | TEST_F(SessionMediatorGBMTest, drm_auth_magic_uses_drm_authenticator) | 130 | TEST_F(SessionMediatorGBMTest, drm_auth_magic_uses_drm_authenticator) |
1565 | 125 | { | 131 | { |
1566 | 126 | mp::ConnectParameters connect_parameters; | 132 | mp::ConnectParameters connect_parameters; |
1567 | 127 | 133 | ||
1568 | === modified file 'tests/unit-tests/shell/test_application_session.cpp' | |||
1569 | --- tests/unit-tests/shell/test_application_session.cpp 2013-04-23 01:40:52 +0000 | |||
1570 | +++ tests/unit-tests/shell/test_application_session.cpp 2013-04-24 09:03:32 +0000 | |||
1571 | @@ -32,6 +32,7 @@ | |||
1572 | 32 | #include <gtest/gtest.h> | 32 | #include <gtest/gtest.h> |
1573 | 33 | 33 | ||
1574 | 34 | namespace mc = mir::compositor; | 34 | namespace mc = mir::compositor; |
1575 | 35 | namespace me = mir::events; | ||
1576 | 35 | namespace mf = mir::frontend; | 36 | namespace mf = mir::frontend; |
1577 | 36 | namespace msh = mir::shell; | 37 | namespace msh = mir::shell; |
1578 | 37 | namespace ms = mir::surfaces; | 38 | namespace ms = mir::surfaces; |
1579 | @@ -47,13 +48,13 @@ | |||
1580 | 47 | auto const mock_surface = std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder)); | 48 | auto const mock_surface = std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder)); |
1581 | 48 | 49 | ||
1582 | 49 | mtd::MockSurfaceFactory surface_factory; | 50 | mtd::MockSurfaceFactory surface_factory; |
1584 | 50 | ON_CALL(surface_factory, create_surface(_)).WillByDefault(Return(mock_surface)); | 51 | ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(Return(mock_surface)); |
1585 | 51 | 52 | ||
1587 | 52 | EXPECT_CALL(surface_factory, create_surface(_)); | 53 | EXPECT_CALL(surface_factory, create_surface(_, _, _)); |
1588 | 53 | EXPECT_CALL(*mock_surface, destroy()); | 54 | EXPECT_CALL(*mock_surface, destroy()); |
1589 | 54 | 55 | ||
1590 | 55 | mtd::StubInputTargetListener input_listener; | 56 | mtd::StubInputTargetListener input_listener; |
1592 | 56 | msh::ApplicationSession session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo"); | 57 | msh::ApplicationSession session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo", std::shared_ptr<me::EventSink>()); |
1593 | 57 | 58 | ||
1594 | 58 | mf::SurfaceCreationParameters params; | 59 | mf::SurfaceCreationParameters params; |
1595 | 59 | auto surf = session.create_surface(params); | 60 | auto surf = session.create_surface(params); |
1596 | @@ -69,16 +70,16 @@ | |||
1597 | 69 | mtd::StubSurfaceBuilder surface_builder; | 70 | mtd::StubSurfaceBuilder surface_builder; |
1598 | 70 | { | 71 | { |
1599 | 71 | InSequence seq; | 72 | InSequence seq; |
1605 | 72 | EXPECT_CALL(surface_factory, create_surface(_)).Times(1) | 73 | EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1) |
1606 | 73 | .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); | 74 | .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); |
1607 | 74 | EXPECT_CALL(surface_factory, create_surface(_)).Times(1) | 75 | EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1) |
1608 | 75 | .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); | 76 | .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); |
1609 | 76 | EXPECT_CALL(surface_factory, create_surface(_)).Times(1) | 77 | EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1) |
1610 | 77 | .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); | 78 | .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); |
1611 | 78 | } | 79 | } |
1612 | 79 | 80 | ||
1613 | 80 | mtd::StubInputTargetListener input_listener; | 81 | mtd::StubInputTargetListener input_listener; |
1615 | 81 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo"); | 82 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo", std::shared_ptr<me::EventSink>()); |
1616 | 82 | 83 | ||
1617 | 83 | mf::SurfaceCreationParameters params; | 84 | mf::SurfaceCreationParameters params; |
1618 | 84 | auto id1 = app_session.create_surface(params); | 85 | auto id1 = app_session.create_surface(params); |
1619 | @@ -106,12 +107,12 @@ | |||
1620 | 106 | auto const mock_surface = std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder)); | 107 | auto const mock_surface = std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder)); |
1621 | 107 | 108 | ||
1622 | 108 | mtd::MockSurfaceFactory surface_factory; | 109 | mtd::MockSurfaceFactory surface_factory; |
1624 | 109 | ON_CALL(surface_factory, create_surface(_)).WillByDefault(Return(mock_surface)); | 110 | ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(Return(mock_surface)); |
1625 | 110 | 111 | ||
1626 | 111 | mtd::StubInputTargetListener input_listener; | 112 | mtd::StubInputTargetListener input_listener; |
1628 | 112 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo"); | 113 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo", std::shared_ptr<me::EventSink>()); |
1629 | 113 | 114 | ||
1631 | 114 | EXPECT_CALL(surface_factory, create_surface(_)); | 115 | EXPECT_CALL(surface_factory, create_surface(_, _, _)); |
1632 | 115 | 116 | ||
1633 | 116 | { | 117 | { |
1634 | 117 | InSequence seq; | 118 | InSequence seq; |
1635 | @@ -135,7 +136,7 @@ | |||
1636 | 135 | 136 | ||
1637 | 136 | mtd::MockSurfaceFactory surface_factory; | 137 | mtd::MockSurfaceFactory surface_factory; |
1638 | 137 | mtd::StubInputTargetListener input_listener; | 138 | mtd::StubInputTargetListener input_listener; |
1640 | 138 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo"); | 139 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo", std::shared_ptr<me::EventSink>()); |
1641 | 139 | mf::SurfaceId invalid_surface_id(1); | 140 | mf::SurfaceId invalid_surface_id(1); |
1642 | 140 | 141 | ||
1643 | 141 | EXPECT_THROW({ | 142 | EXPECT_THROW({ |
1644 | @@ -149,7 +150,7 @@ | |||
1645 | 149 | 150 | ||
1646 | 150 | mtd::MockSurfaceFactory surface_factory; | 151 | mtd::MockSurfaceFactory surface_factory; |
1647 | 151 | mtd::StubInputTargetListener input_listener; | 152 | mtd::StubInputTargetListener input_listener; |
1649 | 152 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo"); | 153 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo", std::shared_ptr<me::EventSink>()); |
1650 | 153 | mf::SurfaceId invalid_surface_id(1); | 154 | mf::SurfaceId invalid_surface_id(1); |
1651 | 154 | 155 | ||
1652 | 155 | EXPECT_THROW({ | 156 | EXPECT_THROW({ |
1653 | 156 | 157 | ||
1654 | === modified file 'tests/unit-tests/shell/test_organising_surface_factory.cpp' | |||
1655 | --- tests/unit-tests/shell/test_organising_surface_factory.cpp 2013-04-02 05:58:55 +0000 | |||
1656 | +++ tests/unit-tests/shell/test_organising_surface_factory.cpp 2013-04-24 09:03:32 +0000 | |||
1657 | @@ -25,6 +25,7 @@ | |||
1658 | 25 | #include <gtest/gtest.h> | 25 | #include <gtest/gtest.h> |
1659 | 26 | #include <gmock/gmock.h> | 26 | #include <gmock/gmock.h> |
1660 | 27 | 27 | ||
1661 | 28 | namespace me = mir::events; | ||
1662 | 28 | namespace mf = mir::frontend; | 29 | namespace mf = mir::frontend; |
1663 | 29 | namespace msh = mir::shell; | 30 | namespace msh = mir::shell; |
1664 | 30 | namespace geom = mir::geometry; | 31 | namespace geom = mir::geometry; |
1665 | @@ -45,7 +46,7 @@ | |||
1666 | 45 | using namespace ::testing; | 46 | using namespace ::testing; |
1667 | 46 | 47 | ||
1668 | 47 | underlying_surface_factory = std::make_shared<mtd::MockSurfaceFactory>(); | 48 | underlying_surface_factory = std::make_shared<mtd::MockSurfaceFactory>(); |
1670 | 48 | ON_CALL(*underlying_surface_factory, create_surface(_)).WillByDefault(Return(null_surface)); | 49 | ON_CALL(*underlying_surface_factory, create_surface(_, _, _)).WillByDefault(Return(null_surface)); |
1671 | 49 | 50 | ||
1672 | 50 | placement_strategy = std::make_shared<MockPlacementStrategy>(); | 51 | placement_strategy = std::make_shared<MockPlacementStrategy>(); |
1673 | 51 | } | 52 | } |
1674 | @@ -62,13 +63,13 @@ | |||
1675 | 62 | 63 | ||
1676 | 63 | msh::OrganisingSurfaceFactory factory(underlying_surface_factory, placement_strategy); | 64 | msh::OrganisingSurfaceFactory factory(underlying_surface_factory, placement_strategy); |
1677 | 64 | 65 | ||
1679 | 65 | EXPECT_CALL(*underlying_surface_factory, create_surface(_)).Times(1); | 66 | EXPECT_CALL(*underlying_surface_factory, create_surface(_, _, _)).Times(1); |
1680 | 66 | 67 | ||
1681 | 67 | auto params = mf::a_surface(); | 68 | auto params = mf::a_surface(); |
1682 | 68 | EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1) | 69 | EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1) |
1683 | 69 | .WillOnce(Return(mf::a_surface())); | 70 | .WillOnce(Return(mf::a_surface())); |
1684 | 70 | 71 | ||
1686 | 71 | factory.create_surface(params); | 72 | factory.create_surface(params, mf::SurfaceId(), std::shared_ptr<me::EventSink>()); |
1687 | 72 | } | 73 | } |
1688 | 73 | 74 | ||
1689 | 74 | TEST_F(OrganisingSurfaceFactorySetup, forwards_create_surface_parameters_from_placement_strategy_to_underlying_factory) | 75 | TEST_F(OrganisingSurfaceFactorySetup, forwards_create_surface_parameters_from_placement_strategy_to_underlying_factory) |
1690 | @@ -83,8 +84,8 @@ | |||
1691 | 83 | 84 | ||
1692 | 84 | EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1) | 85 | EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1) |
1693 | 85 | .WillOnce(Return(placed_params)); | 86 | .WillOnce(Return(placed_params)); |
1695 | 86 | EXPECT_CALL(*underlying_surface_factory, create_surface(placed_params)); | 87 | EXPECT_CALL(*underlying_surface_factory, create_surface(placed_params, mf::SurfaceId(), std::shared_ptr<me::EventSink>())); |
1696 | 87 | 88 | ||
1698 | 88 | factory.create_surface(params); | 89 | factory.create_surface(params, mf::SurfaceId(), std::shared_ptr<me::EventSink>()); |
1699 | 89 | } | 90 | } |
1700 | 90 | 91 | ||
1701 | 91 | 92 | ||
1702 | === modified file 'tests/unit-tests/shell/test_registration_order_focus_sequence.cpp' | |||
1703 | --- tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-04-23 01:40:52 +0000 | |||
1704 | +++ tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-04-24 09:03:32 +0000 | |||
1705 | @@ -33,6 +33,7 @@ | |||
1706 | 33 | #include <string> | 33 | #include <string> |
1707 | 34 | 34 | ||
1708 | 35 | namespace mc = mir::compositor; | 35 | namespace mc = mir::compositor; |
1709 | 36 | namespace me = mir::events; | ||
1710 | 36 | namespace msh = mir::shell; | 37 | namespace msh = mir::shell; |
1711 | 37 | namespace ms = mir::surfaces; | 38 | namespace ms = mir::surfaces; |
1712 | 38 | namespace mt = mir::test; | 39 | namespace mt = mir::test; |
1713 | @@ -65,9 +66,9 @@ | |||
1714 | 65 | { | 66 | { |
1715 | 66 | using namespace ::testing; | 67 | using namespace ::testing; |
1716 | 67 | 68 | ||
1720 | 68 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); | 69 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>()); |
1721 | 69 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2); | 70 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2, std::shared_ptr<me::EventSink>()); |
1722 | 70 | auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3); | 71 | auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3, std::shared_ptr<me::EventSink>()); |
1723 | 71 | 72 | ||
1724 | 72 | container->insert_session(app1); | 73 | container->insert_session(app1); |
1725 | 73 | container->insert_session(app2); | 74 | container->insert_session(app2); |
1726 | @@ -83,9 +84,9 @@ | |||
1727 | 83 | { | 84 | { |
1728 | 84 | using namespace ::testing; | 85 | using namespace ::testing; |
1729 | 85 | 86 | ||
1733 | 86 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); | 87 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>()); |
1734 | 87 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2); | 88 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2, std::shared_ptr<me::EventSink>()); |
1735 | 88 | auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3); | 89 | auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3, std::shared_ptr<me::EventSink>()); |
1736 | 89 | container->insert_session(app1); | 90 | container->insert_session(app1); |
1737 | 90 | container->insert_session(app2); | 91 | container->insert_session(app2); |
1738 | 91 | container->insert_session(app3); | 92 | container->insert_session(app3); |
1739 | @@ -100,7 +101,7 @@ | |||
1740 | 100 | { | 101 | { |
1741 | 101 | using namespace ::testing; | 102 | using namespace ::testing; |
1742 | 102 | 103 | ||
1744 | 103 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); | 104 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>()); |
1745 | 104 | container->insert_session(app1); | 105 | container->insert_session(app1); |
1746 | 105 | 106 | ||
1747 | 106 | msh::RegistrationOrderFocusSequence focus_sequence(container); | 107 | msh::RegistrationOrderFocusSequence focus_sequence(container); |
1748 | @@ -112,8 +113,8 @@ | |||
1749 | 112 | { | 113 | { |
1750 | 113 | using namespace ::testing; | 114 | using namespace ::testing; |
1751 | 114 | 115 | ||
1754 | 115 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); | 116 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>()); |
1755 | 116 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2); | 117 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2, std::shared_ptr<me::EventSink>()); |
1756 | 117 | auto null_session = std::shared_ptr<msh::ApplicationSession>(); | 118 | auto null_session = std::shared_ptr<msh::ApplicationSession>(); |
1757 | 118 | 119 | ||
1758 | 119 | msh::RegistrationOrderFocusSequence focus_sequence(container); | 120 | msh::RegistrationOrderFocusSequence focus_sequence(container); |
1759 | @@ -129,7 +130,7 @@ | |||
1760 | 129 | { | 130 | { |
1761 | 130 | using namespace ::testing; | 131 | using namespace ::testing; |
1762 | 131 | 132 | ||
1764 | 132 | auto invalid_session = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); | 133 | auto invalid_session = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>()); |
1765 | 133 | auto null_session = std::shared_ptr<msh::ApplicationSession>(); | 134 | auto null_session = std::shared_ptr<msh::ApplicationSession>(); |
1766 | 134 | 135 | ||
1767 | 135 | msh::RegistrationOrderFocusSequence focus_sequence(container); | 136 | msh::RegistrationOrderFocusSequence focus_sequence(container); |
1768 | 136 | 137 | ||
1769 | === modified file 'tests/unit-tests/shell/test_session_manager.cpp' | |||
1770 | --- tests/unit-tests/shell/test_session_manager.cpp 2013-04-23 01:40:52 +0000 | |||
1771 | +++ tests/unit-tests/shell/test_session_manager.cpp 2013-04-24 09:03:32 +0000 | |||
1772 | @@ -41,6 +41,7 @@ | |||
1773 | 41 | #include <gtest/gtest.h> | 41 | #include <gtest/gtest.h> |
1774 | 42 | 42 | ||
1775 | 43 | namespace mc = mir::compositor; | 43 | namespace mc = mir::compositor; |
1776 | 44 | namespace me = mir::events; | ||
1777 | 44 | namespace mf = mir::frontend; | 45 | namespace mf = mir::frontend; |
1778 | 45 | namespace msh = mir::shell; | 46 | namespace msh = mir::shell; |
1779 | 46 | namespace ms = mir::surfaces; | 47 | namespace ms = mir::surfaces; |
1780 | @@ -101,7 +102,7 @@ | |||
1781 | 101 | 102 | ||
1782 | 102 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); | 103 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); |
1783 | 103 | 104 | ||
1785 | 104 | auto session = session_manager.open_session("Visual Basic Studio"); | 105 | auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1786 | 105 | session_manager.close_session(session); | 106 | session_manager.close_session(session); |
1787 | 106 | } | 107 | } |
1788 | 107 | 108 | ||
1789 | @@ -109,14 +110,16 @@ | |||
1790 | 109 | { | 110 | { |
1791 | 110 | using namespace ::testing; | 111 | using namespace ::testing; |
1792 | 111 | 112 | ||
1794 | 112 | EXPECT_CALL(surface_factory, create_surface(_)).Times(1); | 113 | EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1); |
1795 | 113 | 114 | ||
1796 | 114 | std::shared_ptr<mi::InputChannel> null_input_channel; | 115 | std::shared_ptr<mi::InputChannel> null_input_channel; |
1798 | 115 | ON_CALL(surface_factory, create_surface(_)).WillByDefault( | 116 | ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault( |
1799 | 116 | Return(std::make_shared<msh::Surface>( | 117 | Return(std::make_shared<msh::Surface>( |
1800 | 117 | mt::fake_shared(surface_builder), | 118 | mt::fake_shared(surface_builder), |
1801 | 118 | mf::a_surface(), | 119 | mf::a_surface(), |
1803 | 119 | null_input_channel))); | 120 | null_input_channel, |
1804 | 121 | mf::SurfaceId(), | ||
1805 | 122 | std::shared_ptr<me::EventSink>()))); | ||
1806 | 120 | 123 | ||
1807 | 121 | EXPECT_CALL(container, insert_session(_)).Times(1); | 124 | EXPECT_CALL(container, insert_session(_)).Times(1); |
1808 | 122 | EXPECT_CALL(container, remove_session(_)).Times(1); | 125 | EXPECT_CALL(container, remove_session(_)).Times(1); |
1809 | @@ -126,7 +129,7 @@ | |||
1810 | 126 | 129 | ||
1811 | 127 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); | 130 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); |
1812 | 128 | 131 | ||
1814 | 129 | auto session = session_manager.open_session("Visual Basic Studio"); | 132 | auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1815 | 130 | session->create_surface(mf::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}})); | 133 | session->create_surface(mf::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}})); |
1816 | 131 | 134 | ||
1817 | 132 | session_manager.close_session(session); | 135 | session_manager.close_session(session); |
1818 | @@ -140,7 +143,7 @@ | |||
1819 | 140 | EXPECT_CALL(container, insert_session(_)).Times(1); | 143 | EXPECT_CALL(container, insert_session(_)).Times(1); |
1820 | 141 | EXPECT_CALL(focus_setter, set_focus_to(_)).WillOnce(SaveArg<0>(&new_session)); | 144 | EXPECT_CALL(focus_setter, set_focus_to(_)).WillOnce(SaveArg<0>(&new_session)); |
1821 | 142 | 145 | ||
1823 | 143 | auto session = session_manager.open_session("Visual Basic Studio"); | 146 | auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1824 | 144 | EXPECT_EQ(session, new_session); | 147 | EXPECT_EQ(session, new_session); |
1825 | 145 | } | 148 | } |
1826 | 146 | 149 | ||
1827 | @@ -148,8 +151,8 @@ | |||
1828 | 148 | { | 151 | { |
1829 | 149 | using namespace ::testing; | 152 | using namespace ::testing; |
1830 | 150 | 153 | ||
1833 | 151 | auto session1 = session_manager.open_session("Visual Basic Studio"); | 154 | auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1834 | 152 | auto session2 = session_manager.open_session("IntelliJ IDEA"); | 155 | auto session2 = session_manager.open_session("IntelliJ IDEA", std::shared_ptr<me::EventSink>()); |
1835 | 153 | 156 | ||
1836 | 154 | session_manager.tag_session_with_lightdm_id(session1, 1); | 157 | session_manager.tag_session_with_lightdm_id(session1, 1); |
1837 | 155 | 158 | ||
1838 | @@ -161,8 +164,8 @@ | |||
1839 | 161 | { | 164 | { |
1840 | 162 | using namespace ::testing; | 165 | using namespace ::testing; |
1841 | 163 | 166 | ||
1844 | 164 | auto session1 = session_manager.open_session("Visual Basic Studio"); | 167 | auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1845 | 165 | auto session2 = session_manager.open_session("IntelliJ IDEA"); | 168 | auto session2 = session_manager.open_session("IntelliJ IDEA", std::shared_ptr<me::EventSink>()); |
1846 | 166 | 169 | ||
1847 | 167 | auto shell_session1 = std::dynamic_pointer_cast<msh::Session>(session1); | 170 | auto shell_session1 = std::dynamic_pointer_cast<msh::Session>(session1); |
1848 | 168 | auto shell_session2 = std::dynamic_pointer_cast<msh::Session>(session2); | 171 | auto shell_session2 = std::dynamic_pointer_cast<msh::Session>(session2); |
1849 | @@ -180,22 +183,24 @@ | |||
1850 | 180 | { | 183 | { |
1851 | 181 | using namespace ::testing; | 184 | using namespace ::testing; |
1852 | 182 | std::shared_ptr<mi::InputChannel> null_input_channel; | 185 | std::shared_ptr<mi::InputChannel> null_input_channel; |
1854 | 183 | ON_CALL(surface_factory, create_surface(_)).WillByDefault( | 186 | ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault( |
1855 | 184 | Return(std::make_shared<msh::Surface>( | 187 | Return(std::make_shared<msh::Surface>( |
1856 | 185 | mt::fake_shared(surface_builder), | 188 | mt::fake_shared(surface_builder), |
1857 | 186 | mf::a_surface(), | 189 | mf::a_surface(), |
1859 | 187 | null_input_channel))); | 190 | null_input_channel, |
1860 | 191 | mf::SurfaceId(), | ||
1861 | 192 | std::shared_ptr<me::EventSink>()))); | ||
1862 | 188 | 193 | ||
1863 | 189 | // Once for session creation and once for surface creation | 194 | // Once for session creation and once for surface creation |
1864 | 190 | { | 195 | { |
1865 | 191 | InSequence seq; | 196 | InSequence seq; |
1866 | 192 | 197 | ||
1867 | 193 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Session creation | 198 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Session creation |
1869 | 194 | EXPECT_CALL(surface_factory, create_surface(_)).Times(1); | 199 | EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1); |
1870 | 195 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation | 200 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation |
1871 | 196 | } | 201 | } |
1872 | 197 | 202 | ||
1874 | 198 | auto session1 = session_manager.open_session("Weather Report"); | 203 | auto session1 = session_manager.open_session("Weather Report", std::shared_ptr<me::EventSink>()); |
1875 | 199 | session_manager.create_surface_for(session1, mf::a_surface()); | 204 | session_manager.create_surface_for(session1, mf::a_surface()); |
1876 | 200 | } | 205 | } |
1877 | 201 | 206 | ||
1878 | @@ -230,12 +235,14 @@ | |||
1879 | 230 | using namespace ::testing; | 235 | using namespace ::testing; |
1880 | 231 | 236 | ||
1881 | 232 | std::shared_ptr<mi::InputChannel> null_input_channel; | 237 | std::shared_ptr<mi::InputChannel> null_input_channel; |
1883 | 233 | ON_CALL(surface_factory, create_surface(_)).WillByDefault( | 238 | ON_CALL(surface_factory, create_surface(_,_,_)).WillByDefault( |
1884 | 234 | Return(std::make_shared<msh::Surface>( | 239 | Return(std::make_shared<msh::Surface>( |
1885 | 235 | mt::fake_shared(surface_builder), | 240 | mt::fake_shared(surface_builder), |
1886 | 236 | mf::a_surface(), | 241 | mf::a_surface(), |
1889 | 237 | null_input_channel))); | 242 | null_input_channel, |
1890 | 238 | EXPECT_CALL(surface_factory, create_surface(_)).Times(1); | 243 | mf::SurfaceId(), |
1891 | 244 | std::shared_ptr<me::EventSink>()))); | ||
1892 | 245 | EXPECT_CALL(surface_factory, create_surface(_,_,_)).Times(1); | ||
1893 | 239 | 246 | ||
1894 | 240 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); | 247 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); |
1895 | 241 | { | 248 | { |
1896 | @@ -252,7 +259,7 @@ | |||
1897 | 252 | } | 259 | } |
1898 | 253 | 260 | ||
1899 | 254 | { | 261 | { |
1901 | 255 | auto session = session_manager.open_session("test"); | 262 | auto session = session_manager.open_session("test", std::shared_ptr<me::EventSink>()); |
1902 | 256 | auto surf = session_manager.create_surface_for(session, mf::a_surface()); | 263 | auto surf = session_manager.create_surface_for(session, mf::a_surface()); |
1903 | 257 | session->destroy_surface(surf); | 264 | session->destroy_surface(surf); |
1904 | 258 | session_manager.close_session(session); | 265 | session_manager.close_session(session); |
1905 | 259 | 266 | ||
1906 | === modified file 'tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp' | |||
1907 | --- tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-04-23 01:40:52 +0000 | |||
1908 | +++ tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-04-24 09:03:32 +0000 | |||
1909 | @@ -57,7 +57,6 @@ | |||
1910 | 57 | MOCK_METHOD0(show, void()); | 57 | MOCK_METHOD0(show, void()); |
1911 | 58 | 58 | ||
1912 | 59 | MOCK_METHOD3(configure_surface, int(mf::SurfaceId, MirSurfaceAttrib, int)); | 59 | MOCK_METHOD3(configure_surface, int(mf::SurfaceId, MirSurfaceAttrib, int)); |
1913 | 60 | MOCK_METHOD1(set_event_sink, void(std::shared_ptr<mir::EventSink> const&)); | ||
1914 | 61 | }; | 60 | }; |
1915 | 62 | 61 | ||
1916 | 63 | TEST(SingleVisibilityFocusMechanism, mechanism_sets_visibility) | 62 | TEST(SingleVisibilityFocusMechanism, mechanism_sets_visibility) |
1917 | 64 | 63 | ||
1918 | === modified file 'tests/unit-tests/shell/test_surface.cpp' | |||
1919 | --- tests/unit-tests/shell/test_surface.cpp 2013-04-19 03:20:05 +0000 | |||
1920 | +++ tests/unit-tests/shell/test_surface.cpp 2013-04-24 09:03:32 +0000 | |||
1921 | @@ -33,6 +33,7 @@ | |||
1922 | 33 | #include <gmock/gmock.h> | 33 | #include <gmock/gmock.h> |
1923 | 34 | #include <gtest/gtest.h> | 34 | #include <gtest/gtest.h> |
1924 | 35 | 35 | ||
1925 | 36 | namespace me = mir::events; | ||
1926 | 36 | namespace ms = mir::surfaces; | 37 | namespace ms = mir::surfaces; |
1927 | 37 | namespace msh = mir::shell; | 38 | namespace msh = mir::shell; |
1928 | 38 | namespace mf = mir::frontend; | 39 | namespace mf = mir::frontend; |
1929 | @@ -137,7 +138,9 @@ | |||
1930 | 137 | msh::Surface test( | 138 | msh::Surface test( |
1931 | 138 | mt::fake_shared(surface_builder), | 139 | mt::fake_shared(surface_builder), |
1932 | 139 | params, | 140 | params, |
1934 | 140 | null_input_channel); | 141 | null_input_channel, |
1935 | 142 | mf::SurfaceId(), | ||
1936 | 143 | std::shared_ptr<me::EventSink>()); | ||
1937 | 141 | } | 144 | } |
1938 | 142 | 145 | ||
1939 | 143 | TEST_F(ShellSurface, creation_throws_means_no_destroy) | 146 | TEST_F(ShellSurface, creation_throws_means_no_destroy) |
1940 | @@ -156,7 +159,9 @@ | |||
1941 | 156 | msh::Surface test( | 159 | msh::Surface test( |
1942 | 157 | mt::fake_shared(surface_builder), | 160 | mt::fake_shared(surface_builder), |
1943 | 158 | params, | 161 | params, |
1945 | 159 | null_input_channel); | 162 | null_input_channel, |
1946 | 163 | mf::SurfaceId(), | ||
1947 | 164 | std::shared_ptr<me::EventSink>()); | ||
1948 | 160 | }, std::runtime_error); | 165 | }, std::runtime_error); |
1949 | 161 | } | 166 | } |
1950 | 162 | 167 | ||
1951 | @@ -172,7 +177,9 @@ | |||
1952 | 172 | msh::Surface test( | 177 | msh::Surface test( |
1953 | 173 | mt::fake_shared(surface_builder), | 178 | mt::fake_shared(surface_builder), |
1954 | 174 | mf::a_surface(), | 179 | mf::a_surface(), |
1956 | 175 | null_input_channel); | 180 | null_input_channel, |
1957 | 181 | mf::SurfaceId(), | ||
1958 | 182 | std::shared_ptr<me::EventSink>()); | ||
1959 | 176 | 183 | ||
1960 | 177 | Mock::VerifyAndClearExpectations(&test); | 184 | Mock::VerifyAndClearExpectations(&test); |
1961 | 178 | EXPECT_CALL(surface_builder, destroy_surface(_)).Times(1); | 185 | EXPECT_CALL(surface_builder, destroy_surface(_)).Times(1); |
1962 | @@ -189,7 +196,9 @@ | |||
1963 | 189 | msh::Surface test( | 196 | msh::Surface test( |
1964 | 190 | mt::fake_shared(surface_builder), | 197 | mt::fake_shared(surface_builder), |
1965 | 191 | mf::a_surface(), | 198 | mf::a_surface(), |
1967 | 192 | null_input_channel); | 199 | null_input_channel, |
1968 | 200 | mf::SurfaceId(), | ||
1969 | 201 | std::shared_ptr<me::EventSink>()); | ||
1970 | 193 | 202 | ||
1971 | 194 | EXPECT_NO_THROW({ | 203 | EXPECT_NO_THROW({ |
1972 | 195 | test.client_buffer(); | 204 | test.client_buffer(); |
1973 | @@ -207,7 +216,9 @@ | |||
1974 | 207 | msh::Surface test( | 216 | msh::Surface test( |
1975 | 208 | mt::fake_shared(surface_builder), | 217 | mt::fake_shared(surface_builder), |
1976 | 209 | mf::a_surface(), | 218 | mf::a_surface(), |
1978 | 210 | null_input_channel); | 219 | null_input_channel, |
1979 | 220 | mf::SurfaceId(), | ||
1980 | 221 | std::shared_ptr<me::EventSink>()); | ||
1981 | 211 | 222 | ||
1982 | 212 | EXPECT_NO_THROW({ | 223 | EXPECT_NO_THROW({ |
1983 | 213 | test.size(); | 224 | test.size(); |
1984 | @@ -225,7 +236,9 @@ | |||
1985 | 225 | msh::Surface test( | 236 | msh::Surface test( |
1986 | 226 | mt::fake_shared(surface_builder), | 237 | mt::fake_shared(surface_builder), |
1987 | 227 | mf::a_surface(), | 238 | mf::a_surface(), |
1989 | 228 | null_input_channel); | 239 | null_input_channel, |
1990 | 240 | mf::SurfaceId(), | ||
1991 | 241 | std::shared_ptr<me::EventSink>()); | ||
1992 | 229 | 242 | ||
1993 | 230 | EXPECT_NO_THROW({ | 243 | EXPECT_NO_THROW({ |
1994 | 231 | test.name(); | 244 | test.name(); |
1995 | @@ -243,7 +256,9 @@ | |||
1996 | 243 | msh::Surface test( | 256 | msh::Surface test( |
1997 | 244 | mt::fake_shared(surface_builder), | 257 | mt::fake_shared(surface_builder), |
1998 | 245 | mf::a_surface(), | 258 | mf::a_surface(), |
2000 | 246 | null_input_channel); | 259 | null_input_channel, |
2001 | 260 | mf::SurfaceId(), | ||
2002 | 261 | std::shared_ptr<me::EventSink>()); | ||
2003 | 247 | 262 | ||
2004 | 248 | EXPECT_NO_THROW({ | 263 | EXPECT_NO_THROW({ |
2005 | 249 | test.pixel_format(); | 264 | test.pixel_format(); |
2006 | @@ -261,7 +276,9 @@ | |||
2007 | 261 | msh::Surface test( | 276 | msh::Surface test( |
2008 | 262 | mt::fake_shared(surface_builder), | 277 | mt::fake_shared(surface_builder), |
2009 | 263 | mf::a_surface(), | 278 | mf::a_surface(), |
2011 | 264 | null_input_channel); | 279 | null_input_channel, |
2012 | 280 | mf::SurfaceId(), | ||
2013 | 281 | std::shared_ptr<me::EventSink>()); | ||
2014 | 265 | 282 | ||
2015 | 266 | EXPECT_NO_THROW({ | 283 | EXPECT_NO_THROW({ |
2016 | 267 | test.hide(); | 284 | test.hide(); |
2017 | @@ -279,7 +296,9 @@ | |||
2018 | 279 | msh::Surface test( | 296 | msh::Surface test( |
2019 | 280 | mt::fake_shared(surface_builder), | 297 | mt::fake_shared(surface_builder), |
2020 | 281 | mf::a_surface(), | 298 | mf::a_surface(), |
2022 | 282 | null_input_channel); | 299 | null_input_channel, |
2023 | 300 | mf::SurfaceId(), | ||
2024 | 301 | std::shared_ptr<me::EventSink>()); | ||
2025 | 283 | 302 | ||
2026 | 284 | EXPECT_NO_THROW({ | 303 | EXPECT_NO_THROW({ |
2027 | 285 | test.show(); | 304 | test.show(); |
2028 | @@ -297,7 +316,9 @@ | |||
2029 | 297 | msh::Surface test( | 316 | msh::Surface test( |
2030 | 298 | mt::fake_shared(surface_builder), | 317 | mt::fake_shared(surface_builder), |
2031 | 299 | mf::a_surface(), | 318 | mf::a_surface(), |
2033 | 300 | null_input_channel); | 319 | null_input_channel, |
2034 | 320 | mf::SurfaceId(), | ||
2035 | 321 | std::shared_ptr<me::EventSink>()); | ||
2036 | 301 | 322 | ||
2037 | 302 | EXPECT_NO_THROW({ | 323 | EXPECT_NO_THROW({ |
2038 | 303 | test.destroy(); | 324 | test.destroy(); |
2039 | @@ -315,7 +336,9 @@ | |||
2040 | 315 | msh::Surface test( | 336 | msh::Surface test( |
2041 | 316 | mt::fake_shared(surface_builder), | 337 | mt::fake_shared(surface_builder), |
2042 | 317 | mf::a_surface(), | 338 | mf::a_surface(), |
2044 | 318 | null_input_channel); | 339 | null_input_channel, |
2045 | 340 | mf::SurfaceId(), | ||
2046 | 341 | std::shared_ptr<me::EventSink>()); | ||
2047 | 319 | 342 | ||
2048 | 320 | EXPECT_NO_THROW({ | 343 | EXPECT_NO_THROW({ |
2049 | 321 | test.force_requests_to_complete(); | 344 | test.force_requests_to_complete(); |
2050 | @@ -333,7 +356,9 @@ | |||
2051 | 333 | msh::Surface test( | 356 | msh::Surface test( |
2052 | 334 | mt::fake_shared(surface_builder), | 357 | mt::fake_shared(surface_builder), |
2053 | 335 | mf::a_surface(), | 358 | mf::a_surface(), |
2055 | 336 | null_input_channel); | 359 | null_input_channel, |
2056 | 360 | mf::SurfaceId(), | ||
2057 | 361 | std::shared_ptr<me::EventSink>()); | ||
2058 | 337 | 362 | ||
2059 | 338 | EXPECT_NO_THROW({ | 363 | EXPECT_NO_THROW({ |
2060 | 339 | test.advance_client_buffer(); | 364 | test.advance_client_buffer(); |
2061 | @@ -352,8 +377,19 @@ | |||
2062 | 352 | const int testing_client_fd = 17; | 377 | const int testing_client_fd = 17; |
2063 | 353 | 378 | ||
2064 | 354 | MockInputChannel mock_package; | 379 | MockInputChannel mock_package; |
2067 | 355 | msh::Surface proxy_surface(mt::fake_shared(surface_builder), mf::a_surface(), null_input_channel); | 380 | msh::Surface proxy_surface( |
2068 | 356 | msh::Surface input_proxy_surface(mt::fake_shared(surface_builder), mf::a_surface(), mt::fake_shared(mock_package)); | 381 | mt::fake_shared(surface_builder), |
2069 | 382 | mf::a_surface(), | ||
2070 | 383 | null_input_channel, | ||
2071 | 384 | mf::SurfaceId(), | ||
2072 | 385 | std::shared_ptr<me::EventSink>()); | ||
2073 | 386 | |||
2074 | 387 | msh::Surface input_proxy_surface( | ||
2075 | 388 | mt::fake_shared(surface_builder), | ||
2076 | 389 | mf::a_surface(), | ||
2077 | 390 | mt::fake_shared(mock_package), | ||
2078 | 391 | mf::SurfaceId(), | ||
2079 | 392 | std::shared_ptr<me::EventSink>()); | ||
2080 | 357 | 393 | ||
2081 | 358 | EXPECT_CALL(mock_package, client_fd()).Times(1).WillOnce(Return(testing_client_fd)); | 394 | EXPECT_CALL(mock_package, client_fd()).Times(1).WillOnce(Return(testing_client_fd)); |
2082 | 359 | 395 | ||
2083 | @@ -374,7 +410,9 @@ | |||
2084 | 374 | msh::Surface surf( | 410 | msh::Surface surf( |
2085 | 375 | mt::fake_shared(surface_builder), | 411 | mt::fake_shared(surface_builder), |
2086 | 376 | mf::a_surface(), | 412 | mf::a_surface(), |
2088 | 377 | null_input_channel); | 413 | null_input_channel, |
2089 | 414 | mf::SurfaceId(), | ||
2090 | 415 | std::shared_ptr<me::EventSink>()); | ||
2091 | 378 | 416 | ||
2092 | 379 | EXPECT_THROW({ | 417 | EXPECT_THROW({ |
2093 | 380 | surf.configure(static_cast<MirSurfaceAttrib>(111), 222); | 418 | surf.configure(static_cast<MirSurfaceAttrib>(111), 222); |
2094 | @@ -388,7 +426,9 @@ | |||
2095 | 388 | msh::Surface surf( | 426 | msh::Surface surf( |
2096 | 389 | mt::fake_shared(surface_builder), | 427 | mt::fake_shared(surface_builder), |
2097 | 390 | mf::a_surface(), | 428 | mf::a_surface(), |
2099 | 391 | null_input_channel); | 429 | null_input_channel, |
2100 | 430 | mf::SurfaceId(), | ||
2101 | 431 | std::shared_ptr<me::EventSink>()); | ||
2102 | 392 | 432 | ||
2103 | 393 | EXPECT_EQ(mir_surface_type_normal, surf.type()); | 433 | EXPECT_EQ(mir_surface_type_normal, surf.type()); |
2104 | 394 | 434 | ||
2105 | @@ -423,7 +463,9 @@ | |||
2106 | 423 | msh::Surface surf( | 463 | msh::Surface surf( |
2107 | 424 | mt::fake_shared(surface_builder), | 464 | mt::fake_shared(surface_builder), |
2108 | 425 | mf::a_surface(), | 465 | mf::a_surface(), |
2110 | 426 | null_input_channel); | 466 | null_input_channel, |
2111 | 467 | mf::SurfaceId(), | ||
2112 | 468 | std::shared_ptr<me::EventSink>()); | ||
2113 | 427 | 469 | ||
2114 | 428 | EXPECT_EQ(mir_surface_state_restored, surf.state()); | 470 | EXPECT_EQ(mir_surface_state_restored, surf.state()); |
2115 | 429 | 471 | ||
2116 | @@ -450,3 +492,4 @@ | |||
2117 | 450 | mir_surface_state_fullscreen)); | 492 | mir_surface_state_fullscreen)); |
2118 | 451 | EXPECT_EQ(mir_surface_state_fullscreen, surf.state()); | 493 | EXPECT_EQ(mir_surface_state_fullscreen, surf.state()); |
2119 | 452 | } | 494 | } |
2120 | 495 | |||
2121 | 453 | 496 | ||
2122 | === modified file 'tests/unit-tests/shell/test_the_session_container_implementation.cpp' | |||
2123 | --- tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-04-23 01:40:52 +0000 | |||
2124 | +++ tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-04-24 09:03:32 +0000 | |||
2125 | @@ -29,6 +29,7 @@ | |||
2126 | 29 | #include <gtest/gtest.h> | 29 | #include <gtest/gtest.h> |
2127 | 30 | #include <string> | 30 | #include <string> |
2128 | 31 | 31 | ||
2129 | 32 | namespace me = mir::events; | ||
2130 | 32 | namespace mf = mir::frontend; | 33 | namespace mf = mir::frontend; |
2131 | 33 | namespace msh = mir::shell; | 34 | namespace msh = mir::shell; |
2132 | 34 | namespace mtd = mir::test::doubles; | 35 | namespace mtd = mir::test::doubles; |
2133 | @@ -39,10 +40,8 @@ | |||
2134 | 39 | auto factory = std::make_shared<mtd::MockSurfaceFactory>(); | 40 | auto factory = std::make_shared<mtd::MockSurfaceFactory>(); |
2135 | 40 | msh::DefaultSessionContainer container; | 41 | msh::DefaultSessionContainer container; |
2136 | 41 | 42 | ||
2141 | 42 | container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), | 43 | container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), "Visual Studio 7", std::shared_ptr<me::EventSink>())); |
2142 | 43 | "Visual Studio 7")); | 44 | container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), "Visual Studio 8", std::shared_ptr<me::EventSink>())); |
2139 | 44 | container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), | ||
2140 | 45 | "Visual Studio 8")); | ||
2143 | 46 | 45 | ||
2144 | 47 | struct local | 46 | struct local |
2145 | 48 | { | 47 | { |
2146 | @@ -67,8 +66,11 @@ | |||
2147 | 67 | auto factory = std::make_shared<mtd::MockSurfaceFactory>(); | 66 | auto factory = std::make_shared<mtd::MockSurfaceFactory>(); |
2148 | 68 | msh::DefaultSessionContainer container; | 67 | msh::DefaultSessionContainer container; |
2149 | 69 | 68 | ||
2152 | 70 | auto session = std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), | 69 | auto session = std::make_shared<msh::ApplicationSession>( |
2153 | 71 | "Visual Studio 7"); | 70 | factory, |
2154 | 71 | std::make_shared<mtd::StubInputTargetListener>(), | ||
2155 | 72 | "Visual Studio 7", | ||
2156 | 73 | std::shared_ptr<me::EventSink>()); | ||
2157 | 72 | EXPECT_THROW({ | 74 | EXPECT_THROW({ |
2158 | 73 | container.remove_session(session); | 75 | container.remove_session(session); |
2159 | 74 | }, std::logic_error); | 76 | }, std::logic_error); |
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".