Mir

Merge lp:~alan-griffiths/mir/surface-states-simplification into lp:~mir-team/mir/trunk

Proposed by Alan Griffiths
Status: Merged
Approved by: Robert Ancell
Approved revision: no longer in the source branch.
Merged at revision: 636
Proposed branch: lp:~alan-griffiths/mir/surface-states-simplification
Merge into: lp:~mir-team/mir/trunk
Prerequisite: lp:~vanvugt/mir/surface-states
Diff against target: 1924 lines (+334/-253)
62 files modified
examples/demo-inprocess-egl/inprocess_egl_client.cpp (+1/-1)
include/server/mir/frontend/protobuf_ipc_factory.h (+4/-2)
include/server/mir/frontend/session.h (+0/-3)
include/server/mir/frontend/session_mediator.h (+5/-3)
include/server/mir/frontend/shell.h (+5/-2)
include/server/mir/shell/application_session.h (+11/-5)
include/server/mir/shell/organising_surface_factory.h (+4/-1)
include/server/mir/shell/session_manager.h (+1/-1)
include/server/mir/shell/surface.h (+13/-7)
include/server/mir/shell/surface_factory.h (+9/-1)
include/server/mir/shell/surface_source.h (+4/-1)
include/shared/mir/events/event_sink.h (+6/-5)
include/test/mir_test_doubles/mock_session.h (+0/-2)
include/test/mir_test_doubles/mock_shell.h (+1/-1)
include/test/mir_test_doubles/mock_surface_factory.h (+4/-1)
include/test/mir_test_doubles/stub_ipc_factory.h (+1/-1)
include/test/mir_test_doubles/stub_session.h (+1/-1)
include/test/mir_test_doubles/stub_shell.h (+1/-1)
src/client/make_rpc_channel.h (+2/-2)
src/client/make_socket_rpc_channel.cpp (+1/-1)
src/client/mir_basic_rpc_channel.cpp (+1/-3)
src/client/mir_basic_rpc_channel.h (+6/-0)
src/client/mir_client_library.cpp (+9/-13)
src/client/mir_connection.cpp (+2/-1)
src/client/mir_connection.h (+5/-4)
src/client/mir_socket_rpc_channel.cpp (+32/-33)
src/client/mir_socket_rpc_channel.h (+4/-4)
src/server/CMakeLists.txt (+0/-1)
src/server/default_server_configuration.cpp (+2/-1)
src/server/frontend/CMakeLists.txt (+1/-0)
src/server/frontend/event_pipe.cpp (+6/-7)
src/server/frontend/event_pipe.h (+12/-10)
src/server/frontend/protobuf_message_processor.cpp (+3/-1)
src/server/frontend/protobuf_message_processor.h (+2/-2)
src/server/frontend/protobuf_socket_communicator.cpp (+4/-5)
src/server/frontend/session_mediator.cpp (+2/-3)
src/server/shell/application_session.cpp (+14/-12)
src/server/shell/organising_surface_factory.cpp (+5/-2)
src/server/shell/session_manager.cpp (+4/-2)
src/server/shell/surface.cpp (+19/-12)
src/server/shell/surface_source.cpp (+7/-2)
src/shared/protobuf/mir_protobuf_wire.proto (+3/-1)
tests/acceptance-tests/test_focus_management_api.cpp (+4/-4)
tests/behavior-tests/session_management_context.cpp (+8/-4)
tests/integration-tests/cucumber/test_session_management_context.cpp (+3/-3)
tests/integration-tests/shell/test_session_manager.cpp (+8/-7)
tests/unit-tests/CMakeLists.txt (+0/-1)
tests/unit-tests/client/test_client_mir_surface.cpp (+1/-1)
tests/unit-tests/client/test_mir_connection.cpp (+3/-1)
tests/unit-tests/event/CMakeLists.txt (+0/-5)
tests/unit-tests/frontend/CMakeLists.txt (+1/-0)
tests/unit-tests/frontend/test_event_pipe.cpp (+14/-11)
tests/unit-tests/frontend/test_session_mediator.cpp (+9/-5)
tests/unit-tests/frontend/test_session_mediator_android.cpp (+9/-3)
tests/unit-tests/frontend/test_session_mediator_gbm.cpp (+9/-3)
tests/unit-tests/shell/test_application_session.cpp (+10/-9)
tests/unit-tests/shell/test_organising_surface_factory.cpp (+6/-5)
tests/unit-tests/shell/test_registration_order_focus_sequence.cpp (+11/-10)
tests/unit-tests/shell/test_session_manager.cpp (+16/-15)
tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp (+0/-1)
tests/unit-tests/shell/test_surface.cpp (+2/-0)
tests/unit-tests/shell/test_the_session_container_implementation.cpp (+3/-4)
To merge this branch: bzr merge lp:~alan-griffiths/mir/surface-states-simplification
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Chris Halse Rogers Approve
Robert Ancell Approve
Kevin DuBois (community) Approve
Daniel van Vugt Pending
Review via email: mp+160583@code.launchpad.net

This proposal supersedes a proposal from 2013-04-23.

Commit message

frontend, shell, tests: surface-states updated to avoid supplying dependencies through public member functions.

Description of the change

frontend, shell, tests: surface-states updated to avoid supplying dependencies through public member functions.

Where possible, dependencies should be supplied as constructor arguments and held as const members.

(This required updates to a few factory interfaces to supply the dependencies.)

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Firstly, needs fixing:
Text conflict in tests/unit-tests/shell/test_application_session.cpp
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".

review: Disapprove
Revision history for this message
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).

Revision history for this message
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://code.launchpad.net/~vanvugt/mir/surface-states/+merge/158289/comments/348068

Revision history for this message
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.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> Firstly, needs fixing:
> Text conflict in tests/unit-tests/shell/test_application_session.cpp
> 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::set_event_sink().

> 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.

Revision history for this message
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.

Revision history for this message
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_change/set_id, set_id() is a dependency that has to be called before notify_change() is called, so the id may as well be in the constructor. Another possibility (if we really don't want any more construction parameters for Surface) is to have another object with expanded functionality that takes

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.

Revision history for this message
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.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal

might be the first time there's been 2 rival reviews going on ;-)

again, seems the biggest point of contention is about 2 phase initialization and what has more or less coupling. maybe a new day will let me rephrase a bit better. :) Seems to me that (for example) in msh::Surface msh::Surface's notify_change function is coupled to having the ID, so whether you put it in the constructor or require a set_ function to be called, both depend on having an id to use notify_change() in a way. I'd rather come down on the side of putting it all dependencies in the constructor, because it allows us to see pretty quickly what a class needs, and gives us an easy-to-read signal about if a class is doing too much and needs to refactor. So, msh::Shell, might just be on the point of needing a refactor. (if its constructor is getting "too bloated" of course)

I know we had a debate similar to this one at an earlier point in the project, I hope we have another one next week :)

Revision history for this message
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal

This doesn't immediately *look* like a simplification to me.

My understanding is that this is a simplification for clients of this code - ie: consumers of this class no longer have to check if the EventSink or SurfaceID is set.

My question is then - do consumers of this class need to check if the EventSink or SurfaceID is set currently? It looks like consumers of this class generally won't care - if they configure() a surface which doesn't have an EventSink set then nothing will get the event but everything else will work as expected?

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

From a high-level perspective I can see two problems here:

1. It's 1000 lines bigger than my proposal. Even if you agree that's not a simplification, but for other purposes, then I think it's still a bit much to review all in one go.

2. This does not solve the problem of code I disagree with ending up in a commit with my name on it. Because once merged it would just show one commit with both our names as authors.

To keep code reviews smaller and simpler, please propose your changes separately (after) surface-states to lp:mir. I won't agree with them, but I won't block them there either.

review: Needs Resubmitting
Revision history for this message
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.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

If you resubmit and prerequisite the surface-states branch, I will close my eyes and happily Abstain.

review: Needs Resubmitting
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> My question is then - do consumers of this class need to check if the
> EventSink or SurfaceID is set currently? It looks like consumers of this class
> generally won't care - if they configure() a surface which doesn't have an
> EventSink set then nothing will get the event but everything else will work as
> expected?

On this point is that consumers shouldn't even know about them - they shouldn't see these functions in the interface they use (i.e. they don't belong in frontend::Surface). Unnecessarily exposing these functions *is* increasing coupling.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

"So, msh::Shell, might just be on the point of needing a refactor. (if its constructor is getting "too bloated" of course"

I assume that means msh::Surface?

I too have questioned in the past whether some of the attributes currently being added to shell::Surface are best modeled as member variables. (As opposed to say, their being an event filter that has an associative map from surface to event sink.)

This proposal doesn't address this question.

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

looks good to me, although a good future improvement might be to consolidate ApplicationSession's constructor

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

It's still not clear to me that this is a simplification, but there's nothing objectionable in here.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/demo-inprocess-egl/inprocess_egl_client.cpp'
--- examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-04-24 05:22:20 +0000
+++ examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-04-25 09:50:50 +0000
@@ -60,7 +60,7 @@
60 .of_size(surface_size)60 .of_size(surface_size)
61 .of_buffer_usage(mc::BufferUsage::hardware)61 .of_buffer_usage(mc::BufferUsage::hardware)
62 .of_pixel_format(geom::PixelFormat::argb_8888);62 .of_pixel_format(geom::PixelFormat::argb_8888);
63 auto surface = surface_factory->create_surface(params);63 auto surface = surface_factory->create_surface(params, mf::SurfaceId(), std::shared_ptr<events::EventSink>());
6464
65 surface->advance_client_buffer(); // TODO: What a wart!65 surface->advance_client_buffer(); // TODO: What a wart!
6666
6767
=== modified file 'include/server/mir/frontend/protobuf_ipc_factory.h'
--- include/server/mir/frontend/protobuf_ipc_factory.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/frontend/protobuf_ipc_factory.h 2013-04-25 09:50:50 +0000
@@ -23,8 +23,10 @@
2323
24namespace mir24namespace mir
25{25{
26namespace events
27{
26class EventSink;28class EventSink;
2729}
28namespace protobuf30namespace protobuf
29{31{
30class DisplayServer;32class DisplayServer;
@@ -38,7 +40,7 @@
38{40{
39public:41public:
40 virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server(42 virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server(
41 std::shared_ptr<EventSink> const& sink) = 0;43 std::shared_ptr<events::EventSink> const& sink) = 0;
42 virtual std::shared_ptr<ResourceCache> resource_cache() = 0;44 virtual std::shared_ptr<ResourceCache> resource_cache() = 0;
43 virtual std::shared_ptr<MessageProcessorReport> report() = 0;45 virtual std::shared_ptr<MessageProcessorReport> report() = 0;
4446
4547
=== modified file 'include/server/mir/frontend/session.h'
--- include/server/mir/frontend/session.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/frontend/session.h 2013-04-25 09:50:50 +0000
@@ -29,7 +29,6 @@
2929
30namespace mir30namespace mir
31{31{
32class EventSink;
3332
34namespace frontend33namespace frontend
35{34{
@@ -52,8 +51,6 @@
5251
53 virtual int configure_surface(SurfaceId id, MirSurfaceAttrib attrib, int value) = 0;52 virtual int configure_surface(SurfaceId id, MirSurfaceAttrib attrib, int value) = 0;
5453
55 virtual void set_event_sink(std::shared_ptr<EventSink> const&) = 0;
56
57protected:54protected:
58 Session() = default;55 Session() = default;
59 Session(Session const&) = delete;56 Session(Session const&) = delete;
6057
=== modified file 'include/server/mir/frontend/session_mediator.h'
--- include/server/mir/frontend/session_mediator.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/frontend/session_mediator.h 2013-04-25 09:50:50 +0000
@@ -27,8 +27,10 @@
2727
28namespace mir28namespace mir
29{29{
30namespace events
31{
30class EventSink;32class EventSink;
3133}
32namespace graphics34namespace graphics
33{35{
34class Platform;36class Platform;
@@ -62,7 +64,7 @@
62 std::shared_ptr<graphics::ViewableArea> const& viewable_area,64 std::shared_ptr<graphics::ViewableArea> const& viewable_area,
63 std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator,65 std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator,
64 std::shared_ptr<SessionMediatorReport> const& report,66 std::shared_ptr<SessionMediatorReport> const& report,
65 std::shared_ptr<EventSink> const& event_sink,67 std::shared_ptr<events::EventSink> const& event_sink,
66 std::shared_ptr<ResourceCache> const& resource_cache);68 std::shared_ptr<ResourceCache> const& resource_cache);
6769
68 /* Platform independent requests */70 /* Platform independent requests */
@@ -119,7 +121,7 @@
119 std::shared_ptr<compositor::GraphicBufferAllocator> const buffer_allocator;121 std::shared_ptr<compositor::GraphicBufferAllocator> const buffer_allocator;
120122
121 std::shared_ptr<SessionMediatorReport> const report;123 std::shared_ptr<SessionMediatorReport> const report;
122 std::shared_ptr<EventSink> const event_sink;124 std::shared_ptr<events::EventSink> const event_sink;
123 std::shared_ptr<ResourceCache> const resource_cache;125 std::shared_ptr<ResourceCache> const resource_cache;
124 std::shared_ptr<ClientBufferTracker> const client_tracker;126 std::shared_ptr<ClientBufferTracker> const client_tracker;
125127
126128
=== modified file 'include/server/mir/frontend/shell.h'
--- include/server/mir/frontend/shell.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/frontend/shell.h 2013-04-25 09:50:50 +0000
@@ -24,7 +24,10 @@
2424
25namespace mir25namespace mir
26{26{
2727namespace events
28{
29class EventSink;
30}
28namespace frontend31namespace frontend
29{32{
30class Session;33class Session;
@@ -35,7 +38,7 @@
35public:38public:
36 virtual ~Shell() {}39 virtual ~Shell() {}
3740
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;
39 virtual void close_session(std::shared_ptr<Session> const& session) = 0;42 virtual void close_session(std::shared_ptr<Session> const& session) = 0;
4043
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;
4245
=== modified file 'include/server/mir/shell/application_session.h'
--- include/server/mir/shell/application_session.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/shell/application_session.h 2013-04-25 09:50:50 +0000
@@ -25,8 +25,10 @@
2525
26namespace mir26namespace mir
27{27{
28namespace events
29{
28class EventSink;30class EventSink;
2931}
30namespace shell32namespace shell
31{33{
32class SurfaceFactory;34class SurfaceFactory;
@@ -38,6 +40,13 @@
38public:40public:
39 explicit ApplicationSession(std::shared_ptr<SurfaceFactory> const& surface_factory, 41 explicit ApplicationSession(std::shared_ptr<SurfaceFactory> const& surface_factory,
40 std::shared_ptr<InputTargetListener> const& input_target_listener, std::string const& session_name);42 std::shared_ptr<InputTargetListener> const& input_target_listener, std::string const& session_name);
43
44 ApplicationSession(
45 std::shared_ptr<SurfaceFactory> const& surface_factory,
46 std::shared_ptr<InputTargetListener> const& input_target_listener,
47 std::string const& session_name,
48 std::shared_ptr<events::EventSink> const& sink);
49
41 ~ApplicationSession();50 ~ApplicationSession();
4251
43 frontend::SurfaceId create_surface(frontend::SurfaceCreationParameters const& params);52 frontend::SurfaceId create_surface(frontend::SurfaceCreationParameters const& params);
@@ -55,8 +64,6 @@
5564
56 int configure_surface(frontend::SurfaceId id, MirSurfaceAttrib attrib, int value);65 int configure_surface(frontend::SurfaceId id, MirSurfaceAttrib attrib, int value);
5766
58 void set_event_sink(std::shared_ptr<mir::EventSink> const& sink);
59
60protected:67protected:
61 ApplicationSession(ApplicationSession const&) = delete;68 ApplicationSession(ApplicationSession const&) = delete;
62 ApplicationSession& operator=(ApplicationSession const&) = delete;69 ApplicationSession& operator=(ApplicationSession const&) = delete;
@@ -65,6 +72,7 @@
65 std::shared_ptr<SurfaceFactory> const surface_factory;72 std::shared_ptr<SurfaceFactory> const surface_factory;
66 std::shared_ptr<InputTargetListener> const input_target_listener;73 std::shared_ptr<InputTargetListener> const input_target_listener;
67 std::string const session_name;74 std::string const session_name;
75 std::shared_ptr<events::EventSink> const event_sink;
6876
69 frontend::SurfaceId next_id();77 frontend::SurfaceId next_id();
7078
@@ -74,8 +82,6 @@
74 Surfaces::const_iterator checked_find(frontend::SurfaceId id) const;82 Surfaces::const_iterator checked_find(frontend::SurfaceId id) const;
75 std::mutex mutable surfaces_mutex;83 std::mutex mutable surfaces_mutex;
76 Surfaces surfaces;84 Surfaces surfaces;
77
78 std::shared_ptr<EventSink> event_sink;
79};85};
8086
81}87}
8288
=== modified file 'include/server/mir/shell/organising_surface_factory.h'
--- include/server/mir/shell/organising_surface_factory.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/shell/organising_surface_factory.h 2013-04-25 09:50:50 +0000
@@ -36,7 +36,10 @@
36 std::shared_ptr<PlacementStrategy> const& placement_strategy);36 std::shared_ptr<PlacementStrategy> const& placement_strategy);
37 virtual ~OrganisingSurfaceFactory();37 virtual ~OrganisingSurfaceFactory();
3838
39 std::shared_ptr<Surface> create_surface(frontend::SurfaceCreationParameters const& params);39 std::shared_ptr<Surface> create_surface(
40 frontend::SurfaceCreationParameters const& params,
41 frontend::SurfaceId id,
42 std::shared_ptr<events::EventSink> const& sink) override;
4043
41protected:44protected:
42 OrganisingSurfaceFactory(OrganisingSurfaceFactory const&) = delete;45 OrganisingSurfaceFactory(OrganisingSurfaceFactory const&) = delete;
4346
=== modified file 'include/server/mir/shell/session_manager.h'
--- include/server/mir/shell/session_manager.h 2013-04-24 22:14:08 +0000
+++ include/server/mir/shell/session_manager.h 2013-04-25 09:50:50 +0000
@@ -54,7 +54,7 @@
54 std::shared_ptr<InputTargetListener> const& input_target_listener);54 std::shared_ptr<InputTargetListener> const& input_target_listener);
55 virtual ~SessionManager();55 virtual ~SessionManager();
5656
57 virtual std::shared_ptr<frontend::Session> open_session(std::string const& name);57 virtual std::shared_ptr<frontend::Session> open_session(std::string const& name, std::shared_ptr<events::EventSink> const& sink);
58 virtual void close_session(std::shared_ptr<frontend::Session> const& session);58 virtual void close_session(std::shared_ptr<frontend::Session> const& session);
5959
60 virtual void tag_session_with_lightdm_id(std::shared_ptr<frontend::Session> const& session, int id);60 virtual void tag_session_with_lightdm_id(std::shared_ptr<frontend::Session> const& session, int id);
6161
=== modified file 'include/server/mir/shell/surface.h'
--- include/server/mir/shell/surface.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/shell/surface.h 2013-04-25 09:50:50 +0000
@@ -31,9 +31,10 @@
3131
32namespace mir32namespace mir
33{33{
3434namespace events
35{
35class EventSink;36class EventSink;
3637}
37namespace frontend38namespace frontend
38{39{
39struct SurfaceCreationParameters;40struct SurfaceCreationParameters;
@@ -54,6 +55,14 @@
54 std::shared_ptr<SurfaceBuilder> const& builder,55 std::shared_ptr<SurfaceBuilder> const& builder,
55 frontend::SurfaceCreationParameters const& params,56 frontend::SurfaceCreationParameters const& params,
56 std::shared_ptr<input::InputChannel> const& input_channel);57 std::shared_ptr<input::InputChannel> const& input_channel);
58
59 Surface(
60 std::shared_ptr<SurfaceBuilder> const& builder,
61 frontend::SurfaceCreationParameters const& params,
62 std::shared_ptr<input::InputChannel> const& input_channel,
63 frontend::SurfaceId id,
64 std::shared_ptr<events::EventSink> const& sink);
65
57 ~Surface();66 ~Surface();
5867
59 virtual void hide();68 virtual void hide();
@@ -82,9 +91,6 @@
82 virtual MirSurfaceType type() const;91 virtual MirSurfaceType type() const;
83 virtual MirSurfaceState state() const;92 virtual MirSurfaceState state() const;
8493
85 void set_id(frontend::SurfaceId i);
86 void set_event_target(std::shared_ptr<EventSink> const& sink);
87
88private:94private:
89 bool set_type(MirSurfaceType t); // Use configure() to make public changes95 bool set_type(MirSurfaceType t); // Use configure() to make public changes
90 bool set_state(MirSurfaceState s);96 bool set_state(MirSurfaceState s);
@@ -94,8 +100,8 @@
94 std::shared_ptr<mir::input::InputChannel> const input_channel;100 std::shared_ptr<mir::input::InputChannel> const input_channel;
95 std::weak_ptr<mir::surfaces::Surface> const surface;101 std::weak_ptr<mir::surfaces::Surface> const surface;
96102
97 std::shared_ptr<EventSink> event_sink;103 frontend::SurfaceId const id;
98 frontend::SurfaceId id;104 std::shared_ptr<events::EventSink> const event_sink;
99105
100 MirSurfaceType type_value;106 MirSurfaceType type_value;
101 MirSurfaceState state_value;107 MirSurfaceState state_value;
102108
=== modified file 'include/server/mir/shell/surface_factory.h'
--- include/server/mir/shell/surface_factory.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/shell/surface_factory.h 2013-04-25 09:50:50 +0000
@@ -19,10 +19,15 @@
19#ifndef MIR_SHELL_SURFACE_FACTORY_H_19#ifndef MIR_SHELL_SURFACE_FACTORY_H_
20#define MIR_SHELL_SURFACE_FACTORY_H_20#define MIR_SHELL_SURFACE_FACTORY_H_
2121
22#include "mir/frontend/surface_id.h"
22#include <memory>23#include <memory>
2324
24namespace mir25namespace mir
25{26{
27namespace events
28{
29class EventSink;
30}
26namespace frontend31namespace frontend
27{32{
28struct SurfaceCreationParameters;33struct SurfaceCreationParameters;
@@ -34,7 +39,10 @@
34class SurfaceFactory39class SurfaceFactory
35{40{
36public:41public:
37 virtual std::shared_ptr<Surface> create_surface(const frontend::SurfaceCreationParameters& params) = 0;42 virtual std::shared_ptr<Surface> create_surface(
43 frontend::SurfaceCreationParameters const& params,
44 frontend::SurfaceId id,
45 std::shared_ptr<events::EventSink> const& sink) = 0;
3846
39protected:47protected:
40 virtual ~SurfaceFactory() {}48 virtual ~SurfaceFactory() {}
4149
=== modified file 'include/server/mir/shell/surface_source.h'
--- include/server/mir/shell/surface_source.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/shell/surface_source.h 2013-04-25 09:50:50 +0000
@@ -40,7 +40,10 @@
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);
41 virtual ~SurfaceSource() {}41 virtual ~SurfaceSource() {}
4242
43 std::shared_ptr<Surface> create_surface(const frontend::SurfaceCreationParameters& params);43 std::shared_ptr<Surface> create_surface(
44 frontend::SurfaceCreationParameters const& params,
45 frontend::SurfaceId id,
46 std::shared_ptr<events::EventSink> const& sink);
4447
45protected:48protected:
46 SurfaceSource(const SurfaceSource&) = delete;49 SurfaceSource(const SurfaceSource&) = delete;
4750
=== added directory 'include/shared/mir/events'
=== renamed file 'include/shared/mir/event_sink.h' => 'include/shared/mir/events/event_sink.h'
--- include/shared/mir/event_sink.h 2013-04-19 04:33:51 +0000
+++ include/shared/mir/events/event_sink.h 2013-04-25 09:50:50 +0000
@@ -16,13 +16,15 @@
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */17 */
1818
19#ifndef MIR_EVENT_SINK_H_19#ifndef MIR_EVENTS_EVENT_SINK_H_
20#define MIR_EVENT_SINK_H_20#define MIR_EVENTS_EVENT_SINK_H_
2121
22#include "mir_toolkit/event.h"22#include "mir_toolkit/event.h"
2323
24namespace mir24namespace mir
25{25{
26namespace events
27{
2628
27class EventSink29class EventSink
28{30{
@@ -36,8 +38,7 @@
36 EventSink(EventSink const&) = delete;38 EventSink(EventSink const&) = delete;
37 EventSink& operator=(EventSink const&) = delete;39 EventSink& operator=(EventSink const&) = delete;
38};40};
3941}
40} // namespace mir42} // namespace mir
4143
42#endif44#endif // MIR_EVENTS_EVENT_SINK_H_
43
4445
=== modified file 'include/test/mir_test_doubles/mock_session.h'
--- include/test/mir_test_doubles/mock_session.h 2013-04-24 05:22:20 +0000
+++ include/test/mir_test_doubles/mock_session.h 2013-04-25 09:50:50 +0000
@@ -43,8 +43,6 @@
43 MOCK_METHOD0(show, void());43 MOCK_METHOD0(show, void());
4444
45 MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int));45 MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int));
46
47 MOCK_METHOD1(set_event_sink, void(std::shared_ptr<mir::EventSink> const&));
48};46};
4947
50}48}
5149
=== modified file 'include/test/mir_test_doubles/mock_shell.h'
--- include/test/mir_test_doubles/mock_shell.h 2013-04-24 05:22:20 +0000
+++ include/test/mir_test_doubles/mock_shell.h 2013-04-25 09:50:50 +0000
@@ -34,7 +34,7 @@
3434
35struct MockShell : public frontend::Shell35struct MockShell : public frontend::Shell
36{36{
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&));
38 MOCK_METHOD1(close_session, void(std::shared_ptr<frontend::Session> const&));38 MOCK_METHOD1(close_session, void(std::shared_ptr<frontend::Session> const&));
3939
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));
4141
=== modified file 'include/test/mir_test_doubles/mock_surface_factory.h'
--- include/test/mir_test_doubles/mock_surface_factory.h 2013-04-24 05:22:20 +0000
+++ include/test/mir_test_doubles/mock_surface_factory.h 2013-04-25 09:50:50 +0000
@@ -33,7 +33,10 @@
3333
34struct MockSurfaceFactory : public shell::SurfaceFactory34struct MockSurfaceFactory : public shell::SurfaceFactory
35{35{
36 MOCK_METHOD1(create_surface, std::shared_ptr<shell::Surface>(const frontend::SurfaceCreationParameters&));36 MOCK_METHOD3(create_surface, std::shared_ptr<shell::Surface>(
37 const frontend::SurfaceCreationParameters&,
38 frontend::SurfaceId,
39 std::shared_ptr<events::EventSink> const&));
37};40};
3841
39}42}
4043
=== modified file 'include/test/mir_test_doubles/stub_ipc_factory.h'
--- include/test/mir_test_doubles/stub_ipc_factory.h 2013-04-24 05:22:20 +0000
+++ include/test/mir_test_doubles/stub_ipc_factory.h 2013-04-25 09:50:50 +0000
@@ -42,7 +42,7 @@
42 }42 }
4343
44 std::shared_ptr<protobuf::DisplayServer> make_ipc_server(44 std::shared_ptr<protobuf::DisplayServer> make_ipc_server(
45 std::shared_ptr<EventSink> const&)45 std::shared_ptr<events::EventSink> const&)
46 {46 {
47 return server;47 return server;
48 }48 }
4949
=== modified file 'include/test/mir_test_doubles/stub_session.h'
--- include/test/mir_test_doubles/stub_session.h 2013-04-24 05:22:20 +0000
+++ include/test/mir_test_doubles/stub_session.h 2013-04-25 09:50:50 +0000
@@ -58,7 +58,7 @@
58 {58 {
59 return 0;59 return 0;
60 }60 }
61 void set_event_sink(std::shared_ptr<EventSink> const&)61 void set_event_sink(std::shared_ptr<events::EventSink> const&)
62 {62 {
63 }63 }
64};64};
6565
=== modified file 'include/test/mir_test_doubles/stub_shell.h'
--- include/test/mir_test_doubles/stub_shell.h 2013-04-24 05:22:20 +0000
+++ include/test/mir_test_doubles/stub_shell.h 2013-04-25 09:50:50 +0000
@@ -31,7 +31,7 @@
3131
32class StubShell : public frontend::Shell32class StubShell : public frontend::Shell
33{33{
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 */)
35 {35 {
36 return std::make_shared<StubSession>();36 return std::make_shared<StubSession>();
37 }37 }
3838
=== modified file 'src/client/make_rpc_channel.h'
--- src/client/make_rpc_channel.h 2013-04-24 05:22:20 +0000
+++ src/client/make_rpc_channel.h 2013-04-25 09:50:50 +0000
@@ -19,7 +19,7 @@
19#define MIR_CLIENT_MAKE_RPC_CHANNEL_H_19#define MIR_CLIENT_MAKE_RPC_CHANNEL_H_
2020
21#include <memory>21#include <memory>
22#include "mir_protobuf.pb.h"22#include "mir_basic_rpc_channel.h"
2323
24namespace mir24namespace mir
25{25{
@@ -27,7 +27,7 @@
27{27{
28class Logger;28class Logger;
2929
30std::shared_ptr<google::protobuf::RpcChannel>30std::shared_ptr<MirBasicRpcChannel>
31make_rpc_channel(std::string const& name, std::shared_ptr<Logger> const& log);31make_rpc_channel(std::string const& name, std::shared_ptr<Logger> const& log);
32}32}
33}33}
3434
=== modified file 'src/client/make_socket_rpc_channel.cpp'
--- src/client/make_socket_rpc_channel.cpp 2013-04-24 05:22:20 +0000
+++ src/client/make_socket_rpc_channel.cpp 2013-04-25 09:50:50 +0000
@@ -21,7 +21,7 @@
2121
22namespace mcl = mir::client;22namespace mcl = mir::client;
2323
24std::shared_ptr<google::protobuf::RpcChannel>24std::shared_ptr<mcl::MirBasicRpcChannel>
25mcl::make_rpc_channel(std::string const& name, std::shared_ptr<Logger> const& log)25mcl::make_rpc_channel(std::string const& name, std::shared_ptr<Logger> const& log)
26{26{
27 return std::make_shared<MirSocketRpcChannel>(name, log);27 return std::make_shared<MirSocketRpcChannel>(name, log);
2828
=== modified file 'src/client/mir_basic_rpc_channel.cpp'
--- src/client/mir_basic_rpc_channel.cpp 2013-04-24 05:22:20 +0000
+++ src/client/mir_basic_rpc_channel.cpp 2013-04-25 09:50:50 +0000
@@ -100,7 +100,5 @@
100100
101int mcl::MirBasicRpcChannel::next_id()101int mcl::MirBasicRpcChannel::next_id()
102{102{
103 int id = next_message_id.load();103 return next_message_id.fetch_add(1);
104 while (!next_message_id.compare_exchange_weak(id, id + 1)) std::this_thread::yield();
105 return id;
106}104}
107105
=== modified file 'src/client/mir_basic_rpc_channel.h'
--- src/client/mir_basic_rpc_channel.h 2013-04-24 05:22:20 +0000
+++ src/client/mir_basic_rpc_channel.h 2013-04-25 09:50:50 +0000
@@ -33,6 +33,10 @@
3333
34namespace mir34namespace mir
35{35{
36namespace events
37{
38class EventSink;
39}
36namespace protobuf40namespace protobuf
37{41{
38namespace wire42namespace wire
@@ -92,6 +96,8 @@
92 MirBasicRpcChannel();96 MirBasicRpcChannel();
93 ~MirBasicRpcChannel();97 ~MirBasicRpcChannel();
9498
99 virtual void set_event_handler(events::EventSink *sink) = 0;
100
95protected:101protected:
96 mir::protobuf::wire::Invocation invocation_for(const google::protobuf::MethodDescriptor* method,102 mir::protobuf::wire::Invocation invocation_for(const google::protobuf::MethodDescriptor* method,
97 const google::protobuf::Message* request);103 const google::protobuf::Message* request);
98104
=== modified file 'src/client/mir_client_library.cpp'
--- src/client/mir_client_library.cpp 2013-04-24 05:22:20 +0000
+++ src/client/mir_client_library.cpp 2013-04-25 09:50:50 +0000
@@ -26,7 +26,7 @@
26#include "native_client_platform_factory.h"26#include "native_client_platform_factory.h"
27#include "egl_native_display_container.h"27#include "egl_native_display_container.h"
28#include "mir_logger.h"28#include "mir_logger.h"
29#include "mir_socket_rpc_channel.h"29#include "make_rpc_channel.h"
3030
31#include <set>31#include <set>
32#include <unordered_set>32#include <unordered_set>
@@ -60,12 +60,10 @@
60 auto log = std::make_shared<mcl::ConsoleLogger>();60 auto log = std::make_shared<mcl::ConsoleLogger>();
61 auto client_platform_factory = std::make_shared<mcl::NativeClientPlatformFactory>();61 auto client_platform_factory = std::make_shared<mcl::NativeClientPlatformFactory>();
6262
63 auto rpc = std::make_shared<mcl::MirSocketRpcChannel>(sock, log);63 MirConnection* connection = new MirConnection(
6464 mcl::make_rpc_channel(sock, log),
65 MirConnection* connection = new MirConnection(rpc, log,65 log,
66 client_platform_factory);66 client_platform_factory);
67
68 rpc->set_event_handler(connection);
6967
70 return connection->connect(name, callback, context);68 return connection->connect(name, callback, context);
71 }69 }
@@ -258,12 +256,10 @@
258 auto log = std::make_shared<mcl::ConsoleLogger>();256 auto log = std::make_shared<mcl::ConsoleLogger>();
259 auto client_platform_factory = std::make_shared<mcl::NativeClientPlatformFactory>();257 auto client_platform_factory = std::make_shared<mcl::NativeClientPlatformFactory>();
260258
261 auto rpc = std::make_shared<mcl::MirSocketRpcChannel>(server, log);259 MirConnection* connection = new MirConnection(
262260 mcl::make_rpc_channel(server, log),
263 MirConnection* connection = new MirConnection(rpc, log,261 log,
264 client_platform_factory);262 client_platform_factory);
265
266 rpc->set_event_handler(connection);
267263
268 return connection->connect(lightdm_id, app_name, callback, client_context);264 return connection->connect(lightdm_id, app_name, callback, client_context);
269}265}
270266
=== modified file 'src/client/mir_connection.cpp'
--- src/client/mir_connection.cpp 2013-04-24 05:22:20 +0000
+++ src/client/mir_connection.cpp 2013-04-25 09:50:50 +0000
@@ -43,7 +43,7 @@
43}43}
4444
45MirConnection::MirConnection(45MirConnection::MirConnection(
46 std::shared_ptr<google::protobuf::RpcChannel> const& channel,46 std::shared_ptr<mir::client::MirBasicRpcChannel> const& channel,
47 std::shared_ptr<mcl::Logger> const & log,47 std::shared_ptr<mcl::Logger> const & log,
48 std::shared_ptr<mcl::ClientPlatformFactory> const& client_platform_factory) :48 std::shared_ptr<mcl::ClientPlatformFactory> const& client_platform_factory) :
49 channel(channel),49 channel(channel),
@@ -52,6 +52,7 @@
52 client_platform_factory(client_platform_factory),52 client_platform_factory(client_platform_factory),
53 input_platform(mcli::InputPlatform::create())53 input_platform(mcli::InputPlatform::create())
54{54{
55 channel->set_event_handler(this);
55 {56 {
56 std::lock_guard<std::mutex> lock(connection_guard);57 std::lock_guard<std::mutex> lock(connection_guard);
57 valid_connections.insert(this);58 valid_connections.insert(this);
5859
=== modified file 'src/client/mir_connection.h'
--- src/client/mir_connection.h 2013-04-24 05:22:20 +0000
+++ src/client/mir_connection.h 2013-04-25 09:50:50 +0000
@@ -34,7 +34,7 @@
34#include "client_context.h"34#include "client_context.h"
3535
36#include "mir_wait_handle.h"36#include "mir_wait_handle.h"
37#include "mir/event_sink.h"37#include "mir/events/event_sink.h"
3838
39namespace mir39namespace mir
40{40{
@@ -44,6 +44,8 @@
44class Logger;44class Logger;
45class ClientBufferDepository;45class ClientBufferDepository;
46class ClientPlatformFactory;46class ClientPlatformFactory;
47class MirBasicRpcChannel;
48
47namespace input49namespace input
48{50{
49class InputPlatform;51class InputPlatform;
@@ -51,13 +53,12 @@
51}53}
52}54}
5355
54struct MirConnection : public mir::client::ClientContext,56struct MirConnection : mir::client::ClientContext, private mir::events::EventSink
55 public mir::EventSink
56{57{
57public:58public:
58 MirConnection();59 MirConnection();
5960
60 MirConnection(std::shared_ptr<google::protobuf::RpcChannel> const& channel,61 MirConnection(std::shared_ptr<mir::client::MirBasicRpcChannel> const& channel,
61 std::shared_ptr<mir::client::Logger> const & log,62 std::shared_ptr<mir::client::Logger> const & log,
62 std::shared_ptr<mir::client::ClientPlatformFactory> const& client_platform_factory);63 std::shared_ptr<mir::client::ClientPlatformFactory> const& client_platform_factory);
63 ~MirConnection() noexcept;64 ~MirConnection() noexcept;
6465
=== modified file 'src/client/mir_socket_rpc_channel.cpp'
--- src/client/mir_socket_rpc_channel.cpp 2013-04-24 05:22:20 +0000
+++ src/client/mir_socket_rpc_channel.cpp 2013-04-25 09:50:50 +0000
@@ -253,11 +253,12 @@
253253
254 log->debug() << __PRETTY_FUNCTION__ << " result.id():" << result.id() << std::endl;254 log->debug() << __PRETTY_FUNCTION__ << " result.id():" << result.id() << std::endl;
255255
256 if (!result.has_id()) // It's an event sequence256 for (int i = 0; i != result.events_size(); ++i)
257 {257 {
258 process_event_sequence(result);258 process_event_sequence(result.events(i));
259 }259 }
260 else260
261 if (result.has_id())
261 {262 {
262 pending_calls.complete_response(result);263 pending_calls.complete_response(result);
263 }264 }
@@ -269,44 +270,42 @@
269 }270 }
270}271}
271272
272void mcl::MirSocketRpcChannel::process_event_sequence(273void mcl::MirSocketRpcChannel::process_event_sequence(std::string const& event)
273 mir::protobuf::wire::Result const& result)
274{274{
275 if (!event_handler)275 if (!event_handler)
276 return;276 return;
277277
278 mir::protobuf::EventSequence seq;278 mir::protobuf::EventSequence seq;
279 if (seq.ParseFromString(result.response()))279
280 seq.ParseFromString(event);
281 int const nevents = seq.event_size();
282 for (int i = 0; i != nevents; ++i)
280 {283 {
281 int const nevents = seq.event_size();284 mir::protobuf::Event const& event = seq.event(i);
282 for (int i = 0; i < nevents; i++)285 if (event.has_raw())
283 {286 {
284 mir::protobuf::Event const& event = seq.event(i);287 std::string const& raw_event = event.raw();
285 if (event.has_raw())288
286 {289 // In future, events might be compressed where possible.
287 std::string const& raw_event = event.raw();290 // But that's a job for later...
288291 if (raw_event.size() == sizeof(MirEvent))
289 // In future, events might be compressed where possible.292 {
290 // But that's a job for later...293 MirEvent e;
291 if (raw_event.size() == sizeof(MirEvent))294
292 {295 // Make a copy to ensure integer fields get correct memory
293 MirEvent e;296 // alignment, which is critical on many non-x86
294297 // architectures.
295 // Make a copy to ensure integer fields get correct memory298 memcpy(&e, raw_event.data(), sizeof e);
296 // alignment, which is critical on many non-x86299 event_handler->handle_event(e);
297 // architectures.300 }
298 memcpy(&e, raw_event.data(), sizeof e);301 else
299 event_handler->handle_event(e);302 {
300 }303 log->error() << __PRETTY_FUNCTION__
301 else304 << " Received MirEvent of an unexpected size."
302 {305 << std::endl;
303 log->error() << __PRETTY_FUNCTION__
304 << " Received MirEvent of an unexpected size."
305 << std::endl;
306 }
307 }306 }
308 }307 }
309 } // else protobuf will log an error308 }
310}309}
311310
312size_t mcl::MirSocketRpcChannel::read_message_header()311size_t mcl::MirSocketRpcChannel::read_message_header()
@@ -331,7 +330,7 @@
331 return result;330 return result;
332}331}
333332
334void mcl::MirSocketRpcChannel::set_event_handler(mir::EventSink *sink)333void mcl::MirSocketRpcChannel::set_event_handler(events::EventSink *sink)
335{334{
336 /*335 /*
337 * Yes, these have to be regular pointers. Because ownership of the object336 * Yes, these have to be regular pointers. Because ownership of the object
338337
=== modified file 'src/client/mir_socket_rpc_channel.h'
--- src/client/mir_socket_rpc_channel.h 2013-04-24 05:22:20 +0000
+++ src/client/mir_socket_rpc_channel.h 2013-04-25 09:50:50 +0000
@@ -22,7 +22,7 @@
2222
23#include "mir_basic_rpc_channel.h"23#include "mir_basic_rpc_channel.h"
24#include "mir_logger.h"24#include "mir_logger.h"
25#include "mir/event_sink.h"25#include "mir/events/event_sink.h"
2626
27#include <boost/asio.hpp>27#include <boost/asio.hpp>
2828
@@ -52,7 +52,7 @@
52 MirSocketRpcChannel(const std::string& endpoint, const std::shared_ptr<Logger>& log);52 MirSocketRpcChannel(const std::string& endpoint, const std::shared_ptr<Logger>& log);
53 ~MirSocketRpcChannel();53 ~MirSocketRpcChannel();
5454
55 void set_event_handler(EventSink *sink);55 void set_event_handler(events::EventSink *sink);
5656
57private:57private:
58 virtual void CallMethod(const google::protobuf::MethodDescriptor* method, google::protobuf::RpcController*,58 virtual void CallMethod(const google::protobuf::MethodDescriptor* method, google::protobuf::RpcController*,
@@ -75,13 +75,13 @@
75 void on_header_read(const boost::system::error_code& error);75 void on_header_read(const boost::system::error_code& error);
7676
77 void read_message();77 void read_message();
78 void process_event_sequence(mir::protobuf::wire::Result const& result);78 void process_event_sequence(std::string const& event);
7979
80 size_t read_message_header();80 size_t read_message_header();
8181
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);
8383
84 EventSink *event_handler;84 events::EventSink *event_handler;
85};85};
8686
87}87}
8888
=== modified file 'src/server/CMakeLists.txt'
--- src/server/CMakeLists.txt 2013-04-24 05:22:20 +0000
+++ src/server/CMakeLists.txt 2013-04-25 09:50:50 +0000
@@ -26,7 +26,6 @@
26 display_server.cpp26 display_server.cpp
27 default_server_configuration.cpp27 default_server_configuration.cpp
28 asio_main_loop.cpp28 asio_main_loop.cpp
29 event_queue.cpp
30)29)
3130
32set(MIRSERVER_LINKAGE SHARED)31set(MIRSERVER_LINKAGE SHARED)
3332
=== modified file 'src/server/default_server_configuration.cpp'
--- src/server/default_server_configuration.cpp 2013-04-24 22:14:08 +0000
+++ src/server/default_server_configuration.cpp 2013-04-25 09:50:50 +0000
@@ -63,6 +63,7 @@
63#include "mir/default_configuration.h"63#include "mir/default_configuration.h"
6464
65namespace mc = mir::compositor;65namespace mc = mir::compositor;
66namespace me = mir::events;
66namespace geom = mir::geometry;67namespace geom = mir::geometry;
67namespace mf = mir::frontend;68namespace mf = mir::frontend;
68namespace mg = mir::graphics;69namespace mg = mir::graphics;
@@ -109,7 +110,7 @@
109 std::shared_ptr<mc::GraphicBufferAllocator> const buffer_allocator;110 std::shared_ptr<mc::GraphicBufferAllocator> const buffer_allocator;
110111
111 virtual std::shared_ptr<mir::protobuf::DisplayServer> make_ipc_server(112 virtual std::shared_ptr<mir::protobuf::DisplayServer> make_ipc_server(
112 std::shared_ptr<mir::EventSink> const& sink)113 std::shared_ptr<me::EventSink> const& sink)
113 {114 {
114 return std::make_shared<mf::SessionMediator>(115 return std::make_shared<mf::SessionMediator>(
115 shell,116 shell,
116117
=== modified file 'src/server/frontend/CMakeLists.txt'
--- src/server/frontend/CMakeLists.txt 2013-04-24 05:22:20 +0000
+++ src/server/frontend/CMakeLists.txt 2013-04-25 09:50:50 +0000
@@ -8,6 +8,7 @@
8 protobuf_message_processor.cpp8 protobuf_message_processor.cpp
9 null_message_processor.cpp9 null_message_processor.cpp
10 surface_creation_parameters.cpp10 surface_creation_parameters.cpp
11 event_pipe.cpp
1112
12 resource_cache.cpp13 resource_cache.cpp
13 ${PROTO_HDRS}14 ${PROTO_HDRS}
1415
=== renamed file 'src/server/event_queue.cpp' => 'src/server/frontend/event_pipe.cpp'
--- src/server/event_queue.cpp 2013-04-24 03:44:27 +0000
+++ src/server/frontend/event_pipe.cpp 2013-04-25 09:50:50 +0000
@@ -16,17 +16,16 @@
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */17 */
1818
19#include "mir/event_queue.h"19#include "event_pipe.h"
20#include "mir/event_sink.h"20
2121namespace mf = mir::frontend;
22using namespace mir;22
2323void mf::EventPipe::set_target(std::weak_ptr<EventSink> const& s)
24void EventQueue::set_target(std::weak_ptr<EventSink> const& s)
25{24{
26 target = s;25 target = s;
27}26}
2827
29void EventQueue::handle_event(MirEvent const& e)28void mf::EventPipe::handle_event(MirEvent const& e)
30{29{
31 // In future, we might put e on a queue and wait for some background30 // In future, we might put e on a queue and wait for some background
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.
3332
=== renamed file 'include/server/mir/event_queue.h' => 'src/server/frontend/event_pipe.h'
--- include/server/mir/event_queue.h 2013-04-16 05:46:28 +0000
+++ src/server/frontend/event_pipe.h 2013-04-25 09:50:50 +0000
@@ -16,25 +16,27 @@
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */17 */
1818
19#ifndef MIR_EVENT_QUEUE_H_19#ifndef MIR_FRONTEND_EVENT_PIPE_H_
20#define MIR_EVENT_QUEUE_H_20#define MIR_FRONTEND_EVENT_PIPE_H_
2121
22#include "mir_toolkit/event.h"22#include "mir_toolkit/event.h"
23#include "mir/event_sink.h"23#include "mir/events/event_sink.h"
24#include <memory>24#include <memory>
2525
26namespace mir26namespace mir
27{27{
28class EventQueue : public EventSink28namespace frontend
29{
30class EventPipe : public events::EventSink
29{31{
30public:32public:
31 void set_target(std::weak_ptr<EventSink> const& s);33 void set_target(std::weak_ptr<events::EventSink> const& s);
32 void handle_event(MirEvent const& e) override;34 void handle_event(MirEvent const& e) override;
3335
34private:36private:
35 std::weak_ptr<EventSink> target;37 std::weak_ptr<events::EventSink> target;
36};38};
3739}
38} // namespace mir40}
3941
40#endif42#endif // MIR_FRONTEND_EVENT_PIPE_H_
4143
=== modified file 'src/server/frontend/protobuf_message_processor.cpp'
--- src/server/frontend/protobuf_message_processor.cpp 2013-04-24 05:22:20 +0000
+++ src/server/frontend/protobuf_message_processor.cpp 2013-04-25 09:50:50 +0000
@@ -138,6 +138,8 @@
138138
139void mfd::ProtobufMessageProcessor::send_event(MirEvent const& e)139void mfd::ProtobufMessageProcessor::send_event(MirEvent const& e)
140{140{
141 // In future we might send multiple events, or insert them into messages
142 // containing other responses, but for now we send them individually.
141 mir::protobuf::EventSequence seq;143 mir::protobuf::EventSequence seq;
142 mir::protobuf::Event *ev = seq.add_event();144 mir::protobuf::Event *ev = seq.add_event();
143 ev->set_raw(&e, sizeof(MirEvent));145 ev->set_raw(&e, sizeof(MirEvent));
@@ -146,7 +148,7 @@
146 seq.SerializeToString(&buffer);148 seq.SerializeToString(&buffer);
147149
148 mir::protobuf::wire::Result result;150 mir::protobuf::wire::Result result;
149 result.set_response(buffer);151 result.add_events(buffer);
150152
151 result.SerializeToString(&buffer);153 result.SerializeToString(&buffer);
152154
153155
=== modified file 'src/server/frontend/protobuf_message_processor.h'
--- src/server/frontend/protobuf_message_processor.h 2013-04-24 05:22:20 +0000
+++ src/server/frontend/protobuf_message_processor.h 2013-04-25 09:50:50 +0000
@@ -24,7 +24,7 @@
2424
25#include "mir_protobuf.pb.h"25#include "mir_protobuf.pb.h"
26#include "mir_protobuf_wire.pb.h"26#include "mir_protobuf_wire.pb.h"
27#include "mir/event_sink.h"27#include "mir/events/event_sink.h"
2828
29#include <vector>29#include <vector>
30#include <memory>30#include <memory>
@@ -44,7 +44,7 @@
44{44{
4545
46struct ProtobufMessageProcessor : MessageProcessor,46struct ProtobufMessageProcessor : MessageProcessor,
47 public EventSink47 public events::EventSink
48{48{
49 ProtobufMessageProcessor(49 ProtobufMessageProcessor(
50 MessageSender* sender,50 MessageSender* sender,
5151
=== modified file 'src/server/frontend/protobuf_socket_communicator.cpp'
--- src/server/frontend/protobuf_socket_communicator.cpp 2013-04-24 05:22:20 +0000
+++ src/server/frontend/protobuf_socket_communicator.cpp 2013-04-25 09:50:50 +0000
@@ -22,8 +22,7 @@
2222
23#include "mir/frontend/protobuf_ipc_factory.h"23#include "mir/frontend/protobuf_ipc_factory.h"
24#include "mir/protobuf/google_protobuf_guard.h"24#include "mir/protobuf/google_protobuf_guard.h"
25#include "mir/event_sink.h"25#include "event_pipe.h"
26#include "mir/event_queue.h"
2726
28#include <boost/signals2.hpp>27#include <boost/signals2.hpp>
2928
@@ -51,7 +50,7 @@
5150
52void mf::ProtobufSocketCommunicator::start_accept()51void mf::ProtobufSocketCommunicator::start_accept()
53{52{
54 std::shared_ptr<EventQueue> event_queue = std::make_shared<EventQueue>();53 auto const& event_pipe = std::make_shared<EventPipe>();
5554
56 auto const& socket_session = std::make_shared<mfd::SocketSession>(55 auto const& socket_session = std::make_shared<mfd::SocketSession>(
57 io_service,56 io_service,
@@ -60,11 +59,11 @@
6059
61 auto session = std::make_shared<detail::ProtobufMessageProcessor>(60 auto session = std::make_shared<detail::ProtobufMessageProcessor>(
62 socket_session.get(),61 socket_session.get(),
63 ipc_factory->make_ipc_server(event_queue),62 ipc_factory->make_ipc_server(event_pipe),
64 ipc_factory->resource_cache(),63 ipc_factory->resource_cache(),
65 ipc_factory->report());64 ipc_factory->report());
6665
67 event_queue->set_target(session);66 event_pipe->set_target(session);
68 socket_session->set_processor(session);67 socket_session->set_processor(session);
6968
70 acceptor.async_accept(69 acceptor.async_accept(
7170
=== modified file 'src/server/frontend/session_mediator.cpp'
--- src/server/frontend/session_mediator.cpp 2013-04-24 05:22:20 +0000
+++ src/server/frontend/session_mediator.cpp 2013-04-25 09:50:50 +0000
@@ -44,7 +44,7 @@
44 std::shared_ptr<graphics::ViewableArea> const& viewable_area,44 std::shared_ptr<graphics::ViewableArea> const& viewable_area,
45 std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator,45 std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator,
46 std::shared_ptr<SessionMediatorReport> const& report,46 std::shared_ptr<SessionMediatorReport> const& report,
47 std::shared_ptr<EventSink> const& event_sink,47 std::shared_ptr<events::EventSink> const& event_sink,
48 std::shared_ptr<ResourceCache> const& resource_cache) :48 std::shared_ptr<ResourceCache> const& resource_cache) :
49 shell(shell),49 shell(shell),
50 graphics_platform(graphics_platform),50 graphics_platform(graphics_platform),
@@ -65,8 +65,7 @@
65{65{
66 report->session_connect_called(request->application_name());66 report->session_connect_called(request->application_name());
6767
68 session = shell->open_session(request->application_name());68 session = shell->open_session(request->application_name(), event_sink);
69 session->set_event_sink(event_sink);
7069
71 auto ipc_package = graphics_platform->get_ipc_package();70 auto ipc_package = graphics_platform->get_ipc_package();
72 auto platform = response->mutable_platform();71 auto platform = response->mutable_platform();
7372
=== modified file 'src/server/shell/application_session.cpp'
--- src/server/shell/application_session.cpp 2013-04-24 05:22:20 +0000
+++ src/server/shell/application_session.cpp 2013-04-25 09:50:50 +0000
@@ -28,21 +28,32 @@
28#include <cassert>28#include <cassert>
29#include <algorithm>29#include <algorithm>
3030
31namespace me = mir::events;
31namespace mf = mir::frontend;32namespace mf = mir::frontend;
32namespace msh = mir::shell;33namespace msh = mir::shell;
3334
34msh::ApplicationSession::ApplicationSession(35msh::ApplicationSession::ApplicationSession(
35 std::shared_ptr<msh::SurfaceFactory> const& surface_factory,36 std::shared_ptr<SurfaceFactory> const& surface_factory,
36 std::shared_ptr<msh::InputTargetListener> const& input_target_listener,37 std::shared_ptr<msh::InputTargetListener> const& input_target_listener,
37 std::string const& session_name) :38 std::string const& session_name,
39 std::shared_ptr<me::EventSink> const& sink) :
38 surface_factory(surface_factory),40 surface_factory(surface_factory),
39 input_target_listener(input_target_listener),41 input_target_listener(input_target_listener),
40 session_name(session_name),42 session_name(session_name),
43 event_sink(sink),
41 next_surface_id(0)44 next_surface_id(0)
42{45{
43 assert(surface_factory);46 assert(surface_factory);
44}47}
4548
49msh::ApplicationSession::ApplicationSession(
50 std::shared_ptr<SurfaceFactory> const& surface_factory,
51 std::shared_ptr<msh::InputTargetListener> const& input_target_listener,
52 std::string const& session_name) :
53 ApplicationSession(surface_factory, input_target_listener, session_name, std::shared_ptr<me::EventSink>())
54{
55}
56
46msh::ApplicationSession::~ApplicationSession()57msh::ApplicationSession::~ApplicationSession()
47{58{
48 std::unique_lock<std::mutex> lock(surfaces_mutex);59 std::unique_lock<std::mutex> lock(surfaces_mutex);
@@ -53,12 +64,6 @@
53 }64 }
54}65}
5566
56void msh::ApplicationSession::set_event_sink(
57 std::shared_ptr<mir::EventSink> const& sink)
58{
59 event_sink = sink;
60}
61
62mf::SurfaceId msh::ApplicationSession::next_id()67mf::SurfaceId msh::ApplicationSession::next_id()
63{68{
64 return mf::SurfaceId(next_surface_id.fetch_add(1));69 return mf::SurfaceId(next_surface_id.fetch_add(1));
@@ -66,11 +71,8 @@
6671
67mf::SurfaceId msh::ApplicationSession::create_surface(const mf::SurfaceCreationParameters& params)72mf::SurfaceId msh::ApplicationSession::create_surface(const mf::SurfaceCreationParameters& params)
68{73{
69 auto surf = surface_factory->create_surface(params);
70 auto const id = next_id();74 auto const id = next_id();
7175 auto surf = surface_factory->create_surface(params, id, event_sink);
72 surf->set_id(id);
73 surf->set_event_target(event_sink);
7476
75 std::unique_lock<std::mutex> lock(surfaces_mutex);77 std::unique_lock<std::mutex> lock(surfaces_mutex);
76 surfaces[id] = surf;78 surfaces[id] = surf;
7779
=== modified file 'src/server/shell/organising_surface_factory.cpp'
--- src/server/shell/organising_surface_factory.cpp 2013-04-24 05:22:20 +0000
+++ src/server/shell/organising_surface_factory.cpp 2013-04-25 09:50:50 +0000
@@ -34,10 +34,13 @@
34{34{
35}35}
3636
37std::shared_ptr<msh::Surface> msh::OrganisingSurfaceFactory::create_surface(const mf::SurfaceCreationParameters& params)37std::shared_ptr<msh::Surface> msh::OrganisingSurfaceFactory::create_surface(
38 frontend::SurfaceCreationParameters const& params,
39 frontend::SurfaceId id,
40 std::shared_ptr<events::EventSink> const& sink)
38{41{
39 auto placed_params = placement_strategy->place(params);42 auto placed_params = placement_strategy->place(params);
4043
41 return underlying_factory->create_surface(placed_params);44 return underlying_factory->create_surface(placed_params, id, sink);
42}45}
4346
4447
=== modified file 'src/server/shell/session_manager.cpp'
--- src/server/shell/session_manager.cpp 2013-04-24 05:22:20 +0000
+++ src/server/shell/session_manager.cpp 2013-04-25 09:50:50 +0000
@@ -55,9 +55,11 @@
55{55{
56}56}
5757
58std::shared_ptr<mf::Session> msh::SessionManager::open_session(std::string const& name)58std::shared_ptr<mf::Session> msh::SessionManager::open_session(
59 std::string const& name,
60 std::shared_ptr<events::EventSink> const& sink)
59{61{
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);
6163
62 app_container->insert_session(new_session);64 app_container->insert_session(new_session);
63 65
6466
=== modified file 'src/server/shell/surface.cpp'
--- src/server/shell/surface.cpp 2013-04-24 05:22:20 +0000
+++ src/server/shell/surface.cpp 2013-04-25 09:50:50 +0000
@@ -20,7 +20,7 @@
20#include "mir/shell/surface_builder.h"20#include "mir/shell/surface_builder.h"
21#include "mir/input/input_channel.h"21#include "mir/input/input_channel.h"
22#include "mir_toolkit/event.h"22#include "mir_toolkit/event.h"
23#include "mir/event_sink.h"23#include "mir/events/event_sink.h"
2424
25#include <boost/throw_exception.hpp>25#include <boost/throw_exception.hpp>
2626
@@ -34,11 +34,28 @@
34msh::Surface::Surface(34msh::Surface::Surface(
35 std::shared_ptr<SurfaceBuilder> const& builder,35 std::shared_ptr<SurfaceBuilder> const& builder,
36 frontend::SurfaceCreationParameters const& params,36 frontend::SurfaceCreationParameters const& params,
37 std::shared_ptr<input::InputChannel> const& input_channel,
38 frontend::SurfaceId id,
39 std::shared_ptr<events::EventSink> const& sink)
40 : builder(builder),
41 input_channel(input_channel),
42 surface(builder->create_surface(params)),
43 id(id),
44 event_sink(sink),
45 type_value(mir_surface_type_normal),
46 state_value(mir_surface_state_restored)
47{
48}
49
50msh::Surface::Surface(
51 std::shared_ptr<SurfaceBuilder> const& builder,
52 frontend::SurfaceCreationParameters const& params,
37 std::shared_ptr<input::InputChannel> const& input_channel)53 std::shared_ptr<input::InputChannel> const& input_channel)
38 : builder(builder),54 : builder(builder),
39 input_channel(input_channel),55 input_channel(input_channel),
40 surface(builder->create_surface(params)),56 surface(builder->create_surface(params)),
41 id(0),57 id(),
58 event_sink(),
42 type_value(mir_surface_type_normal),59 type_value(mir_surface_type_normal),
43 state_value(mir_surface_state_restored)60 state_value(mir_surface_state_restored)
44{61{
@@ -52,16 +69,6 @@
52 }69 }
53}70}
5471
55void msh::Surface::set_id(mir::frontend::SurfaceId i)
56{
57 id = i;
58}
59
60void msh::Surface::set_event_target(std::shared_ptr<EventSink> const& sink)
61{
62 event_sink = sink;
63}
64
65void msh::Surface::hide()72void msh::Surface::hide()
66{73{
67 if (auto const& s = surface.lock())74 if (auto const& s = surface.lock())
6875
=== modified file 'src/server/shell/surface_source.cpp'
--- src/server/shell/surface_source.cpp 2013-04-24 05:22:20 +0000
+++ src/server/shell/surface_source.cpp 2013-04-25 09:50:50 +0000
@@ -39,11 +39,16 @@
39 assert(surface_builder);39 assert(surface_builder);
40}40}
4141
42std::shared_ptr<msh::Surface> msh::SurfaceSource::create_surface(const mf::SurfaceCreationParameters& params)42std::shared_ptr<msh::Surface> msh::SurfaceSource::create_surface(
43 frontend::SurfaceCreationParameters const& params,
44 frontend::SurfaceId id,
45 std::shared_ptr<events::EventSink> const& sink)
43{46{
44 return std::make_shared<Surface>(47 return std::make_shared<Surface>(
45 surface_builder,48 surface_builder,
46 params,49 params,
47 input_factory->make_input_channel());50 input_factory->make_input_channel(),
51 id,
52 sink);
48}53}
4954
5055
=== modified file 'src/shared/protobuf/mir_protobuf_wire.proto'
--- src/shared/protobuf/mir_protobuf_wire.proto 2013-04-24 05:22:20 +0000
+++ src/shared/protobuf/mir_protobuf_wire.proto 2013-04-25 09:50:50 +0000
@@ -7,7 +7,9 @@
7}7}
88
9message Result {9message Result {
10 // Invocation results have id and response. Events only have response.10 // Invocation results have id and response.
11 optional uint32 id = 1;11 optional uint32 id = 1;
12 optional bytes response = 2;12 optional bytes response = 2;
13 // Events are in events.
14 repeated bytes events = 3;
13}15}
1416
=== modified file 'tests/acceptance-tests/test_focus_management_api.cpp'
--- tests/acceptance-tests/test_focus_management_api.cpp 2013-04-24 22:14:08 +0000
+++ tests/acceptance-tests/test_focus_management_api.cpp 2013-04-25 09:50:50 +0000
@@ -126,7 +126,7 @@
126 {126 {
127 using namespace ::testing;127 using namespace ::testing;
128 using frontend::Shell;128 using frontend::Shell;
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));
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));
131131
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));
@@ -135,7 +135,7 @@
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));
136 }136 }
137137
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&));
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));
140140
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));
@@ -167,13 +167,13 @@
167167
168 Sequence s1, s2;168 Sequence s1, s2;
169169
170 EXPECT_CALL(*mock_shell, open_session(_))170 EXPECT_CALL(*mock_shell, open_session(_, _))
171 .InSequence(s1, s2);171 .InSequence(s1, s2);
172172
173 EXPECT_CALL(*mock_shell, create_surface_for(_,_))173 EXPECT_CALL(*mock_shell, create_surface_for(_,_))
174 .InSequence(s1);174 .InSequence(s1);
175175
176 EXPECT_CALL(*mock_shell, open_session(_))176 EXPECT_CALL(*mock_shell, open_session(_, _))
177 .InSequence(s2);177 .InSequence(s2);
178178
179 EXPECT_CALL(*mock_shell, close_session(_))179 EXPECT_CALL(*mock_shell, close_session(_))
180180
=== modified file 'tests/behavior-tests/session_management_context.cpp'
--- tests/behavior-tests/session_management_context.cpp 2013-04-24 05:22:20 +0000
+++ tests/behavior-tests/session_management_context.cpp 2013-04-25 09:50:50 +0000
@@ -66,12 +66,16 @@
66 {66 {
67 }67 }
6868
69 std::shared_ptr<msh::Surface> create_surface(const mf::SurfaceCreationParameters& params)69 std::shared_ptr<msh::Surface> create_surface(const mf::SurfaceCreationParameters& params,
70 frontend::SurfaceId id,
71 std::shared_ptr<events::EventSink> const& sink) override
70 {72 {
71 return std::make_shared<msh::Surface>(73 return std::make_shared<msh::Surface>(
72 mt::fake_shared(surface_builder),74 mt::fake_shared(surface_builder),
73 params,75 params,
74 std::shared_ptr<mir::input::InputChannel>());76 std::shared_ptr<mir::input::InputChannel>(),
77 id,
78 sink);
75 }79 }
7680
77 mtd::StubSurfaceBuilder surface_builder;81 mtd::StubSurfaceBuilder surface_builder;
@@ -152,7 +156,7 @@
152bool mtc::SessionManagementContext::open_window_consuming(std::string const& window_name)156bool mtc::SessionManagementContext::open_window_consuming(std::string const& window_name)
153{157{
154 auto const params = mf::a_surface().of_name(window_name);158 auto const params = mf::a_surface().of_name(window_name);
155 auto session = shell->open_session(window_name);159 auto session = shell->open_session(window_name, std::shared_ptr<mir::events::EventSink>());
156 auto const surface_id = session->create_surface(params);160 auto const surface_id = session->create_surface(params);
157161
158 open_windows[window_name] = std::make_tuple(session, surface_id);162 open_windows[window_name] = std::make_tuple(session, surface_id);
@@ -164,7 +168,7 @@
164 geom::Size const& size)168 geom::Size const& size)
165{169{
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);
167 auto session = shell->open_session(window_name);171 auto session = shell->open_session(window_name, std::shared_ptr<mir::events::EventSink>());
168 auto const surface_id = session->create_surface(params);172 auto const surface_id = session->create_surface(params);
169173
170 open_windows[window_name] = std::make_tuple(session, surface_id);174 open_windows[window_name] = std::make_tuple(session, surface_id);
171175
=== modified file 'tests/integration-tests/cucumber/test_session_management_context.cpp'
--- tests/integration-tests/cucumber/test_session_management_context.cpp 2013-04-24 05:22:20 +0000
+++ tests/integration-tests/cucumber/test_session_management_context.cpp 2013-04-25 09:50:50 +0000
@@ -106,7 +106,7 @@
106106
107 mtd::MockSession session;107 mtd::MockSession session;
108108
109 EXPECT_CALL(shell, open_session(test_window_name)).Times(1)109 EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1)
110 .WillOnce(Return(mt::fake_shared<mf::Session>(session)));110 .WillOnce(Return(mt::fake_shared<mf::Session>(session)));
111111
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.
@@ -122,7 +122,7 @@
122122
123 mtd::MockSession session;123 mtd::MockSession session;
124124
125 EXPECT_CALL(shell, open_session(test_window_name)).Times(1)125 EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1)
126 .WillOnce(Return(mt::fake_shared<mf::Session>(session)));126 .WillOnce(Return(mt::fake_shared<mf::Session>(session)));
127127
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)
@@ -138,7 +138,7 @@
138 mtd::MockSession session;138 mtd::MockSession session;
139 mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>());139 mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>());
140140
141 EXPECT_CALL(shell, open_session(test_window_name)).Times(1)141 EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1)
142 .WillOnce(Return(mt::fake_shared<mf::Session>(session)));142 .WillOnce(Return(mt::fake_shared<mf::Session>(session)));
143143
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)
145145
=== modified file 'tests/integration-tests/shell/test_session_manager.cpp'
--- tests/integration-tests/shell/test_session_manager.cpp 2013-04-24 05:22:20 +0000
+++ tests/integration-tests/shell/test_session_manager.cpp 2013-04-25 09:50:50 +0000
@@ -36,6 +36,7 @@
36#include "mir_test_doubles/stub_input_target_listener.h"36#include "mir_test_doubles/stub_input_target_listener.h"
3737
38namespace mc = mir::compositor;38namespace mc = mir::compositor;
39namespace me = mir::events;
39namespace mf = mir::frontend;40namespace mf = mir::frontend;
40namespace msh = mir::shell;41namespace msh = mir::shell;
41namespace ms = mir::surfaces;42namespace ms = mir::surfaces;
@@ -59,12 +60,12 @@
59 mt::fake_shared(sequence),60 mt::fake_shared(sequence),
60 mt::fake_shared(focus_setter),61 mt::fake_shared(focus_setter),
61 mt::fake_shared(input_target_listener));62 mt::fake_shared(input_target_listener));
62 63
63 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3);64 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3);
6465
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>());
66 auto session2 = session_manager.open_session("Microsoft Access");67 auto session2 = session_manager.open_session("Microsoft Access", std::shared_ptr<me::EventSink>());
67 auto session3 = session_manager.open_session("WordPerfect");68 auto session3 = session_manager.open_session("WordPerfect", std::shared_ptr<me::EventSink>());
6869
69 {70 {
70 InSequence seq;71 InSequence seq;
@@ -98,9 +99,9 @@
9899
99 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3);100 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3);
100101
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>());
102 auto session2 = session_manager.open_session("Microsoft Access");103 auto session2 = session_manager.open_session("Microsoft Access", std::shared_ptr<me::EventSink>());
103 auto session3 = session_manager.open_session("WordPerfect");104 auto session3 = session_manager.open_session("WordPerfect", std::shared_ptr<me::EventSink>());
104105
105 {106 {
106 InSequence seq;107 InSequence seq;
107108
=== modified file 'tests/unit-tests/CMakeLists.txt'
--- tests/unit-tests/CMakeLists.txt 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/CMakeLists.txt 2013-04-25 09:50:50 +0000
@@ -20,7 +20,6 @@
20add_subdirectory(android_input/)20add_subdirectory(android_input/)
21add_subdirectory(surfaces/)21add_subdirectory(surfaces/)
22add_subdirectory(draw/)22add_subdirectory(draw/)
23add_subdirectory(event/)
2423
25add_executable(unit-tests ${UNIT_TEST_SOURCES})24add_executable(unit-tests ${UNIT_TEST_SOURCES})
26uses_android_input(unit-tests)25uses_android_input(unit-tests)
2726
=== modified file 'tests/unit-tests/client/test_client_mir_surface.cpp'
--- tests/unit-tests/client/test_client_mir_surface.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/client/test_client_mir_surface.cpp 2013-04-25 09:50:50 +0000
@@ -298,7 +298,7 @@
298 test_server.reset();298 test_server.reset();
299 }299 }
300300
301 std::shared_ptr<google::protobuf::RpcChannel> channel;301 std::shared_ptr<mcl::MirBasicRpcChannel> channel;
302 std::shared_ptr<mcl::Logger> logger;302 std::shared_ptr<mcl::Logger> logger;
303 std::shared_ptr<mcl::ClientPlatformFactory> platform_factory;303 std::shared_ptr<mcl::ClientPlatformFactory> platform_factory;
304 std::shared_ptr<MirConnection> connection;304 std::shared_ptr<MirConnection> connection;
305305
=== modified file 'tests/unit-tests/client/test_mir_connection.cpp'
--- tests/unit-tests/client/test_mir_connection.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/client/test_mir_connection.cpp 2013-04-25 09:50:50 +0000
@@ -39,7 +39,7 @@
39namespace39namespace
40{40{
4141
42struct MockRpcChannel : public google::protobuf::RpcChannel42struct MockRpcChannel : public mir::client::MirBasicRpcChannel
43{43{
44 void CallMethod(const google::protobuf::MethodDescriptor* method,44 void CallMethod(const google::protobuf::MethodDescriptor* method,
45 google::protobuf::RpcController*,45 google::protobuf::RpcController*,
@@ -63,6 +63,8 @@
6363
64 MOCK_METHOD1(drm_auth_magic, void(const mp::DRMMagic*));64 MOCK_METHOD1(drm_auth_magic, void(const mp::DRMMagic*));
65 MOCK_METHOD2(connect, void(mp::ConnectParameters const*,mp::Connection*));65 MOCK_METHOD2(connect, void(mp::ConnectParameters const*,mp::Connection*));
66
67 void set_event_handler(mir::events::EventSink *) {}
66};68};
6769
68struct MockClientPlatform : public mcl::ClientPlatform70struct MockClientPlatform : public mcl::ClientPlatform
6971
=== removed directory 'tests/unit-tests/event'
=== removed file 'tests/unit-tests/event/CMakeLists.txt'
--- tests/unit-tests/event/CMakeLists.txt 2013-04-09 08:23:32 +0000
+++ tests/unit-tests/event/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
1set (UNIT_TEST_SOURCES
2 ${UNIT_TEST_SOURCES}
3 ${CMAKE_CURRENT_SOURCE_DIR}/test_event_queue.cpp
4 PARENT_SCOPE
5)
60
=== modified file 'tests/unit-tests/frontend/CMakeLists.txt'
--- tests/unit-tests/frontend/CMakeLists.txt 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/frontend/CMakeLists.txt 2013-04-25 09:50:50 +0000
@@ -6,6 +6,7 @@
6 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_reports_errors.cpp6 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_reports_errors.cpp
7 ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_cache.cpp7 ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_cache.cpp
8 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator.cpp8 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator.cpp
9 ${CMAKE_CURRENT_SOURCE_DIR}/test_event_pipe.cpp
9)10)
1011
11# TODO this test is a mess - something better is needed.12# TODO this test is a mess - something better is needed.
1213
=== renamed file 'tests/unit-tests/event/test_event_queue.cpp' => 'tests/unit-tests/frontend/test_event_pipe.cpp'
--- tests/unit-tests/event/test_event_queue.cpp 2013-04-22 03:37:28 +0000
+++ tests/unit-tests/frontend/test_event_pipe.cpp 2013-04-25 09:50:50 +0000
@@ -16,14 +16,17 @@
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */17 */
1818
19#include "src/server/frontend/event_pipe.h"
20#include <cstring>
21
19#include <gtest/gtest.h>22#include <gtest/gtest.h>
20#include "mir/event_queue.h"23
21#include "mir/event_sink.h"24using mir::frontend::EventPipe;
22#include <cstring>25
2326
24TEST(EventQueue, no_sink)27TEST(EventPipe, no_sink)
25{28{
26 mir::EventQueue q;29 EventPipe q;
27 MirEvent e;30 MirEvent e;
2831
29 e.type = mir_event_type_key;32 e.type = mir_event_type_key;
@@ -38,7 +41,7 @@
3841
39namespace42namespace
40{43{
41 class TestSink : public mir::EventSink44 class TestSink : public mir::events::EventSink
42 {45 {
43 public:46 public:
44 TestSink()47 TestSink()
@@ -61,9 +64,9 @@
61 };64 };
62}65}
6366
64TEST(EventQueue, events_get_handled)67TEST(EventPipe, events_get_handled)
65{68{
66 mir::EventQueue q;69 EventPipe q;
67 std::shared_ptr<TestSink> s(new TestSink);70 std::shared_ptr<TestSink> s(new TestSink);
6871
69 q.set_target(s);72 q.set_target(s);
@@ -84,9 +87,9 @@
84 EXPECT_EQ(mir_event_type_surface, s->last_event_handled().type);87 EXPECT_EQ(mir_event_type_surface, s->last_event_handled().type);
85}88}
8689
87TEST(EventQueue, sink_is_changeable)90TEST(EventPipe, sink_is_changeable)
88{91{
89 mir::EventQueue q;92 EventPipe q;
90 std::shared_ptr<TestSink> a(new TestSink);93 std::shared_ptr<TestSink> a(new TestSink);
91 std::shared_ptr<TestSink> b(new TestSink);94 std::shared_ptr<TestSink> b(new TestSink);
9295
9396
=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
--- tests/unit-tests/frontend/test_session_mediator.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/frontend/test_session_mediator.cpp 2013-04-25 09:50:50 +0000
@@ -34,7 +34,7 @@
34#include "mir_test_doubles/stub_session.h"34#include "mir_test_doubles/stub_session.h"
35#include "mir_test_doubles/stub_surface_builder.h"35#include "mir_test_doubles/stub_surface_builder.h"
36#include "mir_test/fake_shared.h"36#include "mir_test/fake_shared.h"
37#include "mir/event_queue.h"37#include "mir/events/event_sink.h"
38#include "mir/shell/surface.h"38#include "mir/shell/surface.h"
3939
40#include <gtest/gtest.h>40#include <gtest/gtest.h>
@@ -129,7 +129,11 @@
129 }129 }
130};130};
131131
132}132class NullEventSink : public mir::events::EventSink
133{
134public:
135 void handle_event(MirEvent const& ) override {}
136};
133137
134struct SessionMediatorTest : public ::testing::Test138struct SessionMediatorTest : public ::testing::Test
135{139{
@@ -142,14 +146,14 @@
142 resource_cache{std::make_shared<mf::ResourceCache>()},146 resource_cache{std::make_shared<mf::ResourceCache>()},
143 mediator{shell, graphics_platform, graphics_display,147 mediator{shell, graphics_platform, graphics_display,
144 buffer_allocator, report, 148 buffer_allocator, report,
145 std::make_shared<mir::EventQueue>(),149 std::make_shared<NullEventSink>(),
146 resource_cache},150 resource_cache},
147 stubbed_session{std::make_shared<StubbedSession>()},151 stubbed_session{std::make_shared<StubbedSession>()},
148 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}152 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
149 {153 {
150 using namespace ::testing;154 using namespace ::testing;
151155
152 ON_CALL(*shell, open_session(_)).WillByDefault(Return(stubbed_session));156 ON_CALL(*shell, open_session(_, _)).WillByDefault(Return(stubbed_session));
153 ON_CALL(*shell, create_surface_for(_, _)).WillByDefault(Return(mf::SurfaceId{1}));157 ON_CALL(*shell, create_surface_for(_, _)).WillByDefault(Return(mf::SurfaceId{1}));
154 }158 }
155159
@@ -164,7 +168,7 @@
164168
165 std::unique_ptr<google::protobuf::Closure> null_callback;169 std::unique_ptr<google::protobuf::Closure> null_callback;
166};170};
167171}
168172
169TEST_F(SessionMediatorTest, disconnect_releases_session)173TEST_F(SessionMediatorTest, disconnect_releases_session)
170{174{
171175
=== modified file 'tests/unit-tests/frontend/test_session_mediator_android.cpp'
--- tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-04-25 09:50:50 +0000
@@ -31,7 +31,7 @@
31#include "mir_test_doubles/mock_session.h"31#include "mir_test_doubles/mock_session.h"
32#include "mir_test_doubles/stub_shell.h"32#include "mir_test_doubles/stub_shell.h"
3333
34#include "mir/event_queue.h"34#include "mir/events/event_sink.h"
3535
36#include <gtest/gtest.h>36#include <gtest/gtest.h>
3737
@@ -87,7 +87,11 @@
87 }87 }
88};88};
8989
90}90class NullEventSink : public mir::events::EventSink
91{
92public:
93 void handle_event(MirEvent const& ) override {}
94};
9195
92struct SessionMediatorAndroidTest : public ::testing::Test96struct SessionMediatorAndroidTest : public ::testing::Test
93{97{
@@ -100,7 +104,7 @@
100 resource_cache{std::make_shared<mf::ResourceCache>()},104 resource_cache{std::make_shared<mf::ResourceCache>()},
101 mediator{shell, graphics_platform, graphics_display,105 mediator{shell, graphics_platform, graphics_display,
102 buffer_allocator, report,106 buffer_allocator, report,
103 std::make_shared<mir::EventQueue>(),107 std::make_shared<NullEventSink>(),
104 resource_cache},108 resource_cache},
105 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}109 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
106 {110 {
@@ -117,6 +121,8 @@
117 std::unique_ptr<google::protobuf::Closure> null_callback;121 std::unique_ptr<google::protobuf::Closure> null_callback;
118};122};
119123
124}
125
120TEST_F(SessionMediatorAndroidTest, drm_auth_magic_throws)126TEST_F(SessionMediatorAndroidTest, drm_auth_magic_throws)
121{127{
122 mp::ConnectParameters connect_parameters;128 mp::ConnectParameters connect_parameters;
123129
=== modified file 'tests/unit-tests/frontend/test_session_mediator_gbm.cpp'
--- tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-04-25 09:50:50 +0000
@@ -27,7 +27,7 @@
27#include "mir/graphics/drm_authenticator.h"27#include "mir/graphics/drm_authenticator.h"
28#include "mir/graphics/platform.h"28#include "mir/graphics/platform.h"
29#include "mir/graphics/platform_ipc_package.h"29#include "mir/graphics/platform_ipc_package.h"
30#include "mir/event_queue.h"30#include "mir/events/event_sink.h"
3131
32#include <boost/exception/errinfo_errno.hpp>32#include <boost/exception/errinfo_errno.hpp>
33#include <boost/throw_exception.hpp>33#include <boost/throw_exception.hpp>
@@ -91,7 +91,11 @@
91 MOCK_METHOD1(drm_auth_magic, void(drm_magic_t));91 MOCK_METHOD1(drm_auth_magic, void(drm_magic_t));
92};92};
9393
94}94class NullEventSink : public mir::events::EventSink
95{
96public:
97 void handle_event(MirEvent const& ) override {}
98};
9599
96struct SessionMediatorGBMTest : public ::testing::Test100struct SessionMediatorGBMTest : public ::testing::Test
97{101{
@@ -104,7 +108,7 @@
104 resource_cache{std::make_shared<mf::ResourceCache>()},108 resource_cache{std::make_shared<mf::ResourceCache>()},
105 mediator{shell, mock_platform, graphics_display,109 mediator{shell, mock_platform, graphics_display,
106 buffer_allocator, report,110 buffer_allocator, report,
107 std::make_shared<mir::EventQueue>(),111 std::make_shared<NullEventSink>(),
108 resource_cache},112 resource_cache},
109 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}113 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
110 {114 {
@@ -121,6 +125,8 @@
121 std::unique_ptr<google::protobuf::Closure> null_callback;125 std::unique_ptr<google::protobuf::Closure> null_callback;
122};126};
123127
128}
129
124TEST_F(SessionMediatorGBMTest, drm_auth_magic_uses_drm_authenticator)130TEST_F(SessionMediatorGBMTest, drm_auth_magic_uses_drm_authenticator)
125{131{
126 mp::ConnectParameters connect_parameters;132 mp::ConnectParameters connect_parameters;
127133
=== modified file 'tests/unit-tests/shell/test_application_session.cpp'
--- tests/unit-tests/shell/test_application_session.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/shell/test_application_session.cpp 2013-04-25 09:50:50 +0000
@@ -32,6 +32,7 @@
32#include <gtest/gtest.h>32#include <gtest/gtest.h>
3333
34namespace mc = mir::compositor;34namespace mc = mir::compositor;
35namespace me = mir::events;
35namespace mf = mir::frontend;36namespace mf = mir::frontend;
36namespace msh = mir::shell;37namespace msh = mir::shell;
37namespace ms = mir::surfaces;38namespace ms = mir::surfaces;
@@ -47,9 +48,9 @@
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));
4849
49 mtd::MockSurfaceFactory surface_factory;50 mtd::MockSurfaceFactory surface_factory;
50 ON_CALL(surface_factory, create_surface(_)).WillByDefault(Return(mock_surface));51 ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(Return(mock_surface));
5152
52 EXPECT_CALL(surface_factory, create_surface(_));53 EXPECT_CALL(surface_factory, create_surface(_, _, _));
53 EXPECT_CALL(*mock_surface, destroy());54 EXPECT_CALL(*mock_surface, destroy());
5455
55 mtd::StubInputTargetListener input_listener;56 mtd::StubInputTargetListener input_listener;
@@ -69,11 +70,11 @@
69 mtd::StubSurfaceBuilder surface_builder;70 mtd::StubSurfaceBuilder surface_builder;
70 {71 {
71 InSequence seq;72 InSequence seq;
72 EXPECT_CALL(surface_factory, create_surface(_)).Times(1)73 EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1)
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))));
74 EXPECT_CALL(surface_factory, create_surface(_)).Times(1)75 EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1)
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))));
76 EXPECT_CALL(surface_factory, create_surface(_)).Times(1)77 EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1)
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))));
78 }79 }
7980
@@ -106,12 +107,12 @@
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));
107108
108 mtd::MockSurfaceFactory surface_factory;109 mtd::MockSurfaceFactory surface_factory;
109 ON_CALL(surface_factory, create_surface(_)).WillByDefault(Return(mock_surface));110 ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(Return(mock_surface));
110111
111 mtd::StubInputTargetListener input_listener;112 mtd::StubInputTargetListener input_listener;
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");
113114
114 EXPECT_CALL(surface_factory, create_surface(_));115 EXPECT_CALL(surface_factory, create_surface(_, _, _));
115116
116 {117 {
117 InSequence seq;118 InSequence seq;
118119
=== modified file 'tests/unit-tests/shell/test_organising_surface_factory.cpp'
--- tests/unit-tests/shell/test_organising_surface_factory.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/shell/test_organising_surface_factory.cpp 2013-04-25 09:50:50 +0000
@@ -25,6 +25,7 @@
25#include <gtest/gtest.h>25#include <gtest/gtest.h>
26#include <gmock/gmock.h>26#include <gmock/gmock.h>
2727
28namespace me = mir::events;
28namespace mf = mir::frontend;29namespace mf = mir::frontend;
29namespace msh = mir::shell;30namespace msh = mir::shell;
30namespace geom = mir::geometry;31namespace geom = mir::geometry;
@@ -45,7 +46,7 @@
45 using namespace ::testing;46 using namespace ::testing;
4647
47 underlying_surface_factory = std::make_shared<mtd::MockSurfaceFactory>();48 underlying_surface_factory = std::make_shared<mtd::MockSurfaceFactory>();
48 ON_CALL(*underlying_surface_factory, create_surface(_)).WillByDefault(Return(null_surface));49 ON_CALL(*underlying_surface_factory, create_surface(_, _, _)).WillByDefault(Return(null_surface));
4950
50 placement_strategy = std::make_shared<MockPlacementStrategy>();51 placement_strategy = std::make_shared<MockPlacementStrategy>();
51 }52 }
@@ -62,13 +63,13 @@
6263
63 msh::OrganisingSurfaceFactory factory(underlying_surface_factory, placement_strategy);64 msh::OrganisingSurfaceFactory factory(underlying_surface_factory, placement_strategy);
6465
65 EXPECT_CALL(*underlying_surface_factory, create_surface(_)).Times(1);66 EXPECT_CALL(*underlying_surface_factory, create_surface(_, _, _)).Times(1);
6667
67 auto params = mf::a_surface();68 auto params = mf::a_surface();
68 EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1)69 EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1)
69 .WillOnce(Return(mf::a_surface()));70 .WillOnce(Return(mf::a_surface()));
7071
71 factory.create_surface(params);72 factory.create_surface(params, mf::SurfaceId(), std::shared_ptr<me::EventSink>());
72}73}
7374
74TEST_F(OrganisingSurfaceFactorySetup, forwards_create_surface_parameters_from_placement_strategy_to_underlying_factory)75TEST_F(OrganisingSurfaceFactorySetup, forwards_create_surface_parameters_from_placement_strategy_to_underlying_factory)
@@ -83,8 +84,8 @@
8384
84 EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1)85 EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1)
85 .WillOnce(Return(placed_params));86 .WillOnce(Return(placed_params));
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>()));
8788
88 factory.create_surface(params);89 factory.create_surface(params, mf::SurfaceId(), std::shared_ptr<me::EventSink>());
89}90}
9091
9192
=== modified file 'tests/unit-tests/shell/test_registration_order_focus_sequence.cpp'
--- tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-04-25 09:50:50 +0000
@@ -33,6 +33,7 @@
33#include <string>33#include <string>
3434
35namespace mc = mir::compositor;35namespace mc = mir::compositor;
36namespace me = mir::events;
36namespace msh = mir::shell;37namespace msh = mir::shell;
37namespace ms = mir::surfaces;38namespace ms = mir::surfaces;
38namespace mt = mir::test;39namespace mt = mir::test;
@@ -65,9 +66,9 @@
65{66{
66 using namespace ::testing;67 using namespace ::testing;
6768
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>());
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>());
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>());
7172
72 container->insert_session(app1);73 container->insert_session(app1);
73 container->insert_session(app2);74 container->insert_session(app2);
@@ -83,9 +84,9 @@
83{84{
84 using namespace ::testing;85 using namespace ::testing;
8586
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>());
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>());
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>());
89 container->insert_session(app1);90 container->insert_session(app1);
90 container->insert_session(app2);91 container->insert_session(app2);
91 container->insert_session(app3);92 container->insert_session(app3);
@@ -100,7 +101,7 @@
100{101{
101 using namespace ::testing;102 using namespace ::testing;
102103
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>());
104 container->insert_session(app1);105 container->insert_session(app1);
105106
106 msh::RegistrationOrderFocusSequence focus_sequence(container);107 msh::RegistrationOrderFocusSequence focus_sequence(container);
@@ -112,8 +113,8 @@
112{113{
113 using namespace ::testing;114 using namespace ::testing;
114115
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>());
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>());
117 auto null_session = std::shared_ptr<msh::ApplicationSession>();118 auto null_session = std::shared_ptr<msh::ApplicationSession>();
118119
119 msh::RegistrationOrderFocusSequence focus_sequence(container);120 msh::RegistrationOrderFocusSequence focus_sequence(container);
@@ -129,7 +130,7 @@
129{130{
130 using namespace ::testing;131 using namespace ::testing;
131132
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>());
133 auto null_session = std::shared_ptr<msh::ApplicationSession>();134 auto null_session = std::shared_ptr<msh::ApplicationSession>();
134135
135 msh::RegistrationOrderFocusSequence focus_sequence(container);136 msh::RegistrationOrderFocusSequence focus_sequence(container);
136137
=== modified file 'tests/unit-tests/shell/test_session_manager.cpp'
--- tests/unit-tests/shell/test_session_manager.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/shell/test_session_manager.cpp 2013-04-25 09:50:50 +0000
@@ -41,6 +41,7 @@
41#include <gtest/gtest.h>41#include <gtest/gtest.h>
4242
43namespace mc = mir::compositor;43namespace mc = mir::compositor;
44namespace me = mir::events;
44namespace mf = mir::frontend;45namespace mf = mir::frontend;
45namespace msh = mir::shell;46namespace msh = mir::shell;
46namespace ms = mir::surfaces;47namespace ms = mir::surfaces;
@@ -101,7 +102,7 @@
101102
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>())));
103104
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>());
105 session_manager.close_session(session);106 session_manager.close_session(session);
106}107}
107108
@@ -109,10 +110,10 @@
109{110{
110 using namespace ::testing;111 using namespace ::testing;
111112
112 EXPECT_CALL(surface_factory, create_surface(_)).Times(1);113 EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1);
113114
114 std::shared_ptr<mi::InputChannel> null_input_channel;115 std::shared_ptr<mi::InputChannel> null_input_channel;
115 ON_CALL(surface_factory, create_surface(_)).WillByDefault(116 ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(
116 Return(std::make_shared<msh::Surface>(117 Return(std::make_shared<msh::Surface>(
117 mt::fake_shared(surface_builder),118 mt::fake_shared(surface_builder),
118 mf::a_surface(),119 mf::a_surface(),
@@ -126,7 +127,7 @@
126127
127 EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>())));128 EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>())));
128129
129 auto session = session_manager.open_session("Visual Basic Studio");130 auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>());
130 session->create_surface(mf::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}}));131 session->create_surface(mf::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}}));
131132
132 session_manager.close_session(session);133 session_manager.close_session(session);
@@ -140,7 +141,7 @@
140 EXPECT_CALL(container, insert_session(_)).Times(1);141 EXPECT_CALL(container, insert_session(_)).Times(1);
141 EXPECT_CALL(focus_setter, set_focus_to(_)).WillOnce(SaveArg<0>(&new_session));142 EXPECT_CALL(focus_setter, set_focus_to(_)).WillOnce(SaveArg<0>(&new_session));
142143
143 auto session = session_manager.open_session("Visual Basic Studio");144 auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>());
144 EXPECT_EQ(session, new_session);145 EXPECT_EQ(session, new_session);
145}146}
146147
@@ -148,8 +149,8 @@
148{149{
149 using namespace ::testing;150 using namespace ::testing;
150151
151 auto session1 = session_manager.open_session("Visual Basic Studio");152 auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>());
152 auto session2 = session_manager.open_session("IntelliJ IDEA");153 auto session2 = session_manager.open_session("IntelliJ IDEA", std::shared_ptr<me::EventSink>());
153154
154 session_manager.tag_session_with_lightdm_id(session1, 1);155 session_manager.tag_session_with_lightdm_id(session1, 1);
155156
@@ -161,8 +162,8 @@
161{162{
162 using namespace ::testing;163 using namespace ::testing;
163164
164 auto session1 = session_manager.open_session("Visual Basic Studio");165 auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>());
165 auto session2 = session_manager.open_session("IntelliJ IDEA");166 auto session2 = session_manager.open_session("IntelliJ IDEA", std::shared_ptr<me::EventSink>());
166167
167 auto shell_session1 = std::dynamic_pointer_cast<msh::Session>(session1);168 auto shell_session1 = std::dynamic_pointer_cast<msh::Session>(session1);
168 auto shell_session2 = std::dynamic_pointer_cast<msh::Session>(session2);169 auto shell_session2 = std::dynamic_pointer_cast<msh::Session>(session2);
@@ -180,7 +181,7 @@
180{181{
181 using namespace ::testing;182 using namespace ::testing;
182 std::shared_ptr<mi::InputChannel> null_input_channel;183 std::shared_ptr<mi::InputChannel> null_input_channel;
183 ON_CALL(surface_factory, create_surface(_)).WillByDefault(184 ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(
184 Return(std::make_shared<msh::Surface>(185 Return(std::make_shared<msh::Surface>(
185 mt::fake_shared(surface_builder),186 mt::fake_shared(surface_builder),
186 mf::a_surface(),187 mf::a_surface(),
@@ -191,11 +192,11 @@
191 InSequence seq;192 InSequence seq;
192193
193 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Session creation194 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Session creation
194 EXPECT_CALL(surface_factory, create_surface(_)).Times(1);195 EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1);
195 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation196 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation
196 }197 }
197198
198 auto session1 = session_manager.open_session("Weather Report");199 auto session1 = session_manager.open_session("Weather Report", std::shared_ptr<me::EventSink>());
199 session_manager.create_surface_for(session1, mf::a_surface());200 session_manager.create_surface_for(session1, mf::a_surface());
200}201}
201202
@@ -230,12 +231,12 @@
230 using namespace ::testing;231 using namespace ::testing;
231232
232 std::shared_ptr<mi::InputChannel> null_input_channel;233 std::shared_ptr<mi::InputChannel> null_input_channel;
233 ON_CALL(surface_factory, create_surface(_)).WillByDefault(234 ON_CALL(surface_factory, create_surface(_,_,_)).WillByDefault(
234 Return(std::make_shared<msh::Surface>(235 Return(std::make_shared<msh::Surface>(
235 mt::fake_shared(surface_builder),236 mt::fake_shared(surface_builder),
236 mf::a_surface(),237 mf::a_surface(),
237 null_input_channel)));238 null_input_channel)));
238 EXPECT_CALL(surface_factory, create_surface(_)).Times(1);239 EXPECT_CALL(surface_factory, create_surface(_,_,_)).Times(1);
239240
240 EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>())));241 EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>())));
241 {242 {
@@ -252,7 +253,7 @@
252 }253 }
253254
254 {255 {
255 auto session = session_manager.open_session("test");256 auto session = session_manager.open_session("test", std::shared_ptr<me::EventSink>());
256 auto surf = session_manager.create_surface_for(session, mf::a_surface());257 auto surf = session_manager.create_surface_for(session, mf::a_surface());
257 session->destroy_surface(surf);258 session->destroy_surface(surf);
258 session_manager.close_session(session);259 session_manager.close_session(session);
259260
=== modified file 'tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp'
--- tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-04-25 09:50:50 +0000
@@ -57,7 +57,6 @@
57 MOCK_METHOD0(show, void());57 MOCK_METHOD0(show, void());
5858
59 MOCK_METHOD3(configure_surface, int(mf::SurfaceId, MirSurfaceAttrib, int));59 MOCK_METHOD3(configure_surface, int(mf::SurfaceId, MirSurfaceAttrib, int));
60 MOCK_METHOD1(set_event_sink, void(std::shared_ptr<mir::EventSink> const&));
61};60};
6261
63TEST(SingleVisibilityFocusMechanism, mechanism_sets_visibility)62TEST(SingleVisibilityFocusMechanism, mechanism_sets_visibility)
6463
=== modified file 'tests/unit-tests/shell/test_surface.cpp'
--- tests/unit-tests/shell/test_surface.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/shell/test_surface.cpp 2013-04-25 09:50:50 +0000
@@ -33,6 +33,7 @@
33#include <gmock/gmock.h>33#include <gmock/gmock.h>
34#include <gtest/gtest.h>34#include <gtest/gtest.h>
3535
36namespace me = mir::events;
36namespace ms = mir::surfaces;37namespace ms = mir::surfaces;
37namespace msh = mir::shell;38namespace msh = mir::shell;
38namespace mf = mir::frontend;39namespace mf = mir::frontend;
@@ -450,3 +451,4 @@
450 mir_surface_state_fullscreen));451 mir_surface_state_fullscreen));
451 EXPECT_EQ(mir_surface_state_fullscreen, surf.state());452 EXPECT_EQ(mir_surface_state_fullscreen, surf.state());
452}453}
454
453455
=== modified file 'tests/unit-tests/shell/test_the_session_container_implementation.cpp'
--- tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-04-25 09:50:50 +0000
@@ -29,6 +29,7 @@
29#include <gtest/gtest.h>29#include <gtest/gtest.h>
30#include <string>30#include <string>
3131
32namespace me = mir::events;
32namespace mf = mir::frontend;33namespace mf = mir::frontend;
33namespace msh = mir::shell;34namespace msh = mir::shell;
34namespace mtd = mir::test::doubles;35namespace mtd = mir::test::doubles;
@@ -39,10 +40,8 @@
39 auto factory = std::make_shared<mtd::MockSurfaceFactory>();40 auto factory = std::make_shared<mtd::MockSurfaceFactory>();
40 msh::DefaultSessionContainer container;41 msh::DefaultSessionContainer container;
4142
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"));
43 "Visual Studio 7"));44 container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), "Visual Studio 8"));
44 container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(),
45 "Visual Studio 8"));
4645
47 struct local46 struct local
48 {47 {

Subscribers

People subscribed via source and target branches