Mir

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

Proposed by Alan Griffiths
Status: Superseded
Proposed branch: lp:~alan-griffiths/mir/surface-states-simplification
Merge into: lp:~vanvugt/mir/surface-states
Diff against target: 4891 lines (+1736/-576) (has conflicts)
104 files modified
CMakeLists.txt (+8/-0)
doc/building_source_for_android.md (+33/-19)
doc/footer.html (+1/-1)
doc/mainpage.md (+8/-0)
examples/demo-inprocess-egl/demo_inprocess_egl.cpp (+12/-0)
examples/demo-inprocess-egl/inprocess_egl_client.cpp (+10/-6)
examples/demo_client.c (+22/-32)
examples/demo_client_accelerated.cpp (+1/-1)
examples/demo_client_unaccelerated.c (+1/-1)
examples/eglapp.c (+3/-4)
examples/render_surfaces.cpp (+131/-25)
include/client/mir_toolkit/mir_client_library.h (+4/-2)
include/server/mir/default_server_configuration.h (+3/-3)
include/server/mir/frontend/protobuf_ipc_factory.h (+12/-0)
include/server/mir/frontend/session.h (+3/-0)
include/server/mir/frontend/session_mediator.h (+15/-0)
include/server/mir/frontend/shell.h (+5/-2)
include/server/mir/input/input_manager.h (+0/-1)
include/server/mir/input/null_input_manager.h (+0/-5)
include/server/mir/input/null_input_target_listener.h (+26/-11)
include/server/mir/shell/application_session.h (+15/-1)
include/server/mir/shell/input_focus_selector.h (+0/-52)
include/server/mir/shell/input_target_listener.h (+59/-0)
include/server/mir/shell/organising_surface_factory.h (+4/-1)
include/server/mir/shell/session.h (+1/-0)
include/server/mir/shell/session_manager.h (+6/-3)
include/server/mir/shell/single_visibility_focus_mechanism.h (+1/-4)
include/server/mir/shell/surface.h (+23/-4)
include/server/mir/shell/surface_factory.h (+9/-1)
include/server/mir/shell/surface_source.h (+4/-1)
include/shared/mir/default_configuration.h (+29/-0)
include/shared/mir/events/event_sink.h (+47/-0)
include/shared/mir/graphics/android/sync_object.h (+1/-1)
include/test/mir_test_doubles/mock_android_buffer.h (+2/-2)
include/test/mir_test_doubles/mock_display_support_provider.h (+2/-2)
include/test/mir_test_doubles/mock_fb_device.h (+2/-2)
include/test/mir_test_doubles/mock_input_configuration.h (+3/-3)
include/test/mir_test_doubles/mock_input_dispatcher.h (+3/-3)
include/test/mir_test_doubles/mock_input_focus_selector.h (+0/-40)
include/test/mir_test_doubles/mock_input_target_listener.h (+49/-0)
include/test/mir_test_doubles/mock_shell.h (+1/-1)
include/test/mir_test_doubles/mock_surface.h (+6/-1)
include/test/mir_test_doubles/mock_surface_factory.h (+4/-1)
include/test/mir_test_doubles/null_virtual_terminal.h (+2/-2)
include/test/mir_test_doubles/stub_input_target_listener.h (+59/-0)
include/test/mir_test_doubles/stub_ipc_factory.h (+5/-0)
include/test/mir_test_doubles/stub_session.h (+6/-0)
include/test/mir_test_doubles/stub_shell.h (+1/-1)
include/test/mir_test_framework/testing_server_configuration.h (+1/-1)
src/client/client_buffer_depository.h (+2/-2)
src/client/mir_client_library.cpp (+3/-0)
src/client/mir_connection.h (+8/-0)
src/client/mir_socket_rpc_channel.cpp (+13/-0)
src/client/mir_socket_rpc_channel.h (+14/-0)
src/server/default_server_configuration.cpp (+16/-9)
src/server/display_server.cpp (+1/-1)
src/server/frontend/CMakeLists.txt (+1/-0)
src/server/frontend/event_pipe.cpp (+39/-0)
src/server/frontend/event_pipe.h (+45/-0)
src/server/frontend/protobuf_message_processor.cpp (+0/-8)
src/server/frontend/protobuf_message_processor.h (+9/-4)
src/server/frontend/protobuf_socket_communicator.cpp (+17/-0)
src/server/frontend/session_mediator.cpp (+8/-0)
src/server/graphics/gbm/linux_virtual_terminal.cpp (+2/-2)
src/server/graphics/gbm/linux_virtual_terminal.h (+2/-2)
src/server/graphics/gbm/virtual_terminal.h (+2/-2)
src/server/input/android/android_dispatcher_controller.cpp (+76/-26)
src/server/input/android/android_dispatcher_controller.h (+22/-9)
src/server/input/android/default_android_input_configuration.cpp (+6/-1)
src/server/input/android/default_android_input_configuration.h (+2/-0)
src/server/input/android/event_filter_dispatcher_policy.cpp (+4/-3)
src/server/input/android/event_filter_dispatcher_policy.h (+2/-1)
src/server/shell/application_session.cpp (+10/-3)
src/server/shell/organising_surface_factory.cpp (+5/-2)
src/server/shell/session_manager.cpp (+30/-11)
src/server/shell/single_visibility_focus_mechanism.cpp (+2/-7)
src/server/shell/surface.cpp (+15/-1)
src/server/shell/surface_source.cpp (+7/-2)
tests/acceptance-tests/test_client_input.cpp (+5/-6)
tests/acceptance-tests/test_focus_management_api.cpp (+4/-4)
tests/acceptance-tests/test_focus_selection.cpp (+21/-21)
tests/behavior-tests/session_management_context.cpp (+8/-4)
tests/death-tests/test_application_manager_death.cpp (+4/-3)
tests/integration-tests/cucumber/test_session_management_context.cpp (+3/-3)
tests/integration-tests/input/android/test_android_input_manager.cpp (+70/-12)
tests/integration-tests/input/android/test_fake_event_hub_to_event_filter.cpp (+1/-1)
tests/integration-tests/shell/test_session_manager.cpp (+34/-26)
tests/mir_test_framework/testing_server_options.cpp (+3/-11)
tests/unit-tests/CMakeLists.txt (+4/-0)
tests/unit-tests/frontend/CMakeLists.txt (+1/-0)
tests/unit-tests/frontend/test_event_pipe.cpp (+119/-0)
tests/unit-tests/frontend/test_session_mediator.cpp (+17/-3)
tests/unit-tests/frontend/test_session_mediator_android.cpp (+18/-1)
tests/unit-tests/frontend/test_session_mediator_gbm.cpp (+17/-1)
tests/unit-tests/input/android/test_android_dispatcher_controller.cpp (+148/-21)
tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp (+1/-1)
tests/unit-tests/shell/test_application_session.cpp (+23/-16)
tests/unit-tests/shell/test_organising_surface_factory.cpp (+6/-5)
tests/unit-tests/shell/test_registration_order_focus_sequence.cpp (+17/-11)
tests/unit-tests/shell/test_session_manager.cpp (+94/-22)
tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp (+1/-24)
tests/unit-tests/shell/test_surface.cpp (+97/-16)
tests/unit-tests/shell/test_the_session_container_implementation.cpp (+9/-4)
tools/setup-partial-armhf-chroot.sh (+5/-24)
Text conflict in examples/render_surfaces.cpp
Path conflict: include/server/mir/event_queue.h / src/server/frontend/event_pipe.h
Text conflict in include/server/mir/frontend/protobuf_ipc_factory.h
Text conflict in include/server/mir/frontend/session.h
Text conflict in include/server/mir/frontend/session_mediator.h
Text conflict in include/server/mir/shell/application_session.h
Text conflict in include/server/mir/shell/surface.h
Path conflict: include/shared/mir/event_sink.h / include/shared/mir/events/event_sink.h
Text conflict in include/shared/mir/events/event_sink.h
Text conflict in include/test/mir_test_doubles/stub_ipc_factory.h
Text conflict in include/test/mir_test_doubles/stub_session.h
Text conflict in src/client/mir_connection.h
Text conflict in src/client/mir_socket_rpc_channel.cpp
Text conflict in src/client/mir_socket_rpc_channel.h
Text conflict in src/server/default_server_configuration.cpp
Path conflict: src/server/event_queue.cpp / src/server/frontend/event_pipe.cpp
Text conflict in src/server/frontend/event_pipe.cpp
Text conflict in src/server/frontend/event_pipe.h
Text conflict in src/server/frontend/protobuf_message_processor.h
Text conflict in src/server/frontend/protobuf_socket_communicator.cpp
Text conflict in src/server/frontend/session_mediator.cpp
Text conflict in src/server/shell/surface.cpp
Text conflict in tests/unit-tests/CMakeLists.txt
Path conflict: tests/unit-tests/event/test_event_queue.cpp / tests/unit-tests/frontend/test_event_pipe.cpp
Text conflict in tests/unit-tests/frontend/test_event_pipe.cpp
Text conflict in tests/unit-tests/frontend/test_session_mediator.cpp
Text conflict in tests/unit-tests/frontend/test_session_mediator_android.cpp
Text conflict in tests/unit-tests/frontend/test_session_mediator_gbm.cpp
Text conflict in tests/unit-tests/shell/test_surface.cpp
To merge this branch: bzr merge lp:~alan-griffiths/mir/surface-states-simplification
Reviewer Review Type Date Requested Status
Daniel van Vugt Disapprove
Review via email: mp+159837@code.launchpad.net

This proposal has been superseded by a proposal from 2013-04-23.

Commit message

frontend, shell, tests: Avoid supplying dependencies through public member functions.

Description of the change

frontend, shell, tests: 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 :

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 :

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 :

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

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 :

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

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 :

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

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
Daniel van Vugt (vanvugt) wrote :

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.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-04-19 03:20:05 +0000
3+++ CMakeLists.txt 2013-04-23 12:15:34 +0000
4@@ -205,4 +205,12 @@
5 add_subdirectory(guides/)
6 add_subdirectory(cmake/)
7
8+# There's no nice way to format this. Thanks CMake.
9+add_test(LGPL-required
10+ /bin/sh -c "! grep -rl 'GNU General' ${PROJECT_SOURCE_DIR}/src/client ${PROJECT_SOURCE_DIR}/include/client ${PROJECT_SOURCE_DIR}/src/shared ${PROJECT_SOURCE_DIR}/include/shared"
11+)
12+add_test(GPL-required
13+ /bin/sh -c "! grep -rl 'GNU Lesser' ${PROJECT_SOURCE_DIR}/src/server ${PROJECT_SOURCE_DIR}/include/server ${PROJECT_SOURCE_DIR}/include/test ${PROJECT_SOURCE_DIR}/tests ${PROJECT_SOURCE_DIR}/examples"
14+)
15+
16 enable_coverage_report(mirserver)
17
18=== modified file 'doc/building_source_for_android.md'
19--- doc/building_source_for_android.md 2013-04-04 06:50:04 +0000
20+++ doc/building_source_for_android.md 2013-04-23 12:15:34 +0000
21@@ -33,12 +33,12 @@
22
23 From within the armhf system:
24
25-1. Set up Dependencies
26+- Set up Dependencies
27
28 $ apt-get install devscripts equivs cmake
29 $ mk-build-deps --install --tool "apt-get -y" --build-dep debian/control
30
31-2. Build
32+- Build
33
34 $ bzr branch lp:mir
35 $ mkdir mir/build; cd mir/build
36@@ -51,23 +51,37 @@
37 ubuntu package) to produce armhf code. This is typically the quickest way to
38 compile and run code, and is well suited for a development workflow.
39
40-1. Be sure that the cross compiler that you are using matches the target
41- environment. (eg, make sure you're using the quantal toolchain if you're
42- targeting a quantal phablet image)
43-
44-2. Set up a chroot with the mir dependencies installed. At the moment, you
45- can look at the script and instructions in lp:mir as an
46- example of how to set up a partial chroot you can build mir against.
47-
48-3. There are a few ways to do this, but here is an example of how to build mir for android
49-
50- $ bzr branch lp:mir
51+- Be sure that the cross compiler that you are using matches the target
52+ environment. (eg, make sure you're using the raring toolchain if you're
53+ targeting a raring phablet image) You can specify the toolchain version
54+ thusly:
55+
56+ $ apt-get install g++-4.7-arm-linux-gnueabihf/raring
57+
58+- Get access to armhf packages via apt-get. On an amd64/ia32 system, you can
59+ do this by adding a file like the one below to /etc/apt/sources.list.d/
60+
61+ #example sources.list with armhf dependencies
62+ deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ raring main restricted universe multiverse
63+ deb [arch=armhf] http://ppa.launchpad.net/phablet-team/ppa/ubuntu raring main #for hybris packages
64+
65+ Then you should run:
66+
67+ $ dpkg --add-architecture armhf
68+ $ apt-get update
69+
70+ To test, try downloading a package like this:
71+
72+ $ apt-get download my-package:armhf
73+
74+- Once you're able to download armhf packages from the repository, the
75+ cross-compile-chroot.sh script provides an example of how to download
76+ a partial chroot with the mir dependencies, and compile the source for
77+ android targets.
78+
79+ The script sets up a partial chroot via tools/setup-partial-armhf-chroot.sh
80+ and then runs build commands similar to this:
81+
82 $ mkdir mir/build; cd mir/build
83 $ MIR_NDK_PATH=/path/to/depenendcies/chroot cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/LinuxCrossCompile.cmake -DBoost_COMPILER=-gcc -DMIR_ENABLE_DEATH_TESTS=NO -DMIR_PLATFORM=android ..
84 $ make
85-
86-N.B. The `cross-compile-android.sh` script in mir's top level directory
87-provides a scripting example of how to cross compile.
88-The 'setup-partial-armhf-chroot.sh' will attempt to download all the arm
89-dependencies you need. You have to have your APT sources.list files pointed at
90-arm repositories.
91
92=== modified file 'doc/footer.html'
93--- doc/footer.html 2012-12-28 08:57:38 +0000
94+++ doc/footer.html 2013-04-23 12:15:34 +0000
95@@ -1,2 +1,2 @@
96 <hr>
97-<p align="center">Copyright &copy; 2012 Canonical Ltd.</p>
98+<p align="center">Copyright &copy; 2012,2013 Canonical Ltd.</p>
99
100=== modified file 'doc/mainpage.md'
101--- doc/mainpage.md 2013-04-22 09:50:06 +0000
102+++ doc/mainpage.md 2013-04-23 12:15:34 +0000
103@@ -57,7 +57,15 @@
104
105 - \ref mir_toolkit "Mir API Documentation"
106 - \subpage demo_client.c "demo_client.c: A simple mir client"
107+
108+Writing server applications
109+---------------------------
110+
111+Mir server is written as a library which allows the server code to be adapted
112+for bespoke applications.
113+
114 - \subpage render_surfaces-example "render_surfaces.cpp: A simple program using the mir library"
115+ - \ref demo_inprocess_egl
116
117 Working on Mir code
118 -------------------
119
120=== modified file 'examples/demo-inprocess-egl/demo_inprocess_egl.cpp'
121--- examples/demo-inprocess-egl/demo_inprocess_egl.cpp 2013-04-19 03:20:05 +0000
122+++ examples/demo-inprocess-egl/demo_inprocess_egl.cpp 2013-04-23 12:15:34 +0000
123@@ -26,9 +26,20 @@
124
125 namespace me = mir::examples;
126
127+///\page demo_inprocess_egl demo_inprocess_egl.cpp: A simple use of egl in process
128+///\section main main
129+/// The main() function uses a default configuration for Mir and sets up an InprocessEGLClient
130+/// that accesses the graphics platform and surface factory.
131+/// \snippet demo_inprocess_egl.cpp main_tag
132+/// This InprocessEGLClient sets up a single surface
133+/// \snippet inprocess_egl_client.cpp setup_tag
134+/// And loops updating the surface
135+/// \snippet inprocess_egl_client.cpp loop_tag
136+
137 int main(int argc, char const* argv[])
138 try
139 {
140+ ///\internal [main_tag]
141 mir::DefaultServerConfiguration config(argc, argv);
142
143 std::shared_ptr<me::InprocessEGLClient> client;
144@@ -38,6 +49,7 @@
145 config.the_graphics_platform(),
146 config.the_shell_surface_factory());
147 });
148+ ///\internal [main_tag]
149
150 return 0;
151 }
152
153=== modified file 'examples/demo-inprocess-egl/inprocess_egl_client.cpp'
154--- examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-04-16 09:16:38 +0000
155+++ examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-04-23 12:15:34 +0000
156@@ -54,24 +54,27 @@
157 {
158 geom::Size const surface_size = geom::Size{geom::Width{512},
159 geom::Height{512}};
160-
161+
162+ ///\internal [setup_tag]
163 auto params = mf::a_surface().of_name("Inprocess EGL Demo")
164 .of_size(surface_size)
165 .of_buffer_usage(mc::BufferUsage::hardware)
166 .of_pixel_format(geom::PixelFormat::argb_8888);
167- auto surface = surface_factory->create_surface(params);
168-
169+ auto surface = surface_factory->create_surface(params, mf::SurfaceId(), std::shared_ptr<events::EventSink>());
170+
171 surface->advance_client_buffer(); // TODO: What a wart!
172-
173+
174 auto native_display = graphics_platform->shell_egl_display();
175 me::EGLHelper helper(reinterpret_cast<EGLNativeDisplayType>(native_display), reinterpret_cast<EGLNativeWindowType>(surface.get()));
176
177 auto rc = eglMakeCurrent(helper.the_display(), helper.the_surface(), helper.the_surface(), helper.the_context());
178 assert(rc == EGL_TRUE);
179-
180+
181 mir::draw::glAnimationBasic gl_animation;
182 gl_animation.init_gl();
183-
184+ ///\internal [setup_tag]
185+
186+ ///\internal [loop_tag]
187 for(;;)
188 {
189 gl_animation.render_gl();
190@@ -80,4 +83,5 @@
191
192 gl_animation.step();
193 }
194+ ///\internal [loop_tag]
195 }
196
197=== modified file 'examples/demo_client.c'
198--- examples/demo_client.c 2013-04-18 04:23:56 +0000
199+++ examples/demo_client.c 2013-04-23 12:15:34 +0000
200@@ -25,14 +25,30 @@
201 #include <getopt.h>
202
203 ///\page demo_client.c demo_client.c: A simple mir client
204-/// demo_client shows the use of mir API
205+/// demo_client shows the use of mir API.
206+/// This program opens a mir connection and creates a surface.
207+///\section demo_client demo_client()
208+/// Opens a mir connection and creates a surface and advances the
209+/// current buffer before closing the surface and connection.
210+///\subsection connect request and wait for connection handle
211+/// \snippet demo_client.c connect_tag
212+///\subsection surface_create request and wait for surface handle
213+/// \snippet demo_client.c surface_create_tag
214+///\subsection next_buffer exchange the current buffer for a new one
215+/// \snippet demo_client.c next_buffer_tag
216+///\subsection surface_release We release our surface
217+/// \snippet demo_client.c surface_release_tag
218+///\subsection connection_release We release our connection
219+/// \snippet demo_client.c connection_release_tag
220 /// \example demo_client.c A simple mir client
221-
222-///\page demo_client.c
223 ///\section MirDemoState MirDemoState
224-/// This program opens a mir connection and creates a surface. The handles
225-/// needs to be accessible both to callbacks and to the control function.
226+/// The handles needs to be accessible both to callbacks and to the control function.
227 /// \snippet demo_client.c MirDemoState_tag
228+///\section Callbacks Callbacks
229+/// This program opens a mir connection and creates a surface. The handles
230+/// needs to be accessible both to callbacks and to the control function.
231+/// \snippet demo_client.c Callback_tag
232+
233 ///\internal [MirDemoState_tag]
234 // Utility structure for the state of a single surface session.
235 typedef struct MirDemoState
236@@ -42,11 +58,6 @@
237 } MirDemoState;
238 ///\internal [MirDemoState_tag]
239
240-///\page demo_client.c
241-///\section Callbacks Callbacks
242-/// This program opens a mir connection and creates a surface. The handles
243-/// needs to be accessible both to callbacks and to the control function.
244-/// \snippet demo_client.c Callback_tag
245 ///\internal [Callback_tag]
246 // Callback to update MirDemoState on connection
247 static void connection_callback(MirConnection *new_connection, void *context)
248@@ -75,11 +86,6 @@
249 }
250 ///\internal [Callback_tag]
251
252-
253-///\page demo_client.c
254-///\section demo_client demo_client()
255-/// Opens a mir connection and creates a surface and advances the
256-/// current buffer before closing the surface and connection.
257 void demo_client(const char* server, int buffer_swap_count)
258 {
259 MirDemoState mcd;
260@@ -88,9 +94,6 @@
261
262 puts("Starting");
263
264- ///\page demo_client.c
265- ///\subsection connect request and wait for connection handle
266- /// \snippet demo_client.c connect_tag
267 ///\internal [connect_tag]
268 // Call mir_connect and wait for callback to complete.
269 mir_wait_for(mir_connect(server, __PRETTY_FUNCTION__, connection_callback, &mcd));
270@@ -124,9 +127,6 @@
271 MirSurfaceParameters const request_params =
272 {__PRETTY_FUNCTION__, 640, 480, pixel_format, mir_buffer_usage_hardware};
273
274- ///\page demo_client.c
275- ///\subsection surface_create request and wait for surface handle
276- /// \snippet demo_client.c surface_create_tag
277 ///\internal [surface_create_tag]
278 // ...we create a surface using that format and wait for callback to complete.
279 mir_wait_for(mir_connection_create_surface(mcd.connection, &request_params, surface_create_callback, &mcd));
280@@ -166,39 +166,29 @@
281 // In a real application we'd render into the current buffer
282 }
283
284- ///\page demo_client.c
285- ///\subsection next_buffer exchange the current buffer for a new one
286- /// \snippet demo_client.c next_buffer_tag
287 ///\internal [next_buffer_tag]
288 mir_wait_for(mir_surface_next_buffer(mcd.surface, surface_next_buffer_callback, &mcd));
289 ///\internal [next_buffer_tag]
290 }
291
292- ///\page demo_client.c
293- ///\subsection surface_release We release our surface
294- /// \snippet demo_client.c surface_release_tag
295 ///\internal [surface_release_tag]
296 // We should release our surface
297 mir_wait_for(mir_surface_release(mcd.surface, surface_release_callback, &mcd));
298 puts("Surface released");
299 ///\internal [surface_release_tag]
300
301- ///\page demo_client.c
302- ///\subsection connection_release We release our connection
303- /// \snippet demo_client.c connection_release_tag
304 ///\internal [connection_release_tag]
305 // We should release our connection
306 mir_connection_release(mcd.connection);
307 puts("Connection released");
308 ///\internal [connection_release_tag]
309 }
310-///\page demo_client.c
311
312 // The main() function deals with parsing arguments and defaults
313 int main(int argc, char* argv[])
314 {
315 // Some variables for holding command line options
316- char const *server = "/tmp/mir_socket";
317+ char const *server = NULL;
318 int buffer_swap_count = 0;
319
320 // Parse the command line
321
322=== modified file 'examples/demo_client_accelerated.cpp'
323--- examples/demo_client_accelerated.cpp 2013-04-18 04:23:56 +0000
324+++ examples/demo_client_accelerated.cpp 2013-04-23 12:15:34 +0000
325@@ -28,7 +28,7 @@
326 #include <EGL/egl.h>
327 #include <GLES2/gl2.h>
328
329-static char const *socket_file = "/tmp/mir_socket";
330+static char const *socket_file = NULL;
331
332 int main(int argc, char* argv[])
333 {
334
335=== modified file 'examples/demo_client_unaccelerated.c'
336--- examples/demo_client_unaccelerated.c 2013-04-18 04:23:56 +0000
337+++ examples/demo_client_unaccelerated.c 2013-04-23 12:15:34 +0000
338@@ -26,7 +26,7 @@
339 #include <getopt.h>
340 #include <stdint.h>
341
342-static char const *socket_file = "/tmp/mir_socket";
343+static char const *socket_file = NULL;
344
345 static void render_pattern(MirGraphicsRegion *region, uint32_t pf)
346 {
347
348=== modified file 'examples/eglapp.c'
349--- examples/eglapp.c 2013-04-18 04:23:56 +0000
350+++ examples/eglapp.c 2013-04-23 12:15:34 +0000
351@@ -26,7 +26,6 @@
352
353 #include <xkbcommon/xkbcommon-keysyms.h>
354
355-static const char servername[] = "/tmp/mir_socket";
356 static const char appname[] = "egldemo";
357
358 static MirConnection *connection;
359@@ -128,13 +127,13 @@
360 EGLContext eglctx;
361 EGLBoolean ok;
362
363- connection = mir_connect_sync(servername, appname);
364+ connection = mir_connect_sync(NULL, appname);
365 CHECK(mir_connection_is_valid(connection), "Can't get connection");
366
367 mir_connection_get_display_info(connection, &dinfo);
368
369- printf("Connected to display %s: %dx%d, supports %d pixel formats\n",
370- servername, dinfo.width, dinfo.height,
371+ printf("Connected to display: %dx%d, supports %d pixel formats\n",
372+ dinfo.width, dinfo.height,
373 dinfo.supported_pixel_format_items);
374
375 surfaceparm.width = *width > 0 ? *width : dinfo.width;
376
377=== modified file 'examples/render_surfaces.cpp'
378--- examples/render_surfaces.cpp 2013-04-22 09:50:06 +0000
379+++ examples/render_surfaces.cpp 2013-04-23 12:15:34 +0000
380@@ -28,6 +28,7 @@
381 #include "mir/surfaces/surface.h"
382 #include "mir/default_server_configuration.h"
383 #include "mir/run_mir.h"
384+#include "mir/abnormal_exit.h"
385
386 #include "mir_image.h"
387 #include "buffer_render_target.h"
388@@ -54,13 +55,27 @@
389 ///\page render_surfaces-example render_surfaces.cpp: A simple program using the mir library.
390 ///\tableofcontents
391 ///render_surfaces shows the use of mir to render some moving surfaces
392+///\section main main()
393+/// The main() function uses a RenderSurfacesServerConfiguration to initialize and run mir.
394+/// \snippet render_surfaces.cpp main_tag
395+///\section RenderSurfacesServerConfiguration RenderSurfacesServerConfiguration
396+/// The configuration stubs out client connectivity and input.
397+/// \snippet render_surfaces.cpp RenderSurfacesServerConfiguration_stubs_tag
398+/// it also provides a bespoke buffer initializer
399+/// \snippet render_surfaces.cpp RenderResourcesBufferInitializer_tag
400+/// and a bespoke compositing strategy
401+/// \snippet render_surfaces.cpp RenderSurfacesCompositingStrategy_tag
402+///\section Utilities Utility classes
403+/// For smooth animation we need to track time and move surfaces accordingly
404+///\subsection StopWatch StopWatch
405+/// \snippet render_surfaces.cpp StopWatch_tag
406+///\subsection Moveable Moveable
407+/// \snippet render_surfaces.cpp Moveable_tag
408+
409 ///\example render_surfaces.cpp A simple program using the mir library.
410
411 namespace
412 {
413-///\page render_surfaces-example
414-///\section StopWatch StopWatch
415-/// \snippet render_surfaces.cpp StopWatch_tag
416 ///\internal [StopWatch_tag]
417 // tracks elapsed time - for animation.
418 class StopWatch
419@@ -103,9 +118,6 @@
420 };
421 ///\internal [StopWatch_tag]
422
423-///\page render_surfaces-example
424-///\section Moveable Moveable
425-/// \snippet render_surfaces.cpp Moveable_tag
426 ///\internal [Moveable_tag]
427 // Adapter to support movement of surfaces.
428 class Moveable
429@@ -175,9 +187,6 @@
430 };
431 ///\internal [Moveable_tag]
432
433-///\page render_surfaces-example
434-///\section RenderSurfacesServerConfiguration RenderSurfacesServerConfiguration
435-/// \snippet render_surfaces.cpp RenderSurfacesServerConfiguration_tag
436 ///\internal [RenderSurfacesServerConfiguration_tag]
437 // Extend the default configuration to manage moveables.
438 class RenderSurfacesServerConfiguration : public mir::DefaultServerConfiguration
439@@ -189,17 +198,103 @@
440 {
441 }
442
443- // Override to stub out the default
444- std::shared_ptr<mf::Communicator> the_communicator() override;
445-
446- // Override to stub out the default
447- std::shared_ptr<mi::InputManager> the_input_manager() override;
448-
449- // Override for a bespoke initializer
450- std::shared_ptr<mg::BufferInitializer> the_buffer_initializer() override;
451-
452- // Override for a bespoke compositing strategy
453- std::shared_ptr<mc::CompositingStrategy> the_compositing_strategy() override;
454+ ///\internal [RenderSurfacesServerConfiguration_stubs_tag]
455+ // Stub out server connectivity.
456+ std::shared_ptr<mf::Communicator> the_communicator() override
457+ {
458+ struct NullCommunicator : public mf::Communicator
459+ {
460+ void start() {}
461+ void stop() {}
462+ };
463+
464+ return std::make_shared<NullCommunicator>();
465+ }
466+
467+ // Stub out input.
468+ std::shared_ptr<mi::InputManager> the_input_manager() override
469+ {
470+ return std::make_shared<mi::NullInputManager>();
471+ }
472+ ///\internal [RenderSurfacesServerConfiguration_stubs_tag]
473+
474+ ///\internal [RenderResourcesBufferInitializer_tag]
475+ // Override for a bespoke buffer initializer
476+ std::shared_ptr<mg::BufferInitializer> the_buffer_initializer() override
477+ {
478+ class RenderResourcesBufferInitializer : public mg::BufferInitializer
479+ {
480+ public:
481+ RenderResourcesBufferInitializer()
482+ : img_renderer{mir_image.pixel_data,
483+ geom::Size{geom::Width{mir_image.width},
484+ geom::Height{mir_image.height}},
485+ mir_image.bytes_per_pixel}
486+ {
487+ }
488+
489+ void operator()(mc::Buffer& buffer)
490+ {
491+ mt::BufferRenderTarget brt{buffer};
492+ brt.make_current();
493+ img_renderer.render();
494+ }
495+
496+ private:
497+ mt::ImageRenderer img_renderer;
498+ };
499+
500+ return std::make_shared<RenderResourcesBufferInitializer>();
501+ }
502+ ///\internal [RenderResourcesBufferInitializer_tag]
503+
504+ ///\internal [RenderSurfacesCompositingStrategy_tag]
505+ // Decorate the DefaultCompositingStrategy in order to move surfaces.
506+ std::shared_ptr<mc::CompositingStrategy> the_compositing_strategy() override
507+ {
508+ class RenderSurfacesCompositingStrategy : public mc::CompositingStrategy
509+ {
510+ public:
511+ RenderSurfacesCompositingStrategy(std::shared_ptr<mc::Renderables> const& renderables,
512+ std::shared_ptr<mg::Renderer> const& renderer,
513+ std::vector<Moveable>& moveables)
514+ : default_compositing_strategy{renderables, renderer},
515+ frames{0},
516+ moveables(moveables)
517+ {
518+ }
519+
520+ void render(mg::DisplayBuffer& display_buffer)
521+ {
522+ stop_watch.stop();
523+ if (stop_watch.elapsed_seconds_since_last_restart() >= 1)
524+ {
525+ std::cout << "FPS: " << frames << " Frame Time: " << 1.0 / frames << std::endl;
526+ frames = 0;
527+ stop_watch.restart();
528+ }
529+
530+ glClearColor(0.0, 1.0, 0.0, 1.0);
531+ default_compositing_strategy.render(display_buffer);
532+
533+ for (auto& m : moveables)
534+ m.step();
535+
536+ frames++;
537+ }
538+
539+ private:
540+ mc::DefaultCompositingStrategy default_compositing_strategy;
541+ StopWatch stop_watch;
542+ uint32_t frames;
543+ std::vector<Moveable>& moveables;
544+ };
545+
546+ return std::make_shared<RenderSurfacesCompositingStrategy>(the_renderables(),
547+ the_renderer(),
548+ moveables);
549+ }
550+ ///\internal [RenderSurfacesCompositingStrategy_tag]
551
552 // New function to initialize moveables with surfaces
553 void create_surfaces()
554@@ -248,13 +343,10 @@
555 ///\internal [RenderSurfacesServerConfiguration_tag]
556 }
557
558-///\page render_surfaces-example
559-///\section main main()
560-/// \snippet render_surfaces.cpp main_tag
561-///\internal [main_tag]
562-// Pull the bits together.
563 int main(int argc, char **argv)
564+try
565 {
566+ ///\internal [main_tag]
567 /* Parse the command line */
568 unsigned int num_moveables{5};
569
570@@ -269,9 +361,11 @@
571 RenderSurfacesServerConfiguration conf{num_moveables};
572
573 mir::run_mir(conf, [&](mir::DisplayServer&) {conf.create_surfaces();});
574+ ///\internal [main_tag]
575
576 return 0;
577 }
578+<<<<<<< TREE
579 ///\internal [main_tag]
580
581 ///\page render_surfaces-example
582@@ -384,3 +478,15 @@
583 return std::make_shared<mi::NullInputManager>();
584 }
585 ///\internal [NullInputManager_tag]
586+=======
587+catch (mir::AbnormalExit const& error)
588+{
589+ std::cerr << error.what() << std::endl;
590+ return 1;
591+}
592+catch (std::exception const& error)
593+{
594+ std::cerr << "ERROR: " << error.what() << std::endl;
595+ return 1;
596+}
597+>>>>>>> MERGE-SOURCE
598
599=== modified file 'include/client/mir_toolkit/mir_client_library.h'
600--- include/client/mir_toolkit/mir_client_library.h 2013-04-18 04:23:56 +0000
601+++ include/client/mir_toolkit/mir_client_library.h 2013-04-23 12:15:34 +0000
602@@ -35,7 +35,8 @@
603 * Request a connection to the Mir server. The supplied callback is called when
604 * the connection is established, or fails. The returned wait handle remains
605 * valid until the connection has been released.
606- * \param [in] server A name identifying the server
607+ * \param [in] server File path of the server socket to connect to, or
608+ * NULL to choose the default server
609 * \param [in] app_name A name referring to the application
610 * \param [in] callback Callback function to be invoked when request
611 * completes
612@@ -50,7 +51,8 @@
613
614 /**
615 * Perform a mir_connect() but also wait for and return the result.
616- * \param [in] server A name identifying the server
617+ * \param [in] server File path of the server socket to connect to, or
618+ * NULL to choose the default server
619 * \param [in] app_name A name referring to the application
620 * \return The resulting MirConnection
621 */
622
623=== modified file 'include/server/mir/default_server_configuration.h'
624--- include/server/mir/default_server_configuration.h 2013-04-22 03:24:56 +0000
625+++ include/server/mir/default_server_configuration.h 2013-04-23 12:15:34 +0000
626@@ -50,7 +50,7 @@
627 {
628 class SurfaceFactory;
629 class SurfaceBuilder;
630-class InputFocusSelector;
631+class InputTargetListener;
632 class SessionContainer;
633 class FocusSetter;
634 class FocusSequence;
635@@ -156,7 +156,6 @@
636 /** @name shell configuration - dependencies
637 * dependencies of shell on the rest of the Mir
638 * @{ */
639- virtual std::shared_ptr<shell::InputFocusSelector> the_input_focus_selector();
640 virtual std::shared_ptr<shell::SurfaceBuilder> the_surface_builder();
641 /** @} */
642
643@@ -178,6 +177,7 @@
644 * @{ */
645 virtual std::shared_ptr<input::android::InputConfiguration> the_input_configuration();
646 virtual std::initializer_list<std::shared_ptr<input::EventFilter> const> the_event_filters();
647+ virtual std::shared_ptr<shell::InputTargetListener> the_input_target_listener();
648 /** @} */
649
650 /** @name logging configuration - customization
651@@ -197,7 +197,7 @@
652 CachedPtr<frontend::Shell> session_manager;
653 std::shared_ptr<input::android::InputConfiguration> input_configuration;
654 CachedPtr<input::InputManager> input_manager;
655- CachedPtr<shell::InputFocusSelector> input_focus_selector;
656+ CachedPtr<shell::InputTargetListener> input_target_listener;
657 CachedPtr<graphics::Platform> graphics_platform;
658 CachedPtr<graphics::BufferInitializer> buffer_initializer;
659 CachedPtr<compositor::GraphicBufferAllocator> buffer_allocator;
660
661=== modified file 'include/server/mir/frontend/protobuf_ipc_factory.h'
662--- include/server/mir/frontend/protobuf_ipc_factory.h 2013-04-19 07:45:44 +0000
663+++ include/server/mir/frontend/protobuf_ipc_factory.h 2013-04-23 12:15:34 +0000
664@@ -23,8 +23,15 @@
665
666 namespace mir
667 {
668+<<<<<<< TREE
669 class EventSink;
670
671+=======
672+namespace events
673+{
674+class EventSink;
675+}
676+>>>>>>> MERGE-SOURCE
677 namespace protobuf
678 {
679 class DisplayServer;
680@@ -37,8 +44,13 @@
681 class ProtobufIpcFactory
682 {
683 public:
684+<<<<<<< TREE
685 virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server(
686 std::shared_ptr<EventSink> const& sink) = 0;
687+=======
688+ virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server(
689+ std::shared_ptr<events::EventSink> const& sink) = 0;
690+>>>>>>> MERGE-SOURCE
691 virtual std::shared_ptr<ResourceCache> resource_cache() = 0;
692 virtual std::shared_ptr<MessageProcessorReport> report() = 0;
693
694
695=== modified file 'include/server/mir/frontend/session.h'
696--- include/server/mir/frontend/session.h 2013-04-22 03:24:56 +0000
697+++ include/server/mir/frontend/session.h 2013-04-23 12:15:34 +0000
698@@ -29,8 +29,11 @@
699
700 namespace mir
701 {
702+<<<<<<< TREE
703 class EventSink;
704
705+=======
706+>>>>>>> MERGE-SOURCE
707 namespace frontend
708 {
709 class Surface;
710
711=== modified file 'include/server/mir/frontend/session_mediator.h'
712--- include/server/mir/frontend/session_mediator.h 2013-04-19 07:45:44 +0000
713+++ include/server/mir/frontend/session_mediator.h 2013-04-23 12:15:34 +0000
714@@ -27,8 +27,15 @@
715
716 namespace mir
717 {
718+<<<<<<< TREE
719 class EventSink;
720
721+=======
722+namespace events
723+{
724+class EventSink;
725+}
726+>>>>>>> MERGE-SOURCE
727 namespace graphics
728 {
729 class Platform;
730@@ -62,7 +69,11 @@
731 std::shared_ptr<graphics::ViewableArea> const& viewable_area,
732 std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator,
733 std::shared_ptr<SessionMediatorReport> const& report,
734+<<<<<<< TREE
735 std::shared_ptr<EventSink> const& event_sink,
736+=======
737+ std::shared_ptr<events::EventSink> const& event_sink,
738+>>>>>>> MERGE-SOURCE
739 std::shared_ptr<ResourceCache> const& resource_cache);
740
741 /* Platform independent requests */
742@@ -119,7 +130,11 @@
743 std::shared_ptr<compositor::GraphicBufferAllocator> const buffer_allocator;
744
745 std::shared_ptr<SessionMediatorReport> const report;
746+<<<<<<< TREE
747 std::shared_ptr<EventSink> const event_sink;
748+=======
749+ std::shared_ptr<events::EventSink> const event_sink;
750+>>>>>>> MERGE-SOURCE
751 std::shared_ptr<ResourceCache> const resource_cache;
752 std::shared_ptr<ClientBufferTracker> const client_tracker;
753
754
755=== modified file 'include/server/mir/frontend/shell.h'
756--- include/server/mir/frontend/shell.h 2013-04-22 03:24:56 +0000
757+++ include/server/mir/frontend/shell.h 2013-04-23 12:15:34 +0000
758@@ -24,7 +24,10 @@
759
760 namespace mir
761 {
762-
763+namespace events
764+{
765+class EventSink;
766+}
767 namespace frontend
768 {
769 class Session;
770@@ -35,7 +38,7 @@
771 public:
772 virtual ~Shell() {}
773
774- virtual std::shared_ptr<Session> open_session(std::string const& name) = 0;
775+ virtual std::shared_ptr<Session> open_session(std::string const& name, std::shared_ptr<events::EventSink> const& sink) = 0;
776 virtual void close_session(std::shared_ptr<Session> const& session) = 0;
777
778 virtual void tag_session_with_lightdm_id(std::shared_ptr<Session> const& session, int id) = 0;
779
780=== modified file 'include/server/mir/input/input_manager.h'
781--- include/server/mir/input/input_manager.h 2013-04-16 09:16:38 +0000
782+++ include/server/mir/input/input_manager.h 2013-04-23 12:15:34 +0000
783@@ -21,7 +21,6 @@
784 #define MIR_INPUT_INPUT_MANAGER_H_
785
786 #include "mir/input/input_channel_factory.h"
787-#include "mir/shell/input_focus_selector.h"
788
789 #include <memory>
790
791
792=== modified file 'include/server/mir/input/null_input_manager.h'
793--- include/server/mir/input/null_input_manager.h 2013-04-16 09:16:38 +0000
794+++ include/server/mir/input/null_input_manager.h 2013-04-23 12:15:34 +0000
795@@ -40,11 +40,6 @@
796 return std::shared_ptr<InputChannel>();
797 }
798
799- virtual void set_input_focus_to(std::shared_ptr<input::SessionTarget> const& /* session */,
800- std::shared_ptr<input::SurfaceTarget> const& /* surface */)
801- {
802- }
803-
804 protected:
805 NullInputManager(const NullInputManager&) = delete;
806 NullInputManager& operator=(const NullInputManager&) = delete;
807
808=== renamed file 'include/server/mir/input/null_input_focus_selector.h' => 'include/server/mir/input/null_input_target_listener.h'
809--- include/server/mir/input/null_input_focus_selector.h 2013-04-17 02:04:35 +0000
810+++ include/server/mir/input/null_input_target_listener.h 2013-04-23 12:15:34 +0000
811@@ -16,33 +16,48 @@
812 * Authored by: Robert Carr <robert.carr@canonical.com>
813 */
814
815-#ifndef MIR_INPUT_NULL_INPUT_FOCUS_SELECTOR_H_
816-#define MIR_INPUT_NULL_INPUT_FOCUS_SELECTOR_H_
817+#ifndef MIR_INPUT_NULL_INPUT_TARGET_LISTENER_H_
818+#define MIR_INPUT_NULL_INPUT_TARGET_LISTENER_H_
819
820-#include "mir/shell/input_focus_selector.h"
821+#include "mir/shell/input_target_listener.h"
822
823 namespace mir
824 {
825 namespace input
826 {
827
828-class NullInputFocusSelector : public shell::InputFocusSelector
829+class NullInputTargetListener : public shell::InputTargetListener
830 {
831 public:
832- NullInputFocusSelector() {};
833- virtual ~NullInputFocusSelector() {}
834+ NullInputTargetListener() {};
835+ virtual ~NullInputTargetListener() noexcept(true) {}
836
837- virtual void set_input_focus_to(std::shared_ptr<input::SessionTarget> const&,
838- std::shared_ptr<input::SurfaceTarget> const&)
839+ virtual void input_application_opened(std::shared_ptr<input::SessionTarget> const&)
840+ {
841+ }
842+ virtual void input_application_closed(std::shared_ptr<input::SessionTarget> const&)
843+ {
844+ }
845+ virtual void input_surface_opened(std::shared_ptr<input::SessionTarget> const&,
846+ std::shared_ptr<input::SurfaceTarget> const&)
847+ {
848+ }
849+ virtual void input_surface_closed(std::shared_ptr<input::SurfaceTarget> const&)
850+ {
851+ }
852+ virtual void focus_changed(std::shared_ptr<input::SurfaceTarget> const&)
853+ {
854+ }
855+ virtual void focus_cleared()
856 {
857 }
858
859 protected:
860- NullInputFocusSelector(const NullInputFocusSelector&) = delete;
861- NullInputFocusSelector& operator=(const NullInputFocusSelector&) = delete;
862+ NullInputTargetListener(const NullInputTargetListener&) = delete;
863+ NullInputTargetListener& operator=(const NullInputTargetListener&) = delete;
864 };
865
866 }
867 }
868
869-#endif // MIR_INPUT_NULL_INPUT_FOCUS_SELECTOR_H_
870+#endif // MIR_INPUT_NULL_INPUT_TARGET_LISTENER_H_
871
872=== modified file 'include/server/mir/shell/application_session.h'
873--- include/server/mir/shell/application_session.h 2013-04-19 08:03:57 +0000
874+++ include/server/mir/shell/application_session.h 2013-04-23 12:15:34 +0000
875@@ -25,17 +25,29 @@
876
877 namespace mir
878 {
879+<<<<<<< TREE
880 class EventSink;
881
882+=======
883+namespace events
884+{
885+class EventSink;
886+}
887+>>>>>>> MERGE-SOURCE
888 namespace shell
889 {
890 class SurfaceFactory;
891 class Surface;
892+class InputTargetListener;
893
894 class ApplicationSession : public Session
895 {
896 public:
897- explicit ApplicationSession(std::shared_ptr<SurfaceFactory> const& surface_factory, std::string const& session_name);
898+ explicit ApplicationSession(
899+ std::shared_ptr<SurfaceFactory> const& surface_factory,
900+ std::shared_ptr<InputTargetListener> const& input_target_listener,
901+ std::string const& session_name,
902+ std::shared_ptr<events::EventSink> const& sink);
903 ~ApplicationSession();
904
905 frontend::SurfaceId create_surface(frontend::SurfaceCreationParameters const& params);
906@@ -61,7 +73,9 @@
907
908 private:
909 std::shared_ptr<SurfaceFactory> const surface_factory;
910+ std::shared_ptr<InputTargetListener> const input_target_listener;
911 std::string const session_name;
912+ std::shared_ptr<events::EventSink> const event_sink;
913
914 frontend::SurfaceId next_id();
915
916
917=== removed file 'include/server/mir/shell/input_focus_selector.h'
918--- include/server/mir/shell/input_focus_selector.h 2013-04-16 09:16:38 +0000
919+++ include/server/mir/shell/input_focus_selector.h 1970-01-01 00:00:00 +0000
920@@ -1,52 +0,0 @@
921-/*
922- * Copyright © 2013 Canonical Ltd.
923- *
924- * This program is free software: you can redistribute it and/or modify it
925- * under the terms of the GNU General Public License version 3,
926- * as published by the Free Software Foundation.
927- *
928- * This program is distributed in the hope that it will be useful,
929- * but WITHOUT ANY WARRANTY; without even the implied warranty of
930- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
931- * GNU General Public License for more details.
932- *
933- * You should have received a copy of the GNU General Public License
934- * along with this program. If not, see <http://www.gnu.org/licenses/>.
935- *
936- * Authored by: Robert Carr <robert.carr@canonical.com>
937- */
938-
939-#ifndef MIR_SHELL_INPUT_FOCUS_SELECTOR_H_
940-#define MIR_SHELL_INPUT_FOCUS_SELECTOR_H_
941-
942-#include <memory>
943-
944-namespace mir
945-{
946-namespace input
947-{
948-class SessionTarget;
949-class SurfaceTarget;
950-}
951-
952-namespace shell
953-{
954-
955-class InputFocusSelector
956-{
957-public:
958- virtual ~InputFocusSelector() {}
959-
960- virtual void set_input_focus_to(std::shared_ptr<input::SessionTarget> const& focus_application,
961- std::shared_ptr<input::SurfaceTarget> const& focus_surface) = 0;
962-
963-protected:
964- InputFocusSelector() = default;
965- InputFocusSelector(InputFocusSelector const&) = delete;
966- InputFocusSelector& operator=(InputFocusSelector const&) = delete;
967-};
968-
969-}
970-} // namespace mir
971-
972-#endif // MIR_SHELL_INPUT_FOCUS_SELECTOR_H_
973
974=== added file 'include/server/mir/shell/input_target_listener.h'
975--- include/server/mir/shell/input_target_listener.h 1970-01-01 00:00:00 +0000
976+++ include/server/mir/shell/input_target_listener.h 2013-04-23 12:15:34 +0000
977@@ -0,0 +1,59 @@
978+/*
979+ * Copyright © 2013 Canonical Ltd.
980+ *
981+ * This program is free software: you can redistribute it and/or modify it
982+ * under the terms of the GNU General Public License version 3,
983+ * as published by the Free Software Foundation.
984+ *
985+ * This program is distributed in the hope that it will be useful,
986+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
987+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
988+ * GNU General Public License for more details.
989+ *
990+ * You should have received a copy of the GNU General Public License
991+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
992+ *
993+ * Authored by: Robert Carr <robert.carr@canonical.com>
994+ */
995+
996+#ifndef MIR_SHELL_INPUT_TARGET_LISTENER_H_
997+#define MIR_SHELL_INPUT_TARGET_LISTENER_H_
998+
999+#include <memory>
1000+
1001+namespace mir
1002+{
1003+namespace input
1004+{
1005+class SessionTarget;
1006+class SurfaceTarget;
1007+}
1008+
1009+namespace shell
1010+{
1011+
1012+class InputTargetListener
1013+{
1014+public:
1015+ virtual ~InputTargetListener() = default;
1016+
1017+ virtual void input_application_opened(std::shared_ptr<input::SessionTarget> const& application) = 0;
1018+ virtual void input_application_closed(std::shared_ptr<input::SessionTarget> const& application) = 0;
1019+
1020+ virtual void input_surface_opened(std::shared_ptr<input::SessionTarget> const& application,
1021+ std::shared_ptr<input::SurfaceTarget> const& opened_surface) = 0;
1022+ virtual void input_surface_closed(std::shared_ptr<input::SurfaceTarget> const& closed_surface) = 0;
1023+
1024+ virtual void focus_changed(std::shared_ptr<input::SurfaceTarget> const& focus_surface) = 0;
1025+ virtual void focus_cleared() = 0;
1026+
1027+protected:
1028+ InputTargetListener() = default;
1029+ InputTargetListener(InputTargetListener const&) = delete;
1030+ InputTargetListener& operator=(InputTargetListener const&) = delete;
1031+};
1032+
1033+}
1034+} // namespace mir
1035+
1036+#endif // MIR_SHELL_INPUT_TARGET_LISTENER_H_
1037
1038=== modified file 'include/server/mir/shell/organising_surface_factory.h'
1039--- include/server/mir/shell/organising_surface_factory.h 2013-04-16 09:16:38 +0000
1040+++ include/server/mir/shell/organising_surface_factory.h 2013-04-23 12:15:34 +0000
1041@@ -36,7 +36,10 @@
1042 std::shared_ptr<PlacementStrategy> const& placement_strategy);
1043 virtual ~OrganisingSurfaceFactory();
1044
1045- std::shared_ptr<Surface> create_surface(frontend::SurfaceCreationParameters const& params);
1046+ std::shared_ptr<Surface> create_surface(
1047+ frontend::SurfaceCreationParameters const& params,
1048+ frontend::SurfaceId id,
1049+ std::shared_ptr<events::EventSink> const& sink) override;
1050
1051 protected:
1052 OrganisingSurfaceFactory(OrganisingSurfaceFactory const&) = delete;
1053
1054=== modified file 'include/server/mir/shell/session.h'
1055--- include/server/mir/shell/session.h 2013-04-22 03:24:56 +0000
1056+++ include/server/mir/shell/session.h 2013-04-23 12:15:34 +0000
1057@@ -32,6 +32,7 @@
1058 class Session : public frontend::Session, public input::SessionTarget
1059 {
1060 public:
1061+ virtual std::string name() const = 0;
1062 virtual void force_requests_to_complete() = 0;
1063
1064 virtual std::shared_ptr<Surface> default_surface() const = 0;
1065
1066=== modified file 'include/server/mir/shell/session_manager.h'
1067--- include/server/mir/shell/session_manager.h 2013-04-22 03:24:56 +0000
1068+++ include/server/mir/shell/session_manager.h 2013-04-23 12:15:34 +0000
1069@@ -40,18 +40,20 @@
1070 class SessionContainer;
1071 class FocusSequence;
1072 class FocusSetter;
1073+class InputTargetListener;
1074 class Session;
1075
1076 class SessionManager : public frontend::Shell
1077 {
1078 public:
1079 explicit SessionManager(std::shared_ptr<SurfaceFactory> const& surface_factory,
1080- std::shared_ptr<SessionContainer> const& session_container,
1081+ std::shared_ptr<SessionContainer> const& app_container,
1082 std::shared_ptr<FocusSequence> const& focus_sequence,
1083- std::shared_ptr<FocusSetter> const& focus_setter);
1084+ std::shared_ptr<FocusSetter> const& focus_setter,
1085+ std::shared_ptr<InputTargetListener> const& input_target_listener);
1086 virtual ~SessionManager();
1087
1088- virtual std::shared_ptr<frontend::Session> open_session(std::string const& name);
1089+ virtual std::shared_ptr<frontend::Session> open_session(std::string const& name, std::shared_ptr<events::EventSink> const& sink);
1090 virtual void close_session(std::shared_ptr<frontend::Session> const& session);
1091
1092 virtual void tag_session_with_lightdm_id(std::shared_ptr<frontend::Session> const& session, int id);
1093@@ -71,6 +73,7 @@
1094 std::shared_ptr<SessionContainer> const app_container;
1095 std::shared_ptr<FocusSequence> const focus_sequence;
1096 std::shared_ptr<FocusSetter> const focus_setter;
1097+ std::shared_ptr<InputTargetListener> const input_target_listener;
1098
1099 std::mutex mutex;
1100 std::weak_ptr<Session> focus_application;
1101
1102=== modified file 'include/server/mir/shell/single_visibility_focus_mechanism.h'
1103--- include/server/mir/shell/single_visibility_focus_mechanism.h 2013-04-16 09:16:38 +0000
1104+++ include/server/mir/shell/single_visibility_focus_mechanism.h 2013-04-23 12:15:34 +0000
1105@@ -28,13 +28,11 @@
1106 namespace shell
1107 {
1108 class SessionContainer;
1109-class InputFocusSelector;
1110
1111 class SingleVisibilityFocusMechanism : public FocusSetter
1112 {
1113 public:
1114- explicit SingleVisibilityFocusMechanism(std::shared_ptr<SessionContainer> const& app_container,
1115- std::shared_ptr<shell::InputFocusSelector> const& input_selector);
1116+ explicit SingleVisibilityFocusMechanism(std::shared_ptr<SessionContainer> const& app_container);
1117 virtual ~SingleVisibilityFocusMechanism() {}
1118
1119 void set_focus_to(std::shared_ptr<shell::Session> const& new_focus);
1120@@ -44,7 +42,6 @@
1121 SingleVisibilityFocusMechanism& operator=(const SingleVisibilityFocusMechanism&) = delete;
1122 private:
1123 std::shared_ptr<SessionContainer> const app_container;
1124- std::shared_ptr<shell::InputFocusSelector> const input_selector;
1125 };
1126
1127 }
1128
1129=== modified file 'include/server/mir/shell/surface.h'
1130--- include/server/mir/shell/surface.h 2013-04-19 03:20:05 +0000
1131+++ include/server/mir/shell/surface.h 2013-04-23 12:15:34 +0000
1132@@ -31,9 +31,16 @@
1133
1134 namespace mir
1135 {
1136-
1137-class EventSink;
1138-
1139+<<<<<<< TREE
1140+
1141+class EventSink;
1142+
1143+=======
1144+namespace events
1145+{
1146+class EventSink;
1147+}
1148+>>>>>>> MERGE-SOURCE
1149 namespace frontend
1150 {
1151 struct SurfaceCreationParameters;
1152@@ -53,7 +60,9 @@
1153 Surface(
1154 std::shared_ptr<SurfaceBuilder> const& builder,
1155 frontend::SurfaceCreationParameters const& params,
1156- std::shared_ptr<input::InputChannel> const& input_channel);
1157+ std::shared_ptr<input::InputChannel> const& input_channel,
1158+ frontend::SurfaceId id,
1159+ std::shared_ptr<events::EventSink> const& sink);
1160 ~Surface();
1161
1162 virtual void hide();
1163@@ -80,10 +89,14 @@
1164
1165 virtual int configure(MirSurfaceAttrib attrib, int value);
1166 virtual MirSurfaceType type() const;
1167+<<<<<<< TREE
1168 virtual MirSurfaceState state() const;
1169
1170 void set_id(frontend::SurfaceId i);
1171 void set_event_target(std::shared_ptr<EventSink> const& sink);
1172+=======
1173+ virtual MirSurfaceState state() const;
1174+>>>>>>> MERGE-SOURCE
1175
1176 private:
1177 bool set_type(MirSurfaceType t); // Use configure() to make public changes
1178@@ -94,9 +107,15 @@
1179 std::shared_ptr<mir::input::InputChannel> const input_channel;
1180 std::weak_ptr<mir::surfaces::Surface> const surface;
1181
1182+<<<<<<< TREE
1183 std::shared_ptr<EventSink> event_sink;
1184 frontend::SurfaceId id;
1185
1186+=======
1187+ frontend::SurfaceId const id;
1188+ std::shared_ptr<events::EventSink> const event_sink;
1189+
1190+>>>>>>> MERGE-SOURCE
1191 MirSurfaceType type_value;
1192 MirSurfaceState state_value;
1193 };
1194
1195=== modified file 'include/server/mir/shell/surface_factory.h'
1196--- include/server/mir/shell/surface_factory.h 2013-04-19 03:20:05 +0000
1197+++ include/server/mir/shell/surface_factory.h 2013-04-23 12:15:34 +0000
1198@@ -19,10 +19,15 @@
1199 #ifndef MIR_SHELL_SURFACE_FACTORY_H_
1200 #define MIR_SHELL_SURFACE_FACTORY_H_
1201
1202+#include "mir/frontend/surface_id.h"
1203 #include <memory>
1204
1205 namespace mir
1206 {
1207+namespace events
1208+{
1209+class EventSink;
1210+}
1211 namespace frontend
1212 {
1213 struct SurfaceCreationParameters;
1214@@ -34,7 +39,10 @@
1215 class SurfaceFactory
1216 {
1217 public:
1218- virtual std::shared_ptr<Surface> create_surface(const frontend::SurfaceCreationParameters& params) = 0;
1219+ virtual std::shared_ptr<Surface> create_surface(
1220+ frontend::SurfaceCreationParameters const& params,
1221+ frontend::SurfaceId id,
1222+ std::shared_ptr<events::EventSink> const& sink) = 0;
1223
1224 protected:
1225 virtual ~SurfaceFactory() {}
1226
1227=== modified file 'include/server/mir/shell/surface_source.h'
1228--- include/server/mir/shell/surface_source.h 2013-04-16 09:16:38 +0000
1229+++ include/server/mir/shell/surface_source.h 2013-04-23 12:15:34 +0000
1230@@ -40,7 +40,10 @@
1231 explicit SurfaceSource(std::shared_ptr<SurfaceBuilder> const& surface_builder, std::shared_ptr<input::InputChannelFactory> const& input_factory);
1232 virtual ~SurfaceSource() {}
1233
1234- std::shared_ptr<Surface> create_surface(const frontend::SurfaceCreationParameters& params);
1235+ std::shared_ptr<Surface> create_surface(
1236+ frontend::SurfaceCreationParameters const& params,
1237+ frontend::SurfaceId id,
1238+ std::shared_ptr<events::EventSink> const& sink);
1239
1240 protected:
1241 SurfaceSource(const SurfaceSource&) = delete;
1242
1243=== added file 'include/shared/mir/default_configuration.h'
1244--- include/shared/mir/default_configuration.h 1970-01-01 00:00:00 +0000
1245+++ include/shared/mir/default_configuration.h 2013-04-23 12:15:34 +0000
1246@@ -0,0 +1,29 @@
1247+/*
1248+ * Private internal defaults shared by client and server code.
1249+ *
1250+ * Copyright © 2013 Canonical Ltd.
1251+ *
1252+ * This program is free software: you can redistribute it and/or modify
1253+ * it under the terms of the GNU Lesser General Public License version 3 as
1254+ * published by the Free Software Foundation.
1255+ *
1256+ * This program is distributed in the hope that it will be useful,
1257+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1258+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1259+ * GNU Lesser General Public License for more details.
1260+ *
1261+ * You should have received a copy of the GNU Lesser General Public License
1262+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1263+ *
1264+ * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
1265+ */
1266+
1267+#ifndef MIR_DEFAULT_CONFIGURATION_
1268+#define MIR_DEFAULT_CONFIGURATION_
1269+
1270+namespace mir
1271+{
1272+const char default_server_socket[] = "/tmp/mir_socket";
1273+}
1274+
1275+#endif
1276
1277=== added directory 'include/shared/mir/events'
1278=== renamed file 'include/shared/mir/event_sink.h' => 'include/shared/mir/events/event_sink.h'
1279--- include/shared/mir/event_sink.h 2013-04-19 04:33:51 +0000
1280+++ include/shared/mir/events/event_sink.h 2013-04-23 12:15:34 +0000
1281@@ -1,3 +1,4 @@
1282+<<<<<<< TREE
1283 /*
1284 * Copyright © 2013 Canonical Ltd.
1285 *
1286@@ -41,3 +42,49 @@
1287
1288 #endif
1289
1290+=======
1291+/*
1292+ * Copyright © 2013 Canonical Ltd.
1293+ *
1294+ * This program is free software: you can redistribute it and/or modify
1295+ * it under the terms of the GNU Lesser General Public License version 3 as
1296+ * published by the Free Software Foundation.
1297+ *
1298+ * This program is distributed in the hope that it will be useful,
1299+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1300+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1301+ * GNU Lesser General Public License for more details.
1302+ *
1303+ * You should have received a copy of the GNU Lesser General Public License
1304+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1305+ *
1306+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
1307+ */
1308+
1309+#ifndef MIR_EVENTS_EVENT_SINK_H_
1310+#define MIR_EVENTS_EVENT_SINK_H_
1311+
1312+#include "mir_toolkit/event.h"
1313+
1314+namespace mir
1315+{
1316+namespace events
1317+{
1318+
1319+class EventSink
1320+{
1321+public:
1322+ virtual ~EventSink() = default;
1323+
1324+ virtual void handle_event(MirEvent const& e) = 0;
1325+
1326+protected:
1327+ EventSink() = default;
1328+ EventSink(EventSink const&) = delete;
1329+ EventSink& operator=(EventSink const&) = delete;
1330+};
1331+}
1332+} // namespace mir
1333+
1334+#endif // MIR_EVENTS_EVENT_SINK_H_
1335+>>>>>>> MERGE-SOURCE
1336
1337=== modified file 'include/shared/mir/graphics/android/sync_object.h'
1338--- include/shared/mir/graphics/android/sync_object.h 2013-04-12 16:28:32 +0000
1339+++ include/shared/mir/graphics/android/sync_object.h 2013-04-23 12:15:34 +0000
1340@@ -8,7 +8,7 @@
1341 * This program is distributed in the hope that it will be useful,
1342 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1343 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1344- * GNU General Public License for more details.
1345+ * GNU Lesser General Public License for more details.
1346 *
1347 * You should have received a copy of the GNU Lesser General Public License
1348 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1349
1350=== modified file 'include/test/mir_test_doubles/mock_android_buffer.h'
1351--- include/test/mir_test_doubles/mock_android_buffer.h 2013-04-11 22:20:59 +0000
1352+++ include/test/mir_test_doubles/mock_android_buffer.h 2013-04-23 12:15:34 +0000
1353@@ -2,7 +2,7 @@
1354 * Copyright © 2012 Canonical Ltd.
1355 *
1356 * This program is free software: you can redistribute it and/or modify it
1357- * under the terms of the GNU Lesser General Public License version 3,
1358+ * under the terms of the GNU General Public License version 3,
1359 * as published by the Free Software Foundation.
1360 *
1361 * This program is distributed in the hope that it will be useful,
1362@@ -10,7 +10,7 @@
1363 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1364 * GNU General Public License for more details.
1365 *
1366- * You should have received a copy of the GNU Lesser General Public License
1367+ * You should have received a copy of the GNU General Public License
1368 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1369 *
1370 * Authored by: Thomas Voss <thomas.voss@canonical.com>
1371
1372=== modified file 'include/test/mir_test_doubles/mock_display_support_provider.h'
1373--- include/test/mir_test_doubles/mock_display_support_provider.h 2013-04-12 16:28:32 +0000
1374+++ include/test/mir_test_doubles/mock_display_support_provider.h 2013-04-23 12:15:34 +0000
1375@@ -2,7 +2,7 @@
1376 * Copyright © 2013 Canonical Ltd.
1377 *
1378 * This program is free software: you can redistribute it and/or modify it
1379- * under the terms of the GNU Lesser General Public License version 3,
1380+ * under the terms of the GNU General Public License version 3,
1381 * as published by the Free Software Foundation.
1382 *
1383 * This program is distributed in the hope that it will be useful,
1384@@ -10,7 +10,7 @@
1385 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1386 * GNU General Public License for more details.
1387 *
1388- * You should have received a copy of the GNU Lesser General Public License
1389+ * You should have received a copy of the GNU General Public License
1390 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1391 *
1392 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
1393
1394=== modified file 'include/test/mir_test_doubles/mock_fb_device.h'
1395--- include/test/mir_test_doubles/mock_fb_device.h 2013-04-22 03:24:56 +0000
1396+++ include/test/mir_test_doubles/mock_fb_device.h 2013-04-23 12:15:34 +0000
1397@@ -2,7 +2,7 @@
1398 * Copyright © 2013 Canonical Ltd.
1399 *
1400 * This program is free software: you can redistribute it and/or modify it
1401- * under the terms of the GNU Lesser General Public License version 3,
1402+ * under the terms of the GNU General Public License version 3,
1403 * as published by the Free Software Foundation.
1404 *
1405 * This program is distributed in the hope that it will be useful,
1406@@ -10,7 +10,7 @@
1407 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1408 * GNU General Public License for more details.
1409 *
1410- * You should have received a copy of the GNU Lesser General Public License
1411+ * You should have received a copy of the GNU General Public License
1412 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1413 *
1414 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
1415
1416=== modified file 'include/test/mir_test_doubles/mock_input_configuration.h'
1417--- include/test/mir_test_doubles/mock_input_configuration.h 2013-04-12 16:35:06 +0000
1418+++ include/test/mir_test_doubles/mock_input_configuration.h 2013-04-23 12:15:34 +0000
1419@@ -2,15 +2,15 @@
1420 * Copyright © 2013 Canonical Ltd.
1421 *
1422 * This program is free software: you can redistribute it and/or modify it
1423- * under the terms of the GNU Lesser General Public License version 3,
1424+ * under the terms of the GNU General Public License version 3,
1425 * as published by the Free Software Foundation.
1426 *
1427 * This program is distributed in the hope that it will be useful,
1428 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1429 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1430- * GNU Lesser General Public License for more details.
1431+ * GNU General Public License for more details.
1432 *
1433- * You should have received a copy of the GNU Lesser General Public License
1434+ * You should have received a copy of the GNU General Public License
1435 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1436 *
1437 * Authored by: Robert Carr <robert.carr@canonical.com>
1438
1439=== modified file 'include/test/mir_test_doubles/mock_input_dispatcher.h'
1440--- include/test/mir_test_doubles/mock_input_dispatcher.h 2013-04-11 23:04:18 +0000
1441+++ include/test/mir_test_doubles/mock_input_dispatcher.h 2013-04-23 12:15:34 +0000
1442@@ -2,15 +2,15 @@
1443 * Copyright © 2013 Canonical Ltd.
1444 *
1445 * This program is free software: you can redistribute it and/or modify it
1446- * under the terms of the GNU Lesser General Public License version 3,
1447+ * under the terms of the GNU General Public License version 3,
1448 * as published by the Free Software Foundation.
1449 *
1450 * This program is distributed in the hope that it will be useful,
1451 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1452 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1453- * GNU Lesser General Public License for more details.
1454+ * GNU General Public License for more details.
1455 *
1456- * You should have received a copy of the GNU Lesser General Public License
1457+ * You should have received a copy of the GNU General Public License
1458 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1459 *
1460 * Authored by: Robert Carr <robert.carr@canonical.com>
1461
1462=== removed file 'include/test/mir_test_doubles/mock_input_focus_selector.h'
1463--- include/test/mir_test_doubles/mock_input_focus_selector.h 2013-04-16 09:16:38 +0000
1464+++ include/test/mir_test_doubles/mock_input_focus_selector.h 1970-01-01 00:00:00 +0000
1465@@ -1,40 +0,0 @@
1466-/*
1467- * Copyright © 2013 Canonical Ltd.
1468- *
1469- * This program is free software: you can redistribute it and/or modify it
1470- * under the terms of the GNU General Public License version 3,
1471- * as published by the Free Software Foundation.
1472- *
1473- * This program is distributed in the hope that it will be useful,
1474- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1475- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1476- * GNU General Public License for more details.
1477- *
1478- * You should have received a copy of the GNU General Public License
1479- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1480- *
1481- * Authored by: Robert Carr <robert.carr@canonical.com>
1482- */
1483-
1484-#ifndef MIR_TEST_DOUBLES_MOCK_INPUT_FOCUS_SELECTOR_H_
1485-#define MIR_TEST_DOUBLES_MOCK_INPUT_FOCUS_SELECTOR_H_
1486-
1487-#include "mir/shell/input_focus_selector.h"
1488-
1489-namespace mir
1490-{
1491-namespace test
1492-{
1493-namespace doubles
1494-{
1495-
1496-struct MockInputFocusSelector : public shell::InputFocusSelector
1497-{
1498- MOCK_METHOD2(set_input_focus_to, void(std::shared_ptr<input::SessionTarget> const&, std::shared_ptr<input::SurfaceTarget> const&));
1499-};
1500-
1501-}
1502-}
1503-} // namespace mir
1504-
1505-#endif // MIR_TEST_DOUBLES_MOCK_INPUT_FOCUS_SELECTOR_H_
1506
1507=== added file 'include/test/mir_test_doubles/mock_input_target_listener.h'
1508--- include/test/mir_test_doubles/mock_input_target_listener.h 1970-01-01 00:00:00 +0000
1509+++ include/test/mir_test_doubles/mock_input_target_listener.h 2013-04-23 12:15:34 +0000
1510@@ -0,0 +1,49 @@
1511+/*
1512+ * Copyright © 2013 Canonical Ltd.
1513+ *
1514+ * This program is free software: you can redistribute it and/or modify it
1515+ * under the terms of the GNU General Public License version 3,
1516+ * as published by the Free Software Foundation.
1517+ *
1518+ * This program is distributed in the hope that it will be useful,
1519+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1520+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1521+ * GNU General Public License for more details.
1522+ *
1523+ * You should have received a copy of the GNU General Public License
1524+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1525+ *
1526+ * Authored by: Robert Carr <robert.carr@canonical.com>
1527+ */
1528+
1529+#ifndef MIR_TEST_DOUBLES_MOCK_INPUT_TARGET_LISTENER_H_
1530+#define MIR_TEST_DOUBLES_MOCK_INPUT_TARGET_LISTENER_H_
1531+
1532+#include "mir/shell/input_target_listener.h"
1533+
1534+#include <gmock/gmock.h>
1535+
1536+namespace mir
1537+{
1538+namespace test
1539+{
1540+namespace doubles
1541+{
1542+
1543+struct MockInputTargetListener : public shell::InputTargetListener
1544+{
1545+ virtual ~MockInputTargetListener() noexcept(true) {}
1546+ MOCK_METHOD1(input_application_opened, void(std::shared_ptr<input::SessionTarget> const& application));
1547+ MOCK_METHOD1(input_application_closed, void(std::shared_ptr<input::SessionTarget> const& application));
1548+ MOCK_METHOD2(input_surface_opened, void(std::shared_ptr<input::SessionTarget> const& application,
1549+ std::shared_ptr<input::SurfaceTarget> const& opened_surface));
1550+ MOCK_METHOD1(input_surface_closed, void(std::shared_ptr<input::SurfaceTarget> const& closed_surface));
1551+ MOCK_METHOD1(focus_changed, void(std::shared_ptr<input::SurfaceTarget> const& focus_surface));
1552+ MOCK_METHOD0(focus_cleared, void());
1553+};
1554+
1555+}
1556+}
1557+} // namespace mir
1558+
1559+#endif // MIR_TEST_DOUBLES_MOCK_INPUT_TARGET_LISTENER_H_
1560
1561=== modified file 'include/test/mir_test_doubles/mock_shell.h'
1562--- include/test/mir_test_doubles/mock_shell.h 2013-04-19 03:20:05 +0000
1563+++ include/test/mir_test_doubles/mock_shell.h 2013-04-23 12:15:34 +0000
1564@@ -34,7 +34,7 @@
1565
1566 struct MockShell : public frontend::Shell
1567 {
1568- MOCK_METHOD1(open_session, std::shared_ptr<frontend::Session>(std::string const&));
1569+ MOCK_METHOD2(open_session, std::shared_ptr<frontend::Session>(std::string const&, std::shared_ptr<events::EventSink> const&));
1570 MOCK_METHOD1(close_session, void(std::shared_ptr<frontend::Session> const&));
1571
1572 MOCK_METHOD2(tag_session_with_lightdm_id, void(std::shared_ptr<frontend::Session> const&, int));
1573
1574=== modified file 'include/test/mir_test_doubles/mock_surface.h'
1575--- include/test/mir_test_doubles/mock_surface.h 2013-04-19 03:20:05 +0000
1576+++ include/test/mir_test_doubles/mock_surface.h 2013-04-23 12:15:34 +0000
1577@@ -37,7 +37,12 @@
1578 struct MockSurface : public shell::Surface
1579 {
1580 MockSurface(std::shared_ptr<shell::SurfaceBuilder> const& builder) :
1581- shell::Surface(builder, frontend::a_surface(), std::shared_ptr<input::InputChannel>())
1582+ shell::Surface(
1583+ builder,
1584+ frontend::a_surface(),
1585+ std::shared_ptr<input::InputChannel>(),
1586+ frontend::SurfaceId(),
1587+ std::shared_ptr<events::EventSink>())
1588 {
1589 }
1590
1591
1592=== modified file 'include/test/mir_test_doubles/mock_surface_factory.h'
1593--- include/test/mir_test_doubles/mock_surface_factory.h 2013-04-16 09:16:38 +0000
1594+++ include/test/mir_test_doubles/mock_surface_factory.h 2013-04-23 12:15:34 +0000
1595@@ -33,7 +33,10 @@
1596
1597 struct MockSurfaceFactory : public shell::SurfaceFactory
1598 {
1599- MOCK_METHOD1(create_surface, std::shared_ptr<shell::Surface>(const frontend::SurfaceCreationParameters&));
1600+ MOCK_METHOD3(create_surface, std::shared_ptr<shell::Surface>(
1601+ const frontend::SurfaceCreationParameters&,
1602+ frontend::SurfaceId,
1603+ std::shared_ptr<events::EventSink> const&));
1604 };
1605
1606 }
1607
1608=== modified file 'include/test/mir_test_doubles/null_virtual_terminal.h'
1609--- include/test/mir_test_doubles/null_virtual_terminal.h 2013-04-22 03:24:56 +0000
1610+++ include/test/mir_test_doubles/null_virtual_terminal.h 2013-04-23 12:15:34 +0000
1611@@ -2,7 +2,7 @@
1612 * Copyright © 2013 Canonical Ltd.
1613 *
1614 * This program is free software: you can redistribute it and/or modify it
1615- * under the terms of the GNU Lesser General Public License version 3,
1616+ * under the terms of the GNU General Public License version 3,
1617 * as published by the Free Software Foundation.
1618 *
1619 * This program is distributed in the hope that it will be useful,
1620@@ -10,7 +10,7 @@
1621 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1622 * GNU General Public License for more details.
1623 *
1624- * You should have received a copy of the GNU Lesser General Public License
1625+ * You should have received a copy of the GNU General Public License
1626 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1627 *
1628 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
1629
1630=== added file 'include/test/mir_test_doubles/stub_input_target_listener.h'
1631--- include/test/mir_test_doubles/stub_input_target_listener.h 1970-01-01 00:00:00 +0000
1632+++ include/test/mir_test_doubles/stub_input_target_listener.h 2013-04-23 12:15:34 +0000
1633@@ -0,0 +1,59 @@
1634+/*
1635+ * Copyright © 2013 Canonical Ltd.
1636+ *
1637+ * This program is free software: you can redistribute it and/or modify it
1638+ * under the terms of the GNU General Public License version 3,
1639+ * as published by the Free Software Foundation.
1640+ *
1641+ * This program is distributed in the hope that it will be useful,
1642+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1643+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1644+ * GNU General Public License for more details.
1645+ *
1646+ * You should have received a copy of the GNU General Public License
1647+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1648+ *
1649+ * Authored by: Robert Carr <robert.carr@canonical.com>
1650+ */
1651+
1652+#ifndef MIR_TEST_DOUBLES_STUB_INPUT_LISTENER_H_
1653+#define MIR_TEST_DOUBLES_STUB_INPUT_LISTENER_H_
1654+
1655+#include "mir/shell/input_target_listener.h"
1656+
1657+namespace mir
1658+{
1659+namespace test
1660+{
1661+namespace doubles
1662+{
1663+
1664+struct StubInputTargetListener : public shell::InputTargetListener
1665+{
1666+ void input_application_opened(std::shared_ptr<input::SessionTarget> const&)
1667+ {
1668+ }
1669+ void input_application_closed(std::shared_ptr<input::SessionTarget> const&)
1670+ {
1671+ }
1672+ void input_surface_opened(std::shared_ptr<input::SessionTarget> const&,
1673+ std::shared_ptr<input::SurfaceTarget> const&)
1674+ {
1675+ }
1676+ void input_surface_closed(std::shared_ptr<input::SurfaceTarget> const&)
1677+ {
1678+ }
1679+ void focus_changed(std::shared_ptr<input::SurfaceTarget> const&)
1680+ {
1681+ }
1682+
1683+ void focus_cleared()
1684+ {
1685+ }
1686+};
1687+
1688+}
1689+}
1690+} // namespace mir
1691+
1692+#endif // MIR_TEST_DOUBLES_STUB_INPUT_LISTENER_H_
1693
1694=== modified file 'include/test/mir_test_doubles/stub_ipc_factory.h'
1695--- include/test/mir_test_doubles/stub_ipc_factory.h 2013-04-19 07:45:44 +0000
1696+++ include/test/mir_test_doubles/stub_ipc_factory.h 2013-04-23 12:15:34 +0000
1697@@ -41,8 +41,13 @@
1698 {
1699 }
1700
1701+<<<<<<< TREE
1702 std::shared_ptr<protobuf::DisplayServer> make_ipc_server(
1703 std::shared_ptr<EventSink> const&)
1704+=======
1705+ std::shared_ptr<protobuf::DisplayServer> make_ipc_server(
1706+ std::shared_ptr<events::EventSink> const&)
1707+>>>>>>> MERGE-SOURCE
1708 {
1709 return server;
1710 }
1711
1712=== modified file 'include/test/mir_test_doubles/stub_session.h'
1713--- include/test/mir_test_doubles/stub_session.h 2013-04-19 08:03:57 +0000
1714+++ include/test/mir_test_doubles/stub_session.h 2013-04-23 12:15:34 +0000
1715@@ -58,9 +58,15 @@
1716 {
1717 return 0;
1718 }
1719+<<<<<<< TREE
1720 void set_event_sink(std::shared_ptr<EventSink> const&)
1721 {
1722 }
1723+=======
1724+ void set_event_sink(std::shared_ptr<events::EventSink> const&)
1725+ {
1726+ }
1727+>>>>>>> MERGE-SOURCE
1728 };
1729
1730 }
1731
1732=== modified file 'include/test/mir_test_doubles/stub_shell.h'
1733--- include/test/mir_test_doubles/stub_shell.h 2013-04-19 03:20:05 +0000
1734+++ include/test/mir_test_doubles/stub_shell.h 2013-04-23 12:15:34 +0000
1735@@ -31,7 +31,7 @@
1736
1737 class StubShell : public frontend::Shell
1738 {
1739- std::shared_ptr<frontend::Session> open_session(std::string const& /* name */)
1740+ std::shared_ptr<frontend::Session> open_session(std::string const& /* name */, std::shared_ptr<events::EventSink> const& /* sink */)
1741 {
1742 return std::make_shared<StubSession>();
1743 }
1744
1745=== modified file 'include/test/mir_test_framework/testing_server_configuration.h'
1746--- include/test/mir_test_framework/testing_server_configuration.h 2013-04-16 09:16:38 +0000
1747+++ include/test/mir_test_framework/testing_server_configuration.h 2013-04-23 12:15:34 +0000
1748@@ -49,7 +49,7 @@
1749 // to avoid starting and stopping the full android input stack for tests
1750 // which do not leverage input.
1751 std::shared_ptr<input::InputManager> the_input_manager();
1752- std::shared_ptr<shell::InputFocusSelector> the_input_focus_selector();
1753+ std::shared_ptr<shell::InputTargetListener> the_input_target_listener();
1754
1755 virtual std::string the_socket_file() const;
1756 using DefaultServerConfiguration::the_options;
1757
1758=== modified file 'src/client/client_buffer_depository.h'
1759--- src/client/client_buffer_depository.h 2013-04-12 03:36:28 +0000
1760+++ src/client/client_buffer_depository.h 2013-04-23 12:15:34 +0000
1761@@ -48,9 +48,9 @@
1762
1763 /// \param factory is the ClientBufferFactory that will be used to convert IPC data to ClientBuffers
1764 /// \param max_buffers is the number of buffers the depository will cache. After the client has received
1765- /// its initial buffers the ClientBufferDepository will always have the last \ref max_buffers buffers
1766+ /// its initial buffers the ClientBufferDepository will always have the last max_buffers buffers
1767 /// cached.
1768- /// \note The server relies on the depository caching \ref max_buffers buffers to optimise away buffer
1769+ /// \note The server relies on the depository caching max_buffers buffers to optimise away buffer
1770 /// passing. As such, this number needs to be shared between the server and client libraries.
1771 ClientBufferDepository(std::shared_ptr<ClientBufferFactory> const& factory, int max_buffers);
1772
1773
1774=== modified file 'src/client/mir_client_library.cpp'
1775--- src/client/mir_client_library.cpp 2013-04-18 04:23:56 +0000
1776+++ src/client/mir_client_library.cpp 2013-04-23 12:15:34 +0000
1777@@ -16,6 +16,7 @@
1778 * Authored by: Thomas Guest <thomas.guest@canonical.com>
1779 */
1780
1781+#include "mir/default_configuration.h"
1782 #include "mir_toolkit/mir_client_library.h"
1783 #include "mir_toolkit/mir_client_library_drm.h"
1784 #include "mir_toolkit/mir_client_library_lightdm.h"
1785@@ -54,6 +55,8 @@
1786
1787 try
1788 {
1789+ const std::string sock = socket_file ? socket_file :
1790+ mir::default_server_socket;
1791 auto log = std::make_shared<mcl::ConsoleLogger>();
1792 auto client_platform_factory = std::make_shared<mcl::NativeClientPlatformFactory>();
1793
1794
1795=== modified file 'src/client/mir_connection.h'
1796--- src/client/mir_connection.h 2013-04-16 09:42:50 +0000
1797+++ src/client/mir_connection.h 2013-04-23 12:15:34 +0000
1798@@ -34,7 +34,11 @@
1799 #include "client_context.h"
1800
1801 #include "mir_wait_handle.h"
1802+<<<<<<< TREE
1803 #include "mir/event_sink.h"
1804+=======
1805+#include "mir/events/event_sink.h"
1806+>>>>>>> MERGE-SOURCE
1807
1808 namespace mir
1809 {
1810@@ -51,8 +55,12 @@
1811 }
1812 }
1813
1814+<<<<<<< TREE
1815 struct MirConnection : public mir::client::ClientContext,
1816 public mir::EventSink
1817+=======
1818+struct MirConnection : mir::client::ClientContext, mir::events::EventSink
1819+>>>>>>> MERGE-SOURCE
1820 {
1821 public:
1822 MirConnection();
1823
1824=== modified file 'src/client/mir_socket_rpc_channel.cpp'
1825--- src/client/mir_socket_rpc_channel.cpp 2013-04-18 04:15:05 +0000
1826+++ src/client/mir_socket_rpc_channel.cpp 2013-04-23 12:15:34 +0000
1827@@ -330,6 +330,7 @@
1828 result.ParseFromIstream(&in);
1829 return result;
1830 }
1831+<<<<<<< TREE
1832
1833 void mcl::MirSocketRpcChannel::set_event_handler(mir::EventSink *sink)
1834 {
1835@@ -340,3 +341,15 @@
1836 */
1837 event_handler = sink;
1838 }
1839+=======
1840+
1841+void mcl::MirSocketRpcChannel::set_event_handler(events::EventSink *sink)
1842+{
1843+ /*
1844+ * Yes, these have to be regular pointers. Because ownership of the object
1845+ * (which is actually a MirConnection) is the responsibility of the calling
1846+ * client. So out of our control.
1847+ */
1848+ event_handler = sink;
1849+}
1850+>>>>>>> MERGE-SOURCE
1851
1852=== modified file 'src/client/mir_socket_rpc_channel.h'
1853--- src/client/mir_socket_rpc_channel.h 2013-04-18 03:54:19 +0000
1854+++ src/client/mir_socket_rpc_channel.h 2013-04-23 12:15:34 +0000
1855@@ -22,7 +22,11 @@
1856
1857 #include "mir_basic_rpc_channel.h"
1858 #include "mir_logger.h"
1859+<<<<<<< TREE
1860 #include "mir/event_sink.h"
1861+=======
1862+#include "mir/events/event_sink.h"
1863+>>>>>>> MERGE-SOURCE
1864
1865 #include <boost/asio.hpp>
1866
1867@@ -52,8 +56,13 @@
1868 MirSocketRpcChannel(const std::string& endpoint, const std::shared_ptr<Logger>& log);
1869 ~MirSocketRpcChannel();
1870
1871+<<<<<<< TREE
1872 void set_event_handler(EventSink *sink);
1873
1874+=======
1875+ void set_event_handler(events::EventSink *sink);
1876+
1877+>>>>>>> MERGE-SOURCE
1878 private:
1879 virtual void CallMethod(const google::protobuf::MethodDescriptor* method, google::protobuf::RpcController*,
1880 const google::protobuf::Message* parameters, google::protobuf::Message* response,
1881@@ -80,8 +89,13 @@
1882 size_t read_message_header();
1883
1884 mir::protobuf::wire::Result read_message_body(const size_t body_size);
1885+<<<<<<< TREE
1886
1887 EventSink *event_handler;
1888+=======
1889+
1890+ events::EventSink *event_handler;
1891+>>>>>>> MERGE-SOURCE
1892 };
1893
1894 }
1895
1896=== modified file 'src/server/default_server_configuration.cpp'
1897--- src/server/default_server_configuration.cpp 2013-04-22 03:24:56 +0000
1898+++ src/server/default_server_configuration.cpp 2013-04-23 12:15:34 +0000
1899@@ -45,7 +45,7 @@
1900 #include "mir/graphics/buffer_initializer.h"
1901 #include "mir/graphics/null_display_report.h"
1902 #include "mir/input/null_input_manager.h"
1903-#include "mir/input/null_input_focus_selector.h"
1904+#include "mir/input/null_input_target_listener.h"
1905 #include "input/android/default_android_input_configuration.h"
1906 #include "input/android/android_input_manager.h"
1907 #include "input/android/android_dispatcher_controller.h"
1908@@ -59,8 +59,10 @@
1909 #include "mir/surfaces/surface_stack.h"
1910 #include "mir/surfaces/surface_controller.h"
1911 #include "mir/time/high_resolution_clock.h"
1912+#include "mir/default_configuration.h"
1913
1914 namespace mc = mir::compositor;
1915+namespace me = mir::events;
1916 namespace geom = mir::geometry;
1917 namespace mf = mir::frontend;
1918 namespace mg = mir::graphics;
1919@@ -106,8 +108,13 @@
1920 std::shared_ptr<mg::ViewableArea> const graphics_display;
1921 std::shared_ptr<mc::GraphicBufferAllocator> const buffer_allocator;
1922
1923+<<<<<<< TREE
1924 virtual std::shared_ptr<mir::protobuf::DisplayServer> make_ipc_server(
1925 std::shared_ptr<mir::EventSink> const& sink)
1926+=======
1927+ virtual std::shared_ptr<mir::protobuf::DisplayServer> make_ipc_server(
1928+ std::shared_ptr<me::EventSink> const& sink)
1929+>>>>>>> MERGE-SOURCE
1930 {
1931 return std::make_shared<mf::SessionMediator>(
1932 shell,
1933@@ -230,7 +237,7 @@
1934
1935 std::string mir::DefaultServerConfiguration::the_socket_file() const
1936 {
1937- return the_options()->get("file", "/tmp/mir_socket");
1938+ return the_options()->get("file", mir::default_server_socket);
1939 }
1940
1941 std::shared_ptr<mir::options::Option> mir::DefaultServerConfiguration::the_options() const
1942@@ -312,8 +319,7 @@
1943 [this]
1944 {
1945 return std::make_shared<msh::SingleVisibilityFocusMechanism>(
1946- the_shell_session_container(),
1947- the_input_focus_selector());
1948+ the_shell_session_container());
1949 });
1950 }
1951
1952@@ -349,7 +355,8 @@
1953 the_shell_surface_factory(),
1954 the_shell_session_container(),
1955 the_shell_focus_sequence(),
1956- the_shell_focus_setter());
1957+ the_shell_focus_setter(),
1958+ the_input_target_listener());
1959 });
1960 }
1961
1962@@ -564,15 +571,15 @@
1963 return the_input_manager();
1964 }
1965
1966-std::shared_ptr<msh::InputFocusSelector> mir::DefaultServerConfiguration::the_input_focus_selector()
1967+std::shared_ptr<msh::InputTargetListener> mir::DefaultServerConfiguration::the_input_target_listener()
1968 {
1969- return input_focus_selector(
1970- [&]() -> std::shared_ptr<msh::InputFocusSelector>
1971+ return input_target_listener(
1972+ [&]() -> std::shared_ptr<msh::InputTargetListener>
1973 {
1974 if (the_options()->get("enable-input", false))
1975 return std::make_shared<mia::DispatcherController>(the_input_configuration());
1976 else
1977- return std::make_shared<mi::NullInputFocusSelector>();
1978+ return std::make_shared<mi::NullInputTargetListener>();
1979 });
1980 }
1981
1982
1983=== modified file 'src/server/display_server.cpp'
1984--- src/server/display_server.cpp 2013-04-22 09:50:06 +0000
1985+++ src/server/display_server.cpp 2013-04-23 12:15:34 +0000
1986@@ -31,9 +31,9 @@
1987
1988 namespace mc = mir::compositor;
1989 namespace mf = mir::frontend;
1990-namespace msh = mir::shell;
1991 namespace mg = mir::graphics;
1992 namespace mi = mir::input;
1993+namespace msh = mir::shell;
1994
1995 namespace
1996 {
1997
1998=== modified file 'src/server/frontend/CMakeLists.txt'
1999--- src/server/frontend/CMakeLists.txt 2013-04-19 04:00:32 +0000
2000+++ src/server/frontend/CMakeLists.txt 2013-04-23 12:15:34 +0000
2001@@ -8,6 +8,7 @@
2002 protobuf_message_processor.cpp
2003 null_message_processor.cpp
2004 surface_creation_parameters.cpp
2005+ event_pipe.cpp
2006
2007 resource_cache.cpp
2008 ${PROTO_HDRS}
2009
2010=== renamed file 'src/server/event_queue.cpp' => 'src/server/frontend/event_pipe.cpp'
2011--- src/server/event_queue.cpp 2013-04-16 05:46:28 +0000
2012+++ src/server/frontend/event_pipe.cpp 2013-04-23 12:15:34 +0000
2013@@ -1,3 +1,4 @@
2014+<<<<<<< TREE
2015 /*
2016 * Copyright © 2013 Canonical Ltd.
2017 *
2018@@ -35,3 +36,41 @@
2019 if (p)
2020 p->handle_event(e);
2021 }
2022+=======
2023+/*
2024+ * Copyright © 2013 Canonical Ltd.
2025+ *
2026+ * This program is free software: you can redistribute it and/or modify
2027+ * it under the terms of the GNU General Public License version 3 as
2028+ * published by the Free Software Foundation.
2029+ *
2030+ * This program is distributed in the hope that it will be useful,
2031+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2032+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2033+ * GNU General Public License for more details.
2034+ *
2035+ * You should have received a copy of the GNU General Public License
2036+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2037+ *
2038+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
2039+ */
2040+
2041+#include "event_pipe.h"
2042+
2043+namespace mf = mir::frontend;
2044+
2045+void mf::EventPipe::set_target(std::weak_ptr<EventSink> const& s)
2046+{
2047+ target = s;
2048+}
2049+
2050+void mf::EventPipe::handle_event(MirEvent const& e)
2051+{
2052+ // In future, post might put e on a queue and wait for some background
2053+ // thread to push it through to sink. But that's not required right now.
2054+
2055+ std::shared_ptr<EventSink> p = target.lock();
2056+ if (p)
2057+ p->handle_event(e);
2058+}
2059+>>>>>>> MERGE-SOURCE
2060
2061=== renamed file 'include/server/mir/event_queue.h' => 'src/server/frontend/event_pipe.h'
2062--- include/server/mir/event_queue.h 2013-04-16 05:46:28 +0000
2063+++ src/server/frontend/event_pipe.h 2013-04-23 12:15:34 +0000
2064@@ -1,3 +1,4 @@
2065+<<<<<<< TREE
2066 /*
2067 * Copyright © 2013 Canonical Ltd.
2068 *
2069@@ -38,3 +39,47 @@
2070 } // namespace mir
2071
2072 #endif
2073+=======
2074+/*
2075+ * Copyright © 2013 Canonical Ltd.
2076+ *
2077+ * This program is free software: you can redistribute it and/or modify
2078+ * it under the terms of the GNU General Public License version 3 as
2079+ * published by the Free Software Foundation.
2080+ *
2081+ * This program is distributed in the hope that it will be useful,
2082+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2083+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2084+ * GNU General Public License for more details.
2085+ *
2086+ * You should have received a copy of the GNU General Public License
2087+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2088+ *
2089+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
2090+ */
2091+
2092+#ifndef MIR_FRONTEND_EVENT_PIPE_H_
2093+#define MIR_FRONTEND_EVENT_PIPE_H_
2094+
2095+#include "mir_toolkit/event.h"
2096+#include "mir/events/event_sink.h"
2097+#include <memory>
2098+
2099+namespace mir
2100+{
2101+namespace frontend
2102+{
2103+class EventPipe : public events::EventSink
2104+{
2105+public:
2106+ void set_target(std::weak_ptr<events::EventSink> const& s);
2107+ void handle_event(MirEvent const& e) override;
2108+
2109+private:
2110+ std::weak_ptr<events::EventSink> target;
2111+};
2112+}
2113+}
2114+
2115+#endif // MIR_FRONTEND_EVENT_PIPE_H_
2116+>>>>>>> MERGE-SOURCE
2117
2118=== modified file 'src/server/frontend/protobuf_message_processor.cpp'
2119--- src/server/frontend/protobuf_message_processor.cpp 2013-04-18 04:15:05 +0000
2120+++ src/server/frontend/protobuf_message_processor.cpp 2013-04-23 12:15:34 +0000
2121@@ -53,14 +53,6 @@
2122 resource_cache->free_resource(response);
2123 }
2124
2125-void mfd::ProtobufMessageProcessor::send_response(::google::protobuf::uint32 id, mir::protobuf::Platform* response)
2126-{
2127- const auto& fd = extract_fds_from(response);
2128- send_response(id, static_cast<google::protobuf::Message*>(response));
2129- sender->send_fds(fd);
2130- resource_cache->free_resource(response);
2131-}
2132-
2133 void mfd::ProtobufMessageProcessor::send_response(::google::protobuf::uint32 id, mir::protobuf::Connection* response)
2134 {
2135 const auto& fd = response->has_platform() ?
2136
2137=== modified file 'src/server/frontend/protobuf_message_processor.h'
2138--- src/server/frontend/protobuf_message_processor.h 2013-04-18 04:15:05 +0000
2139+++ src/server/frontend/protobuf_message_processor.h 2013-04-23 12:15:34 +0000
2140@@ -24,7 +24,11 @@
2141
2142 #include "mir_protobuf.pb.h"
2143 #include "mir_protobuf_wire.pb.h"
2144+<<<<<<< TREE
2145 #include "mir/event_sink.h"
2146+=======
2147+#include "mir/events/event_sink.h"
2148+>>>>>>> MERGE-SOURCE
2149
2150 #include <vector>
2151 #include <memory>
2152@@ -43,8 +47,13 @@
2153 namespace detail
2154 {
2155
2156+<<<<<<< TREE
2157 struct ProtobufMessageProcessor : MessageProcessor,
2158 public EventSink
2159+=======
2160+struct ProtobufMessageProcessor : MessageProcessor,
2161+ public events::EventSink
2162+>>>>>>> MERGE-SOURCE
2163 {
2164 ProtobufMessageProcessor(
2165 MessageSender* sender,
2166@@ -64,10 +73,6 @@
2167
2168 // TODO detecting the message type to see if we send FDs seems a bit of a frig.
2169 // OTOH until we have a real requirement it is hard to see how best to generalise.
2170- void send_response(::google::protobuf::uint32 id, mir::protobuf::Platform* response);
2171-
2172- // TODO detecting the message type to see if we send FDs seems a bit of a frig.
2173- // OTOH until we have a real requirement it is hard to see how best to generalise.
2174 void send_response(::google::protobuf::uint32 id, mir::protobuf::Connection* response);
2175
2176 // TODO detecting the message type to see if we send FDs seems a bit of a frig.
2177
2178=== modified file 'src/server/frontend/protobuf_socket_communicator.cpp'
2179--- src/server/frontend/protobuf_socket_communicator.cpp 2013-04-22 09:54:07 +0000
2180+++ src/server/frontend/protobuf_socket_communicator.cpp 2013-04-23 12:15:34 +0000
2181@@ -22,8 +22,12 @@
2182
2183 #include "mir/frontend/protobuf_ipc_factory.h"
2184 #include "mir/protobuf/google_protobuf_guard.h"
2185+<<<<<<< TREE
2186 #include "mir/event_sink.h"
2187 #include "mir/event_queue.h"
2188+=======
2189+#include "event_pipe.h"
2190+>>>>>>> MERGE-SOURCE
2191
2192 #include <boost/signals2.hpp>
2193
2194@@ -51,8 +55,13 @@
2195
2196 void mf::ProtobufSocketCommunicator::start_accept()
2197 {
2198+<<<<<<< TREE
2199 std::shared_ptr<EventQueue> event_queue = std::make_shared<EventQueue>();
2200
2201+=======
2202+ auto const& event_pipe = std::make_shared<EventPipe>();
2203+
2204+>>>>>>> MERGE-SOURCE
2205 auto const& socket_session = std::make_shared<mfd::SocketSession>(
2206 io_service,
2207 next_id(),
2208@@ -60,11 +69,19 @@
2209
2210 auto session = std::make_shared<detail::ProtobufMessageProcessor>(
2211 socket_session.get(),
2212+<<<<<<< TREE
2213 ipc_factory->make_ipc_server(event_queue),
2214+=======
2215+ ipc_factory->make_ipc_server(event_pipe),
2216+>>>>>>> MERGE-SOURCE
2217 ipc_factory->resource_cache(),
2218 ipc_factory->report());
2219
2220+<<<<<<< TREE
2221 event_queue->set_target(session);
2222+=======
2223+ event_pipe->set_target(session);
2224+>>>>>>> MERGE-SOURCE
2225 socket_session->set_processor(session);
2226
2227 acceptor.async_accept(
2228
2229=== modified file 'src/server/frontend/session_mediator.cpp'
2230--- src/server/frontend/session_mediator.cpp 2013-04-19 07:45:44 +0000
2231+++ src/server/frontend/session_mediator.cpp 2013-04-23 12:15:34 +0000
2232@@ -44,7 +44,11 @@
2233 std::shared_ptr<graphics::ViewableArea> const& viewable_area,
2234 std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator,
2235 std::shared_ptr<SessionMediatorReport> const& report,
2236+<<<<<<< TREE
2237 std::shared_ptr<EventSink> const& event_sink,
2238+=======
2239+ std::shared_ptr<events::EventSink> const& event_sink,
2240+>>>>>>> MERGE-SOURCE
2241 std::shared_ptr<ResourceCache> const& resource_cache) :
2242 shell(shell),
2243 graphics_platform(graphics_platform),
2244@@ -65,8 +69,12 @@
2245 {
2246 report->session_connect_called(request->application_name());
2247
2248+<<<<<<< TREE
2249 session = shell->open_session(request->application_name());
2250 session->set_event_sink(event_sink);
2251+=======
2252+ session = shell->open_session(request->application_name(), event_sink);
2253+>>>>>>> MERGE-SOURCE
2254
2255 auto ipc_package = graphics_platform->get_ipc_package();
2256 auto platform = response->mutable_platform();
2257
2258=== modified file 'src/server/graphics/gbm/linux_virtual_terminal.cpp'
2259--- src/server/graphics/gbm/linux_virtual_terminal.cpp 2013-04-22 03:24:56 +0000
2260+++ src/server/graphics/gbm/linux_virtual_terminal.cpp 2013-04-23 12:15:34 +0000
2261@@ -2,7 +2,7 @@
2262 * Copyright © 2013 Canonical Ltd.
2263 *
2264 * This program is free software: you can redistribute it and/or modify it
2265- * under the terms of the GNU Lesser General Public License version 3,
2266+ * under the terms of the GNU General Public License version 3,
2267 * as published by the Free Software Foundation.
2268 *
2269 * This program is distributed in the hope that it will be useful,
2270@@ -10,7 +10,7 @@
2271 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2272 * GNU General Public License for more details.
2273 *
2274- * You should have received a copy of the GNU Lesser General Public License
2275+ * You should have received a copy of the GNU General Public License
2276 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2277 *
2278 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
2279
2280=== modified file 'src/server/graphics/gbm/linux_virtual_terminal.h'
2281--- src/server/graphics/gbm/linux_virtual_terminal.h 2013-04-22 03:24:56 +0000
2282+++ src/server/graphics/gbm/linux_virtual_terminal.h 2013-04-23 12:15:34 +0000
2283@@ -2,7 +2,7 @@
2284 * Copyright © 2013 Canonical Ltd.
2285 *
2286 * This program is free software: you can redistribute it and/or modify it
2287- * under the terms of the GNU Lesser General Public License version 3,
2288+ * under the terms of the GNU General Public License version 3,
2289 * as published by the Free Software Foundation.
2290 *
2291 * This program is distributed in the hope that it will be useful,
2292@@ -10,7 +10,7 @@
2293 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2294 * GNU General Public License for more details.
2295 *
2296- * You should have received a copy of the GNU Lesser General Public License
2297+ * You should have received a copy of the GNU General Public License
2298 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2299 *
2300 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
2301
2302=== modified file 'src/server/graphics/gbm/virtual_terminal.h'
2303--- src/server/graphics/gbm/virtual_terminal.h 2013-04-22 03:24:56 +0000
2304+++ src/server/graphics/gbm/virtual_terminal.h 2013-04-23 12:15:34 +0000
2305@@ -2,7 +2,7 @@
2306 * Copyright © 2013 Canonical Ltd.
2307 *
2308 * This program is free software: you can redistribute it and/or modify it
2309- * under the terms of the GNU Lesser General Public License version 3,
2310+ * under the terms of the GNU General Public License version 3,
2311 * as published by the Free Software Foundation.
2312 *
2313 * This program is distributed in the hope that it will be useful,
2314@@ -10,7 +10,7 @@
2315 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2316 * GNU General Public License for more details.
2317 *
2318- * You should have received a copy of the GNU Lesser General Public License
2319+ * You should have received a copy of the GNU General Public License
2320 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2321 *
2322 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
2323
2324=== modified file 'src/server/input/android/android_dispatcher_controller.cpp'
2325--- src/server/input/android/android_dispatcher_controller.cpp 2013-04-11 23:06:12 +0000
2326+++ src/server/input/android/android_dispatcher_controller.cpp 2013-04-23 12:15:34 +0000
2327@@ -2,15 +2,15 @@
2328 * Copyright © 2013 Canonical Ltd.
2329 *
2330 * This program is free software: you can redistribute it and/or modify it
2331- * under the terms of the GNU Lesser General Public License version 3,
2332+ * under the terms of the GNU General Public License version 3,
2333 * as published by the Free Software Foundation.
2334 *
2335 * This program is distributed in the hope that it will be useful,
2336 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2337 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2338- * GNU Lesser General Public License for more details.
2339+ * GNU General Public License for more details.
2340 *
2341- * You should have received a copy of the GNU Lesser General Public License
2342+ * You should have received a copy of the GNU General Public License
2343 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2344 *
2345 * Authored by: Robert Carr <robert.carr@canonical.com>
2346@@ -25,35 +25,85 @@
2347
2348 #include <InputDispatcher.h>
2349
2350+#include <boost/throw_exception.hpp>
2351+
2352+#include <stdexcept>
2353+#include <mutex>
2354+
2355 namespace mi = mir::input;
2356 namespace mia = mi::android;
2357
2358 mia::DispatcherController::DispatcherController(std::shared_ptr<mia::InputConfiguration> const& config) :
2359- input_dispatcher(config->the_dispatcher()),
2360- focused_window_handle(0),
2361- focused_application_handle(0)
2362-{
2363-}
2364-
2365-void mia::DispatcherController::set_input_focus_to(std::shared_ptr<mi::SessionTarget> const& session,
2366- std::shared_ptr<mi::SurfaceTarget> const& surface)
2367-{
2368- if (focused_window_handle.get())
2369- {
2370- input_dispatcher->unregisterInputChannel(focused_window_handle->getInfo()->inputChannel);
2371- focused_window_handle.clear();
2372- focused_application_handle.clear();
2373- }
2374+ input_dispatcher(config->the_dispatcher())
2375+{
2376+}
2377+
2378+void mia::DispatcherController::input_application_opened(std::shared_ptr<mi::SessionTarget> const& session)
2379+{
2380+ std::unique_lock<std::mutex> lock(handles_mutex);
2381+ if (application_handles.find(session) != application_handles.end())
2382+ BOOST_THROW_EXCEPTION(std::logic_error("An application was opened twice"));
2383+ application_handles[session] = new mia::InputApplicationHandle(session);
2384+}
2385+
2386+void mia::DispatcherController::input_application_closed(std::shared_ptr<mi::SessionTarget> const& session)
2387+{
2388+ std::unique_lock<std::mutex> lock(handles_mutex);
2389+ if (application_handles.find(session) == application_handles.end())
2390+ BOOST_THROW_EXCEPTION(std::logic_error("An application was closed twice"));
2391+ application_handles.erase(session);
2392+}
2393+
2394+void mia::DispatcherController::input_surface_opened(std::shared_ptr<mi::SessionTarget> const& session,
2395+ std::shared_ptr<input::SurfaceTarget> const& opened_surface)
2396+{
2397+ std::unique_lock<std::mutex> lock(handles_mutex);
2398+ auto application_handle = application_handles.find(session);
2399+ if (application_handle == application_handles.end())
2400+ BOOST_THROW_EXCEPTION(std::logic_error("A surface was opened for an unopened application"));
2401+ if (window_handles.find(opened_surface) != window_handles.end())
2402+ BOOST_THROW_EXCEPTION(std::logic_error("A surface was opened twice"));
2403+
2404+ droidinput::sp<droidinput::InputWindowHandle> window_handle = new mia::InputWindowHandle(application_handle->second, opened_surface);
2405+ input_dispatcher->registerInputChannel(window_handle->getInfo()->inputChannel, window_handle, false);
2406+
2407+ window_handles[opened_surface] = window_handle;
2408+}
2409+
2410+void mia::DispatcherController::input_surface_closed(std::shared_ptr<input::SurfaceTarget> const& closed_surface)
2411+{
2412+ std::unique_lock<std::mutex> lock(handles_mutex);
2413+ auto it = window_handles.find(closed_surface);
2414+ if (it == window_handles.end())
2415+ BOOST_THROW_EXCEPTION(std::logic_error("A surface was closed twice"));
2416+
2417+ input_dispatcher->unregisterInputChannel(it->second->getInfo()->inputChannel);
2418+ window_handles.erase(it);
2419+}
2420+
2421+void mia::DispatcherController::focus_cleared()
2422+{
2423+ droidinput::Vector<droidinput::sp<droidinput::InputWindowHandle>> empty_windows;
2424+ droidinput::sp<droidinput::InputApplicationHandle> null_application = nullptr;
2425+
2426+ input_dispatcher->setFocusedApplication(null_application);
2427+ input_dispatcher->setInputWindows(empty_windows);
2428+}
2429+
2430+void mia::DispatcherController::focus_changed(std::shared_ptr<mi::SurfaceTarget> const& surface)
2431+{
2432+ std::unique_lock<std::mutex> lock(handles_mutex);
2433+
2434+ auto window_handle = window_handles[surface];
2435+
2436+ if (!window_handle.get())
2437+ BOOST_THROW_EXCEPTION(std::logic_error("Focus changed to an unopened surface"));
2438+ auto application_handle = window_handle->inputApplicationHandle;
2439+
2440+ input_dispatcher->setFocusedApplication(application_handle);
2441
2442 droidinput::Vector<droidinput::sp<droidinput::InputWindowHandle>> windows;
2443- if (surface)
2444- {
2445- focused_application_handle = new mia::InputApplicationHandle(session);
2446- focused_window_handle = new mia::InputWindowHandle(focused_application_handle, surface);
2447- input_dispatcher->setFocusedApplication(focused_application_handle);
2448+ windows.push_back(window_handle);
2449
2450- input_dispatcher->registerInputChannel(focused_window_handle->getInfo()->inputChannel, focused_window_handle, false);
2451- windows.push_back(focused_window_handle);
2452- }
2453 input_dispatcher->setInputWindows(windows);
2454 }
2455
2456=== modified file 'src/server/input/android/android_dispatcher_controller.h'
2457--- src/server/input/android/android_dispatcher_controller.h 2013-04-11 23:06:12 +0000
2458+++ src/server/input/android/android_dispatcher_controller.h 2013-04-23 12:15:34 +0000
2459@@ -2,15 +2,15 @@
2460 * Copyright © 2013 Canonical Ltd.
2461 *
2462 * This program is free software: you can redistribute it and/or modify it
2463- * under the terms of the GNU Lesser General Public License version 3,
2464+ * under the terms of the GNU General Public License version 3,
2465 * as published by the Free Software Foundation.
2466 *
2467 * This program is distributed in the hope that it will be useful,
2468 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2469 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2470- * GNU Lesser General Public License for more details.
2471+ * GNU General Public License for more details.
2472 *
2473- * You should have received a copy of the GNU Lesser General Public License
2474+ * You should have received a copy of the GNU General Public License
2475 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2476 *
2477 * Authored by: Robert Carr <robert.carr@canonical.com>
2478@@ -19,10 +19,13 @@
2479 #ifndef MIR_INPUT_ANDROID_DISPATCHER_CONTROLLER_H_
2480 #define MIR_INPUT_ANDROID_DISPATCHER_CONTROLLER_H_
2481
2482-#include "mir/shell/input_focus_selector.h"
2483+#include "mir/shell/input_target_listener.h"
2484
2485 #include <utils/StrongPointer.h>
2486
2487+#include <map>
2488+#include <mutex>
2489+
2490 namespace android
2491 {
2492 class InputDispatcherInterface;
2493@@ -40,13 +43,21 @@
2494 {
2495 class InputConfiguration;
2496
2497-class DispatcherController : public shell::InputFocusSelector
2498+class DispatcherController : public shell::InputTargetListener
2499 {
2500 public:
2501 explicit DispatcherController(std::shared_ptr<InputConfiguration> const& input_configuration);
2502- virtual ~DispatcherController() = default;
2503+ virtual ~DispatcherController() noexcept(true) {}
2504
2505- void set_input_focus_to(std::shared_ptr<input::SessionTarget> const& session, std::shared_ptr<input::SurfaceTarget> const& surface);
2506+ void input_application_opened(std::shared_ptr<input::SessionTarget> const& application);
2507+ void input_application_closed(std::shared_ptr<input::SessionTarget> const& application);
2508+
2509+ void input_surface_opened(std::shared_ptr<input::SessionTarget> const& application,
2510+ std::shared_ptr<input::SurfaceTarget> const& opened_surface);
2511+ void input_surface_closed(std::shared_ptr<input::SurfaceTarget> const& closed_surface);
2512+
2513+ void focus_changed(std::shared_ptr<input::SurfaceTarget> const& focus_surface);
2514+ void focus_cleared();
2515
2516 protected:
2517 DispatcherController(const DispatcherController&) = delete;
2518@@ -55,8 +66,10 @@
2519 private:
2520 droidinput::sp<droidinput::InputDispatcherInterface> input_dispatcher;
2521
2522- droidinput::sp<droidinput::InputWindowHandle> focused_window_handle;
2523- droidinput::sp<droidinput::InputApplicationHandle> focused_application_handle;
2524+ std::map<std::shared_ptr<input::SessionTarget>, droidinput::sp<droidinput::InputApplicationHandle>> application_handles;
2525+ std::map<std::shared_ptr<input::SurfaceTarget>, droidinput::sp<droidinput::InputWindowHandle>> window_handles;
2526+
2527+ std::mutex handles_mutex;
2528 };
2529
2530 }
2531
2532=== modified file 'src/server/input/android/default_android_input_configuration.cpp'
2533--- src/server/input/android/default_android_input_configuration.cpp 2013-04-16 09:16:38 +0000
2534+++ src/server/input/android/default_android_input_configuration.cpp 2013-04-23 12:15:34 +0000
2535@@ -98,7 +98,7 @@
2536 return dispatcher_policy(
2537 [this]()
2538 {
2539- return new mia::EventFilterDispatcherPolicy(filter_chain);
2540+ return new mia::EventFilterDispatcherPolicy(filter_chain, is_key_repeat_enabled());
2541 });
2542 }
2543
2544@@ -149,3 +149,8 @@
2545 new droidinput::InputReaderThread(the_reader()));
2546 });
2547 }
2548+
2549+bool mia::DefaultInputConfiguration::is_key_repeat_enabled()
2550+{
2551+ return true;
2552+}
2553
2554=== modified file 'src/server/input/android/default_android_input_configuration.h'
2555--- src/server/input/android/default_android_input_configuration.h 2013-04-16 09:16:38 +0000
2556+++ src/server/input/android/default_android_input_configuration.h 2013-04-23 12:15:34 +0000
2557@@ -69,6 +69,8 @@
2558
2559 virtual droidinput::sp<droidinput::InputDispatcherPolicyInterface> the_dispatcher_policy();
2560 virtual droidinput::sp<droidinput::InputReaderPolicyInterface> the_reader_policy();
2561+
2562+ virtual bool is_key_repeat_enabled();
2563
2564 protected:
2565 DefaultInputConfiguration(DefaultInputConfiguration const&) = delete;
2566
2567=== modified file 'src/server/input/android/event_filter_dispatcher_policy.cpp'
2568--- src/server/input/android/event_filter_dispatcher_policy.cpp 2013-04-17 02:49:53 +0000
2569+++ src/server/input/android/event_filter_dispatcher_policy.cpp 2013-04-23 12:15:34 +0000
2570@@ -21,8 +21,9 @@
2571 namespace mi = mir::input;
2572 namespace mia = mi::android;
2573
2574-mia::EventFilterDispatcherPolicy::EventFilterDispatcherPolicy(std::shared_ptr<mi::EventFilter> const& event_filter) :
2575- event_filter(event_filter)
2576+mia::EventFilterDispatcherPolicy::EventFilterDispatcherPolicy(std::shared_ptr<mi::EventFilter> const& event_filter, bool key_repeat_enabled) :
2577+ event_filter(event_filter),
2578+ key_repeat_enabled(key_repeat_enabled)
2579 {
2580 }
2581
2582@@ -46,7 +47,7 @@
2583
2584 bool mia::EventFilterDispatcherPolicy::isKeyRepeatEnabled()
2585 {
2586- return true;
2587+ return key_repeat_enabled;
2588 }
2589
2590 bool mia::EventFilterDispatcherPolicy::filterInputEvent(const droidinput::InputEvent* input_event, uint32_t /*policy_flags*/)
2591
2592=== modified file 'src/server/input/android/event_filter_dispatcher_policy.h'
2593--- src/server/input/android/event_filter_dispatcher_policy.h 2013-04-16 09:16:38 +0000
2594+++ src/server/input/android/event_filter_dispatcher_policy.h 2013-04-23 12:15:34 +0000
2595@@ -40,7 +40,7 @@
2596 class EventFilterDispatcherPolicy : public droidinput::InputDispatcherPolicyInterface
2597 {
2598 public:
2599- EventFilterDispatcherPolicy(std::shared_ptr<EventFilter> const& event_filter);
2600+ EventFilterDispatcherPolicy(std::shared_ptr<EventFilter> const& event_filter, bool key_repeat_enabled);
2601 virtual ~EventFilterDispatcherPolicy() {}
2602
2603 void notifyConfigurationChanged(nsecs_t when);
2604@@ -71,6 +71,7 @@
2605 EventFilterDispatcherPolicy& operator=(const EventFilterDispatcherPolicy&) = delete;
2606 private:
2607 std::shared_ptr<EventFilter> event_filter;
2608+ bool key_repeat_enabled;
2609 };
2610
2611 }
2612
2613=== modified file 'src/server/shell/application_session.cpp'
2614--- src/server/shell/application_session.cpp 2013-04-19 08:03:57 +0000
2615+++ src/server/shell/application_session.cpp 2013-04-23 12:15:34 +0000
2616@@ -18,8 +18,8 @@
2617
2618 #include "mir/shell/application_session.h"
2619 #include "mir/shell/surface.h"
2620-
2621 #include "mir/shell/surface_factory.h"
2622+#include "mir/shell/input_target_listener.h"
2623
2624 #include <boost/throw_exception.hpp>
2625
2626@@ -28,14 +28,19 @@
2627 #include <cassert>
2628 #include <algorithm>
2629
2630+namespace me = mir::events;
2631 namespace mf = mir::frontend;
2632 namespace msh = mir::shell;
2633
2634 msh::ApplicationSession::ApplicationSession(
2635 std::shared_ptr<SurfaceFactory> const& surface_factory,
2636- std::string const& session_name) :
2637+ std::shared_ptr<msh::InputTargetListener> const& input_target_listener,
2638+ std::string const& session_name,
2639+ std::shared_ptr<me::EventSink> const& sink) :
2640 surface_factory(surface_factory),
2641+ input_target_listener(input_target_listener),
2642 session_name(session_name),
2643+ event_sink(sink),
2644 next_surface_id(0)
2645 {
2646 assert(surface_factory);
2647@@ -46,6 +51,7 @@
2648 std::unique_lock<std::mutex> lock(surfaces_mutex);
2649 for (auto const& pair_id_surface : surfaces)
2650 {
2651+ input_target_listener->input_surface_closed(pair_id_surface.second);
2652 pair_id_surface.second->destroy();
2653 }
2654 }
2655@@ -63,8 +69,8 @@
2656
2657 mf::SurfaceId msh::ApplicationSession::create_surface(const mf::SurfaceCreationParameters& params)
2658 {
2659- auto surf = surface_factory->create_surface(params);
2660 auto const id = next_id();
2661+ auto surf = surface_factory->create_surface(params, id, event_sink);
2662
2663 surf->set_id(id);
2664 surf->set_event_target(event_sink);
2665@@ -104,6 +110,7 @@
2666 std::unique_lock<std::mutex> lock(surfaces_mutex);
2667 auto p = checked_find(id);
2668
2669+ input_target_listener->input_surface_closed(p->second);
2670 p->second->destroy();
2671 surfaces.erase(p);
2672 }
2673
2674=== modified file 'src/server/shell/organising_surface_factory.cpp'
2675--- src/server/shell/organising_surface_factory.cpp 2013-04-16 09:16:38 +0000
2676+++ src/server/shell/organising_surface_factory.cpp 2013-04-23 12:15:34 +0000
2677@@ -34,10 +34,13 @@
2678 {
2679 }
2680
2681-std::shared_ptr<msh::Surface> msh::OrganisingSurfaceFactory::create_surface(const mf::SurfaceCreationParameters& params)
2682+std::shared_ptr<msh::Surface> msh::OrganisingSurfaceFactory::create_surface(
2683+ frontend::SurfaceCreationParameters const& params,
2684+ frontend::SurfaceId id,
2685+ std::shared_ptr<events::EventSink> const& sink)
2686 {
2687 auto placed_params = placement_strategy->place(params);
2688
2689- return underlying_factory->create_surface(placed_params);
2690+ return underlying_factory->create_surface(placed_params, id, sink);
2691 }
2692
2693
2694=== modified file 'src/server/shell/session_manager.cpp'
2695--- src/server/shell/session_manager.cpp 2013-04-22 03:24:56 +0000
2696+++ src/server/shell/session_manager.cpp 2013-04-23 12:15:34 +0000
2697@@ -23,6 +23,8 @@
2698 #include "mir/shell/focus_sequence.h"
2699 #include "mir/shell/focus_setter.h"
2700 #include "mir/shell/session.h"
2701+#include "mir/shell/surface.h"
2702+#include "mir/shell/input_target_listener.h"
2703
2704 #include <memory>
2705 #include <cassert>
2706@@ -31,47 +33,62 @@
2707 namespace mf = mir::frontend;
2708 namespace msh = mir::shell;
2709
2710-msh::SessionManager::SessionManager(
2711- std::shared_ptr<msh::SurfaceFactory> const& surface_factory,
2712+msh::SessionManager::SessionManager(std::shared_ptr<msh::SurfaceFactory> const& surface_factory,
2713 std::shared_ptr<msh::SessionContainer> const& container,
2714 std::shared_ptr<msh::FocusSequence> const& sequence,
2715- std::shared_ptr<msh::FocusSetter> const& focus_setter) :
2716+ std::shared_ptr<msh::FocusSetter> const& focus_setter,
2717+ std::shared_ptr<msh::InputTargetListener> const& input_target_listener) :
2718 surface_factory(surface_factory),
2719 app_container(container),
2720 focus_sequence(sequence),
2721- focus_setter(focus_setter)
2722+ focus_setter(focus_setter),
2723+ input_target_listener(input_target_listener)
2724 {
2725 assert(surface_factory);
2726 assert(sequence);
2727 assert(container);
2728 assert(focus_setter);
2729+ assert(input_target_listener);
2730 }
2731
2732 msh::SessionManager::~SessionManager()
2733 {
2734 }
2735
2736-std::shared_ptr<mf::Session> msh::SessionManager::open_session(std::string const& name)
2737+std::shared_ptr<mf::Session> msh::SessionManager::open_session(
2738+ std::string const& name,
2739+ std::shared_ptr<events::EventSink> const& sink)
2740 {
2741- auto new_session = std::make_shared<msh::ApplicationSession>(surface_factory, name);
2742+ auto new_session = std::make_shared<msh::ApplicationSession>(surface_factory, input_target_listener, name, sink);
2743
2744 app_container->insert_session(new_session);
2745+
2746+ input_target_listener->input_application_opened(new_session);
2747
2748 set_focus_to_locked(std::unique_lock<std::mutex>(mutex), new_session);
2749
2750 return new_session;
2751 }
2752
2753-inline void msh::SessionManager::set_focus_to_locked(std::unique_lock<std::mutex> const&, std::shared_ptr<Session> const& next_focus)
2754+inline void msh::SessionManager::set_focus_to_locked(std::unique_lock<std::mutex> const&, std::shared_ptr<Session> const& shell_session)
2755 {
2756- focus_application = next_focus;
2757- focus_setter->set_focus_to(next_focus);
2758+ auto old_focus = focus_application.lock();
2759+
2760+ focus_application = shell_session;
2761+ focus_setter->set_focus_to(shell_session);
2762+
2763+ if (shell_session && shell_session->default_surface())
2764+ input_target_listener->focus_changed(shell_session->default_surface());
2765+ else if (shell_session == old_focus || !shell_session)
2766+ input_target_listener->focus_cleared();
2767 }
2768
2769 void msh::SessionManager::close_session(std::shared_ptr<mf::Session> const& session)
2770 {
2771 auto shell_session = std::dynamic_pointer_cast<Session>(session);
2772
2773+ input_target_listener->input_application_closed(shell_session);
2774+
2775 app_container->remove_session(shell_session);
2776
2777 std::unique_lock<std::mutex> lock(mutex);
2778@@ -133,9 +150,11 @@
2779 mf::SurfaceCreationParameters const& params)
2780 {
2781 auto shell_session = std::dynamic_pointer_cast<Session>(session);
2782- auto id = session->create_surface(params);
2783+ auto id = shell_session->create_surface(params);
2784+
2785+ input_target_listener->input_surface_opened(shell_session,
2786+ std::dynamic_pointer_cast<msh::Surface>(shell_session->get_surface(id)));
2787 set_focus_to_locked(std::unique_lock<std::mutex>(mutex), shell_session);
2788
2789 return id;
2790 }
2791-
2792
2793=== modified file 'src/server/shell/single_visibility_focus_mechanism.cpp'
2794--- src/server/shell/single_visibility_focus_mechanism.cpp 2013-04-19 03:20:05 +0000
2795+++ src/server/shell/single_visibility_focus_mechanism.cpp 2013-04-23 12:15:34 +0000
2796@@ -19,7 +19,6 @@
2797 #include "mir/shell/session_container.h"
2798 #include "mir/frontend/session.h"
2799 #include "mir/shell/single_visibility_focus_mechanism.h"
2800-#include "mir/shell/input_focus_selector.h"
2801
2802 #include "mir/shell/session.h"
2803 #include "mir/shell/surface.h"
2804@@ -27,10 +26,8 @@
2805 namespace mf = mir::frontend;
2806 namespace msh = mir::shell;
2807
2808-msh::SingleVisibilityFocusMechanism::SingleVisibilityFocusMechanism(std::shared_ptr<msh::SessionContainer> const& app_container,
2809- std::shared_ptr<msh::InputFocusSelector> const& input_selector)
2810- : app_container(app_container),
2811- input_selector(input_selector)
2812+msh::SingleVisibilityFocusMechanism::SingleVisibilityFocusMechanism(std::shared_ptr<msh::SessionContainer> const& app_container)
2813+ : app_container(app_container)
2814 {
2815 }
2816
2817@@ -41,8 +38,6 @@
2818 if (session == focus_session)
2819 {
2820 session->show();
2821-
2822- input_selector->set_input_focus_to(focus_session, focus_session->default_surface());
2823 }
2824 else
2825 {
2826
2827=== modified file 'src/server/shell/surface.cpp'
2828--- src/server/shell/surface.cpp 2013-04-19 03:20:05 +0000
2829+++ src/server/shell/surface.cpp 2013-04-23 12:15:34 +0000
2830@@ -19,8 +19,13 @@
2831 #include "mir/shell/surface.h"
2832 #include "mir/shell/surface_builder.h"
2833 #include "mir/input/input_channel.h"
2834+<<<<<<< TREE
2835 #include "mir_toolkit/event.h"
2836 #include "mir/event_sink.h"
2837+=======
2838+#include "mir_toolkit/event.h"
2839+#include "mir/events/event_sink.h"
2840+>>>>>>> MERGE-SOURCE
2841
2842 #include <boost/throw_exception.hpp>
2843
2844@@ -34,13 +39,22 @@
2845 msh::Surface::Surface(
2846 std::shared_ptr<SurfaceBuilder> const& builder,
2847 frontend::SurfaceCreationParameters const& params,
2848- std::shared_ptr<input::InputChannel> const& input_channel)
2849+ std::shared_ptr<input::InputChannel> const& input_channel,
2850+ frontend::SurfaceId id,
2851+ std::shared_ptr<events::EventSink> const& sink)
2852 : builder(builder),
2853 input_channel(input_channel),
2854 surface(builder->create_surface(params)),
2855+<<<<<<< TREE
2856 id(0),
2857 type_value(mir_surface_type_normal),
2858 state_value(mir_surface_state_restored)
2859+=======
2860+ id(id),
2861+ event_sink(sink),
2862+ type_value(mir_surface_type_normal),
2863+ state_value(mir_surface_state_restored)
2864+>>>>>>> MERGE-SOURCE
2865 {
2866 }
2867
2868
2869=== modified file 'src/server/shell/surface_source.cpp'
2870--- src/server/shell/surface_source.cpp 2013-04-16 09:16:38 +0000
2871+++ src/server/shell/surface_source.cpp 2013-04-23 12:15:34 +0000
2872@@ -39,11 +39,16 @@
2873 assert(surface_builder);
2874 }
2875
2876-std::shared_ptr<msh::Surface> msh::SurfaceSource::create_surface(const mf::SurfaceCreationParameters& params)
2877+std::shared_ptr<msh::Surface> msh::SurfaceSource::create_surface(
2878+ frontend::SurfaceCreationParameters const& params,
2879+ frontend::SurfaceId id,
2880+ std::shared_ptr<events::EventSink> const& sink)
2881 {
2882 return std::make_shared<Surface>(
2883 surface_builder,
2884 params,
2885- input_factory->make_input_channel());
2886+ input_factory->make_input_channel(),
2887+ id,
2888+ sink);
2889 }
2890
2891
2892=== modified file 'tests/acceptance-tests/test_client_input.cpp'
2893--- tests/acceptance-tests/test_client_input.cpp 2013-04-18 04:23:56 +0000
2894+++ tests/acceptance-tests/test_client_input.cpp 2013-04-23 12:15:34 +0000
2895@@ -65,10 +65,9 @@
2896
2897 }
2898
2899- void set_input_focus_to(
2900- std::shared_ptr<mi::SessionTarget> const& session, std::shared_ptr<mi::SurfaceTarget> const& surface) override
2901+ void focus_changed(std::shared_ptr<mi::SurfaceTarget> const& surface) override
2902 {
2903- DispatcherController::set_input_focus_to(session, surface);
2904+ DispatcherController::focus_changed(surface);
2905
2906 // We need a synchronization primitive inorder to halt test event injection
2907 // until after a surface has taken focus (lest the events be discarded).
2908@@ -122,10 +121,10 @@
2909 });
2910 }
2911
2912- std::shared_ptr<msh::InputFocusSelector>
2913- the_input_focus_selector() override
2914+ std::shared_ptr<msh::InputTargetListener>
2915+ the_input_target_listener() override
2916 {
2917- return input_focus_selector(
2918+ return input_target_listener(
2919 [this]()
2920 {
2921 return std::make_shared<FocusNotifyingDispatcherController>(mt::fake_shared(input_config), on_focus_set);
2922
2923=== modified file 'tests/acceptance-tests/test_focus_management_api.cpp'
2924--- tests/acceptance-tests/test_focus_management_api.cpp 2013-04-22 03:24:56 +0000
2925+++ tests/acceptance-tests/test_focus_management_api.cpp 2013-04-23 12:15:34 +0000
2926@@ -126,7 +126,7 @@
2927 {
2928 using namespace ::testing;
2929 using frontend::Shell;
2930- ON_CALL(*this, open_session(_)).WillByDefault(Invoke(impl.get(), &Shell::open_session));
2931+ ON_CALL(*this, open_session(_, _)).WillByDefault(Invoke(impl.get(), &Shell::open_session));
2932 ON_CALL(*this, close_session(_)).WillByDefault(Invoke(impl.get(), &Shell::close_session));
2933
2934 ON_CALL(*this, tag_session_with_lightdm_id(_, _)).WillByDefault(Invoke(impl.get(), &Shell::tag_session_with_lightdm_id));
2935@@ -135,7 +135,7 @@
2936 ON_CALL(*this, create_surface_for(_, _)).WillByDefault(Invoke(impl.get(), &Shell::create_surface_for));
2937 }
2938
2939- MOCK_METHOD1(open_session, std::shared_ptr<mf::Session> (std::string const& name));
2940+ MOCK_METHOD2(open_session, std::shared_ptr<mf::Session> (std::string const& name, std::shared_ptr<mir::events::EventSink> const&));
2941 MOCK_METHOD1(close_session, void (std::shared_ptr<mf::Session> const& session));
2942
2943 MOCK_METHOD2(tag_session_with_lightdm_id, void (std::shared_ptr<mf::Session> const& session, int id));
2944@@ -165,13 +165,13 @@
2945
2946 Sequence s1, s2;
2947
2948- EXPECT_CALL(*mock_shell, open_session(_))
2949+ EXPECT_CALL(*mock_shell, open_session(_, _))
2950 .InSequence(s1, s2);
2951
2952 EXPECT_CALL(*mock_shell, create_surface_for(_,_))
2953 .InSequence(s1);
2954
2955- EXPECT_CALL(*mock_shell, open_session(_))
2956+ EXPECT_CALL(*mock_shell, open_session(_, _))
2957 .InSequence(s2);
2958
2959 EXPECT_CALL(*mock_shell, close_session(_))
2960
2961=== modified file 'tests/acceptance-tests/test_focus_selection.cpp'
2962--- tests/acceptance-tests/test_focus_selection.cpp 2013-04-18 04:23:56 +0000
2963+++ tests/acceptance-tests/test_focus_selection.cpp 2013-04-23 12:15:34 +0000
2964@@ -24,11 +24,11 @@
2965 #include "mir/shell/organising_surface_factory.h"
2966 #include "mir/shell/session_manager.h"
2967 #include "mir/graphics/display.h"
2968-#include "mir/shell/input_focus_selector.h"
2969+#include "mir/shell/input_target_listener.h"
2970
2971 #include "mir_test_framework/display_server_test_fixture.h"
2972 #include "mir_test_doubles/mock_focus_setter.h"
2973-#include "mir_test_doubles/mock_input_focus_selector.h"
2974+#include "mir_test_doubles/mock_input_target_listener.h"
2975
2976 #include <gtest/gtest.h>
2977 #include <gmock/gmock.h>
2978@@ -36,7 +36,8 @@
2979 namespace mf = mir::frontend;
2980 namespace msh = mir::shell;
2981 namespace mi = mir::input;
2982-namespace mtd = mir::test::doubles;
2983+namespace mt = mir::test;
2984+namespace mtd = mt::doubles;
2985 namespace mtf = mir_test_framework;
2986
2987 namespace
2988@@ -46,6 +47,7 @@
2989
2990 namespace
2991 {
2992+
2993 struct ClientConfigCommon : TestingClientConfiguration
2994 {
2995 ClientConfigCommon() :
2996@@ -121,18 +123,10 @@
2997 {
2998 return arg != std::shared_ptr<msh::Session>();
2999 }
3000-MATCHER(NonNullSessionTarget, "")
3001-{
3002- return arg != std::shared_ptr<mi::SessionTarget>();
3003-}
3004 MATCHER(NonNullSurfaceTarget, "")
3005 {
3006 return arg != std::shared_ptr<mi::SurfaceTarget>();
3007 }
3008-MATCHER(NullSurfaceTarget, "")
3009-{
3010- return arg == std::shared_ptr<mi::SurfaceTarget>();
3011-}
3012 }
3013
3014 TEST_F(BespokeDisplayServerTestFixture, sessions_creating_surface_receive_focus)
3015@@ -148,7 +142,6 @@
3016 using namespace ::testing;
3017
3018 auto focus_setter = std::make_shared<mtd::MockFocusSetter>();
3019-
3020 {
3021 InSequence seq;
3022 // Once on application registration and once on surface creation
3023@@ -174,30 +167,37 @@
3024 {
3025 struct ServerConfig : TestingServerConfiguration
3026 {
3027- std::shared_ptr<mtd::MockInputFocusSelector> focus_selector;
3028+ std::shared_ptr<mtd::MockInputTargetListener> target_listener;
3029 bool expected;
3030
3031 ServerConfig()
3032- : focus_selector(std::make_shared<mtd::MockInputFocusSelector>()),
3033+ : target_listener(std::make_shared<mtd::MockInputTargetListener>()),
3034 expected(false)
3035 {
3036 }
3037
3038- std::shared_ptr<msh::InputFocusSelector>
3039- the_input_focus_selector() override
3040+ std::shared_ptr<msh::InputTargetListener>
3041+ the_input_target_listener() override
3042 {
3043 using namespace ::testing;
3044
3045 if (!expected)
3046 {
3047- InSequence seq;
3048+
3049+ EXPECT_CALL(*target_listener, input_application_opened(_)).Times(AtLeast(0));
3050+ EXPECT_CALL(*target_listener, input_application_closed(_)).Times(AtLeast(0));
3051+ EXPECT_CALL(*target_listener, input_surface_opened(_,_)).Times(AtLeast(0));
3052+ EXPECT_CALL(*target_listener, input_surface_closed(_)).Times(AtLeast(0));
3053+ EXPECT_CALL(*target_listener, focus_cleared()).Times(AtLeast(0));
3054
3055- EXPECT_CALL(*focus_selector, set_input_focus_to(NonNullSessionTarget(), NullSurfaceTarget())).Times(1);
3056- EXPECT_CALL(*focus_selector, set_input_focus_to(NonNullSessionTarget(), NonNullSurfaceTarget())).Times(1);
3057- expected = true;
3058+ {
3059+ InSequence seq;
3060+ EXPECT_CALL(*target_listener, focus_changed(NonNullSurfaceTarget())).Times(1);
3061+ expected = true;
3062+ }
3063 }
3064
3065- return focus_selector;
3066+ return target_listener;
3067 }
3068 } server_config;
3069
3070
3071=== modified file 'tests/behavior-tests/session_management_context.cpp'
3072--- tests/behavior-tests/session_management_context.cpp 2013-04-22 03:24:56 +0000
3073+++ tests/behavior-tests/session_management_context.cpp 2013-04-23 12:15:34 +0000
3074@@ -66,12 +66,16 @@
3075 {
3076 }
3077
3078- std::shared_ptr<msh::Surface> create_surface(const mf::SurfaceCreationParameters& params)
3079+ std::shared_ptr<msh::Surface> create_surface(const mf::SurfaceCreationParameters& params,
3080+ frontend::SurfaceId id,
3081+ std::shared_ptr<events::EventSink> const& sink) override
3082 {
3083 return std::make_shared<msh::Surface>(
3084 mt::fake_shared(surface_builder),
3085 params,
3086- std::shared_ptr<mir::input::InputChannel>());
3087+ std::shared_ptr<mir::input::InputChannel>(),
3088+ id,
3089+ sink);
3090 }
3091
3092 mtd::StubSurfaceBuilder surface_builder;
3093@@ -152,7 +156,7 @@
3094 bool mtc::SessionManagementContext::open_window_consuming(std::string const& window_name)
3095 {
3096 auto const params = mf::a_surface().of_name(window_name);
3097- auto session = shell->open_session(window_name);
3098+ auto session = shell->open_session(window_name, std::shared_ptr<mir::events::EventSink>());
3099 auto const surface_id = session->create_surface(params);
3100
3101 open_windows[window_name] = std::make_tuple(session, surface_id);
3102@@ -164,7 +168,7 @@
3103 geom::Size const& size)
3104 {
3105 auto const params = mf::a_surface().of_name(window_name).of_size(size);
3106- auto session = shell->open_session(window_name);
3107+ auto session = shell->open_session(window_name, std::shared_ptr<mir::events::EventSink>());
3108 auto const surface_id = session->create_surface(params);
3109
3110 open_windows[window_name] = std::make_tuple(session, surface_id);
3111
3112=== modified file 'tests/death-tests/test_application_manager_death.cpp'
3113--- tests/death-tests/test_application_manager_death.cpp 2013-03-21 03:32:59 +0000
3114+++ tests/death-tests/test_application_manager_death.cpp 2013-04-23 12:15:34 +0000
3115@@ -30,11 +30,12 @@
3116 // ::testing::FLAGS_gtest_death_test_style = "threadsafe";
3117 // leads to the test failing under valgrind
3118 EXPECT_EXIT(
3119- std::shared_ptr<msh::SurfaceFactory> factory;
3120- mir::shell::SessionManager app(factory,
3121+ std::shared_ptr<msh::SurfaceFactory> surface_factory;
3122+ mir::shell::SessionManager app(surface_factory,
3123 std::shared_ptr<msh::SessionContainer>(),
3124 std::shared_ptr<msh::FocusSequence>(),
3125- std::shared_ptr<msh::FocusSetter>()),
3126+ std::shared_ptr<msh::FocusSetter>(),
3127+ std::shared_ptr<msh::InputTargetListener>()),
3128 ::testing::KilledBySignal(SIGABRT),
3129 ".*");
3130 }
3131
3132=== modified file 'tests/integration-tests/cucumber/test_session_management_context.cpp'
3133--- tests/integration-tests/cucumber/test_session_management_context.cpp 2013-04-22 03:24:56 +0000
3134+++ tests/integration-tests/cucumber/test_session_management_context.cpp 2013-04-23 12:15:34 +0000
3135@@ -106,7 +106,7 @@
3136
3137 mtd::MockSession session;
3138
3139- EXPECT_CALL(shell, open_session(test_window_name)).Times(1)
3140+ EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1)
3141 .WillOnce(Return(mt::fake_shared<mf::Session>(session)));
3142
3143 // As consuming mode is the default, omiting geometry is sufficient to request it.
3144@@ -122,7 +122,7 @@
3145
3146 mtd::MockSession session;
3147
3148- EXPECT_CALL(shell, open_session(test_window_name)).Times(1)
3149+ EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1)
3150 .WillOnce(Return(mt::fake_shared<mf::Session>(session)));
3151
3152 EXPECT_CALL(session, create_surface(NamedWindowWithGeometry(test_window_name, test_window_size))).Times(1)
3153@@ -138,7 +138,7 @@
3154 mtd::MockSession session;
3155 mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>());
3156
3157- EXPECT_CALL(shell, open_session(test_window_name)).Times(1)
3158+ EXPECT_CALL(shell, open_session(test_window_name, _)).Times(1)
3159 .WillOnce(Return(mt::fake_shared<mf::Session>(session)));
3160
3161 EXPECT_CALL(session, create_surface(NamedWindowWithGeometry(test_window_name, test_window_size))).Times(1)
3162
3163=== modified file 'tests/integration-tests/input/android/test_android_input_manager.cpp'
3164--- tests/integration-tests/input/android/test_android_input_manager.cpp 2013-04-16 04:56:53 +0000
3165+++ tests/integration-tests/input/android/test_android_input_manager.cpp 2013-04-23 12:15:34 +0000
3166@@ -171,7 +171,7 @@
3167 struct MockDispatcherPolicy : public mia::EventFilterDispatcherPolicy
3168 {
3169 MockDispatcherPolicy(std::shared_ptr<mi::EventFilter> const& filter)
3170- : EventFilterDispatcherPolicy(filter)
3171+ : EventFilterDispatcherPolicy(filter, false)
3172 {
3173 }
3174 MOCK_METHOD3(interceptKeyBeforeDispatching, nsecs_t(droidinput::sp<droidinput::InputWindowHandle> const&,
3175@@ -211,24 +211,31 @@
3176 ON_CALL(viewable_area, view_area())
3177 .WillByDefault(Return(default_view_area));
3178 input_manager = std::make_shared<mia::InputManager>(configuration);
3179- input_focus_selector = std::make_shared<mia::DispatcherController>(configuration);
3180+ input_target_listener = std::make_shared<mia::DispatcherController>(configuration);
3181
3182 dispatcher_policy = configuration->the_mock_dispatcher_policy();
3183
3184 }
3185
3186+ ~AndroidInputManagerDispatcherInterceptSetup()
3187+ {
3188+ input_manager->stop();
3189+ }
3190+
3191 // TODO: It would be nice if it were possible to mock the interface between
3192 // droidinput::InputChannel and droidinput::InputDispatcher rather than use
3193 // valid fds to allow non-throwing construction of a real input channel.
3194 void SetUp()
3195 {
3196- test_input_fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
3197 input_manager->start();
3198 }
3199- void TearDown()
3200+
3201+ int test_fd()
3202 {
3203- input_manager->stop();
3204- close(test_input_fd);
3205+ int fds[2];
3206+ // Closed by droidinput InputChannel on shutdown
3207+ socketpair(AF_UNIX, SOCK_SEQPACKET, 0, fds);
3208+ return fds[0];
3209 }
3210
3211 MockEventFilter event_filter;
3212@@ -238,9 +245,7 @@
3213 droidinput::sp<MockDispatcherPolicy> dispatcher_policy;
3214
3215 std::shared_ptr<mia::InputManager> input_manager;
3216- std::shared_ptr<msh::InputFocusSelector> input_focus_selector;
3217-
3218- int test_input_fd;
3219+ std::shared_ptr<msh::InputTargetListener> input_target_listener;
3220 };
3221
3222 MATCHER_P(WindowHandleWithInputFd, input_fd, "")
3223@@ -259,14 +264,18 @@
3224 mt::WaitCondition wait_condition;
3225
3226 mtd::StubSessionTarget session;
3227- mtd::StubSurfaceTarget surface(test_input_fd);
3228+
3229+ auto input_fd = test_fd();
3230+ mtd::StubSurfaceTarget surface(input_fd);
3231
3232 EXPECT_CALL(event_filter, handles(_)).Times(1).WillOnce(Return(false));
3233 // We return -1 here to skip publishing of the event (to an unconnected test socket!).
3234- EXPECT_CALL(*dispatcher_policy, interceptKeyBeforeDispatching(WindowHandleWithInputFd(test_input_fd), _, _))
3235+ EXPECT_CALL(*dispatcher_policy, interceptKeyBeforeDispatching(WindowHandleWithInputFd(input_fd), _, _))
3236 .Times(1).WillOnce(DoAll(mt::WakeUp(&wait_condition), Return(-1)));
3237
3238- input_focus_selector->set_input_focus_to(mt::fake_shared(session), mt::fake_shared(surface));
3239+ input_target_listener->input_application_opened(mt::fake_shared(session));
3240+ input_target_listener->input_surface_opened(mt::fake_shared(session), mt::fake_shared(surface));
3241+ input_target_listener->focus_changed(mt::fake_shared(surface));
3242
3243 fake_event_hub->synthesize_builtin_keyboard_added();
3244 fake_event_hub->synthesize_device_scan_complete();
3245@@ -275,3 +284,52 @@
3246
3247 wait_condition.wait_for_at_most_seconds(1);
3248 }
3249+
3250+TEST_F(AndroidInputManagerDispatcherInterceptSetup, changing_focus_changes_event_recipient)
3251+{
3252+ using namespace ::testing;
3253+
3254+ mt::WaitCondition wait1, wait2, wait3;
3255+
3256+ mtd::StubSessionTarget session;
3257+
3258+ auto input_fd_1 = test_fd();
3259+ mtd::StubSurfaceTarget surface1(input_fd_1);
3260+ auto input_fd_2 = test_fd();
3261+ mtd::StubSurfaceTarget surface2(input_fd_2);
3262+
3263+ input_target_listener->input_application_opened(mt::fake_shared(session));
3264+ input_target_listener->input_surface_opened(mt::fake_shared(session), mt::fake_shared(surface1));
3265+ input_target_listener->input_surface_opened(mt::fake_shared(session), mt::fake_shared(surface2));
3266+
3267+ EXPECT_CALL(event_filter, handles(_)).Times(3).WillRepeatedly(Return(false));
3268+
3269+ {
3270+ InSequence seq;
3271+
3272+ EXPECT_CALL(*dispatcher_policy, interceptKeyBeforeDispatching(WindowHandleWithInputFd(input_fd_1), _, _))
3273+ .Times(1).WillOnce(DoAll(mt::WakeUp(&wait1), Return(-1)));
3274+ EXPECT_CALL(*dispatcher_policy, interceptKeyBeforeDispatching(WindowHandleWithInputFd(input_fd_2), _, _))
3275+ .Times(1).WillOnce(DoAll(mt::WakeUp(&wait2), Return(-1)));
3276+ EXPECT_CALL(*dispatcher_policy, interceptKeyBeforeDispatching(WindowHandleWithInputFd(input_fd_1), _, _))
3277+ .Times(1).WillOnce(DoAll(mt::WakeUp(&wait3), Return(-1)));
3278+ }
3279+
3280+ fake_event_hub->synthesize_builtin_keyboard_added();
3281+ fake_event_hub->synthesize_device_scan_complete();
3282+
3283+ input_target_listener->focus_changed(mt::fake_shared(surface1));
3284+ fake_event_hub->synthesize_event(mis::a_key_down_event()
3285+ .of_scancode(KEY_1));
3286+ wait1.wait_for_at_most_seconds(1);
3287+
3288+ input_target_listener->focus_changed(mt::fake_shared(surface2));
3289+ fake_event_hub->synthesize_event(mis::a_key_down_event()
3290+ .of_scancode(KEY_2));
3291+ wait2.wait_for_at_most_seconds(1);
3292+
3293+ input_target_listener->focus_changed(mt::fake_shared(surface1));
3294+ fake_event_hub->synthesize_event(mis::a_key_down_event()
3295+ .of_scancode(KEY_3));
3296+ wait3.wait_for_at_most_seconds(5);
3297+}
3298
3299=== modified file 'tests/integration-tests/input/android/test_fake_event_hub_to_event_filter.cpp'
3300--- tests/integration-tests/input/android/test_fake_event_hub_to_event_filter.cpp 2013-04-05 07:12:27 +0000
3301+++ tests/integration-tests/input/android/test_fake_event_hub_to_event_filter.cpp 2013-04-23 12:15:34 +0000
3302@@ -56,7 +56,7 @@
3303 void SetUp()
3304 {
3305 event_hub = new mia::FakeEventHub();
3306- dispatcher_policy = new mia::EventFilterDispatcherPolicy(mt::fake_shared(event_filter));
3307+ dispatcher_policy = new mia::EventFilterDispatcherPolicy(mt::fake_shared(event_filter), false);
3308 reader_policy = new mia::RudimentaryInputReaderPolicy();
3309 dispatcher = new droidinput::InputDispatcher(dispatcher_policy);
3310 reader = new droidinput::InputReader(event_hub, reader_policy, dispatcher);
3311
3312=== modified file 'tests/integration-tests/shell/test_session_manager.cpp'
3313--- tests/integration-tests/shell/test_session_manager.cpp 2013-04-19 03:20:05 +0000
3314+++ tests/integration-tests/shell/test_session_manager.cpp 2013-04-23 12:15:34 +0000
3315@@ -33,8 +33,10 @@
3316 #include "mir_test/fake_shared.h"
3317 #include "mir_test_doubles/mock_surface_factory.h"
3318 #include "mir_test_doubles/mock_focus_setter.h"
3319+#include "mir_test_doubles/stub_input_target_listener.h"
3320
3321 namespace mc = mir::compositor;
3322+namespace me = mir::events;
3323 namespace mf = mir::frontend;
3324 namespace msh = mir::shell;
3325 namespace ms = mir::surfaces;
3326@@ -44,29 +46,32 @@
3327 TEST(TestSessionManagerAndFocusSelectionStrategy, cycle_focus)
3328 {
3329 using namespace ::testing;
3330+
3331 mtd::MockSurfaceFactory surface_factory;
3332 std::shared_ptr<msh::DefaultSessionContainer> container(new msh::DefaultSessionContainer());
3333 msh::RegistrationOrderFocusSequence sequence(container);
3334- mtd::MockFocusSetter focus_changer;
3335+ mtd::MockFocusSetter focus_setter;
3336 std::shared_ptr<mf::Session> new_session;
3337+ mtd::StubInputTargetListener input_target_listener;
3338
3339 msh::SessionManager session_manager(
3340 mt::fake_shared(surface_factory),
3341 container,
3342 mt::fake_shared(sequence),
3343- mt::fake_shared(focus_changer));
3344-
3345- EXPECT_CALL(focus_changer, set_focus_to(_)).Times(3);
3346-
3347- auto session1 = session_manager.open_session("Visual Basic Studio");
3348- auto session2 = session_manager.open_session("Microsoft Access");
3349- auto session3 = session_manager.open_session("WordPerfect");
3350+ mt::fake_shared(focus_setter),
3351+ mt::fake_shared(input_target_listener));
3352+
3353+ EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3);
3354+
3355+ auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>());
3356+ auto session2 = session_manager.open_session("Microsoft Access", std::shared_ptr<me::EventSink>());
3357+ auto session3 = session_manager.open_session("WordPerfect", std::shared_ptr<me::EventSink>());
3358
3359 {
3360 InSequence seq;
3361- EXPECT_CALL(focus_changer, set_focus_to(Eq(session1))).Times(1);
3362- EXPECT_CALL(focus_changer, set_focus_to(Eq(session2))).Times(1);
3363- EXPECT_CALL(focus_changer, set_focus_to(Eq(session3))).Times(1);
3364+ EXPECT_CALL(focus_setter, set_focus_to(Eq(session1))).Times(1);
3365+ EXPECT_CALL(focus_setter, set_focus_to(Eq(session2))).Times(1);
3366+ EXPECT_CALL(focus_setter, set_focus_to(Eq(session3))).Times(1);
3367 }
3368
3369 session_manager.focus_next();
3370@@ -77,28 +82,31 @@
3371 TEST(TestSessionManagerAndFocusSelectionStrategy, closing_applications_transfers_focus)
3372 {
3373 using namespace ::testing;
3374+
3375 mtd::MockSurfaceFactory surface_factory;
3376- std::shared_ptr<msh::DefaultSessionContainer> model(new msh::DefaultSessionContainer());
3377- msh::RegistrationOrderFocusSequence sequence(model);
3378- mtd::MockFocusSetter focus_changer;
3379+ std::shared_ptr<msh::DefaultSessionContainer> container(new msh::DefaultSessionContainer());
3380+ msh::RegistrationOrderFocusSequence sequence(container);
3381+ mtd::MockFocusSetter focus_setter;
3382 std::shared_ptr<mf::Session> new_session;
3383+ mtd::StubInputTargetListener input_target_listener;
3384
3385 msh::SessionManager session_manager(
3386- mt::fake_shared(surface_factory),
3387- model,
3388- mt::fake_shared(sequence),
3389- mt::fake_shared(focus_changer));
3390-
3391- EXPECT_CALL(focus_changer, set_focus_to(_)).Times(3);
3392-
3393- auto session1 = session_manager.open_session("Visual Basic Studio");
3394- auto session2 = session_manager.open_session("Microsoft Access");
3395- auto session3 = session_manager.open_session("WordPerfect");
3396+ mt::fake_shared(surface_factory),
3397+ container,
3398+ mt::fake_shared(sequence),
3399+ mt::fake_shared(focus_setter),
3400+ mt::fake_shared(input_target_listener));
3401+
3402+ EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3);
3403+
3404+ auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>());
3405+ auto session2 = session_manager.open_session("Microsoft Access", std::shared_ptr<me::EventSink>());
3406+ auto session3 = session_manager.open_session("WordPerfect", std::shared_ptr<me::EventSink>());
3407
3408 {
3409 InSequence seq;
3410- EXPECT_CALL(focus_changer, set_focus_to(Eq(session2))).Times(1);
3411- EXPECT_CALL(focus_changer, set_focus_to(Eq(session1))).Times(1);
3412+ EXPECT_CALL(focus_setter, set_focus_to(Eq(session2))).Times(1);
3413+ EXPECT_CALL(focus_setter, set_focus_to(Eq(session1))).Times(1);
3414 }
3415
3416 session_manager.close_session(session3);
3417
3418=== modified file 'tests/mir_test_framework/testing_server_options.cpp'
3419--- tests/mir_test_framework/testing_server_options.cpp 2013-04-22 03:24:56 +0000
3420+++ tests/mir_test_framework/testing_server_options.cpp 2013-04-23 12:15:34 +0000
3421@@ -29,7 +29,7 @@
3422 #include "mir/compositor/graphic_buffer_allocator.h"
3423 #include "mir/input/input_channel.h"
3424 #include "mir/input/input_manager.h"
3425-#include "mir/shell/input_focus_selector.h"
3426+#include "mir/input/null_input_target_listener.h"
3427 #include "src/server/input/android/android_input_manager.h"
3428 #include "src/server/input/android/android_dispatcher_controller.h"
3429
3430@@ -159,14 +159,6 @@
3431 }
3432 };
3433
3434-class StubInputFocusSelector : public msh::InputFocusSelector
3435-{
3436-public:
3437- void set_input_focus_to(std::shared_ptr<mi::SessionTarget> const& /* session */, std::shared_ptr<mi::SurfaceTarget> const& /* surface */)
3438- {
3439- }
3440-};
3441-
3442 }
3443
3444 mtf::TestingServerConfiguration::TestingServerConfiguration() :
3445@@ -184,14 +176,14 @@
3446 return std::make_shared<StubInputManager>();
3447 }
3448
3449-std::shared_ptr<msh::InputFocusSelector> mtf::TestingServerConfiguration::the_input_focus_selector()
3450+std::shared_ptr<msh::InputTargetListener> mtf::TestingServerConfiguration::the_input_target_listener()
3451 {
3452 auto options = the_options();
3453
3454 if (options->get("tests-use-real-input", false))
3455 return std::make_shared<mia::DispatcherController>(the_input_configuration());
3456 else
3457- return std::make_shared<StubInputFocusSelector>();
3458+ return std::make_shared<mi::NullInputTargetListener>();
3459 }
3460
3461 std::shared_ptr<mg::Platform> mtf::TestingServerConfiguration::the_graphics_platform()
3462
3463=== modified file 'tests/unit-tests/CMakeLists.txt'
3464--- tests/unit-tests/CMakeLists.txt 2013-04-10 02:48:51 +0000
3465+++ tests/unit-tests/CMakeLists.txt 2013-04-23 12:15:34 +0000
3466@@ -20,8 +20,12 @@
3467 add_subdirectory(android_input/)
3468 add_subdirectory(surfaces/)
3469 add_subdirectory(draw/)
3470+<<<<<<< TREE
3471 add_subdirectory(event/)
3472
3473+=======
3474+
3475+>>>>>>> MERGE-SOURCE
3476 add_executable(unit-tests ${UNIT_TEST_SOURCES})
3477 uses_android_input(unit-tests)
3478
3479
3480=== modified file 'tests/unit-tests/frontend/CMakeLists.txt'
3481--- tests/unit-tests/frontend/CMakeLists.txt 2013-04-11 03:54:01 +0000
3482+++ tests/unit-tests/frontend/CMakeLists.txt 2013-04-23 12:15:34 +0000
3483@@ -6,6 +6,7 @@
3484 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_reports_errors.cpp
3485 ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_cache.cpp
3486 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator.cpp
3487+ ${CMAKE_CURRENT_SOURCE_DIR}/test_event_pipe.cpp
3488 )
3489
3490 # TODO this test is a mess - something better is needed.
3491
3492=== renamed file 'tests/unit-tests/event/test_event_queue.cpp' => 'tests/unit-tests/frontend/test_event_pipe.cpp'
3493--- tests/unit-tests/event/test_event_queue.cpp 2013-04-22 03:37:28 +0000
3494+++ tests/unit-tests/frontend/test_event_pipe.cpp 2013-04-23 12:15:34 +0000
3495@@ -1,3 +1,4 @@
3496+<<<<<<< TREE
3497 /*
3498 * Copyright © 2013 Canonical Ltd.
3499 *
3500@@ -111,3 +112,121 @@
3501 EXPECT_EQ(mir_event_type_key, b->last_event_handled().type);
3502 EXPECT_EQ(mir_event_type_motion, a->last_event_handled().type);
3503 }
3504+=======
3505+/*
3506+ * Copyright © 2013 Canonical Ltd.
3507+ *
3508+ * This program is free software: you can redistribute it and/or modify
3509+ * it under the terms of the GNU General Public License version 3 as
3510+ * published by the Free Software Foundation.
3511+ *
3512+ * This program is distributed in the hope that it will be useful,
3513+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3514+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3515+ * GNU General Public License for more details.
3516+ *
3517+ * You should have received a copy of the GNU General Public License
3518+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3519+ *
3520+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
3521+ */
3522+
3523+#include "src/server/frontend/event_pipe.h"
3524+#include <cstring>
3525+
3526+#include <gtest/gtest.h>
3527+
3528+using mir::frontend::EventPipe;
3529+
3530+
3531+TEST(EventPipe, no_sink)
3532+{
3533+ EventPipe q;
3534+ MirEvent e;
3535+
3536+ e.type = mir_event_type_key;
3537+ q.handle_event(e);
3538+
3539+ e.type = mir_event_type_motion;
3540+ q.handle_event(e);
3541+
3542+ e.type = mir_event_type_surface;
3543+ q.handle_event(e);
3544+}
3545+
3546+namespace
3547+{
3548+ class TestSink : public mir::events::EventSink
3549+ {
3550+ public:
3551+ TestSink()
3552+ {
3553+ memset(&last_event, 0, sizeof last_event);
3554+ }
3555+
3556+ void handle_event(MirEvent const& e)
3557+ {
3558+ last_event = e;
3559+ }
3560+
3561+ MirEvent const& last_event_handled() const
3562+ {
3563+ return last_event;
3564+ }
3565+
3566+ private:
3567+ MirEvent last_event;
3568+ };
3569+}
3570+
3571+TEST(EventPipe, events_get_handled)
3572+{
3573+ EventPipe q;
3574+ std::shared_ptr<TestSink> s(new TestSink);
3575+
3576+ q.set_target(s);
3577+
3578+ MirEvent e;
3579+ memset(&e, 0, sizeof e);
3580+
3581+ e.type = mir_event_type_key;
3582+ q.handle_event(e);
3583+ EXPECT_EQ(mir_event_type_key, s->last_event_handled().type);
3584+
3585+ e.type = mir_event_type_motion;
3586+ q.handle_event(e);
3587+ EXPECT_EQ(mir_event_type_motion, s->last_event_handled().type);
3588+
3589+ e.type = mir_event_type_surface;
3590+ q.handle_event(e);
3591+ EXPECT_EQ(mir_event_type_surface, s->last_event_handled().type);
3592+}
3593+
3594+TEST(EventPipe, sink_is_changeable)
3595+{
3596+ EventPipe q;
3597+ std::shared_ptr<TestSink> a(new TestSink);
3598+ std::shared_ptr<TestSink> b(new TestSink);
3599+
3600+ q.set_target(a);
3601+
3602+ MirEvent e;
3603+ memset(&e, 0, sizeof e);
3604+
3605+ e.type = mir_event_type_motion;
3606+ q.handle_event(e);
3607+ EXPECT_EQ(mir_event_type_motion, a->last_event_handled().type);
3608+
3609+ q.set_target(b);
3610+
3611+ e.type = mir_event_type_surface;
3612+ q.handle_event(e);
3613+ EXPECT_EQ(mir_event_type_surface, b->last_event_handled().type);
3614+ EXPECT_EQ(mir_event_type_motion, a->last_event_handled().type);
3615+
3616+ e.type = mir_event_type_key;
3617+ q.handle_event(e);
3618+ EXPECT_EQ(mir_event_type_key, b->last_event_handled().type);
3619+ EXPECT_EQ(mir_event_type_motion, a->last_event_handled().type);
3620+}
3621+>>>>>>> MERGE-SOURCE
3622
3623=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
3624--- tests/unit-tests/frontend/test_session_mediator.cpp 2013-04-19 08:03:57 +0000
3625+++ tests/unit-tests/frontend/test_session_mediator.cpp 2013-04-23 12:15:34 +0000
3626@@ -34,7 +34,11 @@
3627 #include "mir_test_doubles/stub_session.h"
3628 #include "mir_test_doubles/stub_surface_builder.h"
3629 #include "mir_test/fake_shared.h"
3630+<<<<<<< TREE
3631 #include "mir/event_queue.h"
3632+=======
3633+#include "mir/events/event_sink.h"
3634+>>>>>>> MERGE-SOURCE
3635 #include "mir/shell/surface.h"
3636
3637 #include <gtest/gtest.h>
3638@@ -129,7 +133,11 @@
3639 }
3640 };
3641
3642-}
3643+class NullEventSink : public mir::events::EventSink
3644+{
3645+public:
3646+ void handle_event(MirEvent const& ) override {}
3647+};
3648
3649 struct SessionMediatorTest : public ::testing::Test
3650 {
3651@@ -141,15 +149,21 @@
3652 report{std::make_shared<mf::NullSessionMediatorReport>()},
3653 resource_cache{std::make_shared<mf::ResourceCache>()},
3654 mediator{shell, graphics_platform, graphics_display,
3655+<<<<<<< TREE
3656 buffer_allocator, report,
3657 std::make_shared<mir::EventQueue>(),
3658 resource_cache},
3659+=======
3660+ buffer_allocator, report,
3661+ std::make_shared<NullEventSink>(),
3662+ resource_cache},
3663+>>>>>>> MERGE-SOURCE
3664 stubbed_session{std::make_shared<StubbedSession>()},
3665 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
3666 {
3667 using namespace ::testing;
3668
3669- ON_CALL(*shell, open_session(_)).WillByDefault(Return(stubbed_session));
3670+ ON_CALL(*shell, open_session(_, _)).WillByDefault(Return(stubbed_session));
3671 ON_CALL(*shell, create_surface_for(_, _)).WillByDefault(Return(mf::SurfaceId{1}));
3672 }
3673
3674@@ -164,7 +178,7 @@
3675
3676 std::unique_ptr<google::protobuf::Closure> null_callback;
3677 };
3678-
3679+}
3680
3681 TEST_F(SessionMediatorTest, disconnect_releases_session)
3682 {
3683
3684=== modified file 'tests/unit-tests/frontend/test_session_mediator_android.cpp'
3685--- tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-04-22 03:35:08 +0000
3686+++ tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-04-23 12:15:34 +0000
3687@@ -31,8 +31,13 @@
3688 #include "mir_test_doubles/mock_session.h"
3689 #include "mir_test_doubles/stub_shell.h"
3690
3691+<<<<<<< TREE
3692 #include "mir/event_queue.h"
3693
3694+=======
3695+#include "mir/event_sink.h"
3696+
3697+>>>>>>> MERGE-SOURCE
3698 #include <gtest/gtest.h>
3699
3700 #include <stdexcept>
3701@@ -87,7 +92,11 @@
3702 }
3703 };
3704
3705-}
3706+class NullEventSink : public mir::EventSink
3707+{
3708+public:
3709+ void handle_event(MirEvent const& ) override {}
3710+};
3711
3712 struct SessionMediatorAndroidTest : public ::testing::Test
3713 {
3714@@ -99,9 +108,15 @@
3715 report{std::make_shared<mf::NullSessionMediatorReport>()},
3716 resource_cache{std::make_shared<mf::ResourceCache>()},
3717 mediator{shell, graphics_platform, graphics_display,
3718+<<<<<<< TREE
3719 buffer_allocator, report,
3720 std::make_shared<mir::EventQueue>(),
3721 resource_cache},
3722+=======
3723+ buffer_allocator, report,
3724+ std::make_shared<NullEventSink>(),
3725+ resource_cache},
3726+>>>>>>> MERGE-SOURCE
3727 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
3728 {
3729 }
3730@@ -117,6 +132,8 @@
3731 std::unique_ptr<google::protobuf::Closure> null_callback;
3732 };
3733
3734+}
3735+
3736 TEST_F(SessionMediatorAndroidTest, drm_auth_magic_throws)
3737 {
3738 mp::ConnectParameters connect_parameters;
3739
3740=== modified file 'tests/unit-tests/frontend/test_session_mediator_gbm.cpp'
3741--- tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-04-19 08:03:57 +0000
3742+++ tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-04-23 12:15:34 +0000
3743@@ -27,7 +27,11 @@
3744 #include "mir/graphics/drm_authenticator.h"
3745 #include "mir/graphics/platform.h"
3746 #include "mir/graphics/platform_ipc_package.h"
3747+<<<<<<< TREE
3748 #include "mir/event_queue.h"
3749+=======
3750+#include "mir/events/event_sink.h"
3751+>>>>>>> MERGE-SOURCE
3752
3753 #include <boost/exception/errinfo_errno.hpp>
3754 #include <boost/throw_exception.hpp>
3755@@ -91,7 +95,11 @@
3756 MOCK_METHOD1(drm_auth_magic, void(drm_magic_t));
3757 };
3758
3759-}
3760+class NullEventSink : public mir::events::EventSink
3761+{
3762+public:
3763+ void handle_event(MirEvent const& ) override {}
3764+};
3765
3766 struct SessionMediatorGBMTest : public ::testing::Test
3767 {
3768@@ -103,9 +111,15 @@
3769 report{std::make_shared<mf::NullSessionMediatorReport>()},
3770 resource_cache{std::make_shared<mf::ResourceCache>()},
3771 mediator{shell, mock_platform, graphics_display,
3772+<<<<<<< TREE
3773 buffer_allocator, report,
3774 std::make_shared<mir::EventQueue>(),
3775 resource_cache},
3776+=======
3777+ buffer_allocator, report,
3778+ std::make_shared<NullEventSink>(),
3779+ resource_cache},
3780+>>>>>>> MERGE-SOURCE
3781 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
3782 {
3783 }
3784@@ -121,6 +135,8 @@
3785 std::unique_ptr<google::protobuf::Closure> null_callback;
3786 };
3787
3788+}
3789+
3790 TEST_F(SessionMediatorGBMTest, drm_auth_magic_uses_drm_authenticator)
3791 {
3792 mp::ConnectParameters connect_parameters;
3793
3794=== modified file 'tests/unit-tests/input/android/test_android_dispatcher_controller.cpp'
3795--- tests/unit-tests/input/android/test_android_dispatcher_controller.cpp 2013-04-15 14:39:18 +0000
3796+++ tests/unit-tests/input/android/test_android_dispatcher_controller.cpp 2013-04-23 12:15:34 +0000
3797@@ -2,15 +2,15 @@
3798 * Copyright © 2013 Canonical Ltd.
3799 *
3800 * This program is free software: you can redistribute it and/or modify it
3801- * under the terms of the GNU Lesser General Public License version 3,
3802+ * under the terms of the GNU General Public License version 3,
3803 * as published by the Free Software Foundation.
3804 *
3805 * This program is distributed in the hope that it will be useful,
3806 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3807 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3808- * GNU Lesser General Public License for more details.
3809+ * GNU General Public License for more details.
3810 *
3811- * You should have received a copy of the GNU Lesser General Public License
3812+ * You should have received a copy of the GNU General Public License
3813 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3814 *
3815 * Authored by: Robert Carr <robert.carr@canonical.com>
3816@@ -31,6 +31,8 @@
3817 #include <sys/types.h>
3818 #include <sys/socket.h>
3819
3820+#include <stdexcept>
3821+
3822 namespace mi = mir::input;
3823 namespace mia = mi::android;
3824 namespace mt = mir::test;
3825@@ -47,12 +49,16 @@
3826 void SetUp() override
3827 {
3828 test_input_fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
3829+
3830+ dispatcher = new mtd::MockInputDispatcher();
3831 }
3832 void TearDown() override
3833 {
3834 close(test_input_fd);
3835 }
3836 int test_input_fd;
3837+ droidinput::sp<mtd::MockInputDispatcher> dispatcher;
3838+ mtd::MockInputConfiguration config;
3839 };
3840
3841 static bool
3842@@ -104,30 +110,151 @@
3843
3844 }
3845
3846-TEST_F(AndroidDispatcherControllerFdSetup, set_input_focus)
3847-{
3848- using namespace ::testing;
3849-
3850- auto dispatcher = new mtd::MockInputDispatcher(); // We need droidinput::sp
3851- mtd::MockInputConfiguration config;
3852- EXPECT_CALL(config, the_dispatcher()).Times(1)
3853- .WillOnce(Return(dispatcher));
3854-
3855- auto session = std::make_shared<mtd::StubSessionTarget>();
3856- auto surface = std::make_shared<mtd::StubSurfaceTarget>(test_input_fd);
3857+TEST_F(AndroidDispatcherControllerFdSetup, input_application_opened_behavior)
3858+{
3859+ using namespace ::testing;
3860+
3861+ EXPECT_CALL(config, the_dispatcher()).Times(1)
3862+ .WillOnce(Return(dispatcher));
3863+ mia::DispatcherController controller(mt::fake_shared(config));
3864+
3865+ auto session = std::make_shared<mtd::StubSessionTarget>();
3866+ controller.input_application_opened(session);
3867+ EXPECT_THROW({
3868+ // An application can not be opened twice!
3869+ controller.input_application_opened(session);
3870+ }, std::logic_error);
3871+}
3872+
3873+TEST_F(AndroidDispatcherControllerFdSetup, input_application_closed_behavior)
3874+{
3875+ using namespace ::testing;
3876+
3877+ EXPECT_CALL(config, the_dispatcher()).Times(1)
3878+ .WillOnce(Return(dispatcher));
3879+ mia::DispatcherController controller(mt::fake_shared(config));
3880+
3881+ auto session = std::make_shared<mtd::StubSessionTarget>();
3882+ EXPECT_THROW({
3883+ // We can't close an application which is not open
3884+ controller.input_application_closed(session);
3885+ }, std::logic_error);
3886+ controller.input_application_opened(session);
3887+ controller.input_application_closed(session);
3888+ EXPECT_THROW({
3889+ // Nor can we close an application twice
3890+ controller.input_application_closed(session);
3891+ }, std::logic_error);
3892+}
3893+
3894+TEST_F(AndroidDispatcherControllerFdSetup, input_surface_opened_behavior)
3895+{
3896+ using namespace ::testing;
3897+
3898+ auto session = std::make_shared<mtd::StubSessionTarget>();
3899+ auto surface = std::make_shared<mtd::StubSurfaceTarget>(test_input_fd);
3900+
3901+ EXPECT_CALL(config, the_dispatcher()).Times(1)
3902+ .WillOnce(Return(dispatcher));
3903+ EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(session, surface), false)).Times(1)
3904+ .WillOnce(Return(droidinput::OK));
3905+
3906+ mia::DispatcherController controller(mt::fake_shared(config));
3907+
3908+ EXPECT_THROW({
3909+ // We can't open a surface with an unopened session!
3910+ controller.input_surface_opened(session, surface);
3911+ }, std::logic_error);
3912+ controller.input_application_opened(session);
3913+ controller.input_surface_opened(session, surface);
3914+ EXPECT_THROW({
3915+ // We can't open a surface twice
3916+ controller.input_surface_opened(session, surface);
3917+ }, std::logic_error);
3918+}
3919+
3920+TEST_F(AndroidDispatcherControllerFdSetup, input_surface_closed_behavior)
3921+{
3922+ using namespace ::testing;
3923+
3924+ auto session = std::make_shared<mtd::StubSessionTarget>();
3925+ auto surface = std::make_shared<mtd::StubSurfaceTarget>(test_input_fd);
3926+
3927+ EXPECT_CALL(config, the_dispatcher()).Times(1)
3928+ .WillOnce(Return(dispatcher));
3929+ EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(session, surface), false)).Times(1)
3930+ .WillOnce(Return(droidinput::OK));
3931+ EXPECT_CALL(*dispatcher, unregisterInputChannel(_)).Times(1);
3932+ mia::DispatcherController controller(mt::fake_shared(config));
3933+
3934+ controller.input_application_opened(session);
3935+
3936+ EXPECT_THROW({
3937+ // We can't close a surface which hasn't been opened
3938+ controller.input_surface_closed(surface);
3939+ }, std::logic_error);
3940+ controller.input_surface_opened(session, surface);
3941+ controller.input_surface_closed(surface);
3942+ EXPECT_THROW({
3943+ // Nor can we close a surface twice
3944+ controller.input_surface_closed(surface);
3945+ }, std::logic_error);
3946+}
3947+
3948+TEST_F(AndroidDispatcherControllerFdSetup, on_focus_cleared)
3949+{
3950+ using namespace ::testing;
3951+
3952+ EXPECT_CALL(config, the_dispatcher()).Times(1)
3953+ .WillOnce(Return(dispatcher));
3954+
3955+ EXPECT_CALL(*dispatcher, setFocusedApplication(droidinput::sp<droidinput::InputApplicationHandle>(0))).Times(1);
3956+ EXPECT_CALL(*dispatcher, setInputWindows(EmptyVector())).Times(1);
3957+
3958+ mia::DispatcherController controller(mt::fake_shared(config));
3959+
3960+ controller.focus_cleared();
3961+}
3962+
3963+TEST_F(AndroidDispatcherControllerFdSetup, on_focus_changed)
3964+{
3965+ using namespace ::testing;
3966+
3967+ auto session = std::make_shared<mtd::StubSessionTarget>();
3968+ auto surface = std::make_shared<mtd::StubSurfaceTarget>(test_input_fd);
3969+
3970+ EXPECT_CALL(config, the_dispatcher()).Times(1)
3971+ .WillOnce(Return(dispatcher));
3972+ EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(session, surface), false)).Times(1)
3973+ .WillOnce(Return(droidinput::OK));
3974
3975 {
3976 InSequence seq;
3977 EXPECT_CALL(*dispatcher, setFocusedApplication(ApplicationHandleFor(session))).Times(1);
3978- EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(session, surface), false)).Times(1)
3979- .WillOnce(Return(droidinput::OK));
3980 EXPECT_CALL(*dispatcher, setInputWindows(VectorContainingWindowHandleFor(session, surface))).Times(1);
3981- EXPECT_CALL(*dispatcher, unregisterInputChannel(_)).Times(1);
3982- EXPECT_CALL(*dispatcher, setInputWindows(EmptyVector())).Times(1);
3983 }
3984
3985 mia::DispatcherController controller(mt::fake_shared(config));
3986-
3987- controller.set_input_focus_to(session, surface);
3988- controller.set_input_focus_to(session, std::shared_ptr<mi::SurfaceTarget>());
3989+
3990+ controller.input_application_opened(session);
3991+ controller.input_surface_opened(session, surface);
3992+
3993+ controller.focus_changed(surface);
3994+}
3995+
3996+TEST_F(AndroidDispatcherControllerFdSetup, on_focus_changed_throw_behavior)
3997+{
3998+ using namespace ::testing;
3999+
4000+ EXPECT_CALL(config, the_dispatcher()).Times(1)
4001+ .WillOnce(Return(dispatcher));
4002+
4003+ auto surface = std::make_shared<mtd::StubSurfaceTarget>(test_input_fd);
4004+
4005+ mia::DispatcherController controller(mt::fake_shared(config));
4006+
4007+ EXPECT_THROW({
4008+ // We can't focus surfaces which never opened
4009+ controller.focus_changed(surface);
4010+ }, std::logic_error);
4011 }
4012
4013=== modified file 'tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp'
4014--- tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp 2013-03-26 05:28:14 +0000
4015+++ tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp 2013-04-23 12:15:34 +0000
4016@@ -37,7 +37,7 @@
4017 using namespace ::testing;
4018 droidinput::KeyEvent ev;
4019 mtd::MockEventFilter filter;
4020- mia::EventFilterDispatcherPolicy policy(mt::fake_shared(filter));
4021+ mia::EventFilterDispatcherPolicy policy(mt::fake_shared(filter), true);
4022 uint32_t policy_flags;
4023
4024 EXPECT_CALL(filter, handles(_)).Times(1).WillOnce(Return(false));
4025
4026=== modified file 'tests/unit-tests/shell/test_application_session.cpp'
4027--- tests/unit-tests/shell/test_application_session.cpp 2013-04-22 03:24:56 +0000
4028+++ tests/unit-tests/shell/test_application_session.cpp 2013-04-23 12:15:34 +0000
4029@@ -22,6 +22,7 @@
4030 #include "mir_test/fake_shared.h"
4031 #include "mir_test_doubles/mock_surface_factory.h"
4032 #include "mir_test_doubles/mock_surface.h"
4033+#include "mir_test_doubles/stub_input_target_listener.h"
4034 #include "mir_test_doubles/stub_surface_builder.h"
4035 #include "mir_test_doubles/stub_surface.h"
4036
4037@@ -31,6 +32,7 @@
4038 #include <gtest/gtest.h>
4039
4040 namespace mc = mir::compositor;
4041+namespace me = mir::events;
4042 namespace mf = mir::frontend;
4043 namespace msh = mir::shell;
4044 namespace ms = mir::surfaces;
4045@@ -46,12 +48,13 @@
4046 auto const mock_surface = std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder));
4047
4048 mtd::MockSurfaceFactory surface_factory;
4049- ON_CALL(surface_factory, create_surface(_)).WillByDefault(Return(mock_surface));
4050+ ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(Return(mock_surface));
4051
4052- EXPECT_CALL(surface_factory, create_surface(_));
4053+ EXPECT_CALL(surface_factory, create_surface(_, _, _));
4054 EXPECT_CALL(*mock_surface, destroy());
4055
4056- msh::ApplicationSession session(mt::fake_shared(surface_factory), "Foo");
4057+ mtd::StubInputTargetListener input_listener;
4058+ msh::ApplicationSession session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo", std::shared_ptr<me::EventSink>());
4059
4060 mf::SurfaceCreationParameters params;
4061 auto surf = session.create_surface(params);
4062@@ -67,15 +70,16 @@
4063 mtd::StubSurfaceBuilder surface_builder;
4064 {
4065 InSequence seq;
4066- EXPECT_CALL(surface_factory, create_surface(_)).Times(1)
4067- .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder))));
4068- EXPECT_CALL(surface_factory, create_surface(_)).Times(1)
4069- .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder))));
4070- EXPECT_CALL(surface_factory, create_surface(_)).Times(1)
4071+ EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1)
4072+ .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder))));
4073+ EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1)
4074+ .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder))));
4075+ EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1)
4076 .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder))));
4077 }
4078
4079- msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo");
4080+ mtd::StubInputTargetListener input_listener;
4081+ msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo", std::shared_ptr<me::EventSink>());
4082
4083 mf::SurfaceCreationParameters params;
4084 auto id1 = app_session.create_surface(params);
4085@@ -103,11 +107,12 @@
4086 auto const mock_surface = std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder));
4087
4088 mtd::MockSurfaceFactory surface_factory;
4089- ON_CALL(surface_factory, create_surface(_)).WillByDefault(Return(mock_surface));
4090-
4091- msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo");
4092-
4093- EXPECT_CALL(surface_factory, create_surface(_));
4094+ ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(Return(mock_surface));
4095+
4096+ mtd::StubInputTargetListener input_listener;
4097+ msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo", std::shared_ptr<me::EventSink>());
4098+
4099+ EXPECT_CALL(surface_factory, create_surface(_, _, _));
4100
4101 {
4102 InSequence seq;
4103@@ -130,7 +135,8 @@
4104 using namespace ::testing;
4105
4106 mtd::MockSurfaceFactory surface_factory;
4107- msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo");
4108+ mtd::StubInputTargetListener input_listener;
4109+ msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo", std::shared_ptr<me::EventSink>());
4110 mf::SurfaceId invalid_surface_id(1);
4111
4112 EXPECT_THROW({
4113@@ -143,7 +149,8 @@
4114 using namespace ::testing;
4115
4116 mtd::MockSurfaceFactory surface_factory;
4117- msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo");
4118+ mtd::StubInputTargetListener input_listener;
4119+ msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo", std::shared_ptr<me::EventSink>());
4120 mf::SurfaceId invalid_surface_id(1);
4121
4122 EXPECT_THROW({
4123
4124=== modified file 'tests/unit-tests/shell/test_organising_surface_factory.cpp'
4125--- tests/unit-tests/shell/test_organising_surface_factory.cpp 2013-04-02 05:58:55 +0000
4126+++ tests/unit-tests/shell/test_organising_surface_factory.cpp 2013-04-23 12:15:34 +0000
4127@@ -25,6 +25,7 @@
4128 #include <gtest/gtest.h>
4129 #include <gmock/gmock.h>
4130
4131+namespace me = mir::events;
4132 namespace mf = mir::frontend;
4133 namespace msh = mir::shell;
4134 namespace geom = mir::geometry;
4135@@ -45,7 +46,7 @@
4136 using namespace ::testing;
4137
4138 underlying_surface_factory = std::make_shared<mtd::MockSurfaceFactory>();
4139- ON_CALL(*underlying_surface_factory, create_surface(_)).WillByDefault(Return(null_surface));
4140+ ON_CALL(*underlying_surface_factory, create_surface(_, _, _)).WillByDefault(Return(null_surface));
4141
4142 placement_strategy = std::make_shared<MockPlacementStrategy>();
4143 }
4144@@ -62,13 +63,13 @@
4145
4146 msh::OrganisingSurfaceFactory factory(underlying_surface_factory, placement_strategy);
4147
4148- EXPECT_CALL(*underlying_surface_factory, create_surface(_)).Times(1);
4149+ EXPECT_CALL(*underlying_surface_factory, create_surface(_, _, _)).Times(1);
4150
4151 auto params = mf::a_surface();
4152 EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1)
4153 .WillOnce(Return(mf::a_surface()));
4154
4155- factory.create_surface(params);
4156+ factory.create_surface(params, mf::SurfaceId(), std::shared_ptr<me::EventSink>());
4157 }
4158
4159 TEST_F(OrganisingSurfaceFactorySetup, forwards_create_surface_parameters_from_placement_strategy_to_underlying_factory)
4160@@ -83,8 +84,8 @@
4161
4162 EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1)
4163 .WillOnce(Return(placed_params));
4164- EXPECT_CALL(*underlying_surface_factory, create_surface(placed_params));
4165+ EXPECT_CALL(*underlying_surface_factory, create_surface(placed_params, mf::SurfaceId(), std::shared_ptr<me::EventSink>()));
4166
4167- factory.create_surface(params);
4168+ factory.create_surface(params, mf::SurfaceId(), std::shared_ptr<me::EventSink>());
4169 }
4170
4171
4172=== modified file 'tests/unit-tests/shell/test_registration_order_focus_sequence.cpp'
4173--- tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-04-19 03:20:05 +0000
4174+++ tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-04-23 12:15:34 +0000
4175@@ -22,17 +22,22 @@
4176 #include "mir/shell/registration_order_focus_sequence.h"
4177 #include "mir/frontend/surface_creation_parameters.h"
4178 #include "mir/surfaces/surface.h"
4179+
4180 #include "mir_test_doubles/mock_buffer_bundle.h"
4181 #include "mir_test_doubles/mock_surface_factory.h"
4182+#include "mir_test_doubles/stub_input_target_listener.h"
4183+#include "mir_test/fake_shared.h"
4184
4185 #include <gmock/gmock.h>
4186 #include <gtest/gtest.h>
4187 #include <string>
4188
4189 namespace mc = mir::compositor;
4190+namespace me = mir::events;
4191 namespace msh = mir::shell;
4192 namespace ms = mir::surfaces;
4193-namespace mtd = mir::test::doubles;
4194+namespace mt = mir::test;
4195+namespace mtd = mt::doubles;
4196
4197 namespace
4198 {
4199@@ -45,6 +50,7 @@
4200 }
4201 std::shared_ptr<mtd::MockSurfaceFactory> factory;
4202 std::shared_ptr<msh::DefaultSessionContainer> container;
4203+ mtd::StubInputTargetListener input_listener;
4204
4205 static std::string const testing_app_name1;
4206 static std::string const testing_app_name2;
4207@@ -60,9 +66,9 @@
4208 {
4209 using namespace ::testing;
4210
4211- auto app1 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name1);
4212- auto app2 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name2);
4213- auto app3 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name3);
4214+ auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>());
4215+ auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2, std::shared_ptr<me::EventSink>());
4216+ auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3, std::shared_ptr<me::EventSink>());
4217
4218 container->insert_session(app1);
4219 container->insert_session(app2);
4220@@ -78,9 +84,9 @@
4221 {
4222 using namespace ::testing;
4223
4224- auto app1 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name1);
4225- auto app2 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name2);
4226- auto app3 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name3);
4227+ auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>());
4228+ auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2, std::shared_ptr<me::EventSink>());
4229+ auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3, std::shared_ptr<me::EventSink>());
4230 container->insert_session(app1);
4231 container->insert_session(app2);
4232 container->insert_session(app3);
4233@@ -95,7 +101,7 @@
4234 {
4235 using namespace ::testing;
4236
4237- auto app1 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name1);
4238+ auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>());
4239 container->insert_session(app1);
4240
4241 msh::RegistrationOrderFocusSequence focus_sequence(container);
4242@@ -107,8 +113,8 @@
4243 {
4244 using namespace ::testing;
4245
4246- auto app1 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name1);
4247- auto app2 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name2);
4248+ auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>());
4249+ auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2, std::shared_ptr<me::EventSink>());
4250 auto null_session = std::shared_ptr<msh::ApplicationSession>();
4251
4252 msh::RegistrationOrderFocusSequence focus_sequence(container);
4253@@ -124,7 +130,7 @@
4254 {
4255 using namespace ::testing;
4256
4257- auto invalid_session = std::make_shared<msh::ApplicationSession>(factory, testing_app_name1);
4258+ auto invalid_session = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1, std::shared_ptr<me::EventSink>());
4259 auto null_session = std::shared_ptr<msh::ApplicationSession>();
4260
4261 msh::RegistrationOrderFocusSequence focus_sequence(container);
4262
4263=== modified file 'tests/unit-tests/shell/test_session_manager.cpp'
4264--- tests/unit-tests/shell/test_session_manager.cpp 2013-04-19 03:20:05 +0000
4265+++ tests/unit-tests/shell/test_session_manager.cpp 2013-04-23 12:15:34 +0000
4266@@ -21,15 +21,19 @@
4267 #include "mir/shell/session_manager.h"
4268 #include "mir/shell/default_session_container.h"
4269 #include "mir/shell/session.h"
4270+#include "mir/shell/input_target_listener.h"
4271 #include "mir/frontend/surface_creation_parameters.h"
4272 #include "mir/surfaces/surface.h"
4273 #include "mir/input/input_channel.h"
4274+
4275+#include "mir_test/fake_shared.h"
4276 #include "mir_test_doubles/mock_buffer_bundle.h"
4277-#include "mir_test/fake_shared.h"
4278 #include "mir_test_doubles/mock_surface_factory.h"
4279 #include "mir_test_doubles/mock_focus_setter.h"
4280 #include "mir_test_doubles/null_buffer_bundle.h"
4281 #include "mir_test_doubles/stub_surface_builder.h"
4282+#include "mir_test_doubles/stub_input_target_listener.h"
4283+#include "mir_test_doubles/mock_input_target_listener.h"
4284
4285 #include "mir/shell/surface.h"
4286
4287@@ -37,6 +41,7 @@
4288 #include <gtest/gtest.h>
4289
4290 namespace mc = mir::compositor;
4291+namespace me = mir::events;
4292 namespace mf = mir::frontend;
4293 namespace msh = mir::shell;
4294 namespace ms = mir::surfaces;
4295@@ -56,7 +61,7 @@
4296 ~MockSessionContainer() noexcept {}
4297 };
4298
4299-struct MockFocusSequence: public msh::FocusSequence
4300+struct MockFocusSequence : public msh::FocusSequence
4301 {
4302 MOCK_CONST_METHOD1(successor_of, std::shared_ptr<msh::Session>(std::shared_ptr<msh::Session> const&));
4303 MOCK_CONST_METHOD1(predecessor_of, std::shared_ptr<msh::Session>(std::shared_ptr<msh::Session> const&));
4304@@ -68,16 +73,18 @@
4305 SessionManagerSetup()
4306 : session_manager(mt::fake_shared(surface_factory),
4307 mt::fake_shared(container),
4308- mt::fake_shared(sequence),
4309- mt::fake_shared(focus_setter))
4310+ mt::fake_shared(focus_sequence),
4311+ mt::fake_shared(focus_setter),
4312+ mt::fake_shared(input_target_listener))
4313 {
4314 }
4315
4316 mtd::StubSurfaceBuilder surface_builder;
4317 mtd::MockSurfaceFactory surface_factory;
4318 testing::NiceMock<MockSessionContainer> container; // Inelegant but some tests need a stub
4319- MockFocusSequence sequence;
4320+ MockFocusSequence focus_sequence;
4321 testing::NiceMock<mtd::MockFocusSetter> focus_setter; // Inelegant but some tests need a stub
4322+ mtd::StubInputTargetListener input_target_listener;
4323
4324 msh::SessionManager session_manager;
4325 };
4326@@ -93,9 +100,9 @@
4327 EXPECT_CALL(focus_setter, set_focus_to(_));
4328 EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1);
4329
4330- EXPECT_CALL(sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>())));
4331+ EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>())));
4332
4333- auto session = session_manager.open_session("Visual Basic Studio");
4334+ auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>());
4335 session_manager.close_session(session);
4336 }
4337
4338@@ -103,14 +110,16 @@
4339 {
4340 using namespace ::testing;
4341
4342- EXPECT_CALL(surface_factory, create_surface(_)).Times(1);
4343+ EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1);
4344
4345 std::shared_ptr<mi::InputChannel> null_input_channel;
4346- ON_CALL(surface_factory, create_surface(_)).WillByDefault(
4347+ ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(
4348 Return(std::make_shared<msh::Surface>(
4349 mt::fake_shared(surface_builder),
4350 mf::a_surface(),
4351- null_input_channel)));
4352+ null_input_channel,
4353+ mf::SurfaceId(),
4354+ std::shared_ptr<me::EventSink>())));
4355
4356 EXPECT_CALL(container, insert_session(_)).Times(1);
4357 EXPECT_CALL(container, remove_session(_)).Times(1);
4358@@ -118,9 +127,9 @@
4359 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1);
4360 EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1);
4361
4362- EXPECT_CALL(sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>())));
4363+ EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>())));
4364
4365- auto session = session_manager.open_session("Visual Basic Studio");
4366+ auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>());
4367 session->create_surface(mf::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}}));
4368
4369 session_manager.close_session(session);
4370@@ -134,7 +143,7 @@
4371 EXPECT_CALL(container, insert_session(_)).Times(1);
4372 EXPECT_CALL(focus_setter, set_focus_to(_)).WillOnce(SaveArg<0>(&new_session));
4373
4374- auto session = session_manager.open_session("Visual Basic Studio");
4375+ auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>());
4376 EXPECT_EQ(session, new_session);
4377 }
4378
4379@@ -142,8 +151,8 @@
4380 {
4381 using namespace ::testing;
4382
4383- auto session1 = session_manager.open_session("Visual Basic Studio");
4384- auto session2 = session_manager.open_session("IntelliJ IDEA");
4385+ auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>());
4386+ auto session2 = session_manager.open_session("IntelliJ IDEA", std::shared_ptr<me::EventSink>());
4387
4388 session_manager.tag_session_with_lightdm_id(session1, 1);
4389
4390@@ -155,8 +164,8 @@
4391 {
4392 using namespace ::testing;
4393
4394- auto session1 = session_manager.open_session("Visual Basic Studio");
4395- auto session2 = session_manager.open_session("IntelliJ IDEA");
4396+ auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>());
4397+ auto session2 = session_manager.open_session("IntelliJ IDEA", std::shared_ptr<me::EventSink>());
4398
4399 auto shell_session1 = std::dynamic_pointer_cast<msh::Session>(session1);
4400 auto shell_session2 = std::dynamic_pointer_cast<msh::Session>(session2);
4401@@ -164,7 +173,7 @@
4402 session_manager.tag_session_with_lightdm_id(session1, 1);
4403 session_manager.focus_session_with_lightdm_id(1);
4404
4405- EXPECT_CALL(sequence, default_focus()).WillOnce(Return(shell_session2));
4406+ EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return(shell_session2));
4407 EXPECT_CALL(focus_setter, set_focus_to(Eq(shell_session2)));
4408
4409 session_manager.close_session(session1);
4410@@ -174,22 +183,85 @@
4411 {
4412 using namespace ::testing;
4413 std::shared_ptr<mi::InputChannel> null_input_channel;
4414- ON_CALL(surface_factory, create_surface(_)).WillByDefault(
4415+ ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(
4416 Return(std::make_shared<msh::Surface>(
4417 mt::fake_shared(surface_builder),
4418 mf::a_surface(),
4419- null_input_channel)));
4420+ null_input_channel,
4421+ mf::SurfaceId(),
4422+ std::shared_ptr<me::EventSink>())));
4423
4424 // Once for session creation and once for surface creation
4425 {
4426 InSequence seq;
4427
4428 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Session creation
4429- EXPECT_CALL(surface_factory, create_surface(_)).Times(1);
4430+ EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1);
4431 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation
4432 }
4433
4434- auto session1 = session_manager.open_session("Weather Report");
4435+ auto session1 = session_manager.open_session("Weather Report", std::shared_ptr<me::EventSink>());
4436 session_manager.create_surface_for(session1, mf::a_surface());
4437 }
4438
4439+namespace
4440+{
4441+
4442+struct SessionManagerInputTargetListenerSetup : public testing::Test
4443+{
4444+ SessionManagerInputTargetListenerSetup()
4445+ : session_manager(mt::fake_shared(surface_factory),
4446+ mt::fake_shared(container),
4447+ mt::fake_shared(focus_sequence),
4448+ mt::fake_shared(focus_setter),
4449+ mt::fake_shared(input_target_listener))
4450+ {
4451+ }
4452+
4453+ mtd::StubSurfaceBuilder surface_builder;
4454+ mtd::MockSurfaceFactory surface_factory;
4455+ testing::NiceMock<MockSessionContainer> container; // Inelegant but some tests need a stub
4456+ testing::NiceMock<MockFocusSequence> focus_sequence;
4457+ testing::NiceMock<mtd::MockFocusSetter> focus_setter; // Inelegant but some tests need a stub
4458+ mtd::MockInputTargetListener input_target_listener;
4459+
4460+ msh::SessionManager session_manager;
4461+};
4462+
4463+}
4464+
4465+TEST_F(SessionManagerInputTargetListenerSetup, listener_is_notified_of_session_and_surfacelifecycle)
4466+{
4467+ using namespace ::testing;
4468+
4469+ std::shared_ptr<mi::InputChannel> null_input_channel;
4470+ ON_CALL(surface_factory, create_surface(_,_,_)).WillByDefault(
4471+ Return(std::make_shared<msh::Surface>(
4472+ mt::fake_shared(surface_builder),
4473+ mf::a_surface(),
4474+ null_input_channel,
4475+ mf::SurfaceId(),
4476+ std::shared_ptr<me::EventSink>())));
4477+ EXPECT_CALL(surface_factory, create_surface(_,_,_)).Times(1);
4478+
4479+ EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>())));
4480+ {
4481+ InSequence seq;
4482+
4483+ EXPECT_CALL(input_target_listener, input_application_opened(_))
4484+ .Times(1);
4485+ EXPECT_CALL(input_target_listener, input_surface_opened(_, _)).Times(1);
4486+ EXPECT_CALL(input_target_listener, focus_changed(_)).Times(1);
4487+ EXPECT_CALL(input_target_listener, input_surface_closed(_)).Times(1);
4488+ EXPECT_CALL(input_target_listener, input_application_closed(_))
4489+ .Times(1);
4490+ EXPECT_CALL(input_target_listener, focus_cleared()).Times(1);
4491+ }
4492+
4493+ {
4494+ auto session = session_manager.open_session("test", std::shared_ptr<me::EventSink>());
4495+ auto surf = session_manager.create_surface_for(session, mf::a_surface());
4496+ session->destroy_surface(surf);
4497+ session_manager.close_session(session);
4498+ }
4499+}
4500
4501=== modified file 'tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp'
4502--- tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-04-22 03:24:56 +0000
4503+++ tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-04-23 12:15:34 +0000
4504@@ -27,7 +27,6 @@
4505 #include "mir_test_doubles/mock_buffer_bundle.h"
4506 #include "mir_test/fake_shared.h"
4507 #include "mir_test_doubles/mock_surface_factory.h"
4508-#include "mir_test_doubles/mock_input_focus_selector.h"
4509 #include "mir_test_doubles/stub_surface.h"
4510 #include "mir_test_doubles/mock_surface.h"
4511 #include "mir_test_doubles/stub_surface_builder.h"
4512@@ -65,8 +64,6 @@
4513 {
4514 using namespace ::testing;
4515
4516- NiceMock<mtd::MockInputFocusSelector> input_focus_selector;
4517-
4518 NiceMock<MockShellSession> app1, app2, app3;
4519 msh::DefaultSessionContainer model;
4520
4521@@ -74,7 +71,7 @@
4522 ON_CALL(app2, default_surface()).WillByDefault(Return(std::shared_ptr<msh::Surface>()));
4523 ON_CALL(app3, default_surface()).WillByDefault(Return(std::shared_ptr<msh::Surface>()));
4524
4525- msh::SingleVisibilityFocusMechanism focus_mechanism(mt::fake_shared(model), mt::fake_shared(input_focus_selector));
4526+ msh::SingleVisibilityFocusMechanism focus_mechanism(mt::fake_shared(model));
4527
4528 EXPECT_CALL(app1, show()).Times(1);
4529 EXPECT_CALL(app2, hide()).Times(1);
4530@@ -90,23 +87,3 @@
4531
4532 focus_mechanism.set_focus_to(mt::fake_shared(app1));
4533 }
4534-
4535-TEST(SingleVisibilityFocusMechanism, mechanism_sets_input_focus_from_default_surface)
4536-{
4537- using namespace ::testing;
4538-
4539- mtd::MockInputFocusSelector input_focus_selector;
4540- msh::DefaultSessionContainer model;
4541- auto session = std::make_shared<NiceMock<MockShellSession>>();
4542- auto surface = std::make_shared<mtd::MockSurface>(std::make_shared<mtd::StubSurfaceBuilder>());
4543-
4544- msh::SingleVisibilityFocusMechanism focus_mechanism(mt::fake_shared(model), mt::fake_shared(input_focus_selector));
4545-
4546- EXPECT_CALL(*session, default_surface()).Times(1).WillOnce(Return(surface));
4547-
4548- EXPECT_CALL(input_focus_selector, set_input_focus_to(Eq(session), Eq(surface))).Times(1);
4549-
4550- model.insert_session(session);
4551- focus_mechanism.set_focus_to(session);
4552-}
4553-
4554
4555=== modified file 'tests/unit-tests/shell/test_surface.cpp'
4556--- tests/unit-tests/shell/test_surface.cpp 2013-04-19 03:20:05 +0000
4557+++ tests/unit-tests/shell/test_surface.cpp 2013-04-23 12:15:34 +0000
4558@@ -33,6 +33,7 @@
4559 #include <gmock/gmock.h>
4560 #include <gtest/gtest.h>
4561
4562+namespace me = mir::events;
4563 namespace ms = mir::surfaces;
4564 namespace msh = mir::shell;
4565 namespace mf = mir::frontend;
4566@@ -137,7 +138,9 @@
4567 msh::Surface test(
4568 mt::fake_shared(surface_builder),
4569 params,
4570- null_input_channel);
4571+ null_input_channel,
4572+ mf::SurfaceId(),
4573+ std::shared_ptr<me::EventSink>());
4574 }
4575
4576 TEST_F(ShellSurface, creation_throws_means_no_destroy)
4577@@ -156,7 +159,9 @@
4578 msh::Surface test(
4579 mt::fake_shared(surface_builder),
4580 params,
4581- null_input_channel);
4582+ null_input_channel,
4583+ mf::SurfaceId(),
4584+ std::shared_ptr<me::EventSink>());
4585 }, std::runtime_error);
4586 }
4587
4588@@ -172,7 +177,9 @@
4589 msh::Surface test(
4590 mt::fake_shared(surface_builder),
4591 mf::a_surface(),
4592- null_input_channel);
4593+ null_input_channel,
4594+ mf::SurfaceId(),
4595+ std::shared_ptr<me::EventSink>());
4596
4597 Mock::VerifyAndClearExpectations(&test);
4598 EXPECT_CALL(surface_builder, destroy_surface(_)).Times(1);
4599@@ -189,7 +196,9 @@
4600 msh::Surface test(
4601 mt::fake_shared(surface_builder),
4602 mf::a_surface(),
4603- null_input_channel);
4604+ null_input_channel,
4605+ mf::SurfaceId(),
4606+ std::shared_ptr<me::EventSink>());
4607
4608 EXPECT_NO_THROW({
4609 test.client_buffer();
4610@@ -207,7 +216,9 @@
4611 msh::Surface test(
4612 mt::fake_shared(surface_builder),
4613 mf::a_surface(),
4614- null_input_channel);
4615+ null_input_channel,
4616+ mf::SurfaceId(),
4617+ std::shared_ptr<me::EventSink>());
4618
4619 EXPECT_NO_THROW({
4620 test.size();
4621@@ -225,7 +236,9 @@
4622 msh::Surface test(
4623 mt::fake_shared(surface_builder),
4624 mf::a_surface(),
4625- null_input_channel);
4626+ null_input_channel,
4627+ mf::SurfaceId(),
4628+ std::shared_ptr<me::EventSink>());
4629
4630 EXPECT_NO_THROW({
4631 test.name();
4632@@ -243,7 +256,9 @@
4633 msh::Surface test(
4634 mt::fake_shared(surface_builder),
4635 mf::a_surface(),
4636- null_input_channel);
4637+ null_input_channel,
4638+ mf::SurfaceId(),
4639+ std::shared_ptr<me::EventSink>());
4640
4641 EXPECT_NO_THROW({
4642 test.pixel_format();
4643@@ -261,7 +276,9 @@
4644 msh::Surface test(
4645 mt::fake_shared(surface_builder),
4646 mf::a_surface(),
4647- null_input_channel);
4648+ null_input_channel,
4649+ mf::SurfaceId(),
4650+ std::shared_ptr<me::EventSink>());
4651
4652 EXPECT_NO_THROW({
4653 test.hide();
4654@@ -279,7 +296,9 @@
4655 msh::Surface test(
4656 mt::fake_shared(surface_builder),
4657 mf::a_surface(),
4658- null_input_channel);
4659+ null_input_channel,
4660+ mf::SurfaceId(),
4661+ std::shared_ptr<me::EventSink>());
4662
4663 EXPECT_NO_THROW({
4664 test.show();
4665@@ -297,7 +316,9 @@
4666 msh::Surface test(
4667 mt::fake_shared(surface_builder),
4668 mf::a_surface(),
4669- null_input_channel);
4670+ null_input_channel,
4671+ mf::SurfaceId(),
4672+ std::shared_ptr<me::EventSink>());
4673
4674 EXPECT_NO_THROW({
4675 test.destroy();
4676@@ -315,7 +336,9 @@
4677 msh::Surface test(
4678 mt::fake_shared(surface_builder),
4679 mf::a_surface(),
4680- null_input_channel);
4681+ null_input_channel,
4682+ mf::SurfaceId(),
4683+ std::shared_ptr<me::EventSink>());
4684
4685 EXPECT_NO_THROW({
4686 test.force_requests_to_complete();
4687@@ -333,7 +356,9 @@
4688 msh::Surface test(
4689 mt::fake_shared(surface_builder),
4690 mf::a_surface(),
4691- null_input_channel);
4692+ null_input_channel,
4693+ mf::SurfaceId(),
4694+ std::shared_ptr<me::EventSink>());
4695
4696 EXPECT_NO_THROW({
4697 test.advance_client_buffer();
4698@@ -352,8 +377,19 @@
4699 const int testing_client_fd = 17;
4700
4701 MockInputChannel mock_package;
4702- msh::Surface proxy_surface(mt::fake_shared(surface_builder), mf::a_surface(), null_input_channel);
4703- msh::Surface input_proxy_surface(mt::fake_shared(surface_builder), mf::a_surface(), mt::fake_shared(mock_package));
4704+ msh::Surface proxy_surface(
4705+ mt::fake_shared(surface_builder),
4706+ mf::a_surface(),
4707+ null_input_channel,
4708+ mf::SurfaceId(),
4709+ std::shared_ptr<me::EventSink>());
4710+
4711+ msh::Surface input_proxy_surface(
4712+ mt::fake_shared(surface_builder),
4713+ mf::a_surface(),
4714+ mt::fake_shared(mock_package),
4715+ mf::SurfaceId(),
4716+ std::shared_ptr<me::EventSink>());
4717
4718 EXPECT_CALL(mock_package, client_fd()).Times(1).WillOnce(Return(testing_client_fd));
4719
4720@@ -374,7 +410,9 @@
4721 msh::Surface surf(
4722 mt::fake_shared(surface_builder),
4723 mf::a_surface(),
4724- null_input_channel);
4725+ null_input_channel,
4726+ mf::SurfaceId(),
4727+ std::shared_ptr<me::EventSink>());
4728
4729 EXPECT_THROW({
4730 surf.configure(static_cast<MirSurfaceAttrib>(111), 222);
4731@@ -388,7 +426,9 @@
4732 msh::Surface surf(
4733 mt::fake_shared(surface_builder),
4734 mf::a_surface(),
4735- null_input_channel);
4736+ null_input_channel,
4737+ mf::SurfaceId(),
4738+ std::shared_ptr<me::EventSink>());
4739
4740 EXPECT_EQ(mir_surface_type_normal, surf.type());
4741
4742@@ -415,6 +455,7 @@
4743 mir_surface_type_freestyle));
4744 EXPECT_EQ(mir_surface_type_freestyle, surf.type());
4745 }
4746+<<<<<<< TREE
4747
4748 TEST_F(ShellSurface, states)
4749 {
4750@@ -450,3 +491,43 @@
4751 mir_surface_state_fullscreen));
4752 EXPECT_EQ(mir_surface_state_fullscreen, surf.state());
4753 }
4754+=======
4755+
4756+TEST_F(ShellSurface, states)
4757+{
4758+ using namespace testing;
4759+
4760+ msh::Surface surf(
4761+ mt::fake_shared(surface_builder),
4762+ mf::a_surface(),
4763+ null_input_channel,
4764+ mf::SurfaceId(),
4765+ std::shared_ptr<me::EventSink>());
4766+
4767+ EXPECT_EQ(mir_surface_state_restored, surf.state());
4768+
4769+ EXPECT_EQ(mir_surface_state_vertmaximized,
4770+ surf.configure(mir_surface_attrib_state,
4771+ mir_surface_state_vertmaximized));
4772+ EXPECT_EQ(mir_surface_state_vertmaximized, surf.state());
4773+
4774+ EXPECT_THROW({
4775+ surf.configure(mir_surface_attrib_state, 999);
4776+ }, std::logic_error);
4777+ EXPECT_THROW({
4778+ surf.configure(mir_surface_attrib_state, -1);
4779+ }, std::logic_error);
4780+ EXPECT_EQ(mir_surface_state_vertmaximized, surf.state());
4781+
4782+ EXPECT_EQ(mir_surface_state_minimized,
4783+ surf.configure(mir_surface_attrib_state,
4784+ mir_surface_state_minimized));
4785+ EXPECT_EQ(mir_surface_state_minimized, surf.state());
4786+
4787+ EXPECT_EQ(mir_surface_state_fullscreen,
4788+ surf.configure(mir_surface_attrib_state,
4789+ mir_surface_state_fullscreen));
4790+ EXPECT_EQ(mir_surface_state_fullscreen, surf.state());
4791+}
4792+
4793+>>>>>>> MERGE-SOURCE
4794
4795=== modified file 'tests/unit-tests/shell/test_the_session_container_implementation.cpp'
4796--- tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-04-19 03:20:05 +0000
4797+++ tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-04-23 12:15:34 +0000
4798@@ -22,12 +22,14 @@
4799 #include "mir/frontend/surface_creation_parameters.h"
4800 #include "mir/surfaces/surface.h"
4801 #include "mir_test_doubles/mock_buffer_bundle.h"
4802+#include "mir_test_doubles/stub_input_target_listener.h"
4803 #include "mir_test_doubles/mock_surface_factory.h"
4804
4805 #include <gmock/gmock.h>
4806 #include <gtest/gtest.h>
4807 #include <string>
4808
4809+namespace me = mir::events;
4810 namespace mf = mir::frontend;
4811 namespace msh = mir::shell;
4812 namespace mtd = mir::test::doubles;
4813@@ -38,8 +40,8 @@
4814 auto factory = std::make_shared<mtd::MockSurfaceFactory>();
4815 msh::DefaultSessionContainer container;
4816
4817- container.insert_session(std::make_shared<msh::ApplicationSession>(factory, "Visual Studio 7"));
4818- container.insert_session(std::make_shared<msh::ApplicationSession>(factory, "Visual Studio 8"));
4819+ container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), "Visual Studio 7", std::shared_ptr<me::EventSink>()));
4820+ container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), "Visual Studio 8", std::shared_ptr<me::EventSink>()));
4821
4822 struct local
4823 {
4824@@ -64,8 +66,11 @@
4825 auto factory = std::make_shared<mtd::MockSurfaceFactory>();
4826 msh::DefaultSessionContainer container;
4827
4828- auto session = std::make_shared<msh::ApplicationSession>(factory,
4829- "Visual Studio 7");
4830+ auto session = std::make_shared<msh::ApplicationSession>(
4831+ factory,
4832+ std::make_shared<mtd::StubInputTargetListener>(),
4833+ "Visual Studio 7",
4834+ std::shared_ptr<me::EventSink>());
4835 EXPECT_THROW({
4836 container.remove_session(session);
4837 }, std::logic_error);
4838
4839=== modified file 'tools/setup-partial-armhf-chroot.sh'
4840--- tools/setup-partial-armhf-chroot.sh 2013-04-17 02:49:53 +0000
4841+++ tools/setup-partial-armhf-chroot.sh 2013-04-23 12:15:34 +0000
4842@@ -7,7 +7,7 @@
4843 exit
4844 fi
4845
4846-echo "creating phablet-compatible quantal armhf partial chroot for mir compiles in directory ${1}"
4847+echo "creating phablet-compatible raring armhf partial chroot for mir compiles in directory ${1}"
4848
4849 if [ ! -d ${1} ]; then
4850 mkdir -p ${1}
4851@@ -37,6 +37,10 @@
4852 libboost-program-options1.49.0
4853 libhybris
4854 libhybris-dev
4855+ libgflags2
4856+ libgflags-dev
4857+ libgoogle-glog-dev
4858+ libgoogle-glog0
4859 libicu48
4860 libprotobuf7
4861 libprotobuf-dev
4862@@ -75,29 +79,6 @@
4863 dpkg -x ${PACKAGE_FILENAME} .
4864 done
4865
4866- #glog is only available in raring for armhf. we download the raring sources and
4867- #install them manually for this quantal script
4868- if [ ! -f libgoogle-glog0_0.3.2-4ubuntu1_armhf.deb ]; then
4869- wget "https://launchpad.net/ubuntu/+archive/primary/+files/libgoogle-glog0_0.3.2-4ubuntu1_armhf.deb"
4870- fi
4871-
4872- if [ ! -f libgflags2_2.0-1_armhf.deb ]; then
4873- wget "https://launchpad.net/ubuntu/+archive/primary/+files/libgflags2_2.0-1_armhf.deb"
4874- fi
4875-
4876- if [ ! -f libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb ]; then
4877- wget "http://launchpadlibrarian.net/134086853/libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb"
4878- fi
4879-
4880- if [ ! -f libgflags-dev_2.0-1_armhf.deb ]; then
4881- wget "http://launchpadlibrarian.net/106868249/libgflags-dev_2.0-1_armhf.deb"
4882- fi
4883-
4884- dpkg -x libgflags-dev_2.0-1_armhf.deb .
4885- dpkg -x libgflags2_2.0-1_armhf.deb .
4886- dpkg -x libgoogle-glog0_0.3.2-4ubuntu1_armhf.deb .
4887- dpkg -x libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb .
4888-
4889 #todo: we get egl/gles headers from the mesa packages, but should be pointing at the hybris libraries
4890 #just rewrite the symlinks for now
4891 rm ./usr/lib/arm-linux-gnueabihf/libEGL.so

Subscribers

People subscribed via source and target branches