Mir

Merge lp:~robertcarr/mir/send-input-to-clients into lp:~mir-team/mir/trunk

Proposed by Robert Carr
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 531
Proposed branch: lp:~robertcarr/mir/send-input-to-clients
Merge into: lp:~mir-team/mir/trunk
Diff against target: 2428 lines (+1326/-123)
59 files modified
examples/render_surfaces.cpp (+5/-1)
include/server/mir/default_server_configuration.h (+2/-0)
include/server/mir/input/input_manager.h (+8/-1)
include/server/mir/input/session_target.h (+45/-0)
include/server/mir/input/surface_target.h (+50/-0)
include/server/mir/shell/application_session.h (+4/-2)
include/server/mir/shell/focus_setter.h (+3/-6)
include/server/mir/shell/input_focus_selector.h (+52/-0)
include/server/mir/shell/session.h (+63/-0)
include/server/mir/shell/session_container.h (+3/-3)
include/server/mir/shell/single_visibility_focus_mechanism.h (+6/-7)
include/test/mir_test/wait_condition.h (+4/-0)
include/test/mir_test_doubles/mock_focus_setter.h (+1/-1)
include/test/mir_test_doubles/mock_input_focus_selector.h (+40/-0)
include/test/mir_test_doubles/mock_input_manager.h (+1/-0)
include/test/mir_test_doubles/mock_surface.h (+6/-0)
include/test/mir_test_doubles/stub_session_target.h (+44/-0)
include/test/mir_test_doubles/stub_surface_target.h (+59/-0)
include/test/mir_test_framework/testing_server_configuration.h (+1/-0)
src/server/default_server_configuration.cpp (+7/-2)
src/server/input/android/CMakeLists.txt (+2/-0)
src/server/input/android/android_input_application_handle.cpp (+42/-0)
src/server/input/android/android_input_application_handle.h (+58/-0)
src/server/input/android/android_input_manager.cpp (+28/-1)
src/server/input/android/android_input_manager.h (+7/-0)
src/server/input/android/android_input_window_handle.cpp (+74/-0)
src/server/input/android/android_input_window_handle.h (+59/-0)
src/server/input/android/default_android_input_configuration.cpp (+2/-0)
src/server/input/android/event_filter_dispatcher_policy.cpp (+1/-1)
src/server/input/dummy_input_manager.cpp (+3/-0)
src/server/shell/application_session.cpp (+8/-0)
src/server/shell/registration_order_focus_sequence.cpp (+1/-1)
src/server/shell/session_container.cpp (+1/-2)
src/server/shell/session_manager.cpp (+5/-3)
src/server/shell/single_visibility_focus_mechanism.cpp (+12/-4)
src/server/shell/surface.cpp (+19/-0)
src/server/shell/surface.h (+8/-1)
tests/acceptance-tests/CMakeLists.txt (+1/-1)
tests/acceptance-tests/test_focus_selection.cpp (+78/-25)
tests/behavior-tests/session_management_context.cpp (+1/-1)
tests/integration-tests/CMakeLists.txt (+1/-0)
tests/integration-tests/cucumber/test_session_management_context.cpp (+3/-19)
tests/integration-tests/frontend/CMakeLists.txt (+0/-1)
tests/integration-tests/input/android/test_android_input_manager.cpp (+118/-0)
tests/integration-tests/shell/CMakeLists.txt (+9/-0)
tests/integration-tests/shell/test_session_manager.cpp (+13/-21)
tests/mir_test_doubles/fake_event_hub.cpp (+3/-2)
tests/mir_test_framework/testing_server_options.cpp (+5/-0)
tests/unit-tests/input/android/CMakeLists.txt (+2/-0)
tests/unit-tests/input/android/test_android_input_application_handle.cpp (+58/-0)
tests/unit-tests/input/android/test_android_input_manager.cpp (+94/-2)
tests/unit-tests/input/android/test_android_input_window_handle.cpp (+89/-0)
tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp (+3/-1)
tests/unit-tests/shell/test_application_session.cpp (+36/-0)
tests/unit-tests/shell/test_registration_order_focus_sequence.cpp (+1/-1)
tests/unit-tests/shell/test_session_manager.cpp (+7/-6)
tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp (+51/-6)
tests/unit-tests/shell/test_surface.cpp (+18/-0)
tests/unit-tests/shell/test_the_session_container_implementation.cpp (+1/-1)
To merge this branch: bzr merge lp:~robertcarr/mir/send-input-to-clients
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
Review via email: mp+154221@code.launchpad.net

Commit message

Send input to clients through interfacing the InputManager and SessionManager

Description of the change

Send input to clients through interfacing the InputManager and SessionManager.

Two driving tests:
(acceptance )BespokeDisplayServerTestFixture.sessions_creating_surface_receive_focus

This test ensures the shell passes off focused surfaces to input by selecting the input focus. This is done through passing the InputFocusSelector (InputManager) to the SingleVisibilityFocusMechanism.

(integration) AndroidInputManagerDispatcherInterceptSetup.server_input_fd_of_focused_surface_is_sent_unfiltered_key_events

This test tests at the integration level that the reader policy, dispatcher, and dispatcher policy properly dispatch input to clients.

(unit) AndroidInputManagerFdSetup.set_input_focus is also a good entry point.

This tests that the focus is set correctly on the dispatcher.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

50 + virtual std::string name() const = 0;
51 +
...
59 + virtual int server_input_fd() const = 0;

These are not used by frontend. Therefore they don't belong on the frontend::Surface interface.

In principle, input should be defining interfaces that describe its own requirements. It should not injecting requirements into another part of the system nor relying on accidental similarity to what is needed elsewhere.

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

Also, FocusSelector should be defined in shell::, not in input::, since it's only used by shell::SingleVisibilityFocusMechanism

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

1. Moved focus selector
2. Defined mi::SurfaceTarget and mi::SessionTarget and use them for the interface. It's a little tricky as the focus mechanism, session container, etc...want to work in terms of msh::Session but create/close session, etc want to deal in terms of mf::Session...I couldn't find a clear structuring to make this work besides the dynamic_cast in SessionManager::set_focus_to...looking for improvements but I think some of it may be beyond the scope of this branch. At least these interfaces protect the input from continued session/shell changes.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

79 + virtual void set_input_focus_to(std::shared_ptr<input::SessionTarget> const& session,
80 + std::shared_ptr<input::SurfaceTarget> const& surface) = 0;

A signature like this makes me wonder what should happen if session and surface are not associated. (Or if there is a requirement that surface belongs to session why both need to be supplied.)

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

122 +
123 + virtual std::string name() = 0;

surely this can be const?

~~~~

529 +#include <gtest/gtest.h>

Not needed

~~~~

922 -
923 +

Adding pointless whitespace.

~~~~

1531 === modified file 'tests/integration-tests/frontend/test_session_manager.cpp'

This really ought to be

tests/integration-tests/*shell*/test_session_manager.cpp

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

This might cause a cascade of fixes - if so, it belongs to another cleanup MP...

121 + virtual ~SessionTarget() {}

Shouldn't that be virtual "~SessionTarget() = default" (there is a semantic difference - the latter is noexcept).

Revision history for this message
Robert Carr (robertcarr) wrote :

>> surely this can be const?
r557

>>529 +#include <gtest/gtest.h>
>>
>>Not needed
r558!

>> 922 -
>> 923 +

r559

>>This really ought to be

>>tests/integration-tests/*shell*/test_session_manager.cpp
r560

>> This might cause a cascade of fixes - if so, it belongs to another cleanup MP...

It does cause a cascade so lets fix it next.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Concerns addressed - but has merge conflicts.

Abstaining so to avoid blocking

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

LGTM

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

Looks good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Dammit. My copy of trunk needed updating

Revision history for this message
Robert Carr (robertcarr) wrote :

Merged trunk.

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

We should not be using the system clock - our own timesource can be mocked to facilitate testing of time dependent scenarios.

But that can be fixed later. Let's land the rest.

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

> We should not be using the system clock - our own timesource can be mocked to
> facilitate testing of time dependent scenarios.
>

And

991 +// mInfo->touchableRegion = touchable_region;
...
998 +// mInfo->layer = props.layer;

Comments shouldn't contain code

Revision history for this message
Robert Carr (robertcarr) wrote :

Fixed the comments

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/render_surfaces.cpp'
--- examples/render_surfaces.cpp 2013-03-21 03:32:59 +0000
+++ examples/render_surfaces.cpp 2013-03-22 17:46:22 +0000
@@ -47,9 +47,9 @@
47namespace mc = mir::compositor;47namespace mc = mir::compositor;
48namespace ms = mir::surfaces;48namespace ms = mir::surfaces;
49namespace mf = mir::frontend;49namespace mf = mir::frontend;
50namespace mi = mir::input;
50namespace geom = mir::geometry;51namespace geom = mir::geometry;
51namespace mt = mir::tools;52namespace mt = mir::tools;
52namespace mi = mir::input;
5353
54namespace54namespace
55{55{
@@ -194,6 +194,10 @@
194 {194 {
195 return std::shared_ptr<mi::InputChannel>();195 return std::shared_ptr<mi::InputChannel>();
196 }196 }
197 void set_input_focus_to(std::shared_ptr<mi::SessionTarget> const& /* session */,
198 std::shared_ptr<mi::SurfaceTarget> const& /* surface */)
199 {
200 }
197};201};
198202
199class RenderSurfacesCompositingStrategy : public mc::DefaultCompositingStrategy203class RenderSurfacesCompositingStrategy : public mc::DefaultCompositingStrategy
200204
=== modified file 'include/server/mir/default_server_configuration.h'
--- include/server/mir/default_server_configuration.h 2013-03-22 03:33:00 +0000
+++ include/server/mir/default_server_configuration.h 2013-03-22 17:46:22 +0000
@@ -52,6 +52,7 @@
52class SurfaceFactory;52class SurfaceFactory;
53class SurfaceSource;53class SurfaceSource;
54class SurfaceBuilder;54class SurfaceBuilder;
55class InputFocusSelector;
55}56}
56namespace surfaces57namespace surfaces
57{58{
@@ -113,6 +114,7 @@
113114
114 virtual std::initializer_list<std::shared_ptr<input::EventFilter> const> the_event_filters();115 virtual std::initializer_list<std::shared_ptr<input::EventFilter> const> the_event_filters();
115 virtual std::shared_ptr<input::InputManager> the_input_manager();116 virtual std::shared_ptr<input::InputManager> the_input_manager();
117 virtual std::shared_ptr<shell::InputFocusSelector> the_input_focus_selector();
116118
117 virtual std::shared_ptr<shell::SurfaceBuilder> the_surface_builder();119 virtual std::shared_ptr<shell::SurfaceBuilder> the_surface_builder();
118120
119121
=== modified file 'include/server/mir/input/input_manager.h'
--- include/server/mir/input/input_manager.h 2013-03-21 03:32:59 +0000
+++ include/server/mir/input/input_manager.h 2013-03-22 17:46:22 +0000
@@ -21,6 +21,7 @@
21#define MIR_INPUT_INPUT_MANAGER_H_21#define MIR_INPUT_INPUT_MANAGER_H_
2222
23#include "mir/input/input_channel_factory.h"23#include "mir/input/input_channel_factory.h"
24#include "mir/shell/input_focus_selector.h"
2425
25#include <memory>26#include <memory>
2627
@@ -30,12 +31,15 @@
30{31{
31class ViewableArea;32class ViewableArea;
32}33}
34
33namespace input35namespace input
34{36{
35class EventFilter;37class EventFilter;
36class InputChannel;38class InputChannel;
39class SessionTarget;
40class SurfaceTarget;
3741
38class InputManager : public InputChannelFactory42class InputManager : public InputChannelFactory, public shell::InputFocusSelector
39{43{
40public:44public:
41 virtual void start() = 0;45 virtual void start() = 0;
@@ -43,6 +47,9 @@
43 47
44 virtual std::shared_ptr<InputChannel> make_input_channel() = 0;48 virtual std::shared_ptr<InputChannel> make_input_channel() = 0;
4549
50 virtual void set_input_focus_to(std::shared_ptr<input::SessionTarget> const& session,
51 std::shared_ptr<input::SurfaceTarget> const& surface) = 0;
52
46protected:53protected:
47 InputManager() {};54 InputManager() {};
48 virtual ~InputManager() {}55 virtual ~InputManager() {}
4956
=== added file 'include/server/mir/input/session_target.h'
--- include/server/mir/input/session_target.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/input/session_target.h 2013-03-22 17:46:22 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_INPUT_SESSION_TARGET_H_
20#define MIR_INPUT_SESSION_TARGET_H_
21
22#include <string>
23
24namespace mir
25{
26namespace input
27{
28
29class SessionTarget
30{
31public:
32 virtual ~SessionTarget() {}
33
34 virtual std::string name() const = 0;
35
36protected:
37 SessionTarget() = default;
38 SessionTarget(SessionTarget const&) = delete;
39 SessionTarget& operator=(SessionTarget const&) = delete;
40};
41
42}
43} // namespace mir
44
45#endif // MIR_INPUT_SESSION_TARGET_H_
046
=== added file 'include/server/mir/input/surface_target.h'
--- include/server/mir/input/surface_target.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/input/surface_target.h 2013-03-22 17:46:22 +0000
@@ -0,0 +1,50 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_INPUT_SURFACE_TARGET_H_
20#define MIR_INPUT_SURFACE_TARGET_H_
21
22#include "mir/geometry/size.h"
23
24#include <string>
25
26namespace mir
27{
28namespace input
29{
30
31class SurfaceTarget
32{
33public:
34 virtual ~SurfaceTarget() {}
35
36 virtual geometry::Size size() const = 0;
37 virtual std::string name() const = 0;
38
39 virtual int server_input_fd() const = 0;
40
41protected:
42 SurfaceTarget() = default;
43 SurfaceTarget(SurfaceTarget const&) = delete;
44 SurfaceTarget& operator=(SurfaceTarget const&) = delete;
45};
46
47}
48} // namespace mir
49
50#endif // MIR_INPUT_SURFACE_TARGET_H_
051
=== modified file 'include/server/mir/shell/application_session.h'
--- include/server/mir/shell/application_session.h 2013-03-22 03:33:00 +0000
+++ include/server/mir/shell/application_session.h 2013-03-22 17:46:22 +0000
@@ -19,7 +19,7 @@
19#ifndef MIR_SHELL_APPLICATION_SESSION_H_19#ifndef MIR_SHELL_APPLICATION_SESSION_H_
20#define MIR_SHELL_APPLICATION_SESSION_H_20#define MIR_SHELL_APPLICATION_SESSION_H_
2121
22#include "mir/frontend/session.h"22#include "mir/shell/session.h"
2323
24#include <map>24#include <map>
2525
@@ -31,7 +31,7 @@
31class SurfaceFactory;31class SurfaceFactory;
32class Surface;32class Surface;
3333
34class ApplicationSession : public frontend::Session34class ApplicationSession : public Session
35{35{
36public:36public:
37 explicit ApplicationSession(std::shared_ptr<SurfaceFactory> const& surface_factory, std::string const& session_name);37 explicit ApplicationSession(std::shared_ptr<SurfaceFactory> const& surface_factory, std::string const& session_name);
@@ -41,6 +41,8 @@
41 void destroy_surface(frontend::SurfaceId surface);41 void destroy_surface(frontend::SurfaceId surface);
42 std::shared_ptr<frontend::Surface> get_surface(frontend::SurfaceId surface) const;42 std::shared_ptr<frontend::Surface> get_surface(frontend::SurfaceId surface) const;
4343
44 std::shared_ptr<Surface> default_surface() const;
45
44 std::string name() const;46 std::string name() const;
4547
46 void shutdown();48 void shutdown();
4749
=== modified file 'include/server/mir/shell/focus_setter.h'
--- include/server/mir/shell/focus_setter.h 2013-03-21 03:32:59 +0000
+++ include/server/mir/shell/focus_setter.h 2013-03-22 17:46:22 +0000
@@ -23,20 +23,17 @@
2323
24namespace mir24namespace mir
25{25{
26namespace frontend26
27namespace shell
27{28{
28class Session;29class Session;
29}
30
31namespace shell
32{
3330
34class FocusSetter31class FocusSetter
35{32{
36public:33public:
37 virtual ~FocusSetter() {}34 virtual ~FocusSetter() {}
3835
39 virtual void set_focus_to(std::shared_ptr<frontend::Session> const& new_focus) = 0;36 virtual void set_focus_to(std::shared_ptr<shell::Session> const& new_focus) = 0;
4037
41protected:38protected:
42 FocusSetter() = default;39 FocusSetter() = default;
4340
=== added file 'include/server/mir/shell/input_focus_selector.h'
--- include/server/mir/shell/input_focus_selector.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/shell/input_focus_selector.h 2013-03-22 17:46:22 +0000
@@ -0,0 +1,52 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_SHELL_INPUT_FOCUS_SELECTOR_H_
20#define MIR_SHELL_INPUT_FOCUS_SELECTOR_H_
21
22#include <memory>
23
24namespace mir
25{
26namespace input
27{
28class SessionTarget;
29class SurfaceTarget;
30}
31
32namespace shell
33{
34
35class InputFocusSelector
36{
37public:
38 virtual ~InputFocusSelector() {}
39
40 virtual void set_input_focus_to(std::shared_ptr<input::SessionTarget> const& focus_application,
41 std::shared_ptr<input::SurfaceTarget> const& focus_surface) = 0;
42
43protected:
44 InputFocusSelector() = default;
45 InputFocusSelector(InputFocusSelector const&) = delete;
46 InputFocusSelector& operator=(InputFocusSelector const&) = delete;
47};
48
49}
50} // namespace mir
51
52#endif // MIR_SHELL_INPUT_FOCUS_SELECTOR_H_
053
=== added file 'include/server/mir/shell/session.h'
--- include/server/mir/shell/session.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/shell/session.h 2013-03-22 17:46:22 +0000
@@ -0,0 +1,63 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored By: Robert Carr <racarr@canonical.com>
17 */
18
19#ifndef MIR_SHELL_SESSION_H_
20#define MIR_SHELL_SESSION_H_
21
22#include "mir/frontend/session.h"
23#include "mir/input/session_target.h"
24
25#include <mutex>
26#include <atomic>
27#include <memory>
28#include <string>
29
30namespace mir
31{
32
33namespace shell
34{
35class Surface;
36
37class Session : public frontend::Session, public input::SessionTarget
38{
39public:
40 virtual ~Session() {}
41
42 virtual frontend::SurfaceId create_surface(frontend::SurfaceCreationParameters const& params) = 0;
43 virtual void destroy_surface(frontend::SurfaceId surface) = 0;
44 virtual std::shared_ptr<frontend::Surface> get_surface(frontend::SurfaceId surface) const = 0;
45
46 virtual std::string name() const = 0;
47 virtual void shutdown() = 0;
48
49 virtual void hide() = 0;
50 virtual void show() = 0;
51
52 virtual std::shared_ptr<Surface> default_surface() const = 0;
53
54protected:
55 Session() = default;
56 Session(Session const&) = delete;
57 Session& operator=(Session const&) = delete;
58};
59
60}
61}
62
63#endif // MIR_SHELL_SESSION_H_
064
=== renamed file 'include/server/mir/frontend/session_container.h' => 'include/server/mir/shell/session_container.h'
--- include/server/mir/frontend/session_container.h 2013-03-21 03:32:59 +0000
+++ include/server/mir/shell/session_container.h 2013-03-22 17:46:22 +0000
@@ -16,8 +16,8 @@
16 * Authored by: Robert Carr <robert.carr@canonical.com>16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */17 */
1818
19#ifndef FRONTEND_SESSION_CONTAINER_H_19#ifndef MIR_SHELL_SESSION_CONTAINER_H_
20#define FRONTEND_SESSION_CONTAINER_H_20#define MIR_SHELL_SESSION_CONTAINER_H_
2121
22#include <vector>22#include <vector>
23#include <memory>23#include <memory>
@@ -56,4 +56,4 @@
56}56}
5757
5858
59#endif // FRONTEND_SESSION_CONTAINER_H_59#endif // MIR_SHELL_SESSION_CONTAINER_H_
6060
=== modified file 'include/server/mir/shell/single_visibility_focus_mechanism.h'
--- include/server/mir/shell/single_visibility_focus_mechanism.h 2013-03-21 03:32:59 +0000
+++ include/server/mir/shell/single_visibility_focus_mechanism.h 2013-03-22 17:46:22 +0000
@@ -24,28 +24,27 @@
2424
25namespace mir25namespace mir
26{26{
27namespace frontend
28{
29class Session;
30}
3127
32namespace shell28namespace shell
33{29{
34class SessionContainer;30class SessionContainer;
31class InputFocusSelector;
3532
36class SingleVisibilityFocusMechanism : public FocusSetter33class SingleVisibilityFocusMechanism : public FocusSetter
37{34{
38public:35public:
39 explicit SingleVisibilityFocusMechanism(std::shared_ptr<SessionContainer> const& app_container);36 explicit SingleVisibilityFocusMechanism(std::shared_ptr<SessionContainer> const& app_container,
37 std::shared_ptr<shell::InputFocusSelector> const& input_selector);
40 virtual ~SingleVisibilityFocusMechanism() {}38 virtual ~SingleVisibilityFocusMechanism() {}
4139
42 void set_focus_to(std::shared_ptr<frontend::Session> const& new_focus);40 void set_focus_to(std::shared_ptr<shell::Session> const& new_focus);
4341
44protected:42protected:
45 SingleVisibilityFocusMechanism(const SingleVisibilityFocusMechanism&) = delete;43 SingleVisibilityFocusMechanism(const SingleVisibilityFocusMechanism&) = delete;
46 SingleVisibilityFocusMechanism& operator=(const SingleVisibilityFocusMechanism&) = delete;44 SingleVisibilityFocusMechanism& operator=(const SingleVisibilityFocusMechanism&) = delete;
47private:45private:
48 std::shared_ptr<SessionContainer> app_container;46 std::shared_ptr<SessionContainer> const app_container;
47 std::shared_ptr<shell::InputFocusSelector> const input_selector;
49};48};
5049
51}50}
5251
=== modified file 'include/test/mir_test/wait_condition.h'
--- include/test/mir_test/wait_condition.h 2013-03-13 04:54:15 +0000
+++ include/test/mir_test/wait_condition.h 2013-03-22 17:46:22 +0000
@@ -55,6 +55,10 @@
55 wait_condition->wake_up_everyone();55 wait_condition->wake_up_everyone();
56 return false;56 return false;
57}57}
58ACTION_P(WakeUp, wait_condition)
59{
60 wait_condition->wake_up_everyone();
61}
58}62}
5963
60#endif // MIR_TEST_WAIT_CONDITION_H_64#endif // MIR_TEST_WAIT_CONDITION_H_
6165
=== modified file 'include/test/mir_test_doubles/mock_focus_setter.h'
--- include/test/mir_test_doubles/mock_focus_setter.h 2013-03-15 23:15:45 +0000
+++ include/test/mir_test_doubles/mock_focus_setter.h 2013-03-22 17:46:22 +0000
@@ -32,7 +32,7 @@
3232
33struct MockFocusSetter : public shell::FocusSetter33struct MockFocusSetter : public shell::FocusSetter
34{34{
35 MOCK_METHOD1(set_focus_to, void(std::shared_ptr<frontend::Session> const&));35 MOCK_METHOD1(set_focus_to, void(std::shared_ptr<shell::Session> const&));
36};36};
3737
38}38}
3939
=== added file 'include/test/mir_test_doubles/mock_input_focus_selector.h'
--- include/test/mir_test_doubles/mock_input_focus_selector.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/mock_input_focus_selector.h 2013-03-22 17:46:22 +0000
@@ -0,0 +1,40 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_INPUT_FOCUS_SELECTOR_H_
20#define MIR_TEST_DOUBLES_MOCK_INPUT_FOCUS_SELECTOR_H_
21
22#include "mir/shell/input_focus_selector.h"
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30
31struct MockInputFocusSelector : public shell::InputFocusSelector
32{
33 MOCK_METHOD2(set_input_focus_to, void(std::shared_ptr<input::SessionTarget> const&, std::shared_ptr<input::SurfaceTarget> const&));
34};
35
36}
37}
38} // namespace mir
39
40#endif // MIR_TEST_DOUBLES_MOCK_INPUT_FOCUS_SELECTOR_H_
041
=== modified file 'include/test/mir_test_doubles/mock_input_manager.h'
--- include/test/mir_test_doubles/mock_input_manager.h 2013-03-21 03:32:59 +0000
+++ include/test/mir_test_doubles/mock_input_manager.h 2013-03-22 17:46:22 +0000
@@ -37,6 +37,7 @@
37 MOCK_METHOD0(stop, void());37 MOCK_METHOD0(stop, void());
38 38
39 MOCK_METHOD0(make_input_channel, std::shared_ptr<input::InputChannel>());39 MOCK_METHOD0(make_input_channel, std::shared_ptr<input::InputChannel>());
40 MOCK_METHOD2(set_input_focus_to, void(std::shared_ptr<input::SessionTarget> const& session, std::shared_ptr<input::SurfaceTarget> const& surface));
40};41};
4142
42}43}
4344
=== modified file 'include/test/mir_test_doubles/mock_surface.h'
--- include/test/mir_test_doubles/mock_surface.h 2013-03-21 03:32:59 +0000
+++ include/test/mir_test_doubles/mock_surface.h 2013-03-22 17:46:22 +0000
@@ -21,6 +21,10 @@
2121
22#include "src/server/shell/surface.h"22#include "src/server/shell/surface.h"
2323
24#include "mir/frontend/surface_creation_parameters.h"
25
26#include <gmock/gmock.h>
27
24#include <memory>28#include <memory>
2529
26namespace mir30namespace mir
@@ -43,12 +47,14 @@
43 MOCK_METHOD0(shutdown, void());47 MOCK_METHOD0(shutdown, void());
44 MOCK_METHOD0(advance_client_buffer, void());48 MOCK_METHOD0(advance_client_buffer, void());
4549
50 MOCK_CONST_METHOD0(name, std::string ());
46 MOCK_CONST_METHOD0(size, geometry::Size ());51 MOCK_CONST_METHOD0(size, geometry::Size ());
47 MOCK_CONST_METHOD0(pixel_format, geometry::PixelFormat ());52 MOCK_CONST_METHOD0(pixel_format, geometry::PixelFormat ());
48 MOCK_CONST_METHOD0(client_buffer, std::shared_ptr<compositor::Buffer> ());53 MOCK_CONST_METHOD0(client_buffer, std::shared_ptr<compositor::Buffer> ());
49 54
50 MOCK_CONST_METHOD0(supports_input, bool());55 MOCK_CONST_METHOD0(supports_input, bool());
51 MOCK_CONST_METHOD0(client_input_fd, int());56 MOCK_CONST_METHOD0(client_input_fd, int());
57 MOCK_CONST_METHOD0(server_input_fd, int());
5258
53 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));59 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));
54};60};
5561
=== added file 'include/test/mir_test_doubles/stub_session_target.h'
--- include/test/mir_test_doubles/stub_session_target.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/stub_session_target.h 2013-03-22 17:46:22 +0000
@@ -0,0 +1,44 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_STUB_SESSION_TARGET_H_
20#define MIR_TEST_DOUBLES_STUB_SESSION_TARGET_H_
21
22#include "mir/input/session_target.h"
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30
31struct StubSessionTarget : public input::SessionTarget
32{
33 std::string name() const override
34 {
35 return std::string();
36 }
37};
38
39}
40}
41} // namespace mir
42
43#endif // MIR_TEST_DOUBLES_STUB_SESSION_TARGET_H_
44
045
=== added file 'include/test/mir_test_doubles/stub_surface_target.h'
--- include/test/mir_test_doubles/stub_surface_target.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/stub_surface_target.h 2013-03-22 17:46:22 +0000
@@ -0,0 +1,59 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_STUB_SURFACE_TARGET_H_
20#define MIR_TEST_DOUBLES_STUB_SURFACE_TARGET_H_
21
22#include "mir/input/surface_target.h"
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30
31struct StubSurfaceTarget : public input::SurfaceTarget
32{
33 StubSurfaceTarget(int fd)
34 : input_fd(fd)
35 {
36 }
37
38 int server_input_fd() const override
39 {
40 return input_fd;
41 }
42 geometry::Size size() const override
43 {
44 return geometry::Size();
45 }
46 std::string name() const override
47 {
48 return std::string();
49 }
50
51 int input_fd;
52};
53
54}
55}
56} // namespace mir
57
58#endif // MIR_TEST_DOUBLES_STUB_SURFACE_TARGET_H_
59
060
=== modified file 'include/test/mir_test_framework/testing_server_configuration.h'
--- include/test/mir_test_framework/testing_server_configuration.h 2013-03-13 04:54:15 +0000
+++ include/test/mir_test_framework/testing_server_configuration.h 2013-03-22 17:46:22 +0000
@@ -53,6 +53,7 @@
53 virtual std::string the_socket_file() const;53 virtual std::string the_socket_file() const;
54 using DefaultServerConfiguration::the_options;54 using DefaultServerConfiguration::the_options;
5555
56
56private:57private:
57 std::shared_ptr<graphics::Platform> graphics_platform;58 std::shared_ptr<graphics::Platform> graphics_platform;
58};59};
5960
=== modified file 'src/server/default_server_configuration.cpp'
--- src/server/default_server_configuration.cpp 2013-03-22 17:08:01 +0000
+++ src/server/default_server_configuration.cpp 2013-03-22 17:46:22 +0000
@@ -33,7 +33,7 @@
33#include "mir/shell/session_manager.h"33#include "mir/shell/session_manager.h"
34#include "mir/shell/registration_order_focus_sequence.h"34#include "mir/shell/registration_order_focus_sequence.h"
35#include "mir/shell/single_visibility_focus_mechanism.h"35#include "mir/shell/single_visibility_focus_mechanism.h"
36#include "mir/frontend/session_container.h"36#include "mir/shell/session_container.h"
37#include "mir/shell/consuming_placement_strategy.h"37#include "mir/shell/consuming_placement_strategy.h"
38#include "mir/shell/organising_surface_factory.h"38#include "mir/shell/organising_surface_factory.h"
39#include "mir/graphics/display.h"39#include "mir/graphics/display.h"
@@ -266,7 +266,7 @@
266 [this]() -> std::shared_ptr<msh::SessionManager>266 [this]() -> std::shared_ptr<msh::SessionManager>
267 {267 {
268 auto session_container = std::make_shared<msh::SessionContainer>();268 auto session_container = std::make_shared<msh::SessionContainer>();
269 auto focus_mechanism = std::make_shared<msh::SingleVisibilityFocusMechanism>(session_container);269 auto focus_mechanism = std::make_shared<msh::SingleVisibilityFocusMechanism>(session_container, the_input_focus_selector());
270 auto focus_selection_strategy = std::make_shared<msh::RegistrationOrderFocusSequence>(session_container);270 auto focus_selection_strategy = std::make_shared<msh::RegistrationOrderFocusSequence>(session_container);
271271
272 auto placement_strategy = std::make_shared<msh::ConsumingPlacementStrategy>(the_display());272 auto placement_strategy = std::make_shared<msh::ConsumingPlacementStrategy>(the_display());
@@ -455,3 +455,8 @@
455{455{
456 return the_input_manager();456 return the_input_manager();
457}457}
458
459std::shared_ptr<msh::InputFocusSelector> mir::DefaultServerConfiguration::the_input_focus_selector()
460{
461 return the_input_manager();
462}
458463
=== modified file 'src/server/input/android/CMakeLists.txt'
--- src/server/input/android/CMakeLists.txt 2013-03-21 03:32:59 +0000
+++ src/server/input/android/CMakeLists.txt 2013-03-22 17:46:22 +0000
@@ -8,6 +8,8 @@
8 ${CMAKE_CURRENT_SOURCE_DIR}/rudimentary_input_reader_policy.cpp8 ${CMAKE_CURRENT_SOURCE_DIR}/rudimentary_input_reader_policy.cpp
9 ${CMAKE_CURRENT_SOURCE_DIR}/event_filter_dispatcher_policy.cpp9 ${CMAKE_CURRENT_SOURCE_DIR}/event_filter_dispatcher_policy.cpp
10 ${CMAKE_CURRENT_SOURCE_DIR}/default_android_input_configuration.cpp10 ${CMAKE_CURRENT_SOURCE_DIR}/default_android_input_configuration.cpp
11 ${CMAKE_CURRENT_SOURCE_DIR}/android_input_application_handle.cpp
12 ${CMAKE_CURRENT_SOURCE_DIR}/android_input_window_handle.cpp
11)13)
1214
13set(15set(
1416
=== added file 'src/server/input/android/android_input_application_handle.cpp'
--- src/server/input/android/android_input_application_handle.cpp 1970-01-01 00:00:00 +0000
+++ src/server/input/android/android_input_application_handle.cpp 2013-03-22 17:46:22 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "android_input_application_handle.h"
20
21#include "mir/input/session_target.h"
22
23#include <limits.h>
24
25namespace mi = mir::input;
26namespace mia = mi::android;
27
28mia::InputApplicationHandle::InputApplicationHandle(std::shared_ptr<mi::SessionTarget> const& session)
29 : session(session)
30{
31 updateInfo();
32}
33
34bool mia::InputApplicationHandle::updateInfo()
35{
36 if (mInfo == NULL)
37 mInfo = new droidinput::InputApplicationInfo;
38 mInfo->dispatchingTimeout = INT_MAX;
39 mInfo->name = droidinput::String8(session->name().c_str());
40
41 return true;
42}
043
=== added file 'src/server/input/android/android_input_application_handle.h'
--- src/server/input/android/android_input_application_handle.h 1970-01-01 00:00:00 +0000
+++ src/server/input/android/android_input_application_handle.h 2013-03-22 17:46:22 +0000
@@ -0,0 +1,58 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_INPUT_ANDROID_INPUT_APPLICATION_HANDLE_H_
20#define MIR_INPUT_ANDROID_INPUT_APPLICATION_HANDLE_H_
21
22#include <InputApplication.h>
23
24#include <memory>
25
26namespace droidinput = android;
27
28namespace mir
29{
30
31namespace input
32{
33class SessionTarget;
34
35namespace android
36{
37
38class InputApplicationHandle : public droidinput::InputApplicationHandle
39{
40public:
41 InputApplicationHandle(std::shared_ptr<input::SessionTarget> const& surface);
42 ~InputApplicationHandle() {}
43
44 bool updateInfo();
45
46protected:
47 InputApplicationHandle(InputApplicationHandle const&) = delete;
48 InputApplicationHandle& operator=(InputApplicationHandle const&) = delete;
49
50private:
51 std::shared_ptr<input::SessionTarget> session;
52};
53
54}
55}
56} // namespace mir
57
58#endif // MIR_INPUT_ANDROID_INPUT_APPLICATION_HANDLE_H_
059
=== modified file 'src/server/input/android/android_input_manager.cpp'
--- src/server/input/android/android_input_manager.cpp 2013-03-21 03:32:59 +0000
+++ src/server/input/android/android_input_manager.cpp 2013-03-22 17:46:22 +0000
@@ -18,12 +18,16 @@
18 */18 */
1919
20#include "mir/graphics/viewable_area.h"20#include "mir/graphics/viewable_area.h"
21#include "mir/input/session_target.h"
22#include "mir/input/surface_target.h"
2123
22#include "android_input_manager.h"24#include "android_input_manager.h"
23#include "android_input_constants.h"25#include "android_input_constants.h"
24#include "android_input_configuration.h"26#include "android_input_configuration.h"
25#include "android_input_thread.h"27#include "android_input_thread.h"
26#include "android_input_channel.h"28#include "android_input_channel.h"
29#include "android_input_window_handle.h"
30#include "android_input_application_handle.h"
27#include "default_android_input_configuration.h"31#include "default_android_input_configuration.h"
2832
29#include <EventHub.h>33#include <EventHub.h>
@@ -40,7 +44,8 @@
40 : event_hub(config->the_event_hub()),44 : event_hub(config->the_event_hub()),
41 dispatcher(config->the_dispatcher()),45 dispatcher(config->the_dispatcher()),
42 reader_thread(config->the_reader_thread()),46 reader_thread(config->the_reader_thread()),
43 dispatcher_thread(config->the_dispatcher_thread())47 dispatcher_thread(config->the_dispatcher_thread()),
48 focused_window_handle(0)
44{49{
45}50}
4651
@@ -73,6 +78,28 @@
73 return std::make_shared<mia::AndroidInputChannel>();78 return std::make_shared<mia::AndroidInputChannel>();
74}79}
7580
81void mia::InputManager::set_input_focus_to(std::shared_ptr<mi::SessionTarget> const& session, std::shared_ptr<mi::SurfaceTarget> const& surface)
82{
83 if (focused_window_handle.get())
84 {
85 dispatcher->unregisterInputChannel(focused_window_handle->getInfo()->inputChannel);
86 focused_window_handle.clear();
87 focused_application_handle.clear();
88 }
89
90 droidinput::Vector<droidinput::sp<droidinput::InputWindowHandle>> windows;
91 if (surface)
92 {
93 focused_application_handle = new mia::InputApplicationHandle(session);
94 focused_window_handle = new mia::InputWindowHandle(focused_application_handle, surface);
95 dispatcher->setFocusedApplication(focused_application_handle);
96
97 dispatcher->registerInputChannel(focused_window_handle->getInfo()->inputChannel, focused_window_handle, false);
98 windows.push_back(focused_window_handle);
99 }
100 dispatcher->setInputWindows(windows);
101}
102
76std::shared_ptr<mi::InputManager> mi::create_input_manager(103std::shared_ptr<mi::InputManager> mi::create_input_manager(
77 const std::initializer_list<std::shared_ptr<mi::EventFilter> const>& event_filters,104 const std::initializer_list<std::shared_ptr<mi::EventFilter> const>& event_filters,
78 std::shared_ptr<mg::ViewableArea> const& view_area)105 std::shared_ptr<mg::ViewableArea> const& view_area)
79106
=== modified file 'src/server/input/android/android_input_manager.h'
--- src/server/input/android/android_input_manager.h 2013-03-21 03:32:59 +0000
+++ src/server/input/android/android_input_manager.h 2013-03-22 17:46:22 +0000
@@ -30,6 +30,8 @@
30{30{
31class EventHubInterface;31class EventHubInterface;
32class InputDispatcherInterface;32class InputDispatcherInterface;
33class InputWindowHandle;
34class InputApplicationHandle;
33}35}
3436
35namespace droidinput = android;37namespace droidinput = android;
@@ -40,6 +42,7 @@
40{42{
41class ViewableArea;43class ViewableArea;
42}44}
45
43namespace input46namespace input
44{47{
45class CursorListener;48class CursorListener;
@@ -61,6 +64,7 @@
61 64
62 std::shared_ptr<InputChannel> make_input_channel();65 std::shared_ptr<InputChannel> make_input_channel();
63 66
67 void set_input_focus_to(std::shared_ptr<input::SessionTarget> const& session, std::shared_ptr<input::SurfaceTarget> const& surface);
6468
65protected:69protected:
66 InputManager(const InputManager&) = delete;70 InputManager(const InputManager&) = delete;
@@ -72,6 +76,9 @@
7276
73 std::shared_ptr<InputThread> reader_thread;77 std::shared_ptr<InputThread> reader_thread;
74 std::shared_ptr<InputThread> dispatcher_thread;78 std::shared_ptr<InputThread> dispatcher_thread;
79
80 droidinput::sp<droidinput::InputWindowHandle> focused_window_handle;
81 droidinput::sp<droidinput::InputApplicationHandle> focused_application_handle;
75};82};
7683
77}84}
7885
=== added file 'src/server/input/android/android_input_window_handle.cpp'
--- src/server/input/android/android_input_window_handle.cpp 1970-01-01 00:00:00 +0000
+++ src/server/input/android/android_input_window_handle.cpp 2013-03-22 17:46:22 +0000
@@ -0,0 +1,74 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "android_input_window_handle.h"
20#include "android_input_application_handle.h"
21
22#include "mir/input/input_channel.h"
23#include "mir/input/surface_target.h"
24
25#include <androidfw/InputTransport.h>
26
27#include <limits.h>
28
29namespace mi = mir::input;
30namespace mia = mi::android;
31
32mia::InputWindowHandle::InputWindowHandle(droidinput::sp<droidinput::InputApplicationHandle> const& input_app_handle,
33 std::shared_ptr<mi::SurfaceTarget> const& surface)
34 : droidinput::InputWindowHandle(input_app_handle),
35 surface(surface)
36{
37 updateInfo();
38}
39
40bool mia::InputWindowHandle::updateInfo()
41{
42 if (!mInfo)
43 {
44 mInfo = new droidinput::InputWindowInfo();
45
46 // TODO: How can we avoid recreating the InputChannel which the InputChannelFactory has already created?
47 mInfo->inputChannel = new droidinput::InputChannel(droidinput::String8("TODO: Name"),
48 surface->server_input_fd());
49 }
50
51 mInfo->frameLeft = 0;
52 mInfo->frameTop = 0;
53 auto surface_size = surface->size();
54 mInfo->frameRight = mInfo->frameLeft + surface_size.width.as_uint32_t();
55 mInfo->frameBottom = mInfo->frameTop + surface_size.height.as_uint32_t();
56
57 mInfo->name = droidinput::String8(surface->name().c_str());
58 mInfo->layoutParamsFlags = droidinput::InputWindowInfo::FLAG_NOT_TOUCH_MODAL;
59 mInfo->layoutParamsType = droidinput::InputWindowInfo::TYPE_APPLICATION;
60 mInfo->scaleFactor = 1.f;
61 mInfo->visible = true;
62 mInfo->canReceiveKeys = true;
63 mInfo->hasFocus = true;
64 mInfo->hasWallpaper = false;
65 mInfo->paused = false;
66 mInfo->dispatchingTimeout = INT_MAX;
67 mInfo->ownerPid = 0;
68 mInfo->ownerUid = 0;
69 mInfo->inputFeatures = 0;
70
71 // TODO: Set touchableRegion and layer for touch events.
72
73 return true;
74}
075
=== added file 'src/server/input/android/android_input_window_handle.h'
--- src/server/input/android/android_input_window_handle.h 1970-01-01 00:00:00 +0000
+++ src/server/input/android/android_input_window_handle.h 2013-03-22 17:46:22 +0000
@@ -0,0 +1,59 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_INPUT_ANDROID_INPUT_WINDOW_HANDLE_H_
20#define MIR_INPUT_ANDROID_INPUT_WINDOW_HANDLE_H_
21
22#include <InputWindow.h>
23
24#include <memory>
25
26namespace droidinput = android;
27
28namespace mir
29{
30
31namespace input
32{
33class SurfaceTarget;
34
35namespace android
36{
37
38class InputWindowHandle : public droidinput::InputWindowHandle
39{
40public:
41 InputWindowHandle(droidinput::sp<droidinput::InputApplicationHandle> const& input_app_handle,
42 std::shared_ptr<input::SurfaceTarget> const& surface);
43 ~InputWindowHandle() {}
44
45 bool updateInfo();
46
47protected:
48 InputWindowHandle(InputWindowHandle const&) = delete;
49 InputWindowHandle& operator=(InputWindowHandle const&) = delete;
50
51private:
52 std::shared_ptr<input::SurfaceTarget> surface;
53};
54
55}
56}
57} // namespace mir
58
59#endif // MIR_INPUT_ANDROID_INPUT_WINDOW_HANDLE_H_
060
=== modified file 'src/server/input/android/default_android_input_configuration.cpp'
--- src/server/input/android/default_android_input_configuration.cpp 2013-03-06 17:01:51 +0000
+++ src/server/input/android/default_android_input_configuration.cpp 2013-03-22 17:46:22 +0000
@@ -26,6 +26,8 @@
26#include <InputDispatcher.h>26#include <InputDispatcher.h>
27#include <InputReader.h>27#include <InputReader.h>
2828
29#include <string>
30
29namespace droidinput = android;31namespace droidinput = android;
3032
31namespace mi = mir::input;33namespace mi = mir::input;
3234
=== modified file 'src/server/input/android/event_filter_dispatcher_policy.cpp'
--- src/server/input/android/event_filter_dispatcher_policy.cpp 2013-03-13 04:54:15 +0000
+++ src/server/input/android/event_filter_dispatcher_policy.cpp 2013-03-22 17:46:22 +0000
@@ -39,5 +39,5 @@
3939
40void mia::EventFilterDispatcherPolicy::interceptKeyBeforeQueueing(const droidinput::KeyEvent* /*key_event*/, uint32_t& policy_flags)40void mia::EventFilterDispatcherPolicy::interceptKeyBeforeQueueing(const droidinput::KeyEvent* /*key_event*/, uint32_t& policy_flags)
41{41{
42 policy_flags = droidinput::POLICY_FLAG_FILTERED;42 policy_flags |= droidinput::POLICY_FLAG_PASS_TO_USER;
43}43}
4444
=== modified file 'src/server/input/dummy_input_manager.cpp'
--- src/server/input/dummy_input_manager.cpp 2013-03-21 03:32:59 +0000
+++ src/server/input/dummy_input_manager.cpp 2013-03-22 17:46:22 +0000
@@ -28,6 +28,9 @@
28 void stop() {}28 void stop() {}
29 void start() {}29 void start() {}
30 virtual std::shared_ptr<mi::InputChannel> make_input_channel() { return std::shared_ptr<mi::InputChannel>(); }30 virtual std::shared_ptr<mi::InputChannel> make_input_channel() { return std::shared_ptr<mi::InputChannel>(); }
31 void set_input_focus_to(std::shared_ptr<mi::SessionTarget> const& /* session */, std::shared_ptr<mi::SurfaceTarget> const& /* surface */)
32 {
33 }
31}; 34};
32}35}
3336
3437
=== modified file 'src/server/shell/application_session.cpp'
--- src/server/shell/application_session.cpp 2013-03-22 03:33:00 +0000
+++ src/server/shell/application_session.cpp 2013-03-22 17:46:22 +0000
@@ -82,6 +82,14 @@
82 return checked_find(id)->second;82 return checked_find(id)->second;
83}83}
8484
85std::shared_ptr<msh::Surface> msh::ApplicationSession::default_surface() const
86{
87 if (surfaces.size())
88 return surfaces.begin()->second;
89 else
90 return std::shared_ptr<msh::Surface>();
91}
92
85void msh::ApplicationSession::destroy_surface(mf::SurfaceId id)93void msh::ApplicationSession::destroy_surface(mf::SurfaceId id)
86{94{
87 std::unique_lock<std::mutex> lock(surfaces_mutex);95 std::unique_lock<std::mutex> lock(surfaces_mutex);
8896
=== modified file 'src/server/shell/registration_order_focus_sequence.cpp'
--- src/server/shell/registration_order_focus_sequence.cpp 2013-03-21 03:32:59 +0000
+++ src/server/shell/registration_order_focus_sequence.cpp 2013-03-22 17:46:22 +0000
@@ -18,7 +18,7 @@
1818
19#include "mir/shell/registration_order_focus_sequence.h"19#include "mir/shell/registration_order_focus_sequence.h"
20#include "mir/frontend/session.h"20#include "mir/frontend/session.h"
21#include "mir/frontend/session_container.h"21#include "mir/shell/session_container.h"
2222
23#include <boost/throw_exception.hpp>23#include <boost/throw_exception.hpp>
2424
2525
=== modified file 'src/server/shell/session_container.cpp'
--- src/server/shell/session_container.cpp 2013-03-21 03:32:59 +0000
+++ src/server/shell/session_container.cpp 2013-03-22 17:46:22 +0000
@@ -16,7 +16,7 @@
16 * Authored By: Robert Carr <robert.carr@canonical.com>16 * Authored By: Robert Carr <robert.carr@canonical.com>
17 */17 */
1818
19#include "mir/frontend/session_container.h"19#include "mir/shell/session_container.h"
20#include "mir/frontend/session.h"20#include "mir/frontend/session.h"
2121
22#include <boost/throw_exception.hpp>22#include <boost/throw_exception.hpp>
@@ -42,7 +42,6 @@
42void msh::SessionContainer::insert_session(std::shared_ptr<mf::Session> const& session)42void msh::SessionContainer::insert_session(std::shared_ptr<mf::Session> const& session)
43{43{
44 std::unique_lock<std::mutex> lk(guard);44 std::unique_lock<std::mutex> lk(guard);
45 auto name = session->name();
4645
47 apps.push_back(session);46 apps.push_back(session);
48}47}
4948
=== modified file 'src/server/shell/session_manager.cpp'
--- src/server/shell/session_manager.cpp 2013-03-21 03:32:59 +0000
+++ src/server/shell/session_manager.cpp 2013-03-22 17:46:22 +0000
@@ -18,10 +18,11 @@
1818
19#include "mir/shell/session_manager.h"19#include "mir/shell/session_manager.h"
20#include "mir/shell/application_session.h"20#include "mir/shell/application_session.h"
21#include "mir/frontend/session_container.h"21#include "mir/shell/session_container.h"
22#include "mir/shell/surface_factory.h"22#include "mir/shell/surface_factory.h"
23#include "mir/shell/focus_sequence.h"23#include "mir/shell/focus_sequence.h"
24#include "mir/shell/focus_setter.h"24#include "mir/shell/focus_setter.h"
25#include "mir/shell/session.h"
2526
26#include <memory>27#include <memory>
27#include <cassert>28#include <cassert>
@@ -67,8 +68,9 @@
6768
68inline void msh::SessionManager::set_focus_to(std::shared_ptr<mf::Session> const& next_focus)69inline void msh::SessionManager::set_focus_to(std::shared_ptr<mf::Session> const& next_focus)
69{70{
70 focus_application = next_focus;71 auto shell_session = std::dynamic_pointer_cast<msh::Session>(next_focus);
71 focus_setter->set_focus_to(next_focus);72 focus_application = shell_session;
73 focus_setter->set_focus_to(shell_session);
72}74}
7375
74void msh::SessionManager::close_session(std::shared_ptr<mf::Session> const& session)76void msh::SessionManager::close_session(std::shared_ptr<mf::Session> const& session)
7577
=== modified file 'src/server/shell/single_visibility_focus_mechanism.cpp'
--- src/server/shell/single_visibility_focus_mechanism.cpp 2013-03-21 03:32:59 +0000
+++ src/server/shell/single_visibility_focus_mechanism.cpp 2013-03-22 17:46:22 +0000
@@ -16,25 +16,33 @@
16 * Authored By: Robert Carr <robert.carr@canonical.com>16 * Authored By: Robert Carr <robert.carr@canonical.com>
17 */17 */
1818
19#include "mir/frontend/session_container.h"19#include "mir/shell/session_container.h"
20#include "mir/frontend/session.h"20#include "mir/frontend/session.h"
21#include "mir/shell/single_visibility_focus_mechanism.h"21#include "mir/shell/single_visibility_focus_mechanism.h"
22#include "mir/shell/input_focus_selector.h"
23
24#include "mir/shell/session.h"
25#include "surface.h" // TODO: Cleanup headers ~racarr
2226
23namespace mf = mir::frontend;27namespace mf = mir::frontend;
24namespace msh = mir::shell;28namespace msh = mir::shell;
2529
26msh::SingleVisibilityFocusMechanism::SingleVisibilityFocusMechanism(std::shared_ptr<msh::SessionContainer> const& app_container) :30msh::SingleVisibilityFocusMechanism::SingleVisibilityFocusMechanism(std::shared_ptr<msh::SessionContainer> const& app_container,
27 app_container(app_container)31 std::shared_ptr<msh::InputFocusSelector> const& input_selector)
32 : app_container(app_container),
33 input_selector(input_selector)
28{34{
29}35}
3036
31void msh::SingleVisibilityFocusMechanism::set_focus_to(std::shared_ptr<mf::Session> const& focus_session)37void msh::SingleVisibilityFocusMechanism::set_focus_to(std::shared_ptr<msh::Session> const& focus_session)
32{38{
33 app_container->for_each(39 app_container->for_each(
34 [&](std::shared_ptr<mf::Session> const& session) {40 [&](std::shared_ptr<mf::Session> const& session) {
35 if (session == focus_session)41 if (session == focus_session)
36 {42 {
37 session->show();43 session->show();
44
45 input_selector->set_input_focus_to(focus_session, focus_session->default_surface());
38 }46 }
39 else47 else
40 {48 {
4149
=== modified file 'src/server/shell/surface.cpp'
--- src/server/shell/surface.cpp 2013-03-21 04:03:36 +0000
+++ src/server/shell/surface.cpp 2013-03-22 17:46:22 +0000
@@ -89,6 +89,18 @@
89 }89 }
90}90}
9191
92std::string msh::Surface::name() const
93{
94 if (auto const& s = surface.lock())
95 {
96 return s->name();
97 }
98 else
99 {
100 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid surface"));
101 }
102}
103
92mir::geometry::PixelFormat msh::Surface::pixel_format() const104mir::geometry::PixelFormat msh::Surface::pixel_format() const
93{105{
94 if (auto const& s = surface.lock())106 if (auto const& s = surface.lock())
@@ -135,6 +147,13 @@
135 return input_channel->client_fd();147 return input_channel->client_fd();
136}148}
137149
150int msh::Surface::server_input_fd() const
151{
152 if (!supports_input())
153 BOOST_THROW_EXCEPTION(std::logic_error("Surface does not support input"));
154 return input_channel->server_fd();
155}
156
138int msh::Surface::configure(MirSurfaceAttrib attrib, int value)157int msh::Surface::configure(MirSurfaceAttrib attrib, int value)
139{158{
140 int result = 0;159 int result = 0;
141160
=== modified file 'src/server/shell/surface.h'
--- src/server/shell/surface.h 2013-03-21 04:03:36 +0000
+++ src/server/shell/surface.h 2013-03-22 17:46:22 +0000
@@ -22,8 +22,12 @@
2222
23#include "mir/frontend/surface.h"23#include "mir/frontend/surface.h"
24#include "mir/surfaces/surface.h"24#include "mir/surfaces/surface.h"
25#include "mir/input/surface_target.h"
26
25#include "mir_toolkit/common.h"27#include "mir_toolkit/common.h"
2628
29#include <string>
30
27namespace mir31namespace mir
28{32{
29namespace frontend33namespace frontend
@@ -39,7 +43,7 @@
39{43{
40class SurfaceBuilder;44class SurfaceBuilder;
4145
42class Surface : public frontend::Surface46class Surface : public frontend::Surface, public input::SurfaceTarget
43{47{
44public:48public:
45 Surface(49 Surface(
@@ -56,6 +60,8 @@
5660
57 virtual void shutdown();61 virtual void shutdown();
5862
63 virtual std::string name() const;
64
59 virtual geometry::Size size() const;65 virtual geometry::Size size() const;
6066
61 virtual geometry::PixelFormat pixel_format() const;67 virtual geometry::PixelFormat pixel_format() const;
@@ -66,6 +72,7 @@
6672
67 virtual bool supports_input() const;73 virtual bool supports_input() const;
68 virtual int client_input_fd() const;74 virtual int client_input_fd() const;
75 virtual int server_input_fd() const;
6976
70 virtual int configure(MirSurfaceAttrib attrib, int value);77 virtual int configure(MirSurfaceAttrib attrib, int value);
71 virtual MirSurfaceType type() const;78 virtual MirSurfaceType type() const;
7279
=== modified file 'tests/acceptance-tests/CMakeLists.txt'
--- tests/acceptance-tests/CMakeLists.txt 2013-03-21 03:32:59 +0000
+++ tests/acceptance-tests/CMakeLists.txt 2013-03-22 17:46:22 +0000
@@ -9,7 +9,7 @@
9 test_surfaceloop.cpp9 test_surfaceloop.cpp
10 test_test_framework.cpp10 test_test_framework.cpp
11 test_focus_management_api.cpp11 test_focus_management_api.cpp
12 test_surface_focus.cpp12 test_focus_selection.cpp
13)13)
1414
15# TODO Disabled in binder version as this test uses detect_server() and that15# TODO Disabled in binder version as this test uses detect_server() and that
1616
=== renamed file 'tests/acceptance-tests/test_surface_focus.cpp' => 'tests/acceptance-tests/test_focus_selection.cpp'
--- tests/acceptance-tests/test_surface_focus.cpp 2013-03-15 23:15:45 +0000
+++ tests/acceptance-tests/test_focus_selection.cpp 2013-03-22 17:46:22 +0000
@@ -18,21 +18,24 @@
1818
19#include "mir_toolkit/mir_client_library.h"19#include "mir_toolkit/mir_client_library.h"
2020
21#include "mir/frontend/session_container.h"21#include "mir/shell/session_container.h"
22#include "mir/shell/registration_order_focus_sequence.h"22#include "mir/shell/registration_order_focus_sequence.h"
23#include "mir/shell/consuming_placement_strategy.h"23#include "mir/shell/consuming_placement_strategy.h"
24#include "mir/shell/organising_surface_factory.h"24#include "mir/shell/organising_surface_factory.h"
25#include "mir/shell/session_manager.h"25#include "mir/shell/session_manager.h"
26#include "mir/graphics/display.h"26#include "mir/graphics/display.h"
27#include "mir/shell/input_focus_selector.h"
2728
28#include "mir_test_framework/display_server_test_fixture.h"29#include "mir_test_framework/display_server_test_fixture.h"
29#include "mir_test_doubles/mock_focus_setter.h"30#include "mir_test_doubles/mock_focus_setter.h"
31#include "mir_test_doubles/mock_input_focus_selector.h"
3032
31#include <gtest/gtest.h>33#include <gtest/gtest.h>
32#include <gmock/gmock.h>34#include <gmock/gmock.h>
3335
34namespace mf = mir::frontend;36namespace mf = mir::frontend;
35namespace msh = mir::shell;37namespace msh = mir::shell;
38namespace mi = mir::input;
36namespace mtd = mir::test::doubles;39namespace mtd = mir::test::doubles;
37namespace mtf = mir_test_framework;40namespace mtf = mir_test_framework;
3841
@@ -87,13 +90,48 @@
87 MirConnection* connection;90 MirConnection* connection;
88 MirSurface* surface;91 MirSurface* surface;
89};92};
93
94struct SurfaceCreatingClient : ClientConfigCommon
95{
96 void exec()
97 {
98 mir_wait_for(mir_connect(
99 mir_test_socket,
100 __PRETTY_FUNCTION__,
101 connection_callback,
102 this));
103 ASSERT_TRUE(connection != NULL);
104 MirSurfaceParameters const request_params =
105 {
106 __PRETTY_FUNCTION__,
107 640, 480,
108 mir_pixel_format_abgr_8888,
109 mir_buffer_usage_hardware
110 };
111 mir_wait_for(mir_surface_create(connection, &request_params, create_surface_callback, this));
112 mir_connection_release(connection);
113 }
114};
115
90}116}
91117
92namespace118namespace
93{119{
94MATCHER(NonNullSession, "")120MATCHER(NonNullSession, "")
95{121{
96 return arg != std::shared_ptr<mf::Session>();122 return arg != std::shared_ptr<msh::Session>();
123}
124MATCHER(NonNullSessionTarget, "")
125{
126 return arg != std::shared_ptr<mi::SessionTarget>();
127}
128MATCHER(NonNullSurfaceTarget, "")
129{
130 return arg != std::shared_ptr<mi::SurfaceTarget>();
131}
132MATCHER(NullSurfaceTarget, "")
133{
134 return arg == std::shared_ptr<mi::SurfaceTarget>();
97}135}
98}136}
99137
@@ -132,31 +170,46 @@
132170
133 launch_server_process(server_config);171 launch_server_process(server_config);
134172
135 struct ClientConfig : ClientConfigCommon173 SurfaceCreatingClient client;
174
175 launch_client_process(client);
176}
177
178TEST_F(BespokeDisplayServerTestFixture, surfaces_receive_input_focus_when_created)
179{
180 struct ServerConfig : TestingServerConfiguration
136 {181 {
137 void exec()182 std::shared_ptr<mtd::MockInputFocusSelector> focus_selector;
138 {183 bool expected;
139 mir_wait_for(mir_connect(184
140 mir_test_socket,185 ServerConfig()
141 __PRETTY_FUNCTION__,186 : focus_selector(std::make_shared<mtd::MockInputFocusSelector>()),
142 connection_callback,187 expected(false)
143 this));188 {
144189 }
145 ASSERT_TRUE(connection != NULL);190
146191 std::shared_ptr<msh::InputFocusSelector>
147 MirSurfaceParameters const request_params =192 the_input_focus_selector() override
193 {
194 using namespace ::testing;
195
196 if (!expected)
148 {197 {
149 __PRETTY_FUNCTION__,198 InSequence seq;
150 640, 480,199
151 mir_pixel_format_abgr_8888,200 EXPECT_CALL(*focus_selector, set_input_focus_to(NonNullSessionTarget(), NullSurfaceTarget())).Times(1);
152 mir_buffer_usage_hardware201 EXPECT_CALL(*focus_selector, set_input_focus_to(NonNullSessionTarget(), NonNullSurfaceTarget())).Times(1);
153 };202 expected = true;
154203 }
155 mir_wait_for(mir_surface_create(connection, &request_params, create_surface_callback, this));204
156205 return focus_selector;
157 mir_connection_release(connection);
158 }206 }
159 } focus_config;207 } server_config;
208
209
210 launch_server_process(server_config);
211
212 SurfaceCreatingClient client;
160 213
161 launch_client_process(focus_config);214 launch_client_process(client);
162}215}
163216
=== modified file 'tests/behavior-tests/session_management_context.cpp'
--- tests/behavior-tests/session_management_context.cpp 2013-03-21 03:32:59 +0000
+++ tests/behavior-tests/session_management_context.cpp 2013-03-22 17:46:22 +0000
@@ -23,7 +23,7 @@
23#include "mir/frontend/session.h"23#include "mir/frontend/session.h"
24#include "mir/shell/registration_order_focus_sequence.h"24#include "mir/shell/registration_order_focus_sequence.h"
25#include "mir/shell/single_visibility_focus_mechanism.h"25#include "mir/shell/single_visibility_focus_mechanism.h"
26#include "mir/frontend/session_container.h"26#include "mir/shell/session_container.h"
27#include "mir/frontend/shell.h"27#include "mir/frontend/shell.h"
28#include "mir/input/input_channel.h"28#include "mir/input/input_channel.h"
29#include "mir/shell/surface_factory.h"29#include "mir/shell/surface_factory.h"
3030
=== modified file 'tests/integration-tests/CMakeLists.txt'
--- tests/integration-tests/CMakeLists.txt 2013-03-19 09:51:24 +0000
+++ tests/integration-tests/CMakeLists.txt 2013-03-22 17:46:22 +0000
@@ -10,6 +10,7 @@
10add_subdirectory(client/)10add_subdirectory(client/)
11add_subdirectory(compositor/)11add_subdirectory(compositor/)
12add_subdirectory(frontend/)12add_subdirectory(frontend/)
13add_subdirectory(shell/)
13add_subdirectory(process/)14add_subdirectory(process/)
14if (NOT MIR_DISABLE_INPUT)15if (NOT MIR_DISABLE_INPUT)
15add_subdirectory(input/)16add_subdirectory(input/)
1617
=== modified file 'tests/integration-tests/cucumber/test_session_management_context.cpp'
--- tests/integration-tests/cucumber/test_session_management_context.cpp 2013-03-21 03:32:59 +0000
+++ tests/integration-tests/cucumber/test_session_management_context.cpp 2013-03-22 17:46:22 +0000
@@ -25,6 +25,8 @@
25#include "mir/graphics/viewable_area.h"25#include "mir/graphics/viewable_area.h"
2626
27#include "mir_test_doubles/mock_session.h"27#include "mir_test_doubles/mock_session.h"
28#include "mir_test_doubles/stub_surface_builder.h"
29#include "mir_test_doubles/mock_surface.h"
28#include "mir_test_doubles/mock_shell.h"30#include "mir_test_doubles/mock_shell.h"
29#include "mir_test/fake_shared.h"31#include "mir_test/fake_shared.h"
3032
@@ -52,24 +54,6 @@
52 MOCK_METHOD0(the_compositor, std::shared_ptr<mc::Compositor>());54 MOCK_METHOD0(the_compositor, std::shared_ptr<mc::Compositor>());
53};55};
5456
55struct MockSurface : public mf::Surface
56{
57 MOCK_METHOD0(hide, void());
58 MOCK_METHOD0(show, void());
59 MOCK_METHOD0(destroy, void());
60 MOCK_METHOD0(shutdown, void());
61 MOCK_METHOD0(advance_client_buffer, void());
62
63 MOCK_CONST_METHOD0(size, mir::geometry::Size ());
64 MOCK_CONST_METHOD0(pixel_format, mir::geometry::PixelFormat ());
65 MOCK_CONST_METHOD0(client_buffer, std::shared_ptr<mc::Buffer> ());
66
67 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));
68
69 MOCK_CONST_METHOD0(supports_input, bool());
70 MOCK_CONST_METHOD0(client_input_fd, int());
71};
72
73MATCHER_P(NamedWindowWithNoGeometry, name, "")57MATCHER_P(NamedWindowWithNoGeometry, name, "")
74{58{
75 if (arg.name != name)59 if (arg.name != name)
@@ -181,7 +165,7 @@
181 using namespace ::testing;165 using namespace ::testing;
182166
183 mtd::MockSession session;167 mtd::MockSession session;
184 MockSurface surface;168 mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>());
185169
186 EXPECT_CALL(shell, open_session(test_window_name)).Times(1)170 EXPECT_CALL(shell, open_session(test_window_name)).Times(1)
187 .WillOnce(Return(mt::fake_shared<mf::Session>(session)));171 .WillOnce(Return(mt::fake_shared<mf::Session>(session)));
188172
=== modified file 'tests/integration-tests/frontend/CMakeLists.txt'
--- tests/integration-tests/frontend/CMakeLists.txt 2013-03-13 04:54:15 +0000
+++ tests/integration-tests/frontend/CMakeLists.txt 2013-03-22 17:46:22 +0000
@@ -1,7 +1,6 @@
1list(1list(
2 APPEND INTEGRATION_TESTS_SRCS2 APPEND INTEGRATION_TESTS_SRCS
3 ${CMAKE_CURRENT_SOURCE_DIR}/test_application_mediator_report.cpp3 ${CMAKE_CURRENT_SOURCE_DIR}/test_application_mediator_report.cpp
4 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_manager.cpp
5)4)
65
7set(6set(
87
=== modified file 'tests/integration-tests/input/android/test_android_input_manager.cpp'
--- tests/integration-tests/input/android/test_android_input_manager.cpp 2013-03-21 03:32:59 +0000
+++ tests/integration-tests/input/android/test_android_input_manager.cpp 2013-03-22 17:46:22 +0000
@@ -18,22 +18,32 @@
18 */18 */
1919
20#include "mir/input/event_filter.h"20#include "mir/input/event_filter.h"
21#include "mir/frontend/surface_creation_parameters.h"
22
21#include "src/server/input/android/default_android_input_configuration.h"23#include "src/server/input/android/default_android_input_configuration.h"
22#include "src/server/input/android/android_input_manager.h"24#include "src/server/input/android/android_input_manager.h"
25#include "src/server/input/android/dummy_input_dispatcher_policy.h"
26#include "src/server/input/android/event_filter_dispatcher_policy.h"
2327
24#include "mir_test/fake_shared.h"28#include "mir_test/fake_shared.h"
25#include "mir_test/fake_event_hub.h"29#include "mir_test/fake_event_hub.h"
26#include "mir_test/fake_event_hub_input_configuration.h"30#include "mir_test/fake_event_hub_input_configuration.h"
27#include "mir_test_doubles/mock_event_filter.h"31#include "mir_test_doubles/mock_event_filter.h"
28#include "mir_test_doubles/mock_viewable_area.h"32#include "mir_test_doubles/mock_viewable_area.h"
33#include "mir_test_doubles/stub_session_target.h"
34#include "mir_test_doubles/stub_surface_target.h"
29#include "mir_test/wait_condition.h"35#include "mir_test/wait_condition.h"
30#include "mir_test/event_factory.h"36#include "mir_test/event_factory.h"
3137
32#include <EventHub.h>38#include <EventHub.h>
39#include <InputDispatcher.h>
3340
34#include <gmock/gmock.h>41#include <gmock/gmock.h>
35#include <gtest/gtest.h>42#include <gtest/gtest.h>
3643
44#include <sys/types.h>
45#include <sys/socket.h>
46
37namespace mi = mir::input;47namespace mi = mir::input;
38namespace mia = mir::input::android;48namespace mia = mir::input::android;
39namespace mis = mir::input::synthesis;49namespace mis = mir::input::synthesis;
@@ -154,3 +164,111 @@
154 wait_condition.wait_for_at_most_seconds(1);164 wait_condition.wait_for_at_most_seconds(1);
155}165}
156166
167namespace
168{
169
170struct MockDispatcherPolicy : public mia::EventFilterDispatcherPolicy
171{
172 MockDispatcherPolicy(std::shared_ptr<mi::EventFilter> const& filter)
173 : EventFilterDispatcherPolicy(filter)
174 {
175 }
176 MOCK_METHOD3(interceptKeyBeforeDispatching, nsecs_t(droidinput::sp<droidinput::InputWindowHandle> const&,
177 droidinput::KeyEvent const*, uint32_t));
178};
179
180struct TestingInputConfiguration : public mtd::FakeEventHubInputConfiguration
181{
182 TestingInputConfiguration(std::shared_ptr<mi::EventFilter> const& filter,
183 std::shared_ptr<mg::ViewableArea> const& view_area,
184 std::shared_ptr<mi::CursorListener> const& cursor_listener)
185 : FakeEventHubInputConfiguration({}, view_area, cursor_listener),
186 dispatcher_policy(new MockDispatcherPolicy(filter))
187 {
188 }
189 droidinput::sp<droidinput::InputDispatcherPolicyInterface> the_dispatcher_policy()
190 {
191 return dispatcher_policy;
192 }
193 droidinput::sp<MockDispatcherPolicy> the_mock_dispatcher_policy()
194 {
195 return dispatcher_policy;
196 }
197
198 droidinput::sp<MockDispatcherPolicy> dispatcher_policy;
199};
200
201struct AndroidInputManagerDispatcherInterceptSetup : public testing::Test
202{
203 AndroidInputManagerDispatcherInterceptSetup()
204 {
205 configuration = std::make_shared<TestingInputConfiguration>(
206 mt::fake_shared(event_filter),
207 mt::fake_shared(viewable_area), null_cursor_listener);
208 fake_event_hub = configuration->the_fake_event_hub();
209
210 ON_CALL(viewable_area, view_area())
211 .WillByDefault(Return(default_view_area));
212 input_manager = std::make_shared<mia::InputManager>(configuration);
213
214 dispatcher_policy = configuration->the_mock_dispatcher_policy();
215
216 }
217
218 // TODO: It would be nice if it were possible to mock the interface between
219 // droidinput::InputChannel and droidinput::InputDispatcher rather than use
220 // valid fds to allow non-throwing construction of a real input channel.
221 void SetUp()
222 {
223 test_input_fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
224 input_manager->start();
225 }
226 void TearDown()
227 {
228 input_manager->stop();
229 close(test_input_fd);
230 }
231
232 MockEventFilter event_filter;
233 NiceMock<mtd::MockViewableArea> viewable_area;
234 std::shared_ptr<TestingInputConfiguration> configuration;
235 mia::FakeEventHub* fake_event_hub;
236 droidinput::sp<MockDispatcherPolicy> dispatcher_policy;
237
238 std::shared_ptr<mia::InputManager> input_manager;
239
240 int test_input_fd;
241};
242
243MATCHER_P(WindowHandleWithInputFd, input_fd, "")
244{
245 if (arg->getInputChannel()->getFd() == input_fd)
246 return true;
247 return false;
248}
249
250}
251
252TEST_F(AndroidInputManagerDispatcherInterceptSetup, server_input_fd_of_focused_surface_is_sent_unfiltered_key_events)
253{
254 using namespace ::testing;
255
256 WaitCondition wait_condition;
257
258 mtd::StubSessionTarget session;
259 mtd::StubSurfaceTarget surface(test_input_fd);
260
261 EXPECT_CALL(event_filter, handles(_)).Times(1).WillOnce(Return(false));
262 // We return -1 here to skip publishing of the event (to an unconnected test socket!).
263 EXPECT_CALL(*dispatcher_policy, interceptKeyBeforeDispatching(WindowHandleWithInputFd(test_input_fd), _, _))
264 .Times(1).WillOnce(DoAll(WakeUp(&wait_condition), Return(-1)));
265
266 input_manager->set_input_focus_to(mt::fake_shared(session), mt::fake_shared(surface));
267
268 fake_event_hub->synthesize_builtin_keyboard_added();
269 fake_event_hub->synthesize_device_scan_complete();
270 fake_event_hub->synthesize_event(mis::a_key_down_event()
271 .of_scancode(KEY_ENTER));
272
273 wait_condition.wait_for_at_most_seconds(1);
274}
157275
=== added directory 'tests/integration-tests/shell'
=== added file 'tests/integration-tests/shell/CMakeLists.txt'
--- tests/integration-tests/shell/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/integration-tests/shell/CMakeLists.txt 2013-03-22 17:46:22 +0000
@@ -0,0 +1,9 @@
1list(
2 APPEND INTEGRATION_TESTS_SRCS
3 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_manager.cpp
4)
5
6set(
7 INTEGRATION_TESTS_SRCS
8 ${INTEGRATION_TESTS_SRCS}
9 PARENT_SCOPE)
010
=== renamed file 'tests/integration-tests/frontend/test_session_manager.cpp' => 'tests/integration-tests/shell/test_session_manager.cpp'
--- tests/integration-tests/frontend/test_session_manager.cpp 2013-03-21 03:32:59 +0000
+++ tests/integration-tests/shell/test_session_manager.cpp 2013-03-22 17:46:22 +0000
@@ -17,13 +17,14 @@
17 */17 */
1818
19#include "mir/shell/session_manager.h"19#include "mir/shell/session_manager.h"
20#include "mir/shell/session.h"
21#include "mir/shell/focus_sequence.h"
22#include "mir/shell/focus_setter.h"
23#include "mir/shell/registration_order_focus_sequence.h"
24#include "mir/shell/session_container.h"
20#include "mir/surfaces/buffer_bundle.h"25#include "mir/surfaces/buffer_bundle.h"
21#include "mir/surfaces/surface.h"26#include "mir/surfaces/surface.h"
22#include "mir/compositor/buffer_swapper.h"27#include "mir/compositor/buffer_swapper.h"
23#include "mir/shell/focus_sequence.h"
24#include "mir/shell/focus_setter.h"
25#include "mir/shell/registration_order_focus_sequence.h"
26#include "mir/frontend/session_container.h"
27#include "mir/frontend/surface_creation_parameters.h"28#include "mir/frontend/surface_creation_parameters.h"
2829
29#include <gmock/gmock.h>30#include <gmock/gmock.h>
@@ -31,6 +32,7 @@
31#include "mir_test/gmock_fixes.h"32#include "mir_test/gmock_fixes.h"
32#include "mir_test/fake_shared.h"33#include "mir_test/fake_shared.h"
33#include "mir_test_doubles/mock_surface_factory.h"34#include "mir_test_doubles/mock_surface_factory.h"
35#include "mir_test_doubles/mock_focus_setter.h"
3436
35namespace mc = mir::compositor;37namespace mc = mir::compositor;
36namespace mf = mir::frontend;38namespace mf = mir::frontend;
@@ -39,23 +41,13 @@
39namespace mt = mir::test;41namespace mt = mir::test;
40namespace mtd = mir::test::doubles;42namespace mtd = mir::test::doubles;
4143
42namespace
43{
44
45struct MockFocusSetter: public msh::FocusSetter
46{
47 MOCK_METHOD1(set_focus_to, void(std::shared_ptr<mf::Session> const&));
48};
49
50}
51
52TEST(TestSessionManagerAndFocusSelectionStrategy, cycle_focus)44TEST(TestSessionManagerAndFocusSelectionStrategy, cycle_focus)
53{45{
54 using namespace ::testing;46 using namespace ::testing;
55 mtd::MockSurfaceFactory surface_factory;47 mtd::MockSurfaceFactory surface_factory;
56 std::shared_ptr<msh::SessionContainer> container(new msh::SessionContainer());48 std::shared_ptr<msh::SessionContainer> container(new msh::SessionContainer());
57 msh::RegistrationOrderFocusSequence sequence(container);49 msh::RegistrationOrderFocusSequence sequence(container);
58 MockFocusSetter focus_changer;50 mtd::MockFocusSetter focus_changer;
59 std::shared_ptr<mf::Session> new_session;51 std::shared_ptr<mf::Session> new_session;
6052
61 msh::SessionManager session_manager(53 msh::SessionManager session_manager(
@@ -72,9 +64,9 @@
7264
73 {65 {
74 InSequence seq;66 InSequence seq;
75 EXPECT_CALL(focus_changer, set_focus_to(session1)).Times(1);67 EXPECT_CALL(focus_changer, set_focus_to(Eq(session1))).Times(1);
76 EXPECT_CALL(focus_changer, set_focus_to(session2)).Times(1);68 EXPECT_CALL(focus_changer, set_focus_to(Eq(session2))).Times(1);
77 EXPECT_CALL(focus_changer, set_focus_to(session3)).Times(1);69 EXPECT_CALL(focus_changer, set_focus_to(Eq(session3))).Times(1);
78 }70 }
7971
80 session_manager.focus_next();72 session_manager.focus_next();
@@ -88,7 +80,7 @@
88 mtd::MockSurfaceFactory surface_factory;80 mtd::MockSurfaceFactory surface_factory;
89 std::shared_ptr<msh::SessionContainer> model(new msh::SessionContainer());81 std::shared_ptr<msh::SessionContainer> model(new msh::SessionContainer());
90 msh::RegistrationOrderFocusSequence sequence(model);82 msh::RegistrationOrderFocusSequence sequence(model);
91 MockFocusSetter focus_changer;83 mtd::MockFocusSetter focus_changer;
92 std::shared_ptr<mf::Session> new_session;84 std::shared_ptr<mf::Session> new_session;
9385
94 msh::SessionManager session_manager(86 msh::SessionManager session_manager(
@@ -105,8 +97,8 @@
10597
106 {98 {
107 InSequence seq;99 InSequence seq;
108 EXPECT_CALL(focus_changer, set_focus_to(session2)).Times(1);100 EXPECT_CALL(focus_changer, set_focus_to(Eq(session2))).Times(1);
109 EXPECT_CALL(focus_changer, set_focus_to(session1)).Times(1);101 EXPECT_CALL(focus_changer, set_focus_to(Eq(session1))).Times(1);
110 }102 }
111103
112 session_manager.close_session(session3);104 session_manager.close_session(session3);
113105
=== modified file 'tests/mir_test_doubles/fake_event_hub.cpp'
--- tests/mir_test_doubles/fake_event_hub.cpp 2013-01-11 23:47:40 +0000
+++ tests/mir_test_doubles/fake_event_hub.cpp 2013-03-22 17:46:22 +0000
@@ -2,6 +2,7 @@
22
3#include <androidfw/Keyboard.h>3#include <androidfw/Keyboard.h>
4#include <thread> 4#include <thread>
5#include <chrono>
56
6using droidinput::AxisInfo;7using droidinput::AxisInfo;
7using droidinput::InputDeviceIdentifier;8using droidinput::InputDeviceIdentifier;
@@ -300,7 +301,7 @@
300void mia::FakeEventHub::synthesize_event(const mis::KeyParameters &parameters)301void mia::FakeEventHub::synthesize_event(const mis::KeyParameters &parameters)
301{302{
302 RawEvent event;303 RawEvent event;
303 event.when = 0;304 event.when = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
304 event.type = EV_KEY;305 event.type = EV_KEY;
305 event.code = parameters.scancode;306 event.code = parameters.scancode;
306307
@@ -321,7 +322,7 @@
321void mia::FakeEventHub::synthesize_event(const mis::ButtonParameters &parameters)322void mia::FakeEventHub::synthesize_event(const mis::ButtonParameters &parameters)
322{323{
323 RawEvent event;324 RawEvent event;
324 event.when = 0;325 event.when = 0; // TODO: This may need a timestamp to go over the wire ~racarr
325 event.type = EV_KEY;326 event.type = EV_KEY;
326 event.code = parameters.button;327 event.code = parameters.button;
327328
328329
=== modified file 'tests/mir_test_framework/testing_server_options.cpp'
--- tests/mir_test_framework/testing_server_options.cpp 2013-03-21 03:32:59 +0000
+++ tests/mir_test_framework/testing_server_options.cpp 2013-03-22 17:46:22 +0000
@@ -41,6 +41,7 @@
41namespace mc = mir::compositor;41namespace mc = mir::compositor;
42namespace mg = mir::graphics;42namespace mg = mir::graphics;
43namespace mi = mir::input;43namespace mi = mir::input;
44namespace mf = mir::frontend;
44namespace mtf = mir_test_framework;45namespace mtf = mir_test_framework;
45namespace mtd = mir::test::doubles;46namespace mtd = mir::test::doubles;
4647
@@ -139,6 +140,10 @@
139 {140 {
140 return std::make_shared<StubInputChannel>();141 return std::make_shared<StubInputChannel>();
141 }142 }
143
144 void set_input_focus_to(std::shared_ptr<mi::SessionTarget> const& /* session */, std::shared_ptr<mi::SurfaceTarget> const& /* surface */)
145 {
146 }
142};147};
143}148}
144149
145150
=== modified file 'tests/unit-tests/input/android/CMakeLists.txt'
--- tests/unit-tests/input/android/CMakeLists.txt 2013-03-21 03:32:59 +0000
+++ tests/unit-tests/input/android/CMakeLists.txt 2013-03-22 17:46:22 +0000
@@ -6,6 +6,8 @@
6 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_reader_policy.cpp6 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_reader_policy.cpp
7 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_manager.cpp7 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_manager.cpp
8 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_communication_package.cpp8 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_communication_package.cpp
9 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_application_handle.cpp
10 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_window_handle.cpp
9)11)
1012
11set(13set(
1214
=== added file 'tests/unit-tests/input/android/test_android_input_application_handle.cpp'
--- tests/unit-tests/input/android/test_android_input_application_handle.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit-tests/input/android/test_android_input_application_handle.cpp 2013-03-22 17:46:22 +0000
@@ -0,0 +1,58 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "src/server/input/android/android_input_application_handle.h"
20
21#include "mir/input/session_target.h"
22
23#include "mir_test/fake_shared.h"
24
25#include <gtest/gtest.h>
26#include <gmock/gmock.h>
27
28#include <limits.h>
29
30namespace mi = mir::input;
31namespace mia = mi::android;
32namespace mt = mir::test;
33
34namespace
35{
36struct MockSessionHandle : public mi::SessionTarget
37{
38 MOCK_CONST_METHOD0(name, std::string());
39};
40}
41
42
43TEST(AndroidInputApplicationHandle, takes_name_from_session_and_specifies_max_timeout)
44{
45 using namespace ::testing;
46 std::string const testing_session_name = "Cats";
47 MockSessionHandle session;
48
49 EXPECT_CALL(session, name()).Times(AtLeast(1))
50 .WillRepeatedly(Return(testing_session_name));
51 mia::InputApplicationHandle application_handle(mt::fake_shared(session));
52 EXPECT_TRUE(application_handle.updateInfo());
53 auto info = application_handle.getInfo();
54 EXPECT_EQ(INT_MAX, info->dispatchingTimeout);
55 EXPECT_EQ(droidinput::String8(testing_session_name.c_str()), info->name);
56}
57
58
059
=== modified file 'tests/unit-tests/input/android/test_android_input_manager.cpp'
--- tests/unit-tests/input/android/test_android_input_manager.cpp 2013-03-21 03:32:59 +0000
+++ tests/unit-tests/input/android/test_android_input_manager.cpp 2013-03-22 17:46:22 +0000
@@ -22,9 +22,13 @@
22#include "src/server/input/android/android_input_constants.h"22#include "src/server/input/android/android_input_constants.h"
2323
24#include "mir/input/input_channel.h"24#include "mir/input/input_channel.h"
25#include "mir/input/session_target.h"
26#include "mir/input/surface_target.h"
2527
28#include "mir_test/fake_shared.h"
26#include "mir_test_doubles/mock_viewable_area.h"29#include "mir_test_doubles/mock_viewable_area.h"
27#include "mir_test/fake_shared.h"30#include "mir_test_doubles/stub_session_target.h"
31#include "mir_test_doubles/stub_surface_target.h"
2832
29#include <InputDispatcher.h>33#include <InputDispatcher.h>
30#include <InputListener.h>34#include <InputListener.h>
@@ -126,7 +130,7 @@
126130
127struct AndroidInputManagerSetup : public testing::Test131struct AndroidInputManagerSetup : public testing::Test
128{132{
129 void SetUp()133 AndroidInputManagerSetup()
130 {134 {
131 using namespace ::testing;135 using namespace ::testing;
132136
@@ -207,3 +211,91 @@
207 EXPECT_GT(package->client_fd(), 0);211 EXPECT_GT(package->client_fd(), 0);
208 EXPECT_GT(package->server_fd(), 0);212 EXPECT_GT(package->server_fd(), 0);
209}213}
214
215namespace
216{
217
218static bool
219application_handle_matches_session(droidinput::sp<droidinput::InputApplicationHandle> const& handle,
220 std::shared_ptr<mi::SessionTarget> const& session)
221{
222 if (handle->getName() != droidinput::String8(session->name().c_str()))
223 return false;
224 return true;
225}
226
227static bool
228window_handle_matches_session_and_surface(droidinput::sp<droidinput::InputWindowHandle> const& handle,
229 std::shared_ptr<mi::SessionTarget> const& session,
230 std::shared_ptr<mi::SurfaceTarget> const& surface)
231{
232 if (!application_handle_matches_session(handle->inputApplicationHandle, session))
233 return false;
234 if (handle->getInputChannel()->getFd() != surface->server_input_fd())
235 return false;
236 return true;
237}
238
239MATCHER_P2(WindowHandleFor, session, surface, "")
240{
241 return window_handle_matches_session_and_surface(arg, session, surface);
242}
243
244MATCHER_P(ApplicationHandleFor, session, "")
245{
246 return application_handle_matches_session(arg, session);
247}
248
249MATCHER_P2(VectorContainingWindowHandleFor, session, surface, "")
250{
251 auto i = arg.size();
252 for (i = 0; i < arg.size(); i++)
253 {
254 if (window_handle_matches_session_and_surface(arg[i], session, surface))
255 return true;
256 }
257 return false;
258}
259
260MATCHER(EmptyVector, "")
261{
262 return arg.size() == 0;
263}
264
265// TODO: It would be nice if it were possible to mock the interface between
266// droidinput::InputChannel and droidinput::InputDispatcher rather than use
267// valid fds to allow non-throwing construction of a real input channel.
268struct AndroidInputManagerFdSetup : public AndroidInputManagerSetup
269{
270 void SetUp() override
271 {
272 test_input_fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
273 }
274 void TearDown() override
275 {
276 close(test_input_fd);
277 }
278 int test_input_fd;
279};
280
281}
282
283TEST_F(AndroidInputManagerFdSetup, set_input_focus)
284{
285 using namespace ::testing;
286
287 auto session = std::make_shared<mtd::StubSessionTarget>();
288 auto surface = std::make_shared<mtd::StubSurfaceTarget>(test_input_fd);
289
290 EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(session, surface), false)).Times(1)
291 .WillOnce(Return(droidinput::OK));
292 EXPECT_CALL(*dispatcher, setFocusedApplication(ApplicationHandleFor(session))).Times(1);
293 EXPECT_CALL(*dispatcher, setInputWindows(VectorContainingWindowHandleFor(session, surface))).Times(1);
294 EXPECT_CALL(*dispatcher, unregisterInputChannel(_)).Times(1);
295 EXPECT_CALL(*dispatcher, setInputWindows(EmptyVector())).Times(1);
296
297 mia::InputManager manager(mt::fake_shared(config));
298
299 manager.set_input_focus_to(session, surface);
300 manager.set_input_focus_to(session, std::shared_ptr<mi::SurfaceTarget>());
301}
210302
=== added file 'tests/unit-tests/input/android/test_android_input_window_handle.cpp'
--- tests/unit-tests/input/android/test_android_input_window_handle.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit-tests/input/android/test_android_input_window_handle.cpp 2013-03-22 17:46:22 +0000
@@ -0,0 +1,89 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "src/server/input/android/android_input_window_handle.h"
20
21#include "mir/frontend/surface.h"
22#include "mir/geometry/size.h"
23#include "mir/input/input_channel.h"
24#include "mir/input/surface_target.h"
25
26#include "mir_test/fake_shared.h"
27#include "mir_test_doubles/mock_surface.h"
28#include "mir_test_doubles/stub_surface_builder.h"
29
30#include <gtest/gtest.h>
31#include <gmock/gmock.h>
32
33namespace mc = mir::compositor;
34namespace mi = mir::input;
35namespace mia = mi::android;
36namespace mf = mir::frontend;
37namespace geom = mir::geometry;
38namespace mt = mir::test;
39namespace mtd = mt::doubles;
40
41namespace
42{
43
44struct StubInputApplicationHandle : public droidinput::InputApplicationHandle
45{
46 bool updateInfo() { return true; }
47};
48
49struct MockSurfaceTarget : public mi::SurfaceTarget
50{
51 MOCK_CONST_METHOD0(server_input_fd, int());
52 MOCK_CONST_METHOD0(size, geom::Size());
53 MOCK_CONST_METHOD0(name, std::string());
54};
55
56}
57
58TEST(AndroidInputWindowHandle, update_info_uses_geometry_and_channel_from_surface)
59{
60 using namespace ::testing;
61
62 geom::Size const default_surface_size = geom::Size{geom::Width{256},
63 geom::Height{256}};
64 std::string const testing_surface_name = "Test";
65 int const testing_server_fd = 2;
66
67 MockSurfaceTarget surface;
68
69 EXPECT_CALL(surface, server_input_fd()).Times(1)
70 .WillOnce(Return(testing_server_fd));
71 // For now since we are just doing keyboard input we only need surface size,
72 // for touch/pointer events we will need a position
73 EXPECT_CALL(surface, size()).Times(1)
74 .WillOnce(Return(default_surface_size));
75 EXPECT_CALL(surface, name()).Times(1)
76 .WillOnce(Return(testing_surface_name));
77
78 mia::InputWindowHandle handle(new StubInputApplicationHandle(),
79 mt::fake_shared(surface));
80
81 auto info = handle.getInfo();
82
83 EXPECT_EQ(testing_surface_name, info->name);
84
85 EXPECT_EQ(testing_server_fd, info->inputChannel->getFd());
86
87 EXPECT_EQ(default_surface_size.height.as_uint32_t(), (uint32_t)(info->frameRight - info->frameLeft));
88 EXPECT_EQ(default_surface_size.height.as_uint32_t(), (uint32_t)(info->frameBottom - info->frameTop));
89}
090
=== modified file 'tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp'
--- tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp 2013-03-13 08:09:52 +0000
+++ tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp 2013-03-22 17:46:22 +0000
@@ -44,7 +44,9 @@
4444
45 // The policy filters ALL key events before queuing45 // The policy filters ALL key events before queuing
46 policy.interceptKeyBeforeQueueing(&ev, policy_flags);46 policy.interceptKeyBeforeQueueing(&ev, policy_flags);
47 EXPECT_EQ(policy_flags, droidinput::POLICY_FLAG_FILTERED);47
48 // If the event is unfiltered we will allow it to pass to applications
49 EXPECT_TRUE(policy_flags & droidinput::POLICY_FLAG_PASS_TO_USER);
4850
49 // Android uses alternate notation...the policy returns true if the event was NOT handled (e.g. the EventFilter51 // Android uses alternate notation...the policy returns true if the event was NOT handled (e.g. the EventFilter
50 // returns false)52 // returns false)
5153
=== modified file 'tests/unit-tests/shell/test_application_session.cpp'
--- tests/unit-tests/shell/test_application_session.cpp 2013-03-21 03:32:59 +0000
+++ tests/unit-tests/shell/test_application_session.cpp 2013-03-22 17:46:22 +0000
@@ -23,6 +23,7 @@
23#include "mir_test_doubles/mock_surface_factory.h"23#include "mir_test_doubles/mock_surface_factory.h"
24#include "mir_test_doubles/mock_surface.h"24#include "mir_test_doubles/mock_surface.h"
25#include "mir_test_doubles/stub_surface_builder.h"25#include "mir_test_doubles/stub_surface_builder.h"
26#include "mir_test_doubles/stub_surface.h"
2627
27#include "src/server/shell/surface.h"28#include "src/server/shell/surface.h"
2829
@@ -58,6 +59,41 @@
58 session.destroy_surface(surf);59 session.destroy_surface(surf);
59}60}
6061
62TEST(ApplicationSession, default_surface_is_first_surface)
63{
64 using namespace ::testing;
65
66 mtd::MockSurfaceFactory surface_factory;
67 mtd::StubSurfaceBuilder surface_builder;
68 {
69 InSequence seq;
70 EXPECT_CALL(surface_factory, create_surface(_)).Times(1)
71 .WillOnce(Return(std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder))));
72 EXPECT_CALL(surface_factory, create_surface(_)).Times(1)
73 .WillOnce(Return(std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder))));
74 EXPECT_CALL(surface_factory, create_surface(_)).Times(1)
75 .WillOnce(Return(std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder))));
76 }
77
78 msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo");
79
80 mf::SurfaceCreationParameters params;
81 auto id1 = app_session.create_surface(params);
82 auto id2 = app_session.create_surface(params);
83 auto id3 = app_session.create_surface(params);
84
85 auto default_surf = app_session.default_surface();
86 EXPECT_EQ(app_session.get_surface(id1), default_surf);
87 app_session.destroy_surface(id1);
88
89 default_surf = app_session.default_surface();
90 EXPECT_EQ(app_session.get_surface(id2), default_surf);
91 app_session.destroy_surface(id2);
92
93 default_surf = app_session.default_surface();
94 EXPECT_EQ(app_session.get_surface(id3), default_surf);
95 app_session.destroy_surface(id3);
96}
6197
62TEST(ApplicationSession, session_visbility_propagates_to_surfaces)98TEST(ApplicationSession, session_visbility_propagates_to_surfaces)
63{99{
64100
=== modified file 'tests/unit-tests/shell/test_registration_order_focus_sequence.cpp'
--- tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-03-21 03:32:59 +0000
+++ tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-03-22 17:46:22 +0000
@@ -18,7 +18,7 @@
1818
19#include "mir/surfaces/buffer_bundle.h"19#include "mir/surfaces/buffer_bundle.h"
20#include "mir/shell/application_session.h"20#include "mir/shell/application_session.h"
21#include "mir/frontend/session_container.h"21#include "mir/shell/session_container.h"
22#include "mir/shell/registration_order_focus_sequence.h"22#include "mir/shell/registration_order_focus_sequence.h"
23#include "mir/frontend/surface_creation_parameters.h"23#include "mir/frontend/surface_creation_parameters.h"
24#include "mir/surfaces/surface.h"24#include "mir/surfaces/surface.h"
2525
=== modified file 'tests/unit-tests/shell/test_session_manager.cpp'
--- tests/unit-tests/shell/test_session_manager.cpp 2013-03-21 03:32:59 +0000
+++ tests/unit-tests/shell/test_session_manager.cpp 2013-03-22 17:46:22 +0000
@@ -17,11 +17,12 @@
17 */17 */
1818
19#include "mir/surfaces/buffer_bundle.h"19#include "mir/surfaces/buffer_bundle.h"
20#include "mir/shell/focus_sequence.h"
20#include "mir/shell/session_manager.h"21#include "mir/shell/session_manager.h"
21#include "mir/frontend/session_container.h"22#include "mir/shell/session_container.h"
23#include "mir/shell/session.h"
22#include "mir/frontend/session.h"24#include "mir/frontend/session.h"
23#include "mir/frontend/surface_creation_parameters.h"25#include "mir/frontend/surface_creation_parameters.h"
24#include "mir/shell/focus_sequence.h"
25#include "mir/surfaces/surface.h"26#include "mir/surfaces/surface.h"
26#include "mir/input/input_channel.h"27#include "mir/input/input_channel.h"
27#include "mir_test_doubles/mock_buffer_bundle.h"28#include "mir_test_doubles/mock_buffer_bundle.h"
@@ -90,7 +91,7 @@
90 EXPECT_CALL(container, insert_session(_)).Times(1);91 EXPECT_CALL(container, insert_session(_)).Times(1);
91 EXPECT_CALL(container, remove_session(_)).Times(1);92 EXPECT_CALL(container, remove_session(_)).Times(1);
92 EXPECT_CALL(focus_setter, set_focus_to(_));93 EXPECT_CALL(focus_setter, set_focus_to(_));
93 EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<mf::Session>())).Times(1);94 EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1);
9495
95 EXPECT_CALL(sequence, default_focus()).WillOnce(Return((std::shared_ptr<mf::Session>())));96 EXPECT_CALL(sequence, default_focus()).WillOnce(Return((std::shared_ptr<mf::Session>())));
9697
@@ -115,7 +116,7 @@
115 EXPECT_CALL(container, remove_session(_)).Times(1);116 EXPECT_CALL(container, remove_session(_)).Times(1);
116117
117 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1);118 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1);
118 EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<mf::Session>())).Times(1);119 EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1);
119120
120 EXPECT_CALL(sequence, default_focus()).WillOnce(Return((std::shared_ptr<mf::Session>())));121 EXPECT_CALL(sequence, default_focus()).WillOnce(Return((std::shared_ptr<mf::Session>())));
121122
@@ -146,7 +147,7 @@
146147
147 session_manager.tag_session_with_lightdm_id(session1, 1);148 session_manager.tag_session_with_lightdm_id(session1, 1);
148149
149 EXPECT_CALL(focus_setter, set_focus_to(session1));150 EXPECT_CALL(focus_setter, set_focus_to(Eq(session1)));
150 session_manager.focus_session_with_lightdm_id(1);151 session_manager.focus_session_with_lightdm_id(1);
151}152}
152153
@@ -161,7 +162,7 @@
161 session_manager.focus_session_with_lightdm_id(1);162 session_manager.focus_session_with_lightdm_id(1);
162163
163 EXPECT_CALL(sequence, default_focus()).WillOnce(Return(session2));164 EXPECT_CALL(sequence, default_focus()).WillOnce(Return(session2));
164 EXPECT_CALL(focus_setter, set_focus_to(session2));165 EXPECT_CALL(focus_setter, set_focus_to(Eq(session2)));
165166
166 session_manager.close_session(session1);167 session_manager.close_session(session1);
167}168}
168169
=== modified file 'tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp'
--- tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-03-21 03:32:59 +0000
+++ tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-03-22 17:46:22 +0000
@@ -18,15 +18,19 @@
1818
19#include "mir/surfaces/buffer_bundle.h"19#include "mir/surfaces/buffer_bundle.h"
20#include "mir/shell/application_session.h"20#include "mir/shell/application_session.h"
21#include "mir/frontend/session_container.h"21#include "mir/shell/session_container.h"
22#include "mir/shell/registration_order_focus_sequence.h"22#include "mir/shell/registration_order_focus_sequence.h"
23#include "mir/shell/single_visibility_focus_mechanism.h"23#include "mir/shell/single_visibility_focus_mechanism.h"
24#include "mir/shell/session.h"
24#include "mir/frontend/surface_creation_parameters.h"25#include "mir/frontend/surface_creation_parameters.h"
25#include "mir/surfaces/surface.h"26#include "mir/surfaces/surface.h"
26#include "mir_test_doubles/mock_buffer_bundle.h"27#include "mir_test_doubles/mock_buffer_bundle.h"
27#include "mir_test/fake_shared.h"28#include "mir_test/fake_shared.h"
28#include "mir_test_doubles/mock_surface_factory.h"29#include "mir_test_doubles/mock_surface_factory.h"
29#include "mir_test_doubles/mock_session.h"30#include "mir_test_doubles/mock_input_focus_selector.h"
31#include "mir_test_doubles/stub_surface.h"
32#include "mir_test_doubles/mock_surface.h"
33#include "mir_test_doubles/stub_surface_builder.h"
3034
31#include <gmock/gmock.h>35#include <gmock/gmock.h>
32#include <gtest/gtest.h>36#include <gtest/gtest.h>
@@ -35,19 +39,41 @@
35namespace mc = mir::compositor;39namespace mc = mir::compositor;
36namespace msh = mir::shell;40namespace msh = mir::shell;
37namespace ms = mir::surfaces;41namespace ms = mir::surfaces;
42namespace mf = mir::frontend;
38namespace mt = mir::test;43namespace mt = mir::test;
39namespace mtd = mir::test::doubles;44namespace mtd = mir::test::doubles;
4045
46struct MockShellSession : public msh::Session
47{
48 MOCK_METHOD1(create_surface, mf::SurfaceId(mf::SurfaceCreationParameters const&));
49 MOCK_METHOD1(destroy_surface, void(mf::SurfaceId));
50 MOCK_CONST_METHOD1(get_surface, std::shared_ptr<mf::Surface>(mf::SurfaceId));
51
52 MOCK_CONST_METHOD0(default_surface, std::shared_ptr<msh::Surface>());
53
54 MOCK_CONST_METHOD0(name, std::string());
55 MOCK_METHOD0(shutdown, void());
56
57 MOCK_METHOD0(hide, void());
58 MOCK_METHOD0(show, void());
59
60 MOCK_METHOD3(configure_surface, int(mf::SurfaceId, MirSurfaceAttrib, int));
61};
62
41TEST(SingleVisibilityFocusMechanism, mechanism_sets_visibility)63TEST(SingleVisibilityFocusMechanism, mechanism_sets_visibility)
42{64{
43 using namespace ::testing;65 using namespace ::testing;
4466
45 mtd::MockSession app1;67 NiceMock<mtd::MockInputFocusSelector> input_focus_selector;
46 mtd::MockSession app2;
47 mtd::MockSession app3;
4868
69 MockShellSession app1, app2, app3;
49 msh::SessionContainer model;70 msh::SessionContainer model;
50 msh::SingleVisibilityFocusMechanism focus_mechanism(mt::fake_shared(model));71
72 ON_CALL(app1, default_surface()).WillByDefault(Return(std::shared_ptr<msh::Surface>()));
73 ON_CALL(app2, default_surface()).WillByDefault(Return(std::shared_ptr<msh::Surface>()));
74 ON_CALL(app3, default_surface()).WillByDefault(Return(std::shared_ptr<msh::Surface>()));
75
76 msh::SingleVisibilityFocusMechanism focus_mechanism(mt::fake_shared(model), mt::fake_shared(input_focus_selector));
5177
52 EXPECT_CALL(app1, show()).Times(1);78 EXPECT_CALL(app1, show()).Times(1);
53 EXPECT_CALL(app2, hide()).Times(1);79 EXPECT_CALL(app2, hide()).Times(1);
@@ -60,3 +86,22 @@
60 focus_mechanism.set_focus_to(mt::fake_shared(app1));86 focus_mechanism.set_focus_to(mt::fake_shared(app1));
61}87}
6288
89TEST(SingleVisibilityFocusMechanism, mechanism_sets_input_focus_from_default_surface)
90{
91 using namespace ::testing;
92
93 mtd::MockInputFocusSelector input_focus_selector;
94 msh::SessionContainer model;
95 auto session = std::make_shared<MockShellSession>();
96 auto surface = std::make_shared<mtd::MockSurface>(std::make_shared<mtd::StubSurfaceBuilder>());
97
98 msh::SingleVisibilityFocusMechanism focus_mechanism(mt::fake_shared(model), mt::fake_shared(input_focus_selector));
99
100 EXPECT_CALL(*session, default_surface()).Times(1).WillOnce(Return(surface));
101
102 EXPECT_CALL(input_focus_selector, set_input_focus_to(Eq(session), Eq(surface))).Times(1);
103
104 model.insert_session(session);
105 focus_mechanism.set_focus_to(session);
106}
107
63108
=== modified file 'tests/unit-tests/shell/test_surface.cpp'
--- tests/unit-tests/shell/test_surface.cpp 2013-03-21 03:55:40 +0000
+++ tests/unit-tests/shell/test_surface.cpp 2013-03-22 17:46:22 +0000
@@ -178,6 +178,24 @@
178 }, std::runtime_error);178 }, std::runtime_error);
179}179}
180180
181TEST_F(ShellSurface, name_throw_behavior)
182{
183 msh::Surface test(
184 mt::fake_shared(surface_builder),
185 mf::a_surface(),
186 null_input_channel);
187
188 EXPECT_NO_THROW({
189 test.name();
190 });
191
192 surface_builder.reset_surface();
193
194 EXPECT_THROW({
195 test.name();
196 }, std::runtime_error);
197}
198
181TEST_F(ShellSurface, pixel_format_throw_behavior)199TEST_F(ShellSurface, pixel_format_throw_behavior)
182{200{
183 msh::Surface test(201 msh::Surface test(
184202
=== modified file 'tests/unit-tests/shell/test_the_session_container_implementation.cpp'
--- tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-03-21 03:32:59 +0000
+++ tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-03-22 17:46:22 +0000
@@ -18,7 +18,7 @@
1818
19#include "mir/surfaces/buffer_bundle.h"19#include "mir/surfaces/buffer_bundle.h"
20#include "mir/shell/application_session.h"20#include "mir/shell/application_session.h"
21#include "mir/frontend/session_container.h"21#include "mir/shell/session_container.h"
22#include "mir/frontend/surface_creation_parameters.h"22#include "mir/frontend/surface_creation_parameters.h"
23#include "mir/surfaces/surface.h"23#include "mir/surfaces/surface.h"
24#include "mir_test_doubles/mock_buffer_bundle.h"24#include "mir_test_doubles/mock_buffer_bundle.h"

Subscribers

People subscribed via source and target branches