Merge lp:~andreas-pokorny/mir/combine-modifier-state-accross-devices into lp:mir
- combine-modifier-state-accross-devices
- Merge into development-branch
Status: | Merged |
---|---|
Merged at revision: | 3065 |
Proposed branch: | lp:~andreas-pokorny/mir/combine-modifier-state-accross-devices |
Merge into: | lp:mir |
Prerequisite: | lp:~andreas-pokorny/mir/bump-input-platform-abi-for-0.18 |
Diff against target: |
1512 lines (+615/-265) 24 files modified
include/client/mir/events/event_builders.h (+2/-0) include/platform/mir/input/event_builder.h (+5/-7) include/test/mir/test/event_matchers.h (+8/-0) src/client/events/event_builders.cpp (+22/-0) src/client/symbols.map (+8/-0) src/platforms/evdev/CMakeLists.txt (+2/-3) src/platforms/evdev/button_utils.cpp (+44/-0) src/platforms/evdev/button_utils.h (+36/-0) src/platforms/evdev/libinput_device.cpp (+12/-34) src/platforms/evdev/libinput_device.h (+0/-1) src/platforms/mesa/server/x11/input/input_platform.cpp (+6/-38) src/server/input/CMakeLists.txt (+2/-0) src/server/input/default_event_builder.cpp (+12/-14) src/server/input/default_event_builder.h (+5/-7) src/server/input/default_input_device_hub.cpp (+26/-58) src/server/input/default_input_device_hub.h (+6/-10) src/server/input/input_modifier_utils.cpp (+4/-22) src/server/input/input_modifier_utils.h (+2/-7) src/server/input/seat.cpp (+161/-0) src/server/input/seat.h (+74/-0) tests/mir_test_framework/fake_input_device_impl.cpp (+4/-16) tests/mir_test_framework/fake_input_device_impl.h (+0/-1) tests/unit-tests/input/evdev/test_libinput_device.cpp (+28/-33) tests/unit-tests/input/test_default_input_device_hub.cpp (+146/-14) |
To merge this branch: | bzr merge lp:~andreas-pokorny/mir/combine-modifier-state-accross-devices |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Chris Halse Rogers | Approve | ||
Alan Griffiths | Abstain | ||
Review via email: mp+274412@code.launchpad.net |
This proposal supersedes a proposal from 2015-10-14.
Commit message
Rework Modifier tracking to combine modifiers within
The platform is no longer in charge of the modifier. Instead the new input stack tracks it when the events are received. To reduce the complexity of InputDeviceHub this behavior and similar parts are moved to mir::input::Seat which represents a group of input devices that belong to a user session. (Currently all of them).
Collateral changes:
- allow changing the modifier of MirEvent after creation -> additional symbols to 'hidden' C++ client API
- reduction of EventBuilder interface
- moving of modifier utils to server
Description of the change
This fixes the problem that caused the revert of the input platform probing mp..
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:3019
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Alan Griffiths (alan-griffiths) wrote : | # |
+MIR_CLIENT_
AIUI this should be MIR_CLIENT_
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3019
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3020
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3020
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Alan Griffiths (alan-griffiths) wrote : | # |
I think this is OK, but not yet checked fully
Chris Halse Rogers (raof) wrote : | # |
Hm. The addition of Seat is great, but it looks like this will remove the ability to do per-keyboard modifiers? This isn't super-useful for things like <alt> or <ctrl>, but it's super-annoying for things like <num lock>.
Would it be possible to add the Seat interface, but still have keyboard devices handle their own modifiers? My understanding of the problem suggests that it is, but you've undoubtedly got a better understanding :)
Andreas Pokorny (andreas-pokorny) wrote : | # |
> Hm. The addition of Seat is great, but it looks like this will remove the
> ability to do per-keyboard modifiers? This isn't super-useful for things like
> <alt> or <ctrl>, but it's super-annoying for things like <num lock>.
>
> Would it be possible to add the Seat interface, but still have keyboard
> devices handle their own modifiers? My understanding of the problem suggests
> that it is, but you've undoubtedly got a better understanding :)
I think we can achieve that in several ways.. and I think one of the options to do that looks robust: Have an additional keyboard device modifier property in MirEvent for keyboard events. The modifier which is currently stored per device in seat. After peeking into xkb_mapper. On the client side we would have to track the xkb state per keyboard device, and on every key event from a device inject potentially not experienced scan codes for caps lock and num lock (because it might have happened before the surface existed or when it was not focused) to ensure that the client has the right state..
We also discussed doing the xkb mapping on the server side.. and maybe per surface.. but thats would boil down to similar tasks.
Aaahnnd... we would have to find ways to tunnel that info through qt key events.. i believe..
Hmm why does this work at all right now?
Chris Halse Rogers (raof) wrote : | # |
Hm. Couldn't you just keep the MirInputEventMo
=============
+struct Seat
Class, surely? It has no public data members!
Otherwise looks good.
Andreas Pokorny (andreas-pokorny) wrote : | # |
> Hm. Couldn't you just keep the MirInputEventMo
> constructor and then not call mev::set_
> key events? That should then work just like it does today?
Ah - so combine modifiers only for non key events, but keep per device modifers for key events..
So you cannot do for example ExternalKeyboar
.... sounds good to me .. and simple to implement.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3021
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Chris Halse Rogers (raof) wrote : | # |
Woot! Exactly what I was after.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3023
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'include/client/mir/events/event_builders.h' | |||
2 | --- include/client/mir/events/event_builders.h 2015-10-02 04:27:33 +0000 | |||
3 | +++ include/client/mir/events/event_builders.h 2015-10-26 14:13:05 +0000 | |||
4 | @@ -58,6 +58,8 @@ | |||
5 | 58 | uint64_t mac, MirKeyboardAction action, xkb_keysym_t key_code, | 58 | uint64_t mac, MirKeyboardAction action, xkb_keysym_t key_code, |
6 | 59 | int scan_code, MirInputEventModifiers modifiers); | 59 | int scan_code, MirInputEventModifiers modifiers); |
7 | 60 | 60 | ||
8 | 61 | void set_modifier(MirEvent& event, MirInputEventModifiers modifiers); | ||
9 | 62 | |||
10 | 61 | // Deprecated version without mac | 63 | // Deprecated version without mac |
11 | 62 | EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp, | 64 | EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp, |
12 | 63 | MirKeyboardAction action, xkb_keysym_t key_code, | 65 | MirKeyboardAction action, xkb_keysym_t key_code, |
13 | 64 | 66 | ||
14 | === modified file 'include/platform/mir/input/event_builder.h' | |||
15 | --- include/platform/mir/input/event_builder.h 2015-08-24 23:25:00 +0000 | |||
16 | +++ include/platform/mir/input/event_builder.h 2015-10-26 14:13:05 +0000 | |||
17 | @@ -38,18 +38,16 @@ | |||
18 | 38 | virtual ~EventBuilder() = default; | 38 | virtual ~EventBuilder() = default; |
19 | 39 | using Timestamp = std::chrono::nanoseconds; | 39 | using Timestamp = std::chrono::nanoseconds; |
20 | 40 | 40 | ||
23 | 41 | virtual EventUPtr key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code, int scan_code, | 41 | virtual EventUPtr key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code, int scan_code) = 0; |
22 | 42 | MirInputEventModifiers modifiers) = 0; | ||
24 | 43 | 42 | ||
26 | 44 | virtual EventUPtr touch_event(Timestamp timestamp, MirInputEventModifiers modifiers) = 0; | 43 | virtual EventUPtr touch_event(Timestamp timestamp) = 0; |
27 | 45 | virtual void add_touch(MirEvent& event, MirTouchId touch_id, MirTouchAction action, MirTouchTooltype tooltype, | 44 | virtual void add_touch(MirEvent& event, MirTouchId touch_id, MirTouchAction action, MirTouchTooltype tooltype, |
28 | 46 | float x_axis_value, float y_axis_value, float pressure_value, float touch_major_value, | 45 | float x_axis_value, float y_axis_value, float pressure_value, float touch_major_value, |
29 | 47 | float touch_minor_value, float size_value) = 0; | 46 | float touch_minor_value, float size_value) = 0; |
30 | 48 | 47 | ||
35 | 49 | virtual EventUPtr pointer_event(Timestamp timestamp, MirInputEventModifiers modifiers, MirPointerAction action, | 48 | virtual EventUPtr pointer_event(Timestamp timestamp, MirPointerAction action, MirPointerButtons buttons_pressed, |
36 | 50 | MirPointerButtons buttons_pressed, float x_axis_value, float y_axis_value, | 49 | float x_axis_value, float y_axis_value, float hscroll_value, float vscroll_value, |
37 | 51 | float hscroll_value, float vscroll_value, float relative_x_value, | 50 | float relative_x_value, float relative_y_value) = 0; |
34 | 52 | float relative_y_value) = 0; | ||
38 | 53 | 51 | ||
39 | 54 | virtual EventUPtr configuration_event(Timestamp timestamp, MirInputConfigurationAction action) = 0; | 52 | virtual EventUPtr configuration_event(Timestamp timestamp, MirInputConfigurationAction action) = 0; |
40 | 55 | 53 | ||
41 | 56 | 54 | ||
42 | === modified file 'include/test/mir/test/event_matchers.h' | |||
43 | --- include/test/mir/test/event_matchers.h 2015-10-13 16:25:36 +0000 | |||
44 | +++ include/test/mir/test/event_matchers.h 2015-10-26 14:13:05 +0000 | |||
45 | @@ -353,6 +353,14 @@ | |||
46 | 353 | return true; | 353 | return true; |
47 | 354 | } | 354 | } |
48 | 355 | 355 | ||
49 | 356 | MATCHER_P(PointerEventWithModifiers, modifiers, "") | ||
50 | 357 | { | ||
51 | 358 | auto pev = maybe_pointer_event(to_address(arg)); | ||
52 | 359 | if (pev && mir_pointer_event_modifiers(pev) == modifiers) | ||
53 | 360 | return true; | ||
54 | 361 | return false; | ||
55 | 362 | } | ||
56 | 363 | |||
57 | 356 | MATCHER_P2(PointerEventWithDiff, dx, dy, "") | 364 | MATCHER_P2(PointerEventWithDiff, dx, dy, "") |
58 | 357 | { | 365 | { |
59 | 358 | auto pev = maybe_pointer_event(to_address(arg)); | 366 | auto pev = maybe_pointer_event(to_address(arg)); |
60 | 359 | 367 | ||
61 | === modified file 'src/client/events/event_builders.cpp' | |||
62 | --- src/client/events/event_builders.cpp 2015-10-07 12:07:00 +0000 | |||
63 | +++ src/client/events/event_builders.cpp 2015-10-26 14:13:05 +0000 | |||
64 | @@ -165,6 +165,28 @@ | |||
65 | 165 | return make_event_uptr(e); | 165 | return make_event_uptr(e); |
66 | 166 | } | 166 | } |
67 | 167 | 167 | ||
68 | 168 | |||
69 | 169 | void mev::set_modifier(MirEvent& event, MirInputEventModifiers modifiers) | ||
70 | 170 | { | ||
71 | 171 | switch(event.type) | ||
72 | 172 | { | ||
73 | 173 | case mir_event_type_key: | ||
74 | 174 | { | ||
75 | 175 | auto& kev = event.key; | ||
76 | 176 | kev.modifiers = modifiers; | ||
77 | 177 | break; | ||
78 | 178 | } | ||
79 | 179 | case mir_event_type_motion: | ||
80 | 180 | { | ||
81 | 181 | auto& mev = event.motion; | ||
82 | 182 | mev.modifiers = modifiers; | ||
83 | 183 | break; | ||
84 | 184 | } | ||
85 | 185 | default: | ||
86 | 186 | BOOST_THROW_EXCEPTION(std::invalid_argument("Input event modifiers are only valid for pointer, key and touch events.")); | ||
87 | 187 | } | ||
88 | 188 | } | ||
89 | 189 | |||
90 | 168 | // Deprecated version without mac | 190 | // Deprecated version without mac |
91 | 169 | mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp, | 191 | mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp, |
92 | 170 | MirKeyboardAction action, xkb_keysym_t key_code, | 192 | MirKeyboardAction action, xkb_keysym_t key_code, |
93 | 171 | 193 | ||
94 | === modified file 'src/client/symbols.map' | |||
95 | --- src/client/symbols.map 2015-10-08 21:11:44 +0000 | |||
96 | +++ src/client/symbols.map 2015-10-26 14:13:05 +0000 | |||
97 | @@ -243,3 +243,11 @@ | |||
98 | 243 | mir::operator???std::ostream???Mir* | 243 | mir::operator???std::ostream???Mir* |
99 | 244 | }; | 244 | }; |
100 | 245 | }; | 245 | }; |
101 | 246 | |||
102 | 247 | MIR_CLIENT_DETAIL_unreleased { | ||
103 | 248 | global: | ||
104 | 249 | extern "C++" { | ||
105 | 250 | mir::events::set_modifier*; | ||
106 | 251 | }; | ||
107 | 252 | } MIR_CLIENT_DETAIL_9; | ||
108 | 253 | |||
109 | 246 | 254 | ||
110 | === modified file 'src/platforms/evdev/CMakeLists.txt' | |||
111 | --- src/platforms/evdev/CMakeLists.txt 2015-10-05 20:17:26 +0000 | |||
112 | +++ src/platforms/evdev/CMakeLists.txt 2015-10-26 14:13:05 +0000 | |||
113 | @@ -8,7 +8,7 @@ | |||
114 | 8 | 8 | ||
115 | 9 | add_library(mirevdevutilsobjects OBJECT | 9 | add_library(mirevdevutilsobjects OBJECT |
116 | 10 | evdev_device_detection.cpp | 10 | evdev_device_detection.cpp |
118 | 11 | input_modifier_utils.cpp | 11 | button_utils.cpp |
119 | 12 | ) | 12 | ) |
120 | 13 | 13 | ||
121 | 14 | add_library(mirplatforminputevdevobjects OBJECT | 14 | add_library(mirplatforminputevdevobjects OBJECT |
122 | @@ -34,8 +34,7 @@ | |||
123 | 34 | ) | 34 | ) |
124 | 35 | 35 | ||
125 | 36 | target_link_libraries(mirplatforminputevdev | 36 | target_link_libraries(mirplatforminputevdev |
128 | 37 | mirplatform | 37 | mirplatform # udev wrapper |
127 | 38 | mirclient | ||
129 | 39 | ${Boost_PROGRAM_OPTIONS_LIBRARY} | 38 | ${Boost_PROGRAM_OPTIONS_LIBRARY} |
130 | 40 | ${LIBINPUT_LDFLAGS} ${LIBINPUT_LIBRARIES} | 39 | ${LIBINPUT_LDFLAGS} ${LIBINPUT_LIBRARIES} |
131 | 41 | ) | 40 | ) |
132 | 42 | 41 | ||
133 | === added file 'src/platforms/evdev/button_utils.cpp' | |||
134 | --- src/platforms/evdev/button_utils.cpp 1970-01-01 00:00:00 +0000 | |||
135 | +++ src/platforms/evdev/button_utils.cpp 2015-10-26 14:13:05 +0000 | |||
136 | @@ -0,0 +1,44 @@ | |||
137 | 1 | /* | ||
138 | 2 | * Copyright © 2015 Canonical Ltd. | ||
139 | 3 | * | ||
140 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
141 | 5 | * under the terms of the GNU General Public License version 3, | ||
142 | 6 | * as published by the Free Software Foundation. | ||
143 | 7 | * | ||
144 | 8 | * This program is distributed in the hope that it will be useful, | ||
145 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
146 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
147 | 11 | * GNU General Public License for more details. | ||
148 | 12 | * | ||
149 | 13 | * You should have received a copy of the GNU General Public License | ||
150 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
151 | 15 | * | ||
152 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
153 | 17 | */ | ||
154 | 18 | |||
155 | 19 | #include "button_utils.h" | ||
156 | 20 | #include "boost/throw_exception.hpp" | ||
157 | 21 | |||
158 | 22 | #include "linux/input.h" | ||
159 | 23 | |||
160 | 24 | #include <stdexcept> | ||
161 | 25 | |||
162 | 26 | namespace mie = mir::input::evdev; | ||
163 | 27 | |||
164 | 28 | MirPointerButton mie::to_pointer_button(int button, MirPointerHandedness handedness) | ||
165 | 29 | { | ||
166 | 30 | switch(button) | ||
167 | 31 | { | ||
168 | 32 | case BTN_LEFT: return (handedness == mir_pointer_handedness_right) | ||
169 | 33 | ? mir_pointer_button_primary | ||
170 | 34 | : mir_pointer_button_secondary; | ||
171 | 35 | case BTN_RIGHT: return (handedness == mir_pointer_handedness_right) | ||
172 | 36 | ? mir_pointer_button_secondary | ||
173 | 37 | : mir_pointer_button_primary; | ||
174 | 38 | case BTN_MIDDLE: return mir_pointer_button_tertiary; | ||
175 | 39 | case BTN_BACK: return mir_pointer_button_back; | ||
176 | 40 | case BTN_FORWARD: return mir_pointer_button_forward; | ||
177 | 41 | } | ||
178 | 42 | BOOST_THROW_EXCEPTION(std::runtime_error("Invalid mouse button")); | ||
179 | 43 | } | ||
180 | 44 | |||
181 | 0 | 45 | ||
182 | === added file 'src/platforms/evdev/button_utils.h' | |||
183 | --- src/platforms/evdev/button_utils.h 1970-01-01 00:00:00 +0000 | |||
184 | +++ src/platforms/evdev/button_utils.h 2015-10-26 14:13:05 +0000 | |||
185 | @@ -0,0 +1,36 @@ | |||
186 | 1 | /* | ||
187 | 2 | * Copyright © 2015 Canonical Ltd. | ||
188 | 3 | * | ||
189 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
190 | 5 | * under the terms of the GNU General Public License version 3, | ||
191 | 6 | * as published by the Free Software Foundation. | ||
192 | 7 | * | ||
193 | 8 | * This program is distributed in the hope that it will be useful, | ||
194 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
195 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
196 | 11 | * GNU General Public License for more details. | ||
197 | 12 | * | ||
198 | 13 | * You should have received a copy of the GNU General Public License | ||
199 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
200 | 15 | * | ||
201 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
202 | 17 | */ | ||
203 | 18 | |||
204 | 19 | #ifndef MIR_INPUT_EVDEV_BUTTON_UTILS_H_ | ||
205 | 20 | #define MIR_INPUT_EVDEV_BUTTON_UTILS_H_ | ||
206 | 21 | |||
207 | 22 | #include "mir_toolkit/event.h" | ||
208 | 23 | #include "mir_toolkit/mir_input_device.h" | ||
209 | 24 | |||
210 | 25 | namespace mir | ||
211 | 26 | { | ||
212 | 27 | namespace input | ||
213 | 28 | { | ||
214 | 29 | namespace evdev | ||
215 | 30 | { | ||
216 | 31 | MirPointerButton to_pointer_button(int button, MirPointerHandedness handedness); | ||
217 | 32 | } | ||
218 | 33 | } | ||
219 | 34 | } | ||
220 | 35 | |||
221 | 36 | #endif | ||
222 | 0 | 37 | ||
223 | === modified file 'src/platforms/evdev/libinput_device.cpp' | |||
224 | --- src/platforms/evdev/libinput_device.cpp 2015-10-23 16:32:32 +0000 | |||
225 | +++ src/platforms/evdev/libinput_device.cpp 2015-10-26 14:13:05 +0000 | |||
226 | @@ -19,8 +19,8 @@ | |||
227 | 19 | #include "libinput_device.h" | 19 | #include "libinput_device.h" |
228 | 20 | #include "libinput_ptr.h" | 20 | #include "libinput_ptr.h" |
229 | 21 | #include "libinput_device_ptr.h" | 21 | #include "libinput_device_ptr.h" |
230 | 22 | #include "input_modifier_utils.h" | ||
231 | 23 | #include "evdev_device_detection.h" | 22 | #include "evdev_device_detection.h" |
232 | 23 | #include "button_utils.h" | ||
233 | 24 | 24 | ||
234 | 25 | #include "mir/input/input_sink.h" | 25 | #include "mir/input/input_sink.h" |
235 | 26 | #include "mir/input/input_report.h" | 26 | #include "mir/input/input_report.h" |
236 | @@ -55,8 +55,7 @@ | |||
237 | 55 | 55 | ||
238 | 56 | mie::LibInputDevice::LibInputDevice(std::shared_ptr<mi::InputReport> const& report, char const* path, | 56 | mie::LibInputDevice::LibInputDevice(std::shared_ptr<mi::InputReport> const& report, char const* path, |
239 | 57 | LibInputDevicePtr dev) | 57 | LibInputDevicePtr dev) |
242 | 58 | : report{report}, accumulated_touch_event{nullptr, null_deleter}, pointer_pos{0, 0}, modifier_state{0}, | 58 | : report{report}, accumulated_touch_event{nullptr, null_deleter}, pointer_pos{0, 0}, button_state{0} |
241 | 59 | button_state{0} | ||
243 | 60 | { | 59 | { |
244 | 61 | add_device_of_group(path, std::move(dev)); | 60 | add_device_of_group(path, std::move(dev)); |
245 | 62 | } | 61 | } |
246 | @@ -140,18 +139,7 @@ | |||
247 | 140 | auto const code = libinput_event_keyboard_get_key(keyboard); | 139 | auto const code = libinput_event_keyboard_get_key(keyboard); |
248 | 141 | report->received_event_from_kernel(time.count(), EV_KEY, code, action); | 140 | report->received_event_from_kernel(time.count(), EV_KEY, code, action); |
249 | 142 | 141 | ||
262 | 143 | auto event = builder->key_event(time, | 142 | return builder->key_event(time, action, xkb_keysym_t{0}, code); |
251 | 144 | action, | ||
252 | 145 | xkb_keysym_t{0}, | ||
253 | 146 | code, | ||
254 | 147 | mie::expand_modifiers(modifier_state)); | ||
255 | 148 | |||
256 | 149 | if (action == mir_keyboard_action_down) | ||
257 | 150 | modifier_state |= mie::to_modifiers(code); | ||
258 | 151 | else | ||
259 | 152 | modifier_state &= ~mie::to_modifiers(code); | ||
260 | 153 | |||
261 | 154 | return event; | ||
263 | 155 | } | 143 | } |
264 | 156 | 144 | ||
265 | 157 | mir::EventUPtr mie::LibInputDevice::convert_button_event(libinput_event_pointer* pointer) | 145 | mir::EventUPtr mie::LibInputDevice::convert_button_event(libinput_event_pointer* pointer) |
266 | @@ -175,11 +163,8 @@ | |||
267 | 175 | else | 163 | else |
268 | 176 | button_state = MirPointerButton(button_state & ~uint32_t(pointer_button)); | 164 | button_state = MirPointerButton(button_state & ~uint32_t(pointer_button)); |
269 | 177 | 165 | ||
275 | 178 | auto event = builder->pointer_event(time, mie::expand_modifiers(modifier_state), action, button_state, | 166 | return builder->pointer_event(time, action, button_state, pointer_pos.x.as_float(), pointer_pos.y.as_float(), |
276 | 179 | pointer_pos.x.as_float(), pointer_pos.y.as_float(), hscroll_value, | 167 | hscroll_value, vscroll_value, relative_x_value, relative_y_value); |
272 | 180 | vscroll_value, relative_x_value, relative_y_value); | ||
273 | 181 | |||
274 | 182 | return event; | ||
277 | 183 | } | 168 | } |
278 | 184 | 169 | ||
279 | 185 | mir::EventUPtr mie::LibInputDevice::convert_motion_event(libinput_event_pointer* pointer) | 170 | mir::EventUPtr mie::LibInputDevice::convert_motion_event(libinput_event_pointer* pointer) |
280 | @@ -198,11 +183,8 @@ | |||
281 | 198 | 183 | ||
282 | 199 | sink->confine_pointer(pointer_pos); | 184 | sink->confine_pointer(pointer_pos); |
283 | 200 | 185 | ||
289 | 201 | auto event = builder->pointer_event(time, mie::expand_modifiers(modifier_state), action, button_state, | 186 | return builder->pointer_event(time, action, button_state, pointer_pos.x.as_float(), pointer_pos.y.as_float(), |
290 | 202 | pointer_pos.x.as_float(), pointer_pos.y.as_float(), hscroll_value, | 187 | hscroll_value, vscroll_value, movement.dx.as_float(), movement.dy.as_float()); |
286 | 203 | vscroll_value, movement.dx.as_float(), movement.dy.as_float()); | ||
287 | 204 | |||
288 | 205 | return event; | ||
291 | 206 | } | 188 | } |
292 | 207 | 189 | ||
293 | 208 | mir::EventUPtr mie::LibInputDevice::convert_absolute_motion_event(libinput_event_pointer* pointer) | 190 | mir::EventUPtr mie::LibInputDevice::convert_absolute_motion_event(libinput_event_pointer* pointer) |
294 | @@ -222,10 +204,8 @@ | |||
295 | 222 | 204 | ||
296 | 223 | sink->confine_pointer(pointer_pos); | 205 | sink->confine_pointer(pointer_pos); |
297 | 224 | 206 | ||
302 | 225 | auto event = builder->pointer_event(time, mie::expand_modifiers(modifier_state), action, button_state, | 207 | return builder->pointer_event(time, action, button_state, pointer_pos.x.as_float(), pointer_pos.y.as_float(), |
303 | 226 | pointer_pos.x.as_float(), pointer_pos.y.as_float(), hscroll_value, | 208 | hscroll_value, vscroll_value, movement.dx.as_float(), movement.dy.as_float()); |
300 | 227 | vscroll_value, movement.dx.as_float(), movement.dy.as_float()); | ||
301 | 228 | return event; | ||
304 | 229 | } | 209 | } |
305 | 230 | 210 | ||
306 | 231 | mir::EventUPtr mie::LibInputDevice::convert_axis_event(libinput_event_pointer* pointer) | 211 | mir::EventUPtr mie::LibInputDevice::convert_axis_event(libinput_event_pointer* pointer) |
307 | @@ -244,10 +224,8 @@ | |||
308 | 244 | : 0.0f; | 224 | : 0.0f; |
309 | 245 | 225 | ||
310 | 246 | report->received_event_from_kernel(time.count(), EV_REL, 0, 0); | 226 | report->received_event_from_kernel(time.count(), EV_REL, 0, 0); |
315 | 247 | auto event = builder->pointer_event(time, mie::expand_modifiers(modifier_state), action, button_state, | 227 | return builder->pointer_event(time, action, button_state, pointer_pos.x.as_float(), pointer_pos.y.as_float(), |
316 | 248 | pointer_pos.x.as_float(), pointer_pos.y.as_float(), hscroll_value, | 228 | hscroll_value, vscroll_value, relative_x_value, relative_y_value); |
313 | 249 | vscroll_value, relative_x_value, relative_y_value); | ||
314 | 250 | return event; | ||
317 | 251 | } | 229 | } |
318 | 252 | 230 | ||
319 | 253 | MirEvent& mie::LibInputDevice::get_accumulated_touch_event(std::chrono::nanoseconds timestamp) | 231 | MirEvent& mie::LibInputDevice::get_accumulated_touch_event(std::chrono::nanoseconds timestamp) |
320 | @@ -255,7 +233,7 @@ | |||
321 | 255 | if (!accumulated_touch_event) | 233 | if (!accumulated_touch_event) |
322 | 256 | { | 234 | { |
323 | 257 | report->received_event_from_kernel(timestamp.count(), EV_SYN, 0, 0); | 235 | report->received_event_from_kernel(timestamp.count(), EV_SYN, 0, 0); |
325 | 258 | accumulated_touch_event = builder->touch_event(timestamp, mie::expand_modifiers(modifier_state)); | 236 | accumulated_touch_event = builder->touch_event(timestamp); |
326 | 259 | } | 237 | } |
327 | 260 | 238 | ||
328 | 261 | return *accumulated_touch_event; | 239 | return *accumulated_touch_event; |
329 | 262 | 240 | ||
330 | === modified file 'src/platforms/evdev/libinput_device.h' | |||
331 | --- src/platforms/evdev/libinput_device.h 2015-10-23 16:32:32 +0000 | |||
332 | +++ src/platforms/evdev/libinput_device.h 2015-10-26 14:13:05 +0000 | |||
333 | @@ -88,7 +88,6 @@ | |||
334 | 88 | 88 | ||
335 | 89 | InputDeviceInfo info; | 89 | InputDeviceInfo info; |
336 | 90 | mir::geometry::Point pointer_pos; | 90 | mir::geometry::Point pointer_pos; |
337 | 91 | MirInputEventModifiers modifier_state; | ||
338 | 92 | MirPointerButtons button_state; | 91 | MirPointerButtons button_state; |
339 | 93 | double vertical_scroll_scale{1.0}; | 92 | double vertical_scroll_scale{1.0}; |
340 | 94 | double horizontal_scroll_scale{1.0}; | 93 | double horizontal_scroll_scale{1.0}; |
341 | 95 | 94 | ||
342 | === modified file 'src/platforms/mesa/server/x11/input/input_platform.cpp' | |||
343 | --- src/platforms/mesa/server/x11/input/input_platform.cpp 2015-10-15 16:56:07 +0000 | |||
344 | +++ src/platforms/mesa/server/x11/input/input_platform.cpp 2015-10-26 14:13:05 +0000 | |||
345 | @@ -127,16 +127,6 @@ | |||
346 | 127 | #endif | 127 | #endif |
347 | 128 | XLookupString(&xkev, str, STRMAX, &keysym, NULL); | 128 | XLookupString(&xkev, str, STRMAX, &keysym, NULL); |
348 | 129 | 129 | ||
349 | 130 | MirInputEventModifiers modifiers = mir_input_event_modifier_none; | ||
350 | 131 | if (xkev.state & ShiftMask) | ||
351 | 132 | modifiers |= mir_input_event_modifier_shift; | ||
352 | 133 | if (xkev.state & ControlMask) | ||
353 | 134 | modifiers |= mir_input_event_modifier_ctrl; | ||
354 | 135 | if (xkev.state & Mod1Mask) | ||
355 | 136 | modifiers |= mir_input_event_modifier_alt; | ||
356 | 137 | if (xkev.state & Mod4Mask) | ||
357 | 138 | modifiers |= mir_input_event_modifier_meta; | ||
358 | 139 | |||
359 | 140 | auto event_time = | 130 | auto event_time = |
360 | 141 | std::chrono::duration_cast<std::chrono::nanoseconds>( | 131 | std::chrono::duration_cast<std::chrono::nanoseconds>( |
361 | 142 | std::chrono::milliseconds{xkev.time}); | 132 | std::chrono::milliseconds{xkev.time}); |
362 | @@ -155,8 +145,7 @@ | |||
363 | 155 | mir_keyboard_action_down : | 145 | mir_keyboard_action_down : |
364 | 156 | mir_keyboard_action_up, | 146 | mir_keyboard_action_up, |
365 | 157 | keysym, | 147 | keysym, |
368 | 158 | xkev.keycode-8, | 148 | xkev.keycode-8 |
367 | 159 | modifiers | ||
369 | 160 | ) | 149 | ) |
370 | 161 | ); | 150 | ); |
371 | 162 | break; | 151 | break; |
372 | @@ -185,16 +174,6 @@ | |||
373 | 185 | #endif | 174 | #endif |
374 | 186 | break; | 175 | break; |
375 | 187 | } | 176 | } |
376 | 188 | MirInputEventModifiers modifiers = mir_input_event_modifier_none; | ||
377 | 189 | if (xbev.state & ShiftMask) | ||
378 | 190 | modifiers |= mir_input_event_modifier_shift; | ||
379 | 191 | if (xbev.state & ControlMask) | ||
380 | 192 | modifiers |= mir_input_event_modifier_ctrl; | ||
381 | 193 | if (xbev.state & Mod1Mask) | ||
382 | 194 | modifiers |= mir_input_event_modifier_alt; | ||
383 | 195 | if (xbev.state & Mod4Mask) | ||
384 | 196 | modifiers |= mir_input_event_modifier_meta; | ||
385 | 197 | |||
386 | 198 | auto event_time = | 177 | auto event_time = |
387 | 199 | std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds{xbev.time}); | 178 | std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds{xbev.time}); |
388 | 200 | 179 | ||
389 | @@ -215,15 +194,15 @@ | |||
390 | 215 | 194 | ||
391 | 216 | #ifdef MIR_ON_X11_INPUT_VERBOSE | 195 | #ifdef MIR_ON_X11_INPUT_VERBOSE |
392 | 217 | mir::log_info("Mir button event : x=%d, y=%d, " | 196 | mir::log_info("Mir button event : x=%d, y=%d, " |
395 | 218 | "buttons_pressed=0x%0X, modifiers=0x%0X, event_time=%" PRId64, | 197 | "buttons_pressed=0x%0X, event_time=%" PRId64, |
396 | 219 | xbev.x, xbev.y, buttons_pressed, modifiers, event_time); | 198 | xbev.x, xbev.y, buttons_pressed, event_time); |
397 | 220 | #endif | 199 | #endif |
398 | 200 | |||
399 | 221 | if ((xbev.button == Button4) || (xbev.button == Button5)) | 201 | if ((xbev.button == Button4) || (xbev.button == Button5)) |
400 | 222 | { // scroll event | 202 | { // scroll event |
401 | 223 | core_pointer->sink->handle_input( | 203 | core_pointer->sink->handle_input( |
402 | 224 | *core_pointer->builder->pointer_event( | 204 | *core_pointer->builder->pointer_event( |
403 | 225 | event_time, | 205 | event_time, |
404 | 226 | modifiers, | ||
405 | 227 | mir_pointer_action_motion, | 206 | mir_pointer_action_motion, |
406 | 228 | 0, | 207 | 0, |
407 | 229 | xbev.x, | 208 | xbev.x, |
408 | @@ -240,7 +219,6 @@ | |||
409 | 240 | core_pointer->sink->handle_input( | 219 | core_pointer->sink->handle_input( |
410 | 241 | *core_pointer->builder->pointer_event( | 220 | *core_pointer->builder->pointer_event( |
411 | 242 | event_time, | 221 | event_time, |
412 | 243 | modifiers, | ||
413 | 244 | xbev.type == ButtonPress ? | 222 | xbev.type == ButtonPress ? |
414 | 245 | mir_pointer_action_button_down : | 223 | mir_pointer_action_button_down : |
415 | 246 | mir_pointer_action_button_up, | 224 | mir_pointer_action_button_up, |
416 | @@ -270,15 +248,6 @@ | |||
417 | 270 | xmev.root, xmev.subwindow, xmev.time, xmev.x, xmev.y, xmev.x_root, | 248 | xmev.root, xmev.subwindow, xmev.time, xmev.x, xmev.y, xmev.x_root, |
418 | 271 | xmev.y_root, xmev.state, xmev.is_hint == NotifyNormal ? "no" : "yes", xmev.same_screen); | 249 | xmev.y_root, xmev.state, xmev.is_hint == NotifyNormal ? "no" : "yes", xmev.same_screen); |
419 | 272 | #endif | 250 | #endif |
420 | 273 | MirInputEventModifiers modifiers = mir_input_event_modifier_none; | ||
421 | 274 | if (xmev.state & ShiftMask) | ||
422 | 275 | modifiers |= mir_input_event_modifier_shift; | ||
423 | 276 | if (xmev.state & ControlMask) | ||
424 | 277 | modifiers |= mir_input_event_modifier_ctrl; | ||
425 | 278 | if (xmev.state & Mod1Mask) | ||
426 | 279 | modifiers |= mir_input_event_modifier_alt; | ||
427 | 280 | if (xmev.state & Mod4Mask) | ||
428 | 281 | modifiers |= mir_input_event_modifier_meta; | ||
429 | 282 | 251 | ||
430 | 283 | auto event_time = | 252 | auto event_time = |
431 | 284 | std::chrono::duration_cast<std::chrono::nanoseconds>( | 253 | std::chrono::duration_cast<std::chrono::nanoseconds>( |
432 | @@ -298,13 +267,12 @@ | |||
433 | 298 | 267 | ||
434 | 299 | #ifdef MIR_ON_X11_INPUT_VERBOSE | 268 | #ifdef MIR_ON_X11_INPUT_VERBOSE |
435 | 300 | mir::log_info("Mir pointer event : " | 269 | mir::log_info("Mir pointer event : " |
438 | 301 | "x=%d, y=%d, buttons_pressed=0x%0X, modifiers=0x%0X, event_time=%" PRId64, | 270 | "x=%d, y=%d, buttons_pressed=0x%0X, event_time=%" PRId64, |
439 | 302 | xmev.x, xmev.y, buttons_pressed, modifiers, event_time); | 271 | xmev.x, xmev.y, buttons_pressed, event_time); |
440 | 303 | #endif | 272 | #endif |
441 | 304 | core_pointer->sink->handle_input( | 273 | core_pointer->sink->handle_input( |
442 | 305 | *core_pointer->builder->pointer_event( | 274 | *core_pointer->builder->pointer_event( |
443 | 306 | event_time, | 275 | event_time, |
444 | 307 | modifiers, | ||
445 | 308 | mir_pointer_action_motion, | 276 | mir_pointer_action_motion, |
446 | 309 | buttons_pressed, | 277 | buttons_pressed, |
447 | 310 | xmev.x, | 278 | xmev.x, |
448 | 311 | 279 | ||
449 | === modified file 'src/server/input/CMakeLists.txt' | |||
450 | --- src/server/input/CMakeLists.txt 2015-10-12 19:30:14 +0000 | |||
451 | +++ src/server/input/CMakeLists.txt 2015-10-26 14:13:05 +0000 | |||
452 | @@ -8,6 +8,8 @@ | |||
453 | 8 | default_event_builder.cpp | 8 | default_event_builder.cpp |
454 | 9 | default_input_manager.cpp | 9 | default_input_manager.cpp |
455 | 10 | default_input_device_hub.cpp | 10 | default_input_device_hub.cpp |
456 | 11 | input_modifier_utils.cpp | ||
457 | 12 | seat.cpp | ||
458 | 11 | 13 | ||
459 | 12 | surface_input_dispatcher.cpp | 14 | surface_input_dispatcher.cpp |
460 | 13 | event_filter_chain_dispatcher.cpp | 15 | event_filter_chain_dispatcher.cpp |
461 | 14 | 16 | ||
462 | === modified file 'src/server/input/default_event_builder.cpp' | |||
463 | --- src/server/input/default_event_builder.cpp 2015-10-09 00:15:44 +0000 | |||
464 | +++ src/server/input/default_event_builder.cpp 2015-10-26 14:13:05 +0000 | |||
465 | @@ -33,21 +33,21 @@ | |||
466 | 33 | } | 33 | } |
467 | 34 | 34 | ||
468 | 35 | mir::EventUPtr mi::DefaultEventBuilder::key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code, | 35 | mir::EventUPtr mi::DefaultEventBuilder::key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code, |
470 | 36 | int scan_code, MirInputEventModifiers modifiers) | 36 | int scan_code) |
471 | 37 | { | 37 | { |
472 | 38 | uint64_t mac = cookie_factory->timestamp_to_cookie(timestamp.count()).mac; | 38 | uint64_t mac = cookie_factory->timestamp_to_cookie(timestamp.count()).mac; |
474 | 39 | return me::make_event(device_id, timestamp, mac, action, key_code, scan_code, modifiers); | 39 | return me::make_event(device_id, timestamp, mac, action, key_code, scan_code, mir_input_event_modifier_none); |
475 | 40 | } | 40 | } |
476 | 41 | 41 | ||
478 | 42 | mir::EventUPtr mi::DefaultEventBuilder::touch_event(Timestamp timestamp, MirInputEventModifiers modifiers) | 42 | mir::EventUPtr mi::DefaultEventBuilder::touch_event(Timestamp timestamp) |
479 | 43 | { | 43 | { |
481 | 44 | return me::make_event(device_id, timestamp, 0, modifiers); | 44 | return me::make_event(device_id, timestamp, 0, mir_input_event_modifier_none); |
482 | 45 | } | 45 | } |
483 | 46 | 46 | ||
484 | 47 | void mi::DefaultEventBuilder::add_touch(MirEvent& event, MirTouchId touch_id, MirTouchAction action, | 47 | void mi::DefaultEventBuilder::add_touch(MirEvent& event, MirTouchId touch_id, MirTouchAction action, |
488 | 48 | MirTouchTooltype tooltype, float x_axis_value, float y_axis_value, | 48 | MirTouchTooltype tooltype, float x_axis_value, float y_axis_value, |
489 | 49 | float pressure_value, float touch_major_value, | 49 | float pressure_value, float touch_major_value, float touch_minor_value, |
490 | 50 | float touch_minor_value, float size_value) | 50 | float size_value) |
491 | 51 | { | 51 | { |
492 | 52 | if (action == mir_touch_action_up || action == mir_touch_action_down) | 52 | if (action == mir_touch_action_up || action == mir_touch_action_down) |
493 | 53 | { | 53 | { |
494 | @@ -59,17 +59,15 @@ | |||
495 | 59 | touch_minor_value, size_value); | 59 | touch_minor_value, size_value); |
496 | 60 | } | 60 | } |
497 | 61 | 61 | ||
503 | 62 | mir::EventUPtr mi::DefaultEventBuilder::pointer_event(Timestamp timestamp, MirInputEventModifiers modifiers, | 62 | mir::EventUPtr mi::DefaultEventBuilder::pointer_event(Timestamp timestamp, MirPointerAction action, |
504 | 63 | MirPointerAction action, MirPointerButtons buttons_pressed, | 63 | MirPointerButtons buttons_pressed, float x_axis_value, |
505 | 64 | float x_axis_value, float y_axis_value, float hscroll_value, | 64 | float y_axis_value, float hscroll_value, float vscroll_value, |
506 | 65 | float vscroll_value, float relative_x_value, | 65 | float relative_x_value, float relative_y_value) |
502 | 66 | float relative_y_value) | ||
507 | 67 | { | 66 | { |
508 | 68 | uint64_t mac = 0; | 67 | uint64_t mac = 0; |
509 | 69 | if (action == mir_pointer_action_button_up || action == mir_pointer_action_button_down) | 68 | if (action == mir_pointer_action_button_up || action == mir_pointer_action_button_down) |
510 | 70 | mac = cookie_factory->timestamp_to_cookie(timestamp.count()).mac; | 69 | mac = cookie_factory->timestamp_to_cookie(timestamp.count()).mac; |
513 | 71 | 70 | return me::make_event(device_id, timestamp, mac, mir_input_event_modifier_none, action, buttons_pressed, x_axis_value, y_axis_value, | |
512 | 72 | return me::make_event(device_id, timestamp, mac, modifiers, action, buttons_pressed, x_axis_value, y_axis_value, | ||
514 | 73 | hscroll_value, vscroll_value, relative_x_value, relative_y_value); | 71 | hscroll_value, vscroll_value, relative_x_value, relative_y_value); |
515 | 74 | } | 72 | } |
516 | 75 | 73 | ||
517 | 76 | 74 | ||
518 | === modified file 'src/server/input/default_event_builder.h' | |||
519 | --- src/server/input/default_event_builder.h 2015-10-08 00:23:43 +0000 | |||
520 | +++ src/server/input/default_event_builder.h 2015-10-26 14:13:05 +0000 | |||
521 | @@ -37,18 +37,16 @@ | |||
522 | 37 | explicit DefaultEventBuilder(MirInputDeviceId device_id, | 37 | explicit DefaultEventBuilder(MirInputDeviceId device_id, |
523 | 38 | std::shared_ptr<cookie::CookieFactory> const& cookie_factory); | 38 | std::shared_ptr<cookie::CookieFactory> const& cookie_factory); |
524 | 39 | 39 | ||
527 | 40 | EventUPtr key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code, int scan_code, | 40 | EventUPtr key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code, int scan_code) override; |
526 | 41 | MirInputEventModifiers modifiers) override; | ||
528 | 42 | 41 | ||
530 | 43 | EventUPtr touch_event(Timestamp timestamp, MirInputEventModifiers modifiers) override; | 42 | EventUPtr touch_event(Timestamp timestamp) override; |
531 | 44 | void add_touch(MirEvent& event, MirTouchId touch_id, MirTouchAction action, MirTouchTooltype tooltype, | 43 | void add_touch(MirEvent& event, MirTouchId touch_id, MirTouchAction action, MirTouchTooltype tooltype, |
532 | 45 | float x_axis_value, float y_axis_value, float pressure_value, float touch_major_value, | 44 | float x_axis_value, float y_axis_value, float pressure_value, float touch_major_value, |
533 | 46 | float touch_minor_value, float size_value) override; | 45 | float touch_minor_value, float size_value) override; |
534 | 47 | 46 | ||
539 | 48 | EventUPtr pointer_event(Timestamp timestamp, MirInputEventModifiers modifiers, MirPointerAction action, | 47 | EventUPtr pointer_event(Timestamp timestamp, MirPointerAction action, MirPointerButtons buttons_pressed, |
540 | 49 | MirPointerButtons buttons_pressed, float x_axis_value, float y_axis_value, | 48 | float x_axis_value, float y_axis_value, float hscroll_value, float vscroll_value, |
541 | 50 | float hscroll_value, float vscroll_value, float relative_x_value, | 49 | float relative_x_value, float relative_y_value) override; |
538 | 51 | float relative_y_value) override; | ||
542 | 52 | 50 | ||
543 | 53 | EventUPtr configuration_event(Timestamp timestamp, MirInputConfigurationAction action) override; | 51 | EventUPtr configuration_event(Timestamp timestamp, MirInputConfigurationAction action) override; |
544 | 54 | 52 | ||
545 | 55 | 53 | ||
546 | === modified file 'src/server/input/default_input_device_hub.cpp' | |||
547 | --- src/server/input/default_input_device_hub.cpp 2015-10-08 00:23:43 +0000 | |||
548 | +++ src/server/input/default_input_device_hub.cpp 2015-10-26 14:13:05 +0000 | |||
549 | @@ -19,11 +19,13 @@ | |||
550 | 19 | #include "default_input_device_hub.h" | 19 | #include "default_input_device_hub.h" |
551 | 20 | #include "device_handle.h" | 20 | #include "device_handle.h" |
552 | 21 | 21 | ||
553 | 22 | #include "seat.h" | ||
554 | 22 | #include "mir/input/input_dispatcher.h" | 23 | #include "mir/input/input_dispatcher.h" |
555 | 23 | #include "mir/input/input_device.h" | 24 | #include "mir/input/input_device.h" |
556 | 24 | #include "mir/input/input_device_observer.h" | 25 | #include "mir/input/input_device_observer.h" |
557 | 25 | #include "mir/input/cursor_listener.h" | ||
558 | 26 | #include "mir/input/input_region.h" | 26 | #include "mir/input/input_region.h" |
559 | 27 | #include "mir/geometry/point.h" | ||
560 | 28 | #include "mir/events/event_builders.h" | ||
561 | 27 | #include "mir/dispatch/multiplexing_dispatchable.h" | 29 | #include "mir/dispatch/multiplexing_dispatchable.h" |
562 | 28 | #include "mir/server_action_queue.h" | 30 | #include "mir/server_action_queue.h" |
563 | 29 | #include "mir/cookie_factory.h" | 31 | #include "mir/cookie_factory.h" |
564 | @@ -36,6 +38,8 @@ | |||
565 | 36 | #include <atomic> | 38 | #include <atomic> |
566 | 37 | 39 | ||
567 | 38 | namespace mi = mir::input; | 40 | namespace mi = mir::input; |
568 | 41 | namespace geom = mir::geometry; | ||
569 | 42 | namespace mev = mir::events; | ||
570 | 39 | 43 | ||
571 | 40 | mi::DefaultInputDeviceHub::DefaultInputDeviceHub( | 44 | mi::DefaultInputDeviceHub::DefaultInputDeviceHub( |
572 | 41 | std::shared_ptr<mi::InputDispatcher> const& input_dispatcher, | 45 | std::shared_ptr<mi::InputDispatcher> const& input_dispatcher, |
573 | @@ -45,9 +49,13 @@ | |||
574 | 45 | std::shared_ptr<CursorListener> const& cursor_listener, | 49 | std::shared_ptr<CursorListener> const& cursor_listener, |
575 | 46 | std::shared_ptr<InputRegion> const& input_region, | 50 | std::shared_ptr<InputRegion> const& input_region, |
576 | 47 | std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory) | 51 | std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory) |
580 | 48 | : input_dispatcher(input_dispatcher), input_dispatchable{input_multiplexer}, observer_queue(observer_queue), | 52 | : input_dispatcher(input_dispatcher), |
581 | 49 | touch_visualizer(touch_visualizer), cursor_listener(cursor_listener), input_region(input_region), | 53 | input_dispatchable{input_multiplexer}, |
582 | 50 | cookie_factory(cookie_factory), device_id_generator{0} | 54 | observer_queue(observer_queue), |
583 | 55 | input_region(input_region), | ||
584 | 56 | cookie_factory(cookie_factory), | ||
585 | 57 | seat(touch_visualizer, cursor_listener), | ||
586 | 58 | device_id_generator{0} | ||
587 | 51 | { | 59 | { |
588 | 52 | } | 60 | } |
589 | 53 | 61 | ||
590 | @@ -67,9 +75,10 @@ | |||
591 | 67 | { | 75 | { |
592 | 68 | // send input device info to observer loop.. | 76 | // send input device info to observer loop.. |
593 | 69 | devices.push_back(std::make_unique<RegisteredDevice>( | 77 | devices.push_back(std::make_unique<RegisteredDevice>( |
595 | 70 | device, create_new_device_id(), input_dispatcher, input_dispatchable, cookie_factory, this)); | 78 | device, create_new_device_id(), input_dispatcher, input_dispatchable, cookie_factory, this, &seat)); |
596 | 71 | 79 | ||
597 | 72 | auto const& dev = devices.back(); | 80 | auto const& dev = devices.back(); |
598 | 81 | seat.add_device(dev->id()); | ||
599 | 73 | 82 | ||
600 | 74 | auto handle = std::make_shared<DefaultDevice>( | 83 | auto handle = std::make_shared<DefaultDevice>( |
601 | 75 | dev->id(), device->get_device_info()); | 84 | dev->id(), device->get_device_info()); |
602 | @@ -104,6 +113,7 @@ | |||
603 | 104 | if (item->device_matches(device)) | 113 | if (item->device_matches(device)) |
604 | 105 | { | 114 | { |
605 | 106 | item->stop(); | 115 | item->stop(); |
606 | 116 | seat.remove_device(item->id()); | ||
607 | 107 | 117 | ||
608 | 108 | // send input device info to observer queue.. | 118 | // send input device info to observer queue.. |
609 | 109 | observer_queue->enqueue( | 119 | observer_queue->enqueue( |
610 | @@ -131,9 +141,10 @@ | |||
611 | 131 | std::shared_ptr<InputDispatcher> const& dispatcher, | 141 | std::shared_ptr<InputDispatcher> const& dispatcher, |
612 | 132 | std::shared_ptr<dispatch::MultiplexingDispatchable> const& multiplexer, | 142 | std::shared_ptr<dispatch::MultiplexingDispatchable> const& multiplexer, |
613 | 133 | std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory, | 143 | std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory, |
615 | 134 | DefaultInputDeviceHub* hub) | 144 | DefaultInputDeviceHub* hub, |
616 | 145 | Seat* seat) | ||
617 | 135 | : device_id(device_id), builder(device_id, cookie_factory), device(dev), dispatcher(dispatcher), | 146 | : device_id(device_id), builder(device_id, cookie_factory), device(dev), dispatcher(dispatcher), |
619 | 136 | multiplexer(multiplexer), hub(hub) | 147 | multiplexer(multiplexer), hub(hub), seat(seat) |
620 | 137 | { | 148 | { |
621 | 138 | } | 149 | } |
622 | 139 | 150 | ||
623 | @@ -154,50 +165,17 @@ | |||
624 | 154 | if (type != mir_event_type_input) | 165 | if (type != mir_event_type_input) |
625 | 155 | BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid input event receivd from device")); | 166 | BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid input event receivd from device")); |
626 | 156 | 167 | ||
629 | 157 | update_spots(mir_event_get_input_event(&event)); | 168 | auto input_event = mir_event_get_input_event(&event); |
630 | 158 | notify_cursor_listener(mir_event_get_input_event(&event)); | 169 | seat->update_seat_properties(input_event); |
631 | 170 | |||
632 | 171 | if (mir_input_event_type_key == mir_input_event_get_type(input_event)) | ||
633 | 172 | mev::set_modifier(event, seat->event_modifier(mir_input_event_get_device_id(input_event))); | ||
634 | 173 | else | ||
635 | 174 | mev::set_modifier(event, seat->event_modifier()); | ||
636 | 175 | |||
637 | 159 | dispatcher->dispatch(event); | 176 | dispatcher->dispatch(event); |
638 | 160 | } | 177 | } |
639 | 161 | 178 | ||
640 | 162 | void mi::DefaultInputDeviceHub::RegisteredDevice::notify_cursor_listener(MirInputEvent const* event) | ||
641 | 163 | { | ||
642 | 164 | if (mir_input_event_get_type(event) != mir_input_event_type_pointer) | ||
643 | 165 | return; | ||
644 | 166 | |||
645 | 167 | auto pointer_ev = mir_input_event_get_pointer_event(event); | ||
646 | 168 | hub->cursor_listener->cursor_moved_to( | ||
647 | 169 | mir_pointer_event_axis_value(pointer_ev, mir_pointer_axis_x), | ||
648 | 170 | mir_pointer_event_axis_value(pointer_ev, mir_pointer_axis_y) | ||
649 | 171 | ); | ||
650 | 172 | } | ||
651 | 173 | |||
652 | 174 | void mi::DefaultInputDeviceHub::RegisteredDevice::update_spots(MirInputEvent const* event) | ||
653 | 175 | { | ||
654 | 176 | if (mir_input_event_get_type(event) != mir_input_event_type_touch) | ||
655 | 177 | return; | ||
656 | 178 | |||
657 | 179 | auto const* touch_event = mir_input_event_get_touch_event(event); | ||
658 | 180 | auto count = mir_touch_event_point_count(touch_event); | ||
659 | 181 | touch_spots.reserve(count); | ||
660 | 182 | touch_spots.clear(); | ||
661 | 183 | for (decltype(count) i = 0; i != count; ++i) | ||
662 | 184 | { | ||
663 | 185 | if (mir_touch_event_action(touch_event, i) == mir_touch_action_up) | ||
664 | 186 | continue; | ||
665 | 187 | touch_spots.push_back(mi::TouchVisualizer::Spot{ | ||
666 | 188 | {mir_touch_event_axis_value(touch_event, i, mir_touch_axis_x), | ||
667 | 189 | mir_touch_event_axis_value(touch_event, i, mir_touch_axis_y)}, | ||
668 | 190 | mir_touch_event_axis_value(touch_event, i, mir_touch_axis_pressure)}); | ||
669 | 191 | } | ||
670 | 192 | |||
671 | 193 | hub->update_spots(); | ||
672 | 194 | } | ||
673 | 195 | |||
674 | 196 | std::vector<mir::input::TouchVisualizer::Spot> const& mi::DefaultInputDeviceHub::RegisteredDevice::spots() const | ||
675 | 197 | { | ||
676 | 198 | return touch_spots; | ||
677 | 199 | } | ||
678 | 200 | |||
679 | 201 | bool mi::DefaultInputDeviceHub::RegisteredDevice::device_matches(std::shared_ptr<InputDevice> const& dev) const | 179 | bool mi::DefaultInputDeviceHub::RegisteredDevice::device_matches(std::shared_ptr<InputDevice> const& dev) const |
680 | 202 | { | 180 | { |
681 | 203 | return dev == device; | 181 | return dev == device; |
682 | @@ -278,13 +256,3 @@ | |||
683 | 278 | 256 | ||
684 | 279 | handles.erase(handle_it, end(handles)); | 257 | handles.erase(handle_it, end(handles)); |
685 | 280 | } | 258 | } |
686 | 281 | |||
687 | 282 | void mi::DefaultInputDeviceHub::update_spots() | ||
688 | 283 | { | ||
689 | 284 | std::vector<TouchVisualizer::Spot> spots; | ||
690 | 285 | |||
691 | 286 | for (auto const& dev : devices) | ||
692 | 287 | spots.insert(end(spots), begin(dev->spots()), end(dev->spots())); | ||
693 | 288 | |||
694 | 289 | touch_visualizer->visualize_touches(spots); | ||
695 | 290 | } | ||
696 | 291 | 259 | ||
697 | === modified file 'src/server/input/default_input_device_hub.h' | |||
698 | --- src/server/input/default_input_device_hub.h 2015-10-08 00:23:43 +0000 | |||
699 | +++ src/server/input/default_input_device_hub.h 2015-10-26 14:13:05 +0000 | |||
700 | @@ -20,12 +20,12 @@ | |||
701 | 20 | #define MIR_INPUT_DEFAULT_INPUT_DEVICE_HUB_H_ | 20 | #define MIR_INPUT_DEFAULT_INPUT_DEVICE_HUB_H_ |
702 | 21 | 21 | ||
703 | 22 | #include "default_event_builder.h" | 22 | #include "default_event_builder.h" |
704 | 23 | #include "seat.h" | ||
705 | 23 | 24 | ||
706 | 24 | #include "mir/input/input_device_registry.h" | 25 | #include "mir/input/input_device_registry.h" |
707 | 25 | #include "mir/input/input_sink.h" | 26 | #include "mir/input/input_sink.h" |
708 | 26 | #include "mir/input/input_device_hub.h" | 27 | #include "mir/input/input_device_hub.h" |
709 | 27 | #include "mir/input/input_device_info.h" | 28 | #include "mir/input/input_device_info.h" |
710 | 28 | #include "mir/input/touch_visualizer.h" | ||
711 | 29 | 29 | ||
712 | 30 | #include "mir_toolkit/event.h" | 30 | #include "mir_toolkit/event.h" |
713 | 31 | 31 | ||
714 | @@ -82,10 +82,9 @@ | |||
715 | 82 | std::shared_ptr<InputDispatcher> const input_dispatcher; | 82 | std::shared_ptr<InputDispatcher> const input_dispatcher; |
716 | 83 | std::shared_ptr<dispatch::MultiplexingDispatchable> const input_dispatchable; | 83 | std::shared_ptr<dispatch::MultiplexingDispatchable> const input_dispatchable; |
717 | 84 | std::shared_ptr<ServerActionQueue> const observer_queue; | 84 | std::shared_ptr<ServerActionQueue> const observer_queue; |
718 | 85 | std::shared_ptr<TouchVisualizer> const touch_visualizer; | ||
719 | 86 | std::shared_ptr<CursorListener> const cursor_listener; | ||
720 | 87 | std::shared_ptr<InputRegion> const input_region; | 85 | std::shared_ptr<InputRegion> const input_region; |
721 | 88 | std::shared_ptr<cookie::CookieFactory> const cookie_factory; | 86 | std::shared_ptr<cookie::CookieFactory> const cookie_factory; |
722 | 87 | Seat seat; | ||
723 | 89 | 88 | ||
724 | 90 | struct RegisteredDevice : public InputSink | 89 | struct RegisteredDevice : public InputSink |
725 | 91 | { | 90 | { |
726 | @@ -95,8 +94,8 @@ | |||
727 | 95 | std::shared_ptr<InputDispatcher> const& dispatcher, | 94 | std::shared_ptr<InputDispatcher> const& dispatcher, |
728 | 96 | std::shared_ptr<dispatch::MultiplexingDispatchable> const& multiplexer, | 95 | std::shared_ptr<dispatch::MultiplexingDispatchable> const& multiplexer, |
729 | 97 | std::shared_ptr<cookie::CookieFactory> const& cookie_factory, | 96 | std::shared_ptr<cookie::CookieFactory> const& cookie_factory, |
732 | 98 | DefaultInputDeviceHub* hub); | 97 | DefaultInputDeviceHub* hub, |
733 | 99 | 98 | Seat* seat); | |
734 | 100 | void handle_input(MirEvent& event) override; | 99 | void handle_input(MirEvent& event) override; |
735 | 101 | void confine_pointer(mir::geometry::Point& position) override; | 100 | void confine_pointer(mir::geometry::Point& position) override; |
736 | 102 | mir::geometry::Rectangle bounding_rectangle() const override; | 101 | mir::geometry::Rectangle bounding_rectangle() const override; |
737 | @@ -104,24 +103,21 @@ | |||
738 | 104 | void start(); | 103 | void start(); |
739 | 105 | void stop(); | 104 | void stop(); |
740 | 106 | MirInputDeviceId id(); | 105 | MirInputDeviceId id(); |
741 | 107 | std::vector<TouchVisualizer::Spot> const& spots() const; | ||
742 | 108 | private: | 106 | private: |
743 | 109 | void update_spots(MirInputEvent const* event); | ||
744 | 110 | void notify_cursor_listener(MirInputEvent const* event); | ||
745 | 111 | MirInputDeviceId device_id; | 107 | MirInputDeviceId device_id; |
746 | 112 | DefaultEventBuilder builder; | 108 | DefaultEventBuilder builder; |
747 | 113 | std::shared_ptr<InputDevice> const device; | 109 | std::shared_ptr<InputDevice> const device; |
748 | 114 | std::shared_ptr<InputDispatcher> const dispatcher; | 110 | std::shared_ptr<InputDispatcher> const dispatcher; |
749 | 115 | std::shared_ptr<dispatch::MultiplexingDispatchable> const multiplexer; | 111 | std::shared_ptr<dispatch::MultiplexingDispatchable> const multiplexer; |
750 | 116 | DefaultInputDeviceHub* hub; | 112 | DefaultInputDeviceHub* hub; |
752 | 117 | std::vector<TouchVisualizer::Spot> touch_spots; | 113 | Seat* seat; |
753 | 118 | friend class DefaultInputDeviceHub; | 114 | friend class DefaultInputDeviceHub; |
754 | 119 | }; | 115 | }; |
755 | 120 | 116 | ||
756 | 121 | std::vector<std::shared_ptr<DefaultDevice>> handles; | 117 | std::vector<std::shared_ptr<DefaultDevice>> handles; |
757 | 122 | std::vector<std::unique_ptr<RegisteredDevice>> devices; | 118 | std::vector<std::unique_ptr<RegisteredDevice>> devices; |
758 | 123 | std::vector<std::shared_ptr<InputDeviceObserver>> observers; | 119 | std::vector<std::shared_ptr<InputDeviceObserver>> observers; |
760 | 124 | 120 | ||
761 | 125 | MirInputDeviceId device_id_generator; | 121 | MirInputDeviceId device_id_generator; |
762 | 126 | }; | 122 | }; |
763 | 127 | 123 | ||
764 | 128 | 124 | ||
765 | === renamed file 'src/platforms/evdev/input_modifier_utils.cpp' => 'src/server/input/input_modifier_utils.cpp' | |||
766 | --- src/platforms/evdev/input_modifier_utils.cpp 2015-10-20 03:30:00 +0000 | |||
767 | +++ src/server/input/input_modifier_utils.cpp 2015-10-26 14:13:05 +0000 | |||
768 | @@ -25,26 +25,9 @@ | |||
769 | 25 | 25 | ||
770 | 26 | #include <stdexcept> | 26 | #include <stdexcept> |
771 | 27 | 27 | ||
792 | 28 | namespace mie = mir::input::evdev; | 28 | namespace mi = mir::input; |
793 | 29 | 29 | ||
794 | 30 | MirPointerButton mie::to_pointer_button(int button, MirPointerHandedness handedness) | 30 | MirInputEventModifiers mi::to_modifiers(int32_t scan_code) |
775 | 31 | { | ||
776 | 32 | switch(button) | ||
777 | 33 | { | ||
778 | 34 | case BTN_LEFT: return (handedness == mir_pointer_handedness_right) | ||
779 | 35 | ? mir_pointer_button_primary | ||
780 | 36 | : mir_pointer_button_secondary; | ||
781 | 37 | case BTN_RIGHT: return (handedness == mir_pointer_handedness_right) | ||
782 | 38 | ? mir_pointer_button_secondary | ||
783 | 39 | : mir_pointer_button_primary; | ||
784 | 40 | case BTN_MIDDLE: return mir_pointer_button_tertiary; | ||
785 | 41 | case BTN_BACK: return mir_pointer_button_back; | ||
786 | 42 | case BTN_FORWARD: return mir_pointer_button_forward; | ||
787 | 43 | } | ||
788 | 44 | BOOST_THROW_EXCEPTION(std::runtime_error("Invalid mouse button")); | ||
789 | 45 | } | ||
790 | 46 | |||
791 | 47 | MirInputEventModifiers mie::to_modifiers(int32_t scan_code) | ||
795 | 48 | { | 31 | { |
796 | 49 | switch(scan_code) | 32 | switch(scan_code) |
797 | 50 | { | 33 | { |
798 | @@ -75,7 +58,7 @@ | |||
799 | 75 | } | 58 | } |
800 | 76 | } | 59 | } |
801 | 77 | 60 | ||
803 | 78 | MirInputEventModifiers mie::expand_modifiers(MirInputEventModifiers modifiers) | 61 | MirInputEventModifiers mi::expand_modifiers(MirInputEventModifiers modifiers) |
804 | 79 | { | 62 | { |
805 | 80 | if (modifiers == 0) | 63 | if (modifiers == 0) |
806 | 81 | return mir_input_event_modifier_none; | 64 | return mir_input_event_modifier_none; |
807 | @@ -95,4 +78,3 @@ | |||
808 | 95 | return modifiers; | 78 | return modifiers; |
809 | 96 | } | 79 | } |
810 | 97 | 80 | ||
811 | 98 | |||
812 | 99 | 81 | ||
813 | === renamed file 'src/platforms/evdev/input_modifier_utils.h' => 'src/server/input/input_modifier_utils.h' | |||
814 | --- src/platforms/evdev/input_modifier_utils.h 2015-10-20 03:30:00 +0000 | |||
815 | +++ src/server/input/input_modifier_utils.h 2015-10-26 14:13:05 +0000 | |||
816 | @@ -16,23 +16,18 @@ | |||
817 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
818 | 17 | */ | 17 | */ |
819 | 18 | 18 | ||
822 | 19 | #ifndef MIR_INPUT_EVDEV_INPUT_MODIFIER_UTILS_H_ | 19 | #ifndef MIR_INPUT_INPUT_MODIFIER_UTILS_H_ |
823 | 20 | #define MIR_INPUT_EVDEV_INPUT_MODIFIER_UTILS_H_ | 20 | #define MIR_INPUT_INPUT_MODIFIER_UTILS_H_ |
824 | 21 | 21 | ||
825 | 22 | #include "mir_toolkit/event.h" | 22 | #include "mir_toolkit/event.h" |
826 | 23 | #include "mir_toolkit/mir_input_device.h" | ||
827 | 24 | 23 | ||
828 | 25 | namespace mir | 24 | namespace mir |
829 | 26 | { | 25 | { |
830 | 27 | namespace input | 26 | namespace input |
831 | 28 | { | 27 | { |
832 | 29 | namespace evdev | ||
833 | 30 | { | ||
834 | 31 | MirPointerButton to_pointer_button(int button, MirPointerHandedness handedness); | ||
835 | 32 | MirInputEventModifiers to_modifiers(int32_t scan_code); | 28 | MirInputEventModifiers to_modifiers(int32_t scan_code); |
836 | 33 | MirInputEventModifiers expand_modifiers(MirInputEventModifiers modifiers); | 29 | MirInputEventModifiers expand_modifiers(MirInputEventModifiers modifiers); |
837 | 34 | } | 30 | } |
838 | 35 | } | 31 | } |
839 | 36 | } | ||
840 | 37 | 32 | ||
841 | 38 | #endif | 33 | #endif |
842 | 39 | 34 | ||
843 | === added file 'src/server/input/seat.cpp' | |||
844 | --- src/server/input/seat.cpp 1970-01-01 00:00:00 +0000 | |||
845 | +++ src/server/input/seat.cpp 2015-10-26 14:13:05 +0000 | |||
846 | @@ -0,0 +1,161 @@ | |||
847 | 1 | /* | ||
848 | 2 | * Copyright © 2015 Canonical Ltd. | ||
849 | 3 | * | ||
850 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
851 | 5 | * under the terms of the GNU General Public License version 3, | ||
852 | 6 | * as published by the Free Software Foundation. | ||
853 | 7 | * | ||
854 | 8 | * This program is distributed in the hope that it will be useful, | ||
855 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
856 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
857 | 11 | * GNU General Public License for more details. | ||
858 | 12 | * | ||
859 | 13 | * You should have received a copy of the GNU General Public License | ||
860 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
861 | 15 | * | ||
862 | 16 | * Authored by: | ||
863 | 17 | * Andreas Pokorny <andreas.pokorny@canonical.com> | ||
864 | 18 | */ | ||
865 | 19 | |||
866 | 20 | #include "seat.h" | ||
867 | 21 | #include "mir/input/device.h" | ||
868 | 22 | #include "mir/input/cursor_listener.h" | ||
869 | 23 | |||
870 | 24 | #include "input_modifier_utils.h" | ||
871 | 25 | |||
872 | 26 | #include <boost/throw_exception.hpp> | ||
873 | 27 | |||
874 | 28 | #include <stdexcept> | ||
875 | 29 | #include <algorithm> | ||
876 | 30 | |||
877 | 31 | namespace mi = mir::input; | ||
878 | 32 | |||
879 | 33 | mi::Seat::Seat(std::shared_ptr<TouchVisualizer> const& touch_visualizer, | ||
880 | 34 | std::shared_ptr<CursorListener> const& cursor_listener) | ||
881 | 35 | : touch_visualizer{touch_visualizer}, cursor_listener{cursor_listener}, modifier{0} | ||
882 | 36 | { | ||
883 | 37 | } | ||
884 | 38 | |||
885 | 39 | void mi::Seat::add_device(MirInputDeviceId id) | ||
886 | 40 | { | ||
887 | 41 | device_data[id]; | ||
888 | 42 | } | ||
889 | 43 | |||
890 | 44 | void mi::Seat::remove_device(MirInputDeviceId id) | ||
891 | 45 | { | ||
892 | 46 | auto stored_data = device_data.find(id); | ||
893 | 47 | |||
894 | 48 | if (stored_data == end(device_data)) | ||
895 | 49 | BOOST_THROW_EXCEPTION(std::logic_error("Modifier for unknown device changed")); | ||
896 | 50 | |||
897 | 51 | bool mod_update_needed = stored_data->second.mod != mir_input_event_modifier_none; | ||
898 | 52 | bool spot_update_needed = !stored_data->second.spots.empty(); | ||
899 | 53 | |||
900 | 54 | device_data.erase(stored_data); | ||
901 | 55 | |||
902 | 56 | if (mod_update_needed) | ||
903 | 57 | update_modifier(); | ||
904 | 58 | if (spot_update_needed) | ||
905 | 59 | update_spots(); | ||
906 | 60 | } | ||
907 | 61 | |||
908 | 62 | MirInputEventModifiers mi::Seat::event_modifier() const | ||
909 | 63 | { | ||
910 | 64 | return expand_modifiers(modifier); | ||
911 | 65 | } | ||
912 | 66 | |||
913 | 67 | MirInputEventModifiers mi::Seat::event_modifier(MirInputDeviceId id) const | ||
914 | 68 | { | ||
915 | 69 | auto stored_data = device_data.find(id); | ||
916 | 70 | if (stored_data == end(device_data)) | ||
917 | 71 | BOOST_THROW_EXCEPTION(std::logic_error("Modifier for unknown device requested")); | ||
918 | 72 | return expand_modifiers(stored_data->second.mod); | ||
919 | 73 | } | ||
920 | 74 | |||
921 | 75 | void mi::Seat::update_seat_properties(MirInputEvent const* event) | ||
922 | 76 | { | ||
923 | 77 | auto id = mir_input_event_get_device_id(event); | ||
924 | 78 | |||
925 | 79 | auto stored_data = device_data.find(id); | ||
926 | 80 | |||
927 | 81 | if (stored_data == end(device_data)) | ||
928 | 82 | BOOST_THROW_EXCEPTION(std::logic_error("Modifier for unknown device changed")); | ||
929 | 83 | |||
930 | 84 | switch(mir_input_event_get_type(event)) | ||
931 | 85 | { | ||
932 | 86 | case mir_input_event_type_key: | ||
933 | 87 | { | ||
934 | 88 | auto const* key = mir_input_event_get_keyboard_event(event); | ||
935 | 89 | if (stored_data->second.update_modifier(mir_keyboard_event_action(key), | ||
936 | 90 | mir_keyboard_event_scan_code(key))) | ||
937 | 91 | update_modifier(); | ||
938 | 92 | break; | ||
939 | 93 | } | ||
940 | 94 | case mir_input_event_type_touch: | ||
941 | 95 | if (stored_data->second.update_spots(mir_input_event_get_touch_event(event))) | ||
942 | 96 | update_spots(); | ||
943 | 97 | break; | ||
944 | 98 | case mir_input_event_type_pointer: | ||
945 | 99 | update_cursor(mir_input_event_get_pointer_event(event)); | ||
946 | 100 | break; | ||
947 | 101 | default: | ||
948 | 102 | break; | ||
949 | 103 | } | ||
950 | 104 | } | ||
951 | 105 | |||
952 | 106 | bool mi::Seat::DeviceData::update_modifier(MirKeyboardAction key_action, int scan_code) | ||
953 | 107 | { | ||
954 | 108 | auto mod_change = to_modifiers(scan_code); | ||
955 | 109 | |||
956 | 110 | if (mod_change == 0 || key_action == mir_keyboard_action_repeat) | ||
957 | 111 | return false; | ||
958 | 112 | |||
959 | 113 | if (key_action == mir_keyboard_action_down) | ||
960 | 114 | mod |= mod_change; | ||
961 | 115 | else if (key_action == mir_keyboard_action_up) | ||
962 | 116 | mod &= ~mod_change; | ||
963 | 117 | |||
964 | 118 | return true; | ||
965 | 119 | } | ||
966 | 120 | |||
967 | 121 | bool mi::Seat::DeviceData::update_spots(MirTouchEvent const* event) | ||
968 | 122 | { | ||
969 | 123 | auto count = mir_touch_event_point_count(event); | ||
970 | 124 | spots.clear(); | ||
971 | 125 | for (decltype(count) i = 0; i != count; ++i) | ||
972 | 126 | { | ||
973 | 127 | if (mir_touch_event_action(event, i) == mir_touch_action_up) | ||
974 | 128 | continue; | ||
975 | 129 | spots.push_back({{mir_touch_event_axis_value(event, i, mir_touch_axis_x), | ||
976 | 130 | mir_touch_event_axis_value(event, i, mir_touch_axis_y)}, | ||
977 | 131 | mir_touch_event_axis_value(event, i, mir_touch_axis_pressure)}); | ||
978 | 132 | } | ||
979 | 133 | return true; | ||
980 | 134 | } | ||
981 | 135 | |||
982 | 136 | void mi::Seat::update_spots() | ||
983 | 137 | { | ||
984 | 138 | spots.clear(); | ||
985 | 139 | for (auto const& dev : device_data) | ||
986 | 140 | spots.insert(end(spots), begin(dev.second.spots), end(dev.second.spots)); | ||
987 | 141 | |||
988 | 142 | touch_visualizer->visualize_touches(spots); | ||
989 | 143 | } | ||
990 | 144 | |||
991 | 145 | void mi::Seat::update_modifier() | ||
992 | 146 | { | ||
993 | 147 | modifier = std::accumulate(begin(device_data), | ||
994 | 148 | end(device_data), | ||
995 | 149 | MirInputEventModifiers{0}, | ||
996 | 150 | [](auto const& acc, auto const& item) | ||
997 | 151 | { | ||
998 | 152 | return acc | item.second.mod; | ||
999 | 153 | }); | ||
1000 | 154 | } | ||
1001 | 155 | |||
1002 | 156 | void mi::Seat::update_cursor(MirPointerEvent const* event) | ||
1003 | 157 | { | ||
1004 | 158 | cursor_listener->cursor_moved_to(mir_pointer_event_axis_value(event, mir_pointer_axis_x), | ||
1005 | 159 | mir_pointer_event_axis_value(event, mir_pointer_axis_y)); | ||
1006 | 160 | } | ||
1007 | 161 | |||
1008 | 0 | 162 | ||
1009 | === added file 'src/server/input/seat.h' | |||
1010 | --- src/server/input/seat.h 1970-01-01 00:00:00 +0000 | |||
1011 | +++ src/server/input/seat.h 2015-10-26 14:13:05 +0000 | |||
1012 | @@ -0,0 +1,74 @@ | |||
1013 | 1 | /* | ||
1014 | 2 | * Copyright © 2015 Canonical Ltd. | ||
1015 | 3 | * | ||
1016 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1017 | 5 | * under the terms of the GNU General Public License version 3, | ||
1018 | 6 | * as published by the Free Software Foundation. | ||
1019 | 7 | * | ||
1020 | 8 | * This program is distributed in the hope that it will be useful, | ||
1021 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1022 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1023 | 11 | * GNU General Public License for more details. | ||
1024 | 12 | * | ||
1025 | 13 | * You should have received a copy of the GNU General Public License | ||
1026 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1027 | 15 | * | ||
1028 | 16 | * Authored by: | ||
1029 | 17 | * Andreas Pokorny <andreas.pokorny@canonical.com> | ||
1030 | 18 | */ | ||
1031 | 19 | |||
1032 | 20 | #ifndef MIR_INPUT_DEFAULT_SEAT_H_ | ||
1033 | 21 | #define MIR_INPUT_DEFAULT_SEAT_H_ | ||
1034 | 22 | |||
1035 | 23 | #include "mir/input/touch_visualizer.h" | ||
1036 | 24 | #include "mir_toolkit/event.h" | ||
1037 | 25 | #include <unordered_map> | ||
1038 | 26 | #include <memory> | ||
1039 | 27 | |||
1040 | 28 | namespace mir | ||
1041 | 29 | { | ||
1042 | 30 | namespace input | ||
1043 | 31 | { | ||
1044 | 32 | class CursorListener; | ||
1045 | 33 | |||
1046 | 34 | /* | ||
1047 | 35 | * The seat bundles a group of devices. A cursor position, input event modifiers and the visible touch spots are properties | ||
1048 | 36 | * controlled by this grouping of input devices. | ||
1049 | 37 | */ | ||
1050 | 38 | class Seat | ||
1051 | 39 | { | ||
1052 | 40 | public: | ||
1053 | 41 | Seat(std::shared_ptr<TouchVisualizer> const& touch_visualizer, std::shared_ptr<CursorListener> const& cursor_listener); | ||
1054 | 42 | void add_device(MirInputDeviceId); | ||
1055 | 43 | void remove_device(MirInputDeviceId); | ||
1056 | 44 | |||
1057 | 45 | MirInputEventModifiers event_modifier() const; | ||
1058 | 46 | MirInputEventModifiers event_modifier(MirInputDeviceId) const; | ||
1059 | 47 | void update_seat_properties(MirInputEvent const* event); | ||
1060 | 48 | private: | ||
1061 | 49 | void update_cursor(MirPointerEvent const* event); | ||
1062 | 50 | void update_spots(); | ||
1063 | 51 | void update_modifier(); | ||
1064 | 52 | |||
1065 | 53 | std::shared_ptr<TouchVisualizer> const touch_visualizer; | ||
1066 | 54 | std::shared_ptr<CursorListener> const cursor_listener; | ||
1067 | 55 | |||
1068 | 56 | struct DeviceData | ||
1069 | 57 | { | ||
1070 | 58 | DeviceData() {} | ||
1071 | 59 | bool update_modifier(MirKeyboardAction action, int scan_code); | ||
1072 | 60 | bool update_spots(MirTouchEvent const* event); | ||
1073 | 61 | |||
1074 | 62 | MirInputEventModifiers mod{0}; | ||
1075 | 63 | std::vector<TouchVisualizer::Spot> spots; | ||
1076 | 64 | }; | ||
1077 | 65 | |||
1078 | 66 | MirInputEventModifiers modifier; | ||
1079 | 67 | std::unordered_map<MirInputDeviceId, DeviceData> device_data; | ||
1080 | 68 | std::vector<TouchVisualizer::Spot> spots; | ||
1081 | 69 | }; | ||
1082 | 70 | |||
1083 | 71 | } | ||
1084 | 72 | } | ||
1085 | 73 | |||
1086 | 74 | #endif | ||
1087 | 0 | 75 | ||
1088 | === modified file 'tests/mir_test_framework/fake_input_device_impl.cpp' | |||
1089 | --- tests/mir_test_framework/fake_input_device_impl.cpp 2015-10-23 16:32:32 +0000 | |||
1090 | +++ tests/mir_test_framework/fake_input_device_impl.cpp 2015-10-26 14:13:05 +0000 | |||
1091 | @@ -27,8 +27,7 @@ | |||
1092 | 27 | #include "mir/input/event_builder.h" | 27 | #include "mir/input/event_builder.h" |
1093 | 28 | #include "mir/dispatch/action_queue.h" | 28 | #include "mir/dispatch/action_queue.h" |
1094 | 29 | #include "mir/geometry/displacement.h" | 29 | #include "mir/geometry/displacement.h" |
1097 | 30 | #include "mir/module_deleter.h" | 30 | #include "src/platforms/evdev/button_utils.h" |
1096 | 31 | #include "src/platforms/evdev/input_modifier_utils.h" | ||
1098 | 32 | 31 | ||
1099 | 33 | #include "boost/throw_exception.hpp" | 32 | #include "boost/throw_exception.hpp" |
1100 | 34 | 33 | ||
1101 | @@ -103,13 +102,7 @@ | |||
1102 | 103 | auto input_action = | 102 | auto input_action = |
1103 | 104 | (key_params.action == synthesis::EventAction::Down) ? mir_keyboard_action_down : mir_keyboard_action_up; | 103 | (key_params.action == synthesis::EventAction::Down) ? mir_keyboard_action_down : mir_keyboard_action_up; |
1104 | 105 | 104 | ||
1112 | 106 | auto event_modifiers = mie::expand_modifiers(modifiers); | 105 | auto key_event = builder->key_event(event_time, input_action, key_code, key_params.scancode); |
1106 | 107 | auto key_event = builder->key_event(event_time, input_action, key_code, key_params.scancode, event_modifiers); | ||
1107 | 108 | |||
1108 | 109 | if (key_params.action == synthesis::EventAction::Down) | ||
1109 | 110 | modifiers |= mie::to_modifiers(key_params.scancode); | ||
1110 | 111 | else | ||
1111 | 112 | modifiers &= ~mie::to_modifiers(key_params.scancode); | ||
1113 | 113 | 106 | ||
1114 | 114 | if (!sink) | 107 | if (!sink) |
1115 | 115 | BOOST_THROW_EXCEPTION(std::runtime_error("Device is not started.")); | 108 | BOOST_THROW_EXCEPTION(std::runtime_error("Device is not started.")); |
1116 | @@ -121,9 +114,7 @@ | |||
1117 | 121 | auto event_time = std::chrono::duration_cast<std::chrono::nanoseconds>( | 114 | auto event_time = std::chrono::duration_cast<std::chrono::nanoseconds>( |
1118 | 122 | std::chrono::system_clock::now().time_since_epoch()); | 115 | std::chrono::system_clock::now().time_since_epoch()); |
1119 | 123 | auto action = update_buttons(button.action, mie::to_pointer_button(button.button, settings.handedness)); | 116 | auto action = update_buttons(button.action, mie::to_pointer_button(button.button, settings.handedness)); |
1120 | 124 | auto event_modifiers = mie::expand_modifiers(modifiers); | ||
1121 | 125 | auto button_event = builder->pointer_event(event_time, | 117 | auto button_event = builder->pointer_event(event_time, |
1122 | 126 | event_modifiers, | ||
1123 | 127 | action, | 118 | action, |
1124 | 128 | buttons, | 119 | buttons, |
1125 | 129 | pos.x.as_float(), | 120 | pos.x.as_float(), |
1126 | @@ -159,17 +150,15 @@ | |||
1127 | 159 | 150 | ||
1128 | 160 | auto event_time = std::chrono::duration_cast<std::chrono::nanoseconds>( | 151 | auto event_time = std::chrono::duration_cast<std::chrono::nanoseconds>( |
1129 | 161 | std::chrono::system_clock::now().time_since_epoch()); | 152 | std::chrono::system_clock::now().time_since_epoch()); |
1130 | 162 | auto event_modifiers = mie::expand_modifiers(modifiers); | ||
1131 | 163 | // constant scaling is used here to simplify checking for the | 153 | // constant scaling is used here to simplify checking for the |
1132 | 164 | // expected results. Default settings of the device lead to no | 154 | // expected results. Default settings of the device lead to no |
1133 | 165 | // scaling at all. | 155 | // scaling at all. |
1134 | 166 | auto acceleration = (settings.cursor_acceleration_bias + 1.0); | 156 | auto acceleration = (settings.cursor_acceleration_bias + 1.0); |
1135 | 167 | auto rel_x = pointer.rel_x * acceleration; | 157 | auto rel_x = pointer.rel_x * acceleration; |
1136 | 168 | auto rel_y = pointer.rel_y * acceleration; | 158 | auto rel_y = pointer.rel_y * acceleration; |
1138 | 169 | 159 | ||
1139 | 170 | update_position(rel_x, rel_y); | 160 | update_position(rel_x, rel_y); |
1140 | 171 | auto pointer_event = builder->pointer_event(event_time, | 161 | auto pointer_event = builder->pointer_event(event_time, |
1141 | 172 | event_modifiers, | ||
1142 | 173 | mir_pointer_action_motion, | 162 | mir_pointer_action_motion, |
1143 | 174 | buttons, | 163 | buttons, |
1144 | 175 | pos.x.as_float(), | 164 | pos.x.as_float(), |
1145 | @@ -195,9 +184,8 @@ | |||
1146 | 195 | 184 | ||
1147 | 196 | auto event_time = std::chrono::duration_cast<std::chrono::nanoseconds>( | 185 | auto event_time = std::chrono::duration_cast<std::chrono::nanoseconds>( |
1148 | 197 | std::chrono::system_clock::now().time_since_epoch()); | 186 | std::chrono::system_clock::now().time_since_epoch()); |
1149 | 198 | auto event_modifiers = mie::expand_modifiers(modifiers); | ||
1150 | 199 | 187 | ||
1152 | 200 | auto touch_event = builder->touch_event(event_time, event_modifiers); | 188 | auto touch_event = builder->touch_event(event_time); |
1153 | 201 | 189 | ||
1154 | 202 | auto touch_action = mir_touch_action_up; | 190 | auto touch_action = mir_touch_action_up; |
1155 | 203 | if (touch.action == synthesis::TouchParameters::Action::Tap) | 191 | if (touch.action == synthesis::TouchParameters::Action::Tap) |
1156 | 204 | 192 | ||
1157 | === modified file 'tests/mir_test_framework/fake_input_device_impl.h' | |||
1158 | --- tests/mir_test_framework/fake_input_device_impl.h 2015-10-23 16:32:32 +0000 | |||
1159 | +++ tests/mir_test_framework/fake_input_device_impl.h 2015-10-26 14:13:05 +0000 | |||
1160 | @@ -79,7 +79,6 @@ | |||
1161 | 79 | mir::input::EventBuilder* builder{nullptr}; | 79 | mir::input::EventBuilder* builder{nullptr}; |
1162 | 80 | mir::input::InputDeviceInfo info; | 80 | mir::input::InputDeviceInfo info; |
1163 | 81 | std::shared_ptr<mir::dispatch::Dispatchable> const queue; | 81 | std::shared_ptr<mir::dispatch::Dispatchable> const queue; |
1164 | 82 | uint32_t modifiers{0}; | ||
1165 | 83 | mir::geometry::Point pos, scroll; | 82 | mir::geometry::Point pos, scroll; |
1166 | 84 | MirPointerButtons buttons; | 83 | MirPointerButtons buttons; |
1167 | 85 | mir::input::PointerSettings settings; | 84 | mir::input::PointerSettings settings; |
1168 | 86 | 85 | ||
1169 | === modified file 'tests/unit-tests/input/evdev/test_libinput_device.cpp' | |||
1170 | --- tests/unit-tests/input/evdev/test_libinput_device.cpp 2015-10-23 16:32:32 +0000 | |||
1171 | +++ tests/unit-tests/input/evdev/test_libinput_device.cpp 2015-10-26 14:13:05 +0000 | |||
1172 | @@ -78,16 +78,15 @@ | |||
1173 | 78 | mi::DefaultEventBuilder builder{MirInputDeviceId{3}, cookie_factory}; | 78 | mi::DefaultEventBuilder builder{MirInputDeviceId{3}, cookie_factory}; |
1174 | 79 | MockEventBuilder() | 79 | MockEventBuilder() |
1175 | 80 | { | 80 | { |
1179 | 81 | ON_CALL(*this, key_event(_,_,_,_,_)) | 81 | ON_CALL(*this, key_event(_,_,_,_)) |
1180 | 82 | .WillByDefault(Invoke([this](Timestamp time, MirKeyboardAction action, xkb_keysym_t key, int scan_code, | 82 | .WillByDefault(Invoke([this](Timestamp time, MirKeyboardAction action, xkb_keysym_t key, int scan_code) |
1178 | 83 | MirInputEventModifiers modifier) | ||
1181 | 84 | { | 83 | { |
1183 | 85 | return builder.key_event(time, action, key, scan_code, modifier); | 84 | return builder.key_event(time, action, key, scan_code); |
1184 | 86 | })); | 85 | })); |
1187 | 87 | ON_CALL(*this, touch_event(_,_)) | 86 | ON_CALL(*this, touch_event(_)) |
1188 | 88 | .WillByDefault(Invoke([this](Timestamp time, MirInputEventModifiers modifier) | 87 | .WillByDefault(Invoke([this](Timestamp time) |
1189 | 89 | { | 88 | { |
1191 | 90 | return builder.touch_event(time, modifier); | 89 | return builder.touch_event(time); |
1192 | 91 | })); | 90 | })); |
1193 | 92 | ON_CALL(*this, add_touch(_,_,_,_,_,_,_,_,_,_)) | 91 | ON_CALL(*this, add_touch(_,_,_,_,_,_,_,_,_,_)) |
1194 | 93 | .WillByDefault(Invoke([this](MirEvent& event, MirTouchId id, MirTouchAction action, | 92 | .WillByDefault(Invoke([this](MirEvent& event, MirTouchId id, MirTouchAction action, |
1195 | @@ -97,13 +96,12 @@ | |||
1196 | 97 | return builder.add_touch(event, id, action, tooltype, x, y, major, minor, | 96 | return builder.add_touch(event, id, action, tooltype, x, y, major, minor, |
1197 | 98 | pressure, size); | 97 | pressure, size); |
1198 | 99 | })); | 98 | })); |
1203 | 100 | ON_CALL(*this, pointer_event(_,_,_,_,_,_,_,_,_,_)) | 99 | ON_CALL(*this, pointer_event(_, _, _, _, _, _, _, _, _)) |
1204 | 101 | .WillByDefault(Invoke([this](Timestamp time, MirInputEventModifiers modifier, MirPointerAction action, | 100 | .WillByDefault(Invoke([this](Timestamp time, MirPointerAction action, MirPointerButtons buttons, float x, |
1205 | 102 | MirPointerButtons buttons, float x, float y, float hscroll, float vscroll, | 101 | float y, float hscroll, float vscroll, float relative_x, float relative_y) |
1202 | 103 | float relative_x, float relative_y) | ||
1206 | 104 | { | 102 | { |
1209 | 105 | return builder.pointer_event(time, modifier, action, buttons, x, y, hscroll, | 103 | return builder.pointer_event(time, action, buttons, x, y, hscroll, vscroll, |
1210 | 106 | vscroll, relative_x, relative_y); | 104 | relative_x, relative_y); |
1211 | 107 | })); | 105 | })); |
1212 | 108 | ON_CALL(*this, configuration_event(_,_)) | 106 | ON_CALL(*this, configuration_event(_,_)) |
1213 | 109 | .WillByDefault(Invoke([this](Timestamp time, MirInputConfigurationAction action) | 107 | .WillByDefault(Invoke([this](Timestamp time, MirInputConfigurationAction action) |
1214 | @@ -112,14 +110,14 @@ | |||
1215 | 112 | })); | 110 | })); |
1216 | 113 | } | 111 | } |
1217 | 114 | using EventBuilder::Timestamp; | 112 | using EventBuilder::Timestamp; |
1219 | 115 | MOCK_METHOD5(key_event, mir::EventUPtr(Timestamp, MirKeyboardAction, xkb_keysym_t, int, MirInputEventModifiers)); | 113 | MOCK_METHOD4(key_event, mir::EventUPtr(Timestamp, MirKeyboardAction, xkb_keysym_t, int)); |
1220 | 116 | 114 | ||
1222 | 117 | MOCK_METHOD2(touch_event, mir::EventUPtr(Timestamp, MirInputEventModifiers)); | 115 | MOCK_METHOD1(touch_event, mir::EventUPtr(Timestamp)); |
1223 | 118 | MOCK_METHOD10(add_touch, void(MirEvent&, MirTouchId, MirTouchAction, MirTouchTooltype, float, float, float, float, | 116 | MOCK_METHOD10(add_touch, void(MirEvent&, MirTouchId, MirTouchAction, MirTouchTooltype, float, float, float, float, |
1224 | 119 | float, float)); | 117 | float, float)); |
1225 | 120 | 118 | ||
1228 | 121 | MOCK_METHOD10(pointer_event, mir::EventUPtr(Timestamp, MirInputEventModifiers, MirPointerAction, MirPointerButtons, | 119 | MOCK_METHOD9(pointer_event, mir::EventUPtr(Timestamp, MirPointerAction, MirPointerButtons, float, float, float, |
1229 | 122 | float, float, float, float, float, float)); | 120 | float, float, float)); |
1230 | 123 | MOCK_METHOD2(configuration_event, mir::EventUPtr(Timestamp, MirInputConfigurationAction)); | 121 | MOCK_METHOD2(configuration_event, mir::EventUPtr(Timestamp, MirInputConfigurationAction)); |
1231 | 124 | }; | 122 | }; |
1232 | 125 | 123 | ||
1233 | @@ -478,9 +476,9 @@ | |||
1234 | 478 | setup_key_event(fake_event_1, event_time_1, KEY_A, LIBINPUT_KEY_STATE_PRESSED); | 476 | setup_key_event(fake_event_1, event_time_1, KEY_A, LIBINPUT_KEY_STATE_PRESSED); |
1235 | 479 | setup_key_event(fake_event_2, event_time_2, KEY_A, LIBINPUT_KEY_STATE_RELEASED); | 477 | setup_key_event(fake_event_2, event_time_2, KEY_A, LIBINPUT_KEY_STATE_RELEASED); |
1236 | 480 | 478 | ||
1238 | 481 | EXPECT_CALL(mock_builder, key_event(time_stamp_1, mir_keyboard_action_down, _, KEY_A, mir_input_event_modifier_none)); | 479 | EXPECT_CALL(mock_builder, key_event(time_stamp_1, mir_keyboard_action_down, _, KEY_A)); |
1239 | 482 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_A),mt::KeyDownEvent()))); | 480 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_A),mt::KeyDownEvent()))); |
1241 | 483 | EXPECT_CALL(mock_builder, key_event(time_stamp_2, mir_keyboard_action_up, _, KEY_A, mir_input_event_modifier_none)); | 481 | EXPECT_CALL(mock_builder, key_event(time_stamp_2, mir_keyboard_action_up, _, KEY_A)); |
1242 | 484 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_A),mt::KeyUpEvent()))); | 482 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_A),mt::KeyUpEvent()))); |
1243 | 485 | 483 | ||
1244 | 486 | keyboard.start(&mock_sink, &mock_builder); | 484 | keyboard.start(&mock_sink, &mock_builder); |
1245 | @@ -495,15 +493,12 @@ | |||
1246 | 495 | setup_key_event(fake_event_3, event_time_3, KEY_C, LIBINPUT_KEY_STATE_RELEASED); | 493 | setup_key_event(fake_event_3, event_time_3, KEY_C, LIBINPUT_KEY_STATE_RELEASED); |
1247 | 496 | 494 | ||
1248 | 497 | InSequence seq; | 495 | InSequence seq; |
1250 | 498 | EXPECT_CALL(mock_builder, key_event(time_stamp_1, mir_keyboard_action_down, _, KEY_C, mir_input_event_modifier_none)); | 496 | EXPECT_CALL(mock_builder, key_event(time_stamp_1, mir_keyboard_action_down, _, KEY_C)); |
1251 | 499 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_C),mt::KeyDownEvent()))); | 497 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_C),mt::KeyDownEvent()))); |
1253 | 500 | EXPECT_CALL(mock_builder, key_event(time_stamp_2, mir_keyboard_action_down, _, KEY_LEFTALT, mir_input_event_modifier_none)); | 498 | EXPECT_CALL(mock_builder, key_event(time_stamp_2, mir_keyboard_action_down, _, KEY_LEFTALT)); |
1254 | 501 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_LEFTALT),mt::KeyDownEvent()))); | 499 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_LEFTALT),mt::KeyDownEvent()))); |
1257 | 502 | EXPECT_CALL(mock_builder, key_event(time_stamp_3, mir_keyboard_action_up, _, KEY_C, | 500 | EXPECT_CALL(mock_builder, key_event(time_stamp_3, mir_keyboard_action_up, _, KEY_C)); |
1256 | 503 | mir_input_event_modifier_alt | mir_input_event_modifier_alt_left)); | ||
1258 | 504 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_C), | 501 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_C), |
1259 | 505 | mt::KeyWithModifiers(MirInputEventModifiers{ | ||
1260 | 506 | mir_input_event_modifier_alt | mir_input_event_modifier_alt_left}), | ||
1261 | 507 | mt::KeyUpEvent()))); | 502 | mt::KeyUpEvent()))); |
1262 | 508 | 503 | ||
1263 | 509 | keyboard.start(&mock_sink, &mock_builder); | 504 | keyboard.start(&mock_sink, &mock_builder); |
1264 | @@ -583,11 +578,11 @@ | |||
1265 | 583 | 578 | ||
1266 | 584 | InSequence seq; | 579 | InSequence seq; |
1267 | 585 | // expect two scroll events.. | 580 | // expect two scroll events.. |
1270 | 586 | EXPECT_CALL(mock_builder, pointer_event(time_stamp_1, mir_input_event_modifier_none, mir_pointer_action_motion, 0, | 581 | EXPECT_CALL(mock_builder, |
1271 | 587 | 0.0f, 0.0f, 0.0f, 20.0f, 0.0f, 0.0f)); | 582 | pointer_event(time_stamp_1, mir_pointer_action_motion, 0, 0.0f, 0.0f, 0.0f, 20.0f, 0.0f, 0.0f)); |
1272 | 588 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, 20.0f))); | 583 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, 20.0f))); |
1275 | 589 | EXPECT_CALL(mock_builder, pointer_event(time_stamp_2, mir_input_event_modifier_none, mir_pointer_action_motion, 0, | 584 | EXPECT_CALL(mock_builder, |
1276 | 590 | 0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f)); | 585 | pointer_event(time_stamp_2, mir_pointer_action_motion, 0, 0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f)); |
1277 | 591 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_hscroll, 5.0f))); | 586 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_hscroll, 5.0f))); |
1278 | 592 | 587 | ||
1279 | 593 | mouse.start(&mock_sink, &mock_builder); | 588 | mouse.start(&mock_sink, &mock_builder); |
1280 | @@ -608,7 +603,7 @@ | |||
1281 | 608 | setup_touch_frame(fake_event_2); | 603 | setup_touch_frame(fake_event_2); |
1282 | 609 | 604 | ||
1283 | 610 | InSequence seq; | 605 | InSequence seq; |
1285 | 611 | EXPECT_CALL(mock_builder, touch_event(time_stamp_1, mir_input_event_modifier_none)); | 606 | EXPECT_CALL(mock_builder, touch_event(time_stamp_1)); |
1286 | 612 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{0}, mir_touch_action_down, mir_touch_tooltype_finger, x, y, | 607 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{0}, mir_touch_action_down, mir_touch_tooltype_finger, x, y, |
1287 | 613 | pressure, major, minor, major)); | 608 | pressure, major, minor, major)); |
1288 | 614 | EXPECT_CALL(mock_sink, handle_input(mt::TouchEvent(x, y))); | 609 | EXPECT_CALL(mock_sink, handle_input(mt::TouchEvent(x, y))); |
1289 | @@ -631,7 +626,7 @@ | |||
1290 | 631 | setup_touch_frame(fake_event_2); | 626 | setup_touch_frame(fake_event_2); |
1291 | 632 | 627 | ||
1292 | 633 | InSequence seq; | 628 | InSequence seq; |
1294 | 634 | EXPECT_CALL(mock_builder, touch_event(time_stamp_1, mir_input_event_modifier_none)); | 629 | EXPECT_CALL(mock_builder, touch_event(time_stamp_1)); |
1295 | 635 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{0}, mir_touch_action_change, mir_touch_tooltype_finger, x, y, | 630 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{0}, mir_touch_action_change, mir_touch_tooltype_finger, x, y, |
1296 | 636 | pressure, major, minor, major)); | 631 | pressure, major, minor, major)); |
1297 | 637 | EXPECT_CALL(mock_sink, handle_input(mt::TouchMovementEvent())); | 632 | EXPECT_CALL(mock_sink, handle_input(mt::TouchMovementEvent())); |
1298 | @@ -656,12 +651,12 @@ | |||
1299 | 656 | setup_touch_frame(fake_event_4); | 651 | setup_touch_frame(fake_event_4); |
1300 | 657 | 652 | ||
1301 | 658 | InSequence seq; | 653 | InSequence seq; |
1303 | 659 | EXPECT_CALL(mock_builder, touch_event(time_stamp_1, mir_input_event_modifier_none)); | 654 | EXPECT_CALL(mock_builder, touch_event(time_stamp_1)); |
1304 | 660 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{slot}, mir_touch_action_down, mir_touch_tooltype_finger, x, y, | 655 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{slot}, mir_touch_action_down, mir_touch_tooltype_finger, x, y, |
1305 | 661 | pressure, major, minor, major)); | 656 | pressure, major, minor, major)); |
1306 | 662 | EXPECT_CALL(mock_sink, handle_input(mt::TouchEvent(x, y))); | 657 | EXPECT_CALL(mock_sink, handle_input(mt::TouchEvent(x, y))); |
1307 | 663 | 658 | ||
1309 | 664 | EXPECT_CALL(mock_builder, touch_event(time_stamp_2, mir_input_event_modifier_none)); | 659 | EXPECT_CALL(mock_builder, touch_event(time_stamp_2)); |
1310 | 665 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{slot}, mir_touch_action_up, mir_touch_tooltype_finger, x, y, | 660 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{slot}, mir_touch_action_up, mir_touch_tooltype_finger, x, y, |
1311 | 666 | pressure, major, minor, major)); | 661 | pressure, major, minor, major)); |
1312 | 667 | EXPECT_CALL(mock_sink, handle_input(mt::TouchUpEvent(x, y))); | 662 | EXPECT_CALL(mock_sink, handle_input(mt::TouchUpEvent(x, y))); |
1313 | 668 | 663 | ||
1314 | === modified file 'tests/unit-tests/input/test_default_input_device_hub.cpp' | |||
1315 | --- tests/unit-tests/input/test_default_input_device_hub.cpp 2015-10-23 16:32:32 +0000 | |||
1316 | +++ tests/unit-tests/input/test_default_input_device_hub.cpp 2015-10-26 14:13:05 +0000 | |||
1317 | @@ -274,7 +274,7 @@ | |||
1318 | 274 | observer_loop.trigger_server_actions(); | 274 | observer_loop.trigger_server_actions(); |
1319 | 275 | 275 | ||
1320 | 276 | auto event = builder->key_event(arbitrary_timestamp, mir_keyboard_action_down, 0, | 276 | auto event = builder->key_event(arbitrary_timestamp, mir_keyboard_action_down, 0, |
1322 | 277 | KEY_A, mir_input_event_modifier_none); | 277 | KEY_A); |
1323 | 278 | 278 | ||
1324 | 279 | EXPECT_CALL(mock_dispatcher, dispatch(AllOf(mt::InputDeviceIdMatches(handle->id()), mt::MirKeyEventMatches(event.get())))); | 279 | EXPECT_CALL(mock_dispatcher, dispatch(AllOf(mt::InputDeviceIdMatches(handle->id()), mt::MirKeyEventMatches(event.get())))); |
1325 | 280 | 280 | ||
1326 | @@ -293,23 +293,23 @@ | |||
1327 | 293 | 293 | ||
1328 | 294 | observer_loop.trigger_server_actions(); | 294 | observer_loop.trigger_server_actions(); |
1329 | 295 | 295 | ||
1331 | 296 | auto touch_event_1 = builder->touch_event(arbitrary_timestamp, mir_input_event_modifier_none); | 296 | auto touch_event_1 = builder->touch_event(arbitrary_timestamp); |
1332 | 297 | builder->add_touch(*touch_event_1, 0, mir_touch_action_down, mir_touch_tooltype_finger, 21.0f, 34.0f, 50.0f, 15.0f, | 297 | builder->add_touch(*touch_event_1, 0, mir_touch_action_down, mir_touch_tooltype_finger, 21.0f, 34.0f, 50.0f, 15.0f, |
1333 | 298 | 5.0f, 4.0f); | 298 | 5.0f, 4.0f); |
1334 | 299 | 299 | ||
1336 | 300 | auto touch_event_2 = builder->touch_event(arbitrary_timestamp, mir_input_event_modifier_none); | 300 | auto touch_event_2 = builder->touch_event(arbitrary_timestamp); |
1337 | 301 | builder->add_touch(*touch_event_2, 0, mir_touch_action_change, mir_touch_tooltype_finger, 24.0f, 34.0f, 50.0f, | 301 | builder->add_touch(*touch_event_2, 0, mir_touch_action_change, mir_touch_tooltype_finger, 24.0f, 34.0f, 50.0f, |
1338 | 302 | 15.0f, 5.0f, 4.0f); | 302 | 15.0f, 5.0f, 4.0f); |
1339 | 303 | builder->add_touch(*touch_event_2, 1, mir_touch_action_down, mir_touch_tooltype_finger, 60.0f, 34.0f, 50.0f, 15.0f, | 303 | builder->add_touch(*touch_event_2, 1, mir_touch_action_down, mir_touch_tooltype_finger, 60.0f, 34.0f, 50.0f, 15.0f, |
1340 | 304 | 5.0f, 4.0f); | 304 | 5.0f, 4.0f); |
1341 | 305 | 305 | ||
1343 | 306 | auto touch_event_3 = builder->touch_event(arbitrary_timestamp, mir_input_event_modifier_none); | 306 | auto touch_event_3 = builder->touch_event(arbitrary_timestamp); |
1344 | 307 | builder->add_touch(*touch_event_3, 0, mir_touch_action_up, mir_touch_tooltype_finger, 24.0f, 34.0f, 50.0f, 15.0f, | 307 | builder->add_touch(*touch_event_3, 0, mir_touch_action_up, mir_touch_tooltype_finger, 24.0f, 34.0f, 50.0f, 15.0f, |
1345 | 308 | 5.0f, 4.0f); | 308 | 5.0f, 4.0f); |
1346 | 309 | builder->add_touch(*touch_event_3, 1, mir_touch_action_change, mir_touch_tooltype_finger, 70.0f, 30.0f, 50.0f, | 309 | builder->add_touch(*touch_event_3, 1, mir_touch_action_change, mir_touch_tooltype_finger, 70.0f, 30.0f, 50.0f, |
1347 | 310 | 15.0f, 5.0f, 4.0f); | 310 | 15.0f, 5.0f, 4.0f); |
1348 | 311 | 311 | ||
1350 | 312 | auto touch_event_4 = builder->touch_event(arbitrary_timestamp, mir_input_event_modifier_none); | 312 | auto touch_event_4 = builder->touch_event(arbitrary_timestamp); |
1351 | 313 | builder->add_touch(*touch_event_4, 1, mir_touch_action_up, mir_touch_tooltype_finger, 70.0f, 35.0f, 50.0f, 15.0f, | 313 | builder->add_touch(*touch_event_4, 1, mir_touch_action_up, mir_touch_tooltype_finger, 70.0f, 35.0f, 50.0f, 15.0f, |
1352 | 314 | 5.0f, 4.0f); | 314 | 5.0f, 4.0f); |
1353 | 315 | 315 | ||
1354 | @@ -378,17 +378,149 @@ | |||
1355 | 378 | using namespace ::testing; | 378 | using namespace ::testing; |
1356 | 379 | 379 | ||
1357 | 380 | auto x = 12.2f, y = 14.3f; | 380 | auto x = 12.2f, y = 14.3f; |
1362 | 381 | auto const mac = 0; | 381 | |
1363 | 382 | 382 | mi::InputSink* sink; | |
1364 | 383 | auto event = mir::events::make_event(0, 0ns, mac, mir_input_event_modifier_none, mir_pointer_action_motion, 0, | 383 | mi::EventBuilder* builder; |
1365 | 384 | x, y, 0.0f, 0.0f, 0.0f, 0.0f); | 384 | capture_input_sink(device, sink, builder); |
1366 | 385 | hub.add_device(mt::fake_shared(device)); | ||
1367 | 386 | |||
1368 | 387 | auto event = builder->pointer_event(0ns, mir_pointer_action_motion, 0, x, y, 0.0f, 0.0f, 0.0f, 0.0f); | ||
1369 | 385 | 388 | ||
1370 | 386 | EXPECT_CALL(mock_cursor_listener, cursor_moved_to(x, y)).Times(1); | 389 | EXPECT_CALL(mock_cursor_listener, cursor_moved_to(x, y)).Times(1); |
1371 | 387 | 390 | ||
1372 | 388 | mi::InputSink* sink; | ||
1373 | 389 | mi::EventBuilder* builder; | ||
1374 | 390 | capture_input_sink(device, sink, builder); | ||
1375 | 391 | hub.add_device(mt::fake_shared(device)); | ||
1376 | 392 | |||
1377 | 393 | sink->handle_input(*event); | 391 | sink->handle_input(*event); |
1378 | 394 | } | 392 | } |
1379 | 393 | |||
1380 | 394 | TEST_F(InputDeviceHubTest, input_sink_tracks_modifier) | ||
1381 | 395 | { | ||
1382 | 396 | using namespace ::testing; | ||
1383 | 397 | |||
1384 | 398 | mi::InputSink* key_board_sink; | ||
1385 | 399 | mi::EventBuilder* key_event_builder; | ||
1386 | 400 | std::shared_ptr<mi::Device> key_handle; | ||
1387 | 401 | |||
1388 | 402 | capture_input_sink(device, key_board_sink, key_event_builder); | ||
1389 | 403 | |||
1390 | 404 | InSequence seq; | ||
1391 | 405 | EXPECT_CALL(mock_observer,device_added(_)) | ||
1392 | 406 | .WillOnce(SaveArg<0>(&key_handle)); | ||
1393 | 407 | |||
1394 | 408 | hub.add_observer(mt::fake_shared(mock_observer)); | ||
1395 | 409 | hub.add_device(mt::fake_shared(device)); | ||
1396 | 410 | |||
1397 | 411 | observer_loop.trigger_server_actions(); | ||
1398 | 412 | |||
1399 | 413 | const MirInputEventModifiers shift_left = mir_input_event_modifier_shift_left | mir_input_event_modifier_shift; | ||
1400 | 414 | auto shift_down = | ||
1401 | 415 | key_event_builder->key_event(arbitrary_timestamp, mir_keyboard_action_down, 0, KEY_LEFTSHIFT); | ||
1402 | 416 | auto shift_up = | ||
1403 | 417 | key_event_builder->key_event(arbitrary_timestamp, mir_keyboard_action_up, 0, KEY_LEFTSHIFT); | ||
1404 | 418 | |||
1405 | 419 | EXPECT_CALL(mock_dispatcher, dispatch(mt::KeyWithModifiers(shift_left))); | ||
1406 | 420 | EXPECT_CALL(mock_dispatcher, dispatch(mt::KeyWithModifiers(mir_input_event_modifier_none))); | ||
1407 | 421 | |||
1408 | 422 | key_board_sink->handle_input(*shift_down); | ||
1409 | 423 | key_board_sink->handle_input(*shift_up); | ||
1410 | 424 | } | ||
1411 | 425 | |||
1412 | 426 | TEST_F(InputDeviceHubTest, input_sink_unifies_modifier_state_accross_devices) | ||
1413 | 427 | { | ||
1414 | 428 | using namespace ::testing; | ||
1415 | 429 | |||
1416 | 430 | mi::InputSink* mouse_sink; | ||
1417 | 431 | mi::EventBuilder* mouse_event_builder; | ||
1418 | 432 | mi::InputSink* key_board_sink; | ||
1419 | 433 | mi::EventBuilder* key_event_builder; | ||
1420 | 434 | std::shared_ptr<mi::Device> mouse_handle; | ||
1421 | 435 | std::shared_ptr<mi::Device> key_handle; | ||
1422 | 436 | |||
1423 | 437 | capture_input_sink(device, mouse_sink, mouse_event_builder); | ||
1424 | 438 | capture_input_sink(another_device, key_board_sink, key_event_builder); | ||
1425 | 439 | |||
1426 | 440 | InSequence seq; | ||
1427 | 441 | EXPECT_CALL(mock_observer,device_added(_)) | ||
1428 | 442 | .WillOnce(SaveArg<0>(&mouse_handle)); | ||
1429 | 443 | EXPECT_CALL(mock_observer,device_added(_)) | ||
1430 | 444 | .WillOnce(SaveArg<0>(&key_handle)); | ||
1431 | 445 | |||
1432 | 446 | hub.add_observer(mt::fake_shared(mock_observer)); | ||
1433 | 447 | hub.add_device(mt::fake_shared(device)); | ||
1434 | 448 | hub.add_device(mt::fake_shared(another_device)); | ||
1435 | 449 | |||
1436 | 450 | observer_loop.trigger_server_actions(); | ||
1437 | 451 | |||
1438 | 452 | const MirInputEventModifiers r_alt_modifier = mir_input_event_modifier_alt_right | mir_input_event_modifier_alt; | ||
1439 | 453 | auto key = | ||
1440 | 454 | key_event_builder->key_event(arbitrary_timestamp, mir_keyboard_action_down, 0, KEY_RIGHTALT); | ||
1441 | 455 | auto motion = | ||
1442 | 456 | mouse_event_builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 12, 40, 0, 0, 12, 40); | ||
1443 | 457 | |||
1444 | 458 | EXPECT_CALL(mock_dispatcher, dispatch(mt::KeyWithModifiers(r_alt_modifier))); | ||
1445 | 459 | EXPECT_CALL(mock_dispatcher, dispatch(mt::PointerEventWithModifiers(r_alt_modifier))); | ||
1446 | 460 | |||
1447 | 461 | key_board_sink->handle_input(*key); | ||
1448 | 462 | mouse_sink->handle_input(*motion); | ||
1449 | 463 | |||
1450 | 464 | EXPECT_THAT(key_handle->id(), Ne(mouse_handle->id())); | ||
1451 | 465 | } | ||
1452 | 466 | |||
1453 | 467 | TEST_F(InputDeviceHubTest, input_sink_reduces_modifier_state_accross_devices) | ||
1454 | 468 | { | ||
1455 | 469 | using namespace ::testing; | ||
1456 | 470 | |||
1457 | 471 | mi::InputSink* mouse_sink; | ||
1458 | 472 | mi::EventBuilder* mouse_event_builder; | ||
1459 | 473 | mi::InputSink* key_board_sink_1; | ||
1460 | 474 | mi::EventBuilder* key_event_builder_1; | ||
1461 | 475 | mi::InputSink* key_board_sink_2; | ||
1462 | 476 | mi::EventBuilder* key_event_builder_2; | ||
1463 | 477 | std::shared_ptr<mi::Device> mouse_handle; | ||
1464 | 478 | std::shared_ptr<mi::Device> key_handle_1; | ||
1465 | 479 | std::shared_ptr<mi::Device> key_handle_2; | ||
1466 | 480 | |||
1467 | 481 | capture_input_sink(device, mouse_sink, mouse_event_builder); | ||
1468 | 482 | capture_input_sink(another_device, key_board_sink_1, key_event_builder_1); | ||
1469 | 483 | capture_input_sink(third_device, key_board_sink_2, key_event_builder_2); | ||
1470 | 484 | |||
1471 | 485 | InSequence seq; | ||
1472 | 486 | EXPECT_CALL(mock_observer, device_added(_)) | ||
1473 | 487 | .WillOnce(SaveArg<0>(&mouse_handle)); | ||
1474 | 488 | EXPECT_CALL(mock_observer, device_added(_)) | ||
1475 | 489 | .WillOnce(SaveArg<0>(&key_handle_1)); | ||
1476 | 490 | EXPECT_CALL(mock_observer, device_added(_)) | ||
1477 | 491 | .WillOnce(SaveArg<0>(&key_handle_2)); | ||
1478 | 492 | |||
1479 | 493 | hub.add_observer(mt::fake_shared(mock_observer)); | ||
1480 | 494 | hub.add_device(mt::fake_shared(device)); | ||
1481 | 495 | hub.add_device(mt::fake_shared(another_device)); | ||
1482 | 496 | hub.add_device(mt::fake_shared(third_device)); | ||
1483 | 497 | |||
1484 | 498 | const MirInputEventModifiers r_alt_modifier = mir_input_event_modifier_alt_right | mir_input_event_modifier_alt; | ||
1485 | 499 | const MirInputEventModifiers l_ctrl_modifier = mir_input_event_modifier_ctrl_left | mir_input_event_modifier_ctrl; | ||
1486 | 500 | const MirInputEventModifiers combined_modifier = r_alt_modifier | l_ctrl_modifier; | ||
1487 | 501 | |||
1488 | 502 | observer_loop.trigger_server_actions(); | ||
1489 | 503 | |||
1490 | 504 | auto alt_down = key_event_builder_1->key_event(arbitrary_timestamp, mir_keyboard_action_down, 0, KEY_RIGHTALT); | ||
1491 | 505 | auto ctrl_down = key_event_builder_2->key_event(arbitrary_timestamp, mir_keyboard_action_down, 0, KEY_LEFTCTRL); | ||
1492 | 506 | auto ctrl_up = key_event_builder_2->key_event(arbitrary_timestamp, mir_keyboard_action_up, 0, KEY_LEFTCTRL); | ||
1493 | 507 | |||
1494 | 508 | auto motion_1 = | ||
1495 | 509 | mouse_event_builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 12, 40, 0, 0, 12, 40); | ||
1496 | 510 | auto motion_2 = | ||
1497 | 511 | mouse_event_builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 30, 50, 0, 0, 18, 10); | ||
1498 | 512 | |||
1499 | 513 | EXPECT_CALL(mock_dispatcher, dispatch(mt::KeyWithModifiers(r_alt_modifier))); | ||
1500 | 514 | EXPECT_CALL(mock_dispatcher, dispatch(mt::KeyWithModifiers(l_ctrl_modifier))); | ||
1501 | 515 | EXPECT_CALL(mock_dispatcher, dispatch(mt::PointerEventWithModifiers(combined_modifier))); | ||
1502 | 516 | EXPECT_CALL(mock_dispatcher, dispatch(mt::KeyWithModifiers(mir_input_event_modifier_none))); | ||
1503 | 517 | EXPECT_CALL(mock_dispatcher, dispatch(mt::PointerEventWithModifiers(r_alt_modifier))); | ||
1504 | 518 | |||
1505 | 519 | key_board_sink_1->handle_input(*alt_down); | ||
1506 | 520 | key_board_sink_2->handle_input(*ctrl_down); | ||
1507 | 521 | mouse_sink->handle_input(*motion_1); | ||
1508 | 522 | key_board_sink_2->handle_input(*ctrl_up); | ||
1509 | 523 | mouse_sink->handle_input(*motion_2); | ||
1510 | 524 | |||
1511 | 525 | EXPECT_THAT(key_handle_1->id(), Ne(key_handle_2->id())); | ||
1512 | 526 | } |
FAILED: Continuous integration, rev:3018 jenkins. qa.ubuntu. com/job/ mir-ci/ 5248/ jenkins. qa.ubuntu. com/job/ mir-android- vivid-i386- build/4424 jenkins. qa.ubuntu. com/job/ mir-clang- vivid-amd64- build/3331/ console jenkins. qa.ubuntu. com/job/ mir-mediumtests -vivid- touch/4366 jenkins. qa.ubuntu. com/job/ mir-mediumtests -wily-touch/ 324/console jenkins. qa.ubuntu. com/job/ mir-wily- amd64-ci/ 1402 jenkins. qa.ubuntu. com/job/ mir-wily- amd64-ci/ 1402/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-wily- i386-ci/ 324 jenkins. qa.ubuntu. com/job/ mir-wily- i386-ci/ 324/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 4367 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 4367/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- touch/7011 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 24181 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- wily-armhf/ 325/console
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/mir- ci/5248/ rebuild
http://