Merge lp:~andreas-pokorny/mir/use-input-channel-to-send-input into lp:mir
- use-input-channel-to-send-input
- Merge into development-branch
Status: | Rejected |
---|---|
Rejected by: | Andreas Pokorny |
Proposed branch: | lp:~andreas-pokorny/mir/use-input-channel-to-send-input |
Merge into: | lp:mir |
Diff against target: |
378 lines (+181/-18) 9 files modified
include/server/mir/input/input_channel.h (+4/-1) include/test/mir_test_doubles/stub_input_channel.h (+3/-0) src/server/input/android/android_input_channel.cpp (+100/-2) src/server/input/android/android_input_channel.h (+10/-3) src/server/input/android/android_input_window_handle.cpp (+11/-3) tests/acceptance-tests/test_client_input.cpp (+39/-1) tests/mir_test_framework/stubbed_server_configuration.cpp (+12/-8) tests/unit-tests/input/android/test_android_input_window_handle.cpp (+1/-0) tests/unit-tests/scene/test_surface.cpp (+1/-0) |
To merge this branch: | bzr merge lp:~andreas-pokorny/mir/use-input-channel-to-send-input |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel d'Andrada (community) | Needs Fixing | ||
Robert Carr (community) | Needs Fixing | ||
Alan Griffiths | Needs Fixing | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Kevin DuBois (community) | Needs Information | ||
Review via email: mp+215450@code.launchpad.net |
Commit message
Add send_event to InputChannel - to be able to dispatch user input events to the client surfaces.
Description of the change
Adds a method to the InputChannel to send MirEvents to clients. This is necessary to implement a custom InputDispatcher outside of mir - hence without access to the adopted android input stack.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1545
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alan Griffiths (alan-griffiths) wrote : | # |
24 + virtual void send_event(uint32_t seq, MirEvent const& event) const = 0;
Like Kevin says: What is the significance of seq? Why do I need it to send an event?
~~~~
77 +void react_to_
This seems a bad name. Vis:
142 + react_to_
"check_result" is slightly better, "check" possibly better still.
~~~~
90 + channel = new droidinput:
"TODO: Name" is a distracting choice. What is going on here?
Andreas Pokorny (andreas-pokorny) wrote : | # |
Kevin:
> send_event(uint32_t seq, MirEvent)
> as someone calling send_event, how do I arrange seq;
> is a particular sequence needed? Would it be better to have
> AndroidInputChannel manage the sequence if a particular ordering is required?
Alan:
> 24 + virtual void send_event(uint32_t seq, MirEvent const& event) const =
> 0;
>
> Like Kevin says: What is the significance of seq? Why do I need it to send an
> event?
I believe down - motion - up sequences of events need to have the same sequence number. So I suspect AndroidInputChannel could keep track of press / release event occurrences. The sequence number must be unique for some time, as the client has to respond using the sequence number, as a form of ACK to the server.
> ~~~~
>
> 77 +void react_to_
>
> This seems a bad name. Vis:
>
> 142 + react_to_
>
> "check_result" is slightly better, "check" possibly better still.
ack
> ~~~~
>
> 90 + channel = new droidinput:
> Name"), s_fd);
>
> "TODO: Name" is a distracting choice. What is going on here?
just moved the code - I believe we could use the surface name here instead. fixing that.
Robert Carr (robertcarr) wrote : | # |
We talked a little about seq_id on IRC:
< anpok> dandrader: i would keep the current mir::input:
18:52 < anpok> or the thing to dispatch the input too
18:52 < dandrader> anpok, what's wrong with InputChannel?
18:53 < racarr__> one thing is send_event(seq_id, MirEvent) is weird because the caller cant know how to use seq_id really so its weird as a public interface
18:53 < anpok> it has to be non null :) and should not collide with other input sequences
18:54 < anpok> and nobody reads the ACK signals that come back from the input reader..
18:54 < racarr__> indeed but they will
18:54 < anpok> I only discovered that part today
18:54 < dandrader> racarr__, true
18:54 < racarr__> and if it has to be non null and not collide and thats all
18:54 < racarr__> then it should just be hidden inside the object
Robert Carr (robertcarr) wrote : | # |
79 (missing spaces), 143, 166 (wrong indentation), 310 (trailing line):
whitespace.
Definitely use surface named for TODO: Name now...that was an artifact of interface inadequacies long past...sorry for never coming and fixing my own todo ><. Only used for logging (which is redundantly named elsewhere iirc) anyway
Given seq_id cleanup as part of dispatcher split this is basically good to go to unblock qt compositor I think
Daniel d'Andrada (dandrader) wrote : | # |
That's too low level. It's the android:
What is needed is something like a mir::input:
the hood, calls eventually android:
surface-
MirSurfaceItem:
/qpa-mirserver does.
Daniel d'Andrada (dandrader) wrote : | # |
So in the end we will have to go all the way and refactor android:
Making it only shepherd events through android:
Daniel d'Andrada (dandrader) wrote : | # |
> So in the end we will have to go all the way and refactor
> android:
>
> Making it only shepherd events through android:
> its stripped-down version existing in lp:~unity-team/+junk/qpa-mirserver) and
> leaving the responsibility of selecting which input channel gets the input
> event coming out of the android:
> compositor case, the QQuickWindow dispatch logic that selects the qml item
> that will receive incoming input) that receives all input coming out of
> android:
> surface it decides that should receive the event, if any.
Then, that stripped down android:
Unmerged revisions
- 1545. By Andreas Pokorny
-
Add send_event to InputChannel - for sending events to the client fd.
Preview Diff
1 | === modified file 'include/server/mir/input/input_channel.h' | |||
2 | --- include/server/mir/input/input_channel.h 2013-08-28 03:41:48 +0000 | |||
3 | +++ include/server/mir/input/input_channel.h 2014-04-11 16:00:27 +0000 | |||
4 | @@ -1,5 +1,5 @@ | |||
5 | 1 | /* | 1 | /* |
7 | 2 | * Copyright © 2013 Canonical Ltd. | 2 | * Copyright © 2013-2014 Canonical Ltd. |
8 | 3 | * | 3 | * |
9 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
10 | 5 | * under the terms of the GNU General Public License version 3, | 5 | * under the terms of the GNU General Public License version 3, |
11 | @@ -19,6 +19,8 @@ | |||
12 | 19 | #ifndef MIR_INPUT_INPUT_CHANNEL_H_ | 19 | #ifndef MIR_INPUT_INPUT_CHANNEL_H_ |
13 | 20 | #define MIR_INPUT_INPUT_CHANNEL_H_ | 20 | #define MIR_INPUT_INPUT_CHANNEL_H_ |
14 | 21 | 21 | ||
15 | 22 | #include "mir_toolkit/event.h" | ||
16 | 23 | |||
17 | 22 | namespace mir | 24 | namespace mir |
18 | 23 | { | 25 | { |
19 | 24 | namespace input | 26 | namespace input |
20 | @@ -32,6 +34,7 @@ | |||
21 | 32 | 34 | ||
22 | 33 | virtual int client_fd() const = 0; | 35 | virtual int client_fd() const = 0; |
23 | 34 | virtual int server_fd() const = 0; | 36 | virtual int server_fd() const = 0; |
24 | 37 | virtual void send_event(uint32_t seq, MirEvent const& event) const = 0; | ||
25 | 35 | 38 | ||
26 | 36 | protected: | 39 | protected: |
27 | 37 | InputChannel() = default; | 40 | InputChannel() = default; |
28 | 38 | 41 | ||
29 | === modified file 'include/test/mir_test_doubles/stub_input_channel.h' | |||
30 | --- include/test/mir_test_doubles/stub_input_channel.h 2013-08-28 03:41:48 +0000 | |||
31 | +++ include/test/mir_test_doubles/stub_input_channel.h 2014-04-11 16:00:27 +0000 | |||
32 | @@ -48,6 +48,9 @@ | |||
33 | 48 | { | 48 | { |
34 | 49 | return input_fd; | 49 | return input_fd; |
35 | 50 | } | 50 | } |
36 | 51 | void send_event(uint32_t /*seq*/, MirEvent const& /*event*/) const override | ||
37 | 52 | { | ||
38 | 53 | } | ||
39 | 51 | int input_fd; | 54 | int input_fd; |
40 | 52 | }; | 55 | }; |
41 | 53 | 56 | ||
42 | 54 | 57 | ||
43 | === modified file 'src/server/input/android/android_input_channel.cpp' | |||
44 | --- src/server/input/android/android_input_channel.cpp 2014-03-06 06:05:17 +0000 | |||
45 | +++ src/server/input/android/android_input_channel.cpp 2014-04-11 16:00:27 +0000 | |||
46 | @@ -1,5 +1,5 @@ | |||
47 | 1 | /* | 1 | /* |
49 | 2 | * Copyright © 2013 Canonical Ltd. | 2 | * Copyright © 2013-2014 Canonical Ltd. |
50 | 3 | * | 3 | * |
51 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
52 | 5 | * under the terms of the GNU General Public License version 3, | 5 | * under the terms of the GNU General Public License version 3, |
53 | @@ -14,21 +14,44 @@ | |||
54 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
55 | 15 | * | 15 | * |
56 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> |
57 | 17 | * Andreas Pokorny <andreas.pokorny@canonical.com> | ||
58 | 17 | */ | 18 | */ |
59 | 18 | 19 | ||
60 | 19 | #include "android_input_channel.h" | 20 | #include "android_input_channel.h" |
61 | 20 | 21 | ||
62 | 21 | #include <androidfw/InputTransport.h> | 22 | #include <androidfw/InputTransport.h> |
63 | 23 | #include <std/Errors.h> | ||
64 | 24 | |||
65 | 25 | #include <boost/exception/errinfo_errno.hpp> | ||
66 | 26 | #include <boost/throw_exception.hpp> | ||
67 | 27 | |||
68 | 28 | #include <cmath> | ||
69 | 22 | 29 | ||
70 | 23 | #include <unistd.h> | 30 | #include <unistd.h> |
71 | 24 | 31 | ||
72 | 25 | namespace mia = mir::input::android; | 32 | namespace mia = mir::input::android; |
73 | 26 | namespace droidinput = android; | 33 | namespace droidinput = android; |
74 | 27 | 34 | ||
75 | 35 | namespace | ||
76 | 36 | { | ||
77 | 37 | void react_to_result(droidinput::status_t result) | ||
78 | 38 | { | ||
79 | 39 | if (result!=droidinput::OK) | ||
80 | 40 | { | ||
81 | 41 | BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("Failure sending input event ")) << boost::errinfo_errno(result)); | ||
82 | 42 | } | ||
83 | 43 | } | ||
84 | 44 | } | ||
85 | 45 | |||
86 | 28 | mia::AndroidInputChannel::AndroidInputChannel() | 46 | mia::AndroidInputChannel::AndroidInputChannel() |
87 | 29 | { | 47 | { |
88 | 30 | |||
89 | 31 | droidinput::InputChannel::openInputFdPair(s_fd, c_fd); | 48 | droidinput::InputChannel::openInputFdPair(s_fd, c_fd); |
90 | 49 | channel = new droidinput::InputChannel(droidinput::String8("TODO: Name"), s_fd); | ||
91 | 50 | } | ||
92 | 51 | |||
93 | 52 | droidinput::sp<droidinput::InputChannel> mia::AndroidInputChannel::get_android_channel() const | ||
94 | 53 | { | ||
95 | 54 | return channel; | ||
96 | 32 | } | 55 | } |
97 | 33 | 56 | ||
98 | 34 | mia::AndroidInputChannel::~AndroidInputChannel() | 57 | mia::AndroidInputChannel::~AndroidInputChannel() |
99 | @@ -46,3 +69,78 @@ | |||
100 | 46 | { | 69 | { |
101 | 47 | return s_fd; | 70 | return s_fd; |
102 | 48 | } | 71 | } |
103 | 72 | |||
104 | 73 | void mia::AndroidInputChannel::send_event(uint32_t seq, MirEvent const& event) const | ||
105 | 74 | { | ||
106 | 75 | switch(event.type) | ||
107 | 76 | { | ||
108 | 77 | case mir_event_type_key: | ||
109 | 78 | send_key_event(seq, event.key); | ||
110 | 79 | break; | ||
111 | 80 | case mir_event_type_motion: | ||
112 | 81 | send_motion_event(seq, event.motion); | ||
113 | 82 | break; | ||
114 | 83 | default: | ||
115 | 84 | break; | ||
116 | 85 | } | ||
117 | 86 | } | ||
118 | 87 | |||
119 | 88 | void mia::AndroidInputChannel::send_motion_event(uint32_t seq, MirMotionEvent const& event) const | ||
120 | 89 | { | ||
121 | 90 | droidinput::PointerCoords coords[MIR_INPUT_EVENT_MAX_POINTER_COUNT]; | ||
122 | 91 | droidinput::PointerProperties properties[MIR_INPUT_EVENT_MAX_POINTER_COUNT]; | ||
123 | 92 | for (size_t i = 0; i < event.pointer_count; i++) | ||
124 | 93 | { | ||
125 | 94 | // TODO this assumes that: x == raw_x + x_offset; | ||
126 | 95 | // here x,y is used instead of the raw co-ordinates and offset is set to zero | ||
127 | 96 | coords[i].setAxisValue(AMOTION_EVENT_AXIS_X, event.pointer_coordinates[i].x); | ||
128 | 97 | coords[i].setAxisValue(AMOTION_EVENT_AXIS_Y, event.pointer_coordinates[i].y); | ||
129 | 98 | |||
130 | 99 | coords[i].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, event.pointer_coordinates[i].touch_major); | ||
131 | 100 | coords[i].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, event.pointer_coordinates[i].touch_minor); | ||
132 | 101 | coords[i].setAxisValue(AMOTION_EVENT_AXIS_SIZE, event.pointer_coordinates[i].size); | ||
133 | 102 | coords[i].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, event.pointer_coordinates[i].pressure); | ||
134 | 103 | coords[i].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, event.pointer_coordinates[i].orientation); | ||
135 | 104 | coords[i].setAxisValue(AMOTION_EVENT_AXIS_VSCROLL, event.pointer_coordinates[i].vscroll); | ||
136 | 105 | coords[i].setAxisValue(AMOTION_EVENT_AXIS_HSCROLL, event.pointer_coordinates[i].hscroll); | ||
137 | 106 | properties[i].toolType = event.pointer_coordinates[i].tool_type; | ||
138 | 107 | } | ||
139 | 108 | |||
140 | 109 | droidinput::InputPublisher publisher(channel); | ||
141 | 110 | |||
142 | 111 | react_to_result(publisher.publishMotionEvent(seq, | ||
143 | 112 | event.device_id, | ||
144 | 113 | event.source_id, | ||
145 | 114 | event.action, | ||
146 | 115 | static_cast<int32_t>(event.flags), | ||
147 | 116 | event.edge_flags, | ||
148 | 117 | static_cast<int32_t>(event.modifiers), | ||
149 | 118 | static_cast<int32_t>(event.button_state), | ||
150 | 119 | 0.0f, // event.x_offset, | ||
151 | 120 | 0.0f, // event.y_offset, | ||
152 | 121 | event.x_precision, | ||
153 | 122 | event.y_precision, | ||
154 | 123 | event.down_time, | ||
155 | 124 | event.event_time, | ||
156 | 125 | event.pointer_count, | ||
157 | 126 | properties, | ||
158 | 127 | coords)); | ||
159 | 128 | } | ||
160 | 129 | |||
161 | 130 | void mia::AndroidInputChannel::send_key_event(uint32_t seq, MirKeyEvent const& event) const | ||
162 | 131 | { | ||
163 | 132 | droidinput::InputPublisher publisher(channel); | ||
164 | 133 | |||
165 | 134 | react_to_result(publisher.publishKeyEvent(seq, | ||
166 | 135 | event.device_id, | ||
167 | 136 | event.source_id, | ||
168 | 137 | event.action, | ||
169 | 138 | event.flags, | ||
170 | 139 | event.key_code, | ||
171 | 140 | event.scan_code, | ||
172 | 141 | event.modifiers, | ||
173 | 142 | event.repeat_count, | ||
174 | 143 | event.down_time, | ||
175 | 144 | event.event_time)); | ||
176 | 145 | } | ||
177 | 146 | |||
178 | 49 | 147 | ||
179 | === modified file 'src/server/input/android/android_input_channel.h' | |||
180 | --- src/server/input/android/android_input_channel.h 2013-08-28 03:41:48 +0000 | |||
181 | +++ src/server/input/android/android_input_channel.h 2014-04-11 16:00:27 +0000 | |||
182 | @@ -1,5 +1,5 @@ | |||
183 | 1 | /* | 1 | /* |
185 | 2 | * Copyright © 2013 Canonical Ltd. | 2 | * Copyright © 2013-2014 Canonical Ltd. |
186 | 3 | * | 3 | * |
187 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
188 | 5 | * under the terms of the GNU General Public License version 3, | 5 | * under the terms of the GNU General Public License version 3, |
189 | @@ -14,6 +14,7 @@ | |||
190 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
191 | 15 | * | 15 | * |
192 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> |
193 | 17 | * Andreas Pokorny <andreas.pokorny@canonical.com> | ||
194 | 17 | */ | 18 | */ |
195 | 18 | 19 | ||
196 | 19 | #ifndef MIR_INPUT_ANDROID_INPUT_CHANNEL_H_ | 20 | #ifndef MIR_INPUT_ANDROID_INPUT_CHANNEL_H_ |
197 | @@ -22,6 +23,7 @@ | |||
198 | 22 | #include "mir/input/input_channel.h" | 23 | #include "mir/input/input_channel.h" |
199 | 23 | 24 | ||
200 | 24 | #include <utils/StrongPointer.h> | 25 | #include <utils/StrongPointer.h> |
201 | 26 | #include <androidfw/InputTransport.h> | ||
202 | 25 | 27 | ||
203 | 26 | namespace android | 28 | namespace android |
204 | 27 | { | 29 | { |
205 | @@ -43,15 +45,20 @@ | |||
206 | 43 | explicit AndroidInputChannel(); | 45 | explicit AndroidInputChannel(); |
207 | 44 | virtual ~AndroidInputChannel(); | 46 | virtual ~AndroidInputChannel(); |
208 | 45 | 47 | ||
211 | 46 | int client_fd() const; | 48 | int client_fd() const override; |
212 | 47 | int server_fd() const; | 49 | int server_fd() const override; |
213 | 50 | void send_event(uint32_t seq, MirEvent const& event) const override; | ||
214 | 48 | 51 | ||
215 | 52 | droidinput::sp<droidinput::InputChannel> get_android_channel() const; | ||
216 | 49 | protected: | 53 | protected: |
217 | 50 | AndroidInputChannel(AndroidInputChannel const&) = delete; | 54 | AndroidInputChannel(AndroidInputChannel const&) = delete; |
218 | 51 | AndroidInputChannel& operator=(AndroidInputChannel const&) = delete; | 55 | AndroidInputChannel& operator=(AndroidInputChannel const&) = delete; |
219 | 52 | 56 | ||
220 | 53 | private: | 57 | private: |
221 | 54 | int s_fd, c_fd; | 58 | int s_fd, c_fd; |
222 | 59 | droidinput::sp<droidinput::InputChannel> channel; | ||
223 | 60 | void send_key_event(uint32_t seq, MirKeyEvent const& event) const; | ||
224 | 61 | void send_motion_event(uint32_t seq, MirMotionEvent const& event) const; | ||
225 | 55 | }; | 62 | }; |
226 | 56 | 63 | ||
227 | 57 | } | 64 | } |
228 | 58 | 65 | ||
229 | === modified file 'src/server/input/android/android_input_window_handle.cpp' | |||
230 | --- src/server/input/android/android_input_window_handle.cpp 2014-03-06 06:05:17 +0000 | |||
231 | +++ src/server/input/android/android_input_window_handle.cpp 2014-04-11 16:00:27 +0000 | |||
232 | @@ -18,6 +18,7 @@ | |||
233 | 18 | 18 | ||
234 | 19 | #include "android_input_window_handle.h" | 19 | #include "android_input_window_handle.h" |
235 | 20 | #include "android_input_application_handle.h" | 20 | #include "android_input_application_handle.h" |
236 | 21 | #include "android_input_channel.h" | ||
237 | 21 | 22 | ||
238 | 22 | #include "mir/input/input_channel.h" | 23 | #include "mir/input/input_channel.h" |
239 | 23 | #include "mir/input/surface.h" | 24 | #include "mir/input/surface.h" |
240 | @@ -64,9 +65,16 @@ | |||
241 | 64 | { | 65 | { |
242 | 65 | mInfo = new WindowInfo(surface); | 66 | mInfo = new WindowInfo(surface); |
243 | 66 | 67 | ||
247 | 67 | // TODO: How can we avoid recreating the InputChannel which the InputChannelFactory has already created? | 68 | std::shared_ptr<AndroidInputChannel> droidchannel = std::dynamic_pointer_cast<AndroidInputChannel>(input_channel); |
248 | 68 | mInfo->inputChannel = new droidinput::InputChannel(droidinput::String8("TODO: Name"), | 69 | if (droidchannel) |
249 | 69 | input_channel->server_fd()); | 70 | { |
250 | 71 | mInfo->inputChannel = droidchannel->get_android_channel(); | ||
251 | 72 | } | ||
252 | 73 | else | ||
253 | 74 | { | ||
254 | 75 | mInfo->inputChannel = new droidinput::InputChannel(droidinput::String8("TODO: Name"), | ||
255 | 76 | input_channel->server_fd()); | ||
256 | 77 | } | ||
257 | 70 | } | 78 | } |
258 | 71 | 79 | ||
259 | 72 | auto surface_size = surface->size(); | 80 | auto surface_size = surface->size(); |
260 | 73 | 81 | ||
261 | === modified file 'tests/acceptance-tests/test_client_input.cpp' | |||
262 | --- tests/acceptance-tests/test_client_input.cpp 2014-04-04 14:42:55 +0000 | |||
263 | +++ tests/acceptance-tests/test_client_input.cpp 2014-04-11 16:00:27 +0000 | |||
264 | @@ -1,5 +1,5 @@ | |||
265 | 1 | /* | 1 | /* |
267 | 2 | * Copyright © 2013 Canonical Ltd. | 2 | * Copyright © 2013-2014 Canonical Ltd. |
268 | 3 | * | 3 | * |
269 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
270 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
271 | @@ -14,11 +14,13 @@ | |||
272 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
273 | 15 | * | 15 | * |
274 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> |
275 | 17 | * Andreas Pokorny <andreas.pokorny@canonical.com> | ||
276 | 17 | */ | 18 | */ |
277 | 18 | 19 | ||
278 | 19 | #include "mir/graphics/display.h" | 20 | #include "mir/graphics/display.h" |
279 | 20 | #include "mir/shell/surface_creation_parameters.h" | 21 | #include "mir/shell/surface_creation_parameters.h" |
280 | 21 | #include "mir/shell/placement_strategy.h" | 22 | #include "mir/shell/placement_strategy.h" |
281 | 23 | #include "mir/input/input_channel.h" | ||
282 | 22 | #include "mir/scene/surface_coordinator.h" | 24 | #include "mir/scene/surface_coordinator.h" |
283 | 23 | #include "mir/scene/surface.h" | 25 | #include "mir/scene/surface.h" |
284 | 24 | #include "src/server/scene/session_container.h" | 26 | #include "src/server/scene/session_container.h" |
285 | @@ -613,3 +615,39 @@ | |||
286 | 613 | 615 | ||
287 | 614 | launch_client_process(*client); | 616 | launch_client_process(*client); |
288 | 615 | } | 617 | } |
289 | 618 | |||
290 | 619 | TEST_F(TestClientInput, send_mir_events_with_input_channel) | ||
291 | 620 | { | ||
292 | 621 | using namespace ::testing; | ||
293 | 622 | |||
294 | 623 | static std::string const test_client_name = "1"; | ||
295 | 624 | |||
296 | 625 | mtf::CrossProcessSync fence; | ||
297 | 626 | |||
298 | 627 | MirEvent key_event; | ||
299 | 628 | memset(&key_event,0,sizeof(key_event)); | ||
300 | 629 | key_event.type = mir_event_type_key; | ||
301 | 630 | key_event.key.action= mir_key_action_down; | ||
302 | 631 | |||
303 | 632 | auto server_config = make_event_producing_server(fence, 1, | ||
304 | 633 | [&](mtf::InputTestingServerConfiguration& server) | ||
305 | 634 | { | ||
306 | 635 | server.the_session_container()->for_each([&](std::shared_ptr<ms::Session> const& session) -> void | ||
307 | 636 | { | ||
308 | 637 | session->default_surface()->input_channel()->send_event(1,key_event); | ||
309 | 638 | }); | ||
310 | 639 | |||
311 | 640 | }); | ||
312 | 641 | launch_server_process(*server_config); | ||
313 | 642 | |||
314 | 643 | auto client_config = make_event_expecting_client(fence, | ||
315 | 644 | [&](MockHandler& handler, mt::WaitCondition& events_received) | ||
316 | 645 | { | ||
317 | 646 | using namespace ::testing; | ||
318 | 647 | InSequence seq; | ||
319 | 648 | EXPECT_CALL(handler, handle_input(mt::KeyDownEvent())).Times(1) | ||
320 | 649 | .WillOnce(mt::WakeUp(&events_received)); | ||
321 | 650 | |||
322 | 651 | }); | ||
323 | 652 | launch_client_process(*client_config); | ||
324 | 653 | } | ||
325 | 616 | 654 | ||
326 | === modified file 'tests/mir_test_framework/stubbed_server_configuration.cpp' | |||
327 | --- tests/mir_test_framework/stubbed_server_configuration.cpp 2014-03-27 09:46:09 +0000 | |||
328 | +++ tests/mir_test_framework/stubbed_server_configuration.cpp 2014-04-11 16:00:27 +0000 | |||
329 | @@ -217,14 +217,18 @@ | |||
330 | 217 | 217 | ||
331 | 218 | struct StubInputChannel : public mi::InputChannel | 218 | struct StubInputChannel : public mi::InputChannel |
332 | 219 | { | 219 | { |
341 | 220 | int client_fd() const | 220 | int client_fd() const override |
342 | 221 | { | 221 | { |
343 | 222 | return 0; | 222 | return 0; |
344 | 223 | } | 223 | } |
345 | 224 | 224 | ||
346 | 225 | int server_fd() const | 225 | int server_fd() const override |
347 | 226 | { | 226 | { |
348 | 227 | return 0; | 227 | return 0; |
349 | 228 | } | ||
350 | 229 | |||
351 | 230 | void send_event(uint32_t /*seq*/, MirEvent const& /*event*/) const override | ||
352 | 231 | { | ||
353 | 228 | } | 232 | } |
354 | 229 | }; | 233 | }; |
355 | 230 | 234 | ||
356 | 231 | 235 | ||
357 | === modified file 'tests/unit-tests/input/android/test_android_input_window_handle.cpp' | |||
358 | --- tests/unit-tests/input/android/test_android_input_window_handle.cpp 2014-03-26 14:20:14 +0000 | |||
359 | +++ tests/unit-tests/input/android/test_android_input_window_handle.cpp 2014-04-11 16:00:27 +0000 | |||
360 | @@ -52,6 +52,7 @@ | |||
361 | 52 | { | 52 | { |
362 | 53 | MOCK_CONST_METHOD0(client_fd, int()); | 53 | MOCK_CONST_METHOD0(client_fd, int()); |
363 | 54 | MOCK_CONST_METHOD0(server_fd, int()); | 54 | MOCK_CONST_METHOD0(server_fd, int()); |
364 | 55 | MOCK_CONST_METHOD2(send_event,void(uint32_t /*seq*/, MirEvent const& /*event*/)); | ||
365 | 55 | }; | 56 | }; |
366 | 56 | 57 | ||
367 | 57 | } | 58 | } |
368 | 58 | 59 | ||
369 | === modified file 'tests/unit-tests/scene/test_surface.cpp' | |||
370 | --- tests/unit-tests/scene/test_surface.cpp 2014-03-31 16:51:06 +0000 | |||
371 | +++ tests/unit-tests/scene/test_surface.cpp 2014-04-11 16:00:27 +0000 | |||
372 | @@ -52,6 +52,7 @@ | |||
373 | 52 | { | 52 | { |
374 | 53 | MOCK_CONST_METHOD0(server_fd, int()); | 53 | MOCK_CONST_METHOD0(server_fd, int()); |
375 | 54 | MOCK_CONST_METHOD0(client_fd, int()); | 54 | MOCK_CONST_METHOD0(client_fd, int()); |
376 | 55 | MOCK_CONST_METHOD2(send_event,void(uint32_t /*seq*/, MirEvent const& /*event*/)); | ||
377 | 55 | }; | 56 | }; |
378 | 56 | } | 57 | } |
379 | 57 | 58 |
send_event(uint32_t seq, MirEvent)
as someone calling send_event, how do I arrange seq; is a particular sequence needed? Would it be better to have AndroidInputChannel manage the sequence if a particular ordering is required?