Merge lp:~andreas-pokorny/mir/libinput-platform-touch-pad-settings into lp:mir
- libinput-platform-touch-pad-settings
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Andreas Pokorny |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3052 |
Proposed branch: | lp:~andreas-pokorny/mir/libinput-platform-touch-pad-settings |
Merge into: | lp:mir |
Prerequisite: | lp:~andreas-pokorny/mir/libinput-platform-pointer-settings |
Diff against target: |
1248 lines (+546/-274) 12 files modified
include/client/mir_toolkit/mir_input_device.h (+17/-0) include/platform/mir/input/input_device.h (+4/-1) include/platform/mir/input/touchpad_settings.h (+46/-0) include/server/mir/input/device.h (+1/-1) src/platforms/evdev/libinput_device.cpp (+75/-0) src/platforms/evdev/libinput_device.h (+3/-1) src/platforms/mesa/server/x11/input/input_device.cpp (+14/-0) src/platforms/mesa/server/x11/input/input_device.h (+3/-1) tests/mir_test_framework/fake_input_device_impl.cpp (+16/-0) tests/mir_test_framework/fake_input_device_impl.h (+2/-0) tests/unit-tests/input/evdev/test_libinput_device.cpp (+362/-270) tests/unit-tests/input/test_default_input_device_hub.cpp (+3/-0) |
To merge this branch: | bzr merge lp:~andreas-pokorny/mir/libinput-platform-touch-pad-settings |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Daniel van Vugt | Abstain | ||
Alan Griffiths | Approve | ||
Kevin DuBois (community) | Approve | ||
Review via email:
|
Commit message
Add mir::input:
Description of the change
Adds settings for touch pads. So far again only supported within libinput...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2977
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2978
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2979
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2980
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2981
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
+ char const* path = setup_mouse(
There's an awful lot of this. Would it be worth creating a fixture that does this in SetUp() instead of repeating it in so many tests? Or setting up all the devices in SetUp()?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
+ EXPECT_
+ .WillRepeatedly
+ EXPECT_
+ .WillRepeatedly
+ EXPECT_
+ .WillRepeatedly
+ EXPECT_
+ .WillRepeatedly
+ LIBINPUT_
+ LIBINPUT_
+ EXPECT_
+ .WillRepeatedly
+ LIBINPUT_
+ LIBINPUT_
+ EXPECT_
+ .WillRepeatedly
+ LIBINPUT_
+ LIBINPUT_
+ EXPECT_
+ .WillRepeatedly
+ LIBINPUT_
+ LIBINPUT_
Setting expectations in the test setup is best avoided (admittedly not always possible).
But these look like they could be replaced with:
ON_CALL(
Is there something I'm missing?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kevin DuBois (kdub) wrote : | # |
just some nits:
+ TouchPadSettings() {}
not needed
+const int no_scroll_button = 0;
const ordering
+ // forwards aldready interpreted events.
typo
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andreas Pokorny (andreas-pokorny) wrote : | # |
> just some nits:
>
> + TouchPadSettings() {}
> not needed
This is needed when I want to use that with mir::optional_
fixiing the rest now
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2985
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://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
+ TouchPadSettings() {}
I think our current practice is to write "TouchPadSettings() = default;" - but I don't know if that avoids the problems you note with clang. (And isn't a blocker.)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel van Vugt (vanvugt) wrote : | # |
Your plural/singulars are backwards :)
MirTouchPadClic
MirTouchPadClic
8 +typedef enum MirTouchPadClic
9 +{
10 + mir_touch_
11 + mir_touch_
12 + mir_touch_
13 +} MirTouchPadClic
14 +typedef unsigned int MirTouchPadClic
15 +
16 +typedef enum MirTouchPadScro
17 +{
18 + mir_touch_
19 + mir_touch_
20 + mir_touch_
21 + mir_touch_
22 +} MirTouchPadScro
23 +typedef unsigned int MirTouchPadScro
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel van Vugt (vanvugt) wrote : | # |
(2) Also your forgot to make use of bit zero: foo = 1 << 0;
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andreas Pokorny (andreas-pokorny) wrote : | # |
> (2) Also your forgot to make use of bit zero: foo = 1 << 0;
ack done.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2986
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://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
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://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel van Vugt (vanvugt) wrote : | # |
Although Touchpad is a single word, so maybe also:
s/mir_touch_
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel van Vugt (vanvugt) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel van Vugt (vanvugt) wrote : | # |
Minor spelling correction suggested per above.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2987
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://
Preview Diff
1 | === modified file 'include/client/mir_toolkit/mir_input_device.h' | |||
2 | --- include/client/mir_toolkit/mir_input_device.h 2015-10-19 10:45:47 +0000 | |||
3 | +++ include/client/mir_toolkit/mir_input_device.h 2015-10-23 10:50:47 +0000 | |||
4 | @@ -32,6 +32,23 @@ | |||
5 | 32 | mir_pointer_handedness_left = 1 | 32 | mir_pointer_handedness_left = 1 |
6 | 33 | } MirPointerHandedness; | 33 | } MirPointerHandedness; |
7 | 34 | 34 | ||
8 | 35 | typedef enum MirTouchpadClickMode | ||
9 | 36 | { | ||
10 | 37 | mir_touchpad_click_mode_none = 0, | ||
11 | 38 | mir_touchpad_click_mode_area_to_click = 1 << 0, | ||
12 | 39 | mir_touchpad_click_mode_finger_count = 1 << 1 | ||
13 | 40 | } MirTouchpadClickMode; | ||
14 | 41 | typedef unsigned int MirTouchpadClickModes; | ||
15 | 42 | |||
16 | 43 | typedef enum MirTouchpadScrollMode | ||
17 | 44 | { | ||
18 | 45 | mir_touchpad_scroll_mode_none = 0, | ||
19 | 46 | mir_touchpad_scroll_mode_two_finger_scroll = 1 << 0, | ||
20 | 47 | mir_touchpad_scroll_mode_edge_scroll = 1 << 1, | ||
21 | 48 | mir_touchpad_scroll_mode_button_down_scroll = 1 << 2 | ||
22 | 49 | } MirTouchpadScrollMode; | ||
23 | 50 | typedef unsigned int MirTouchpadScrollModes; | ||
24 | 51 | |||
25 | 35 | #ifdef __cplusplus | 52 | #ifdef __cplusplus |
26 | 36 | } | 53 | } |
27 | 37 | #endif | 54 | #endif |
28 | 38 | 55 | ||
29 | === modified file 'include/platform/mir/input/input_device.h' | |||
30 | --- include/platform/mir/input/input_device.h 2015-10-20 03:30:00 +0000 | |||
31 | +++ include/platform/mir/input/input_device.h 2015-10-23 10:50:47 +0000 | |||
32 | @@ -38,6 +38,7 @@ | |||
33 | 38 | class EventBuilder; | 38 | class EventBuilder; |
34 | 39 | 39 | ||
35 | 40 | class PointerSettings; | 40 | class PointerSettings; |
36 | 41 | class TouchpadSettings; | ||
37 | 41 | 42 | ||
38 | 42 | /** | 43 | /** |
39 | 43 | * Represents an input device. | 44 | * Represents an input device. |
40 | @@ -59,9 +60,11 @@ | |||
41 | 59 | 60 | ||
42 | 60 | virtual InputDeviceInfo get_device_info() = 0; | 61 | virtual InputDeviceInfo get_device_info() = 0; |
43 | 61 | 62 | ||
45 | 62 | virtual mir::optional_value<PointerSettings> get_pointer_settings() const = 0; | 63 | virtual optional_value<PointerSettings> get_pointer_settings() const = 0; |
46 | 63 | virtual void apply_settings(PointerSettings const&) = 0; | 64 | virtual void apply_settings(PointerSettings const&) = 0; |
47 | 64 | 65 | ||
48 | 66 | virtual optional_value<TouchpadSettings> get_touchpad_settings() const = 0; | ||
49 | 67 | virtual void apply_settings(TouchpadSettings const&) = 0; | ||
50 | 65 | protected: | 68 | protected: |
51 | 66 | InputDevice(InputDevice const&) = delete; | 69 | InputDevice(InputDevice const&) = delete; |
52 | 67 | InputDevice& operator=(InputDevice const&) = delete; | 70 | InputDevice& operator=(InputDevice const&) = delete; |
53 | 68 | 71 | ||
54 | === added file 'include/platform/mir/input/touchpad_settings.h' | |||
55 | --- include/platform/mir/input/touchpad_settings.h 1970-01-01 00:00:00 +0000 | |||
56 | +++ include/platform/mir/input/touchpad_settings.h 2015-10-23 10:50:47 +0000 | |||
57 | @@ -0,0 +1,46 @@ | |||
58 | 1 | /* | ||
59 | 2 | * Copyright © 2015 Canonical Ltd. | ||
60 | 3 | * | ||
61 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
62 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
63 | 6 | * as published by the Free Software Foundation. | ||
64 | 7 | * | ||
65 | 8 | * This program is distributed in the hope that it will be useful, | ||
66 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
67 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
68 | 11 | * GNU Lesser General Public License for more details. | ||
69 | 12 | * | ||
70 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
71 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
72 | 15 | * | ||
73 | 16 | * Authored by: | ||
74 | 17 | * Andreas Pokorny <andreas.pokorny@canonical.com> | ||
75 | 18 | */ | ||
76 | 19 | |||
77 | 20 | #ifndef MIR_INPUT_TOUCH_PAD_SETTINGS_H_ | ||
78 | 21 | #define MIR_INPUT_TOUCH_PAD_SETTINGS_H_ | ||
79 | 22 | |||
80 | 23 | #include "mir_toolkit/mir_input_device.h" | ||
81 | 24 | |||
82 | 25 | namespace mir | ||
83 | 26 | { | ||
84 | 27 | namespace input | ||
85 | 28 | { | ||
86 | 29 | int const no_scroll_button = 0; | ||
87 | 30 | |||
88 | 31 | struct TouchpadSettings | ||
89 | 32 | { | ||
90 | 33 | TouchpadSettings() {} | ||
91 | 34 | MirTouchpadClickModes click_mode{mir_touchpad_click_mode_finger_count}; | ||
92 | 35 | MirTouchpadScrollModes scroll_mode{mir_touchpad_scroll_mode_two_finger_scroll}; | ||
93 | 36 | int button_down_scroll_button{no_scroll_button}; | ||
94 | 37 | bool tap_to_click{true}; | ||
95 | 38 | bool disable_while_typing{false}; | ||
96 | 39 | bool disable_with_mouse{false}; | ||
97 | 40 | bool middle_mouse_button_emulation{true}; | ||
98 | 41 | }; | ||
99 | 42 | |||
100 | 43 | } | ||
101 | 44 | } | ||
102 | 45 | |||
103 | 46 | #endif | ||
104 | 0 | 47 | ||
105 | === modified file 'include/server/mir/input/device.h' | |||
106 | --- include/server/mir/input/device.h 2015-10-01 09:52:28 +0000 | |||
107 | +++ include/server/mir/input/device.h 2015-10-23 10:50:47 +0000 | |||
108 | @@ -31,7 +31,7 @@ | |||
109 | 31 | { | 31 | { |
110 | 32 | 32 | ||
111 | 33 | class PointerSettings; | 33 | class PointerSettings; |
113 | 34 | class TouchPadSettings; | 34 | class TouchpadSettings; |
114 | 35 | 35 | ||
115 | 36 | class Device | 36 | class Device |
116 | 37 | { | 37 | { |
117 | 38 | 38 | ||
118 | === modified file 'src/platforms/evdev/libinput_device.cpp' | |||
119 | --- src/platforms/evdev/libinput_device.cpp 2015-10-20 03:30:00 +0000 | |||
120 | +++ src/platforms/evdev/libinput_device.cpp 2015-10-23 10:50:47 +0000 | |||
121 | @@ -26,6 +26,7 @@ | |||
122 | 26 | #include "mir/input/input_report.h" | 26 | #include "mir/input/input_report.h" |
123 | 27 | #include "mir/input/device_capability.h" | 27 | #include "mir/input/device_capability.h" |
124 | 28 | #include "mir/input/pointer_settings.h" | 28 | #include "mir/input/pointer_settings.h" |
125 | 29 | #include "mir/input/touchpad_settings.h" | ||
126 | 29 | #include "mir/input/input_device_info.h" | 30 | #include "mir/input/input_device_info.h" |
127 | 30 | #include "mir/events/event_builders.h" | 31 | #include "mir/events/event_builders.h" |
128 | 31 | #include "mir/geometry/displacement.h" | 32 | #include "mir/geometry/displacement.h" |
129 | @@ -393,3 +394,77 @@ | |||
130 | 393 | vertical_scroll_scale = settings.vertical_scroll_scale; | 394 | vertical_scroll_scale = settings.vertical_scroll_scale; |
131 | 394 | horizontal_scroll_scale = settings.horizontal_scroll_scale; | 395 | horizontal_scroll_scale = settings.horizontal_scroll_scale; |
132 | 395 | } | 396 | } |
133 | 397 | |||
134 | 398 | mir::optional_value<mi::TouchpadSettings> mie::LibInputDevice::get_touchpad_settings() const | ||
135 | 399 | { | ||
136 | 400 | if (!contains(info.capabilities, mi::DeviceCapability::touchpad)) | ||
137 | 401 | return {}; | ||
138 | 402 | |||
139 | 403 | auto dev = device(); | ||
140 | 404 | auto click_modes = libinput_device_config_click_get_method(dev); | ||
141 | 405 | auto scroll_modes = libinput_device_config_scroll_get_method(dev); | ||
142 | 406 | |||
143 | 407 | TouchpadSettings settings; | ||
144 | 408 | |||
145 | 409 | settings.click_mode = mir_touchpad_click_mode_none; | ||
146 | 410 | if (click_modes & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) | ||
147 | 411 | settings.click_mode |= mir_touchpad_click_mode_area_to_click; | ||
148 | 412 | if (click_modes & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) | ||
149 | 413 | settings.click_mode |= mir_touchpad_click_mode_finger_count; | ||
150 | 414 | |||
151 | 415 | settings.scroll_mode = mir_touchpad_scroll_mode_none; | ||
152 | 416 | if (scroll_modes & LIBINPUT_CONFIG_SCROLL_2FG) | ||
153 | 417 | settings.scroll_mode |= mir_touchpad_scroll_mode_two_finger_scroll; | ||
154 | 418 | if (scroll_modes & LIBINPUT_CONFIG_SCROLL_EDGE) | ||
155 | 419 | settings.scroll_mode |= mir_touchpad_scroll_mode_edge_scroll; | ||
156 | 420 | if (scroll_modes & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) | ||
157 | 421 | settings.scroll_mode |= mir_touchpad_scroll_mode_button_down_scroll; | ||
158 | 422 | |||
159 | 423 | settings.tap_to_click = libinput_device_config_tap_get_enabled(dev) == LIBINPUT_CONFIG_TAP_ENABLED; | ||
160 | 424 | settings.disable_while_typing = libinput_device_config_dwt_get_enabled(dev) == LIBINPUT_CONFIG_DWT_ENABLED; | ||
161 | 425 | settings.disable_with_mouse = | ||
162 | 426 | libinput_device_config_send_events_get_mode(dev) == LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; | ||
163 | 427 | settings.middle_mouse_button_emulation = | ||
164 | 428 | libinput_device_config_middle_emulation_get_enabled(dev) == LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED; | ||
165 | 429 | |||
166 | 430 | return settings; | ||
167 | 431 | } | ||
168 | 432 | |||
169 | 433 | void mie::LibInputDevice::apply_settings(mi::TouchpadSettings const& settings) | ||
170 | 434 | { | ||
171 | 435 | auto dev = device(); | ||
172 | 436 | |||
173 | 437 | uint32_t click_method = LIBINPUT_CONFIG_CLICK_METHOD_NONE; | ||
174 | 438 | if (settings.click_mode & mir_touchpad_click_mode_area_to_click) | ||
175 | 439 | click_method |= LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; | ||
176 | 440 | if (settings.click_mode & mir_touchpad_click_mode_finger_count) | ||
177 | 441 | click_method |= LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; | ||
178 | 442 | |||
179 | 443 | uint32_t scroll_method = LIBINPUT_CONFIG_CLICK_METHOD_NONE; | ||
180 | 444 | if (settings.scroll_mode & mir_touchpad_scroll_mode_button_down_scroll) | ||
181 | 445 | { | ||
182 | 446 | scroll_method |= LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; | ||
183 | 447 | libinput_device_config_scroll_set_button(dev, settings.button_down_scroll_button); | ||
184 | 448 | } | ||
185 | 449 | if (settings.scroll_mode & mir_touchpad_scroll_mode_edge_scroll) | ||
186 | 450 | scroll_method |= LIBINPUT_CONFIG_SCROLL_EDGE; | ||
187 | 451 | if (settings.scroll_mode & mir_touchpad_scroll_mode_two_finger_scroll) | ||
188 | 452 | scroll_method |= LIBINPUT_CONFIG_SCROLL_2FG; | ||
189 | 453 | |||
190 | 454 | libinput_device_config_click_set_method(dev, static_cast<libinput_config_click_method>(click_method)); | ||
191 | 455 | libinput_device_config_scroll_set_method(dev, static_cast<libinput_config_scroll_method>(scroll_method)); | ||
192 | 456 | |||
193 | 457 | libinput_device_config_tap_set_enabled( | ||
194 | 458 | dev, settings.tap_to_click ? LIBINPUT_CONFIG_TAP_ENABLED : LIBINPUT_CONFIG_TAP_DISABLED); | ||
195 | 459 | |||
196 | 460 | libinput_device_config_dwt_set_enabled( | ||
197 | 461 | dev, settings.disable_while_typing ? LIBINPUT_CONFIG_DWT_ENABLED : LIBINPUT_CONFIG_DWT_DISABLED); | ||
198 | 462 | |||
199 | 463 | libinput_device_config_send_events_set_mode(dev, settings.disable_with_mouse ? | ||
200 | 464 | LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE : | ||
201 | 465 | LIBINPUT_CONFIG_SEND_EVENTS_ENABLED); | ||
202 | 466 | |||
203 | 467 | libinput_device_config_middle_emulation_set_enabled(dev, settings.middle_mouse_button_emulation ? | ||
204 | 468 | LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED : | ||
205 | 469 | LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED); | ||
206 | 470 | } | ||
207 | 396 | 471 | ||
208 | === modified file 'src/platforms/evdev/libinput_device.h' | |||
209 | --- src/platforms/evdev/libinput_device.h 2015-10-20 03:30:00 +0000 | |||
210 | +++ src/platforms/evdev/libinput_device.h 2015-10-23 10:50:47 +0000 | |||
211 | @@ -54,8 +54,10 @@ | |||
212 | 54 | void start(InputSink* sink, EventBuilder* builder) override; | 54 | void start(InputSink* sink, EventBuilder* builder) override; |
213 | 55 | void stop() override; | 55 | void stop() override; |
214 | 56 | InputDeviceInfo get_device_info() override; | 56 | InputDeviceInfo get_device_info() override; |
216 | 57 | mir::optional_value<PointerSettings> get_pointer_settings() const override; | 57 | optional_value<PointerSettings> get_pointer_settings() const override; |
217 | 58 | void apply_settings(PointerSettings const&) override; | 58 | void apply_settings(PointerSettings const&) override; |
218 | 59 | optional_value<TouchpadSettings> get_touchpad_settings() const override; | ||
219 | 60 | void apply_settings(TouchpadSettings const&) override; | ||
220 | 59 | 61 | ||
221 | 60 | void process_event(libinput_event* event); | 62 | void process_event(libinput_event* event); |
222 | 61 | ::libinput_device* device() const; | 63 | ::libinput_device* device() const; |
223 | 62 | 64 | ||
224 | === modified file 'src/platforms/mesa/server/x11/input/input_device.cpp' | |||
225 | --- src/platforms/mesa/server/x11/input/input_device.cpp 2015-10-20 03:30:00 +0000 | |||
226 | +++ src/platforms/mesa/server/x11/input/input_device.cpp 2015-10-23 10:50:47 +0000 | |||
227 | @@ -19,6 +19,7 @@ | |||
228 | 19 | #include "input_device.h" | 19 | #include "input_device.h" |
229 | 20 | 20 | ||
230 | 21 | #include "mir/input/pointer_settings.h" | 21 | #include "mir/input/pointer_settings.h" |
231 | 22 | #include "mir/input/touchpad_settings.h" | ||
232 | 22 | #include "mir/input/input_device_info.h" | 23 | #include "mir/input/input_device_info.h" |
233 | 23 | #include "mir/input/device_capability.h" | 24 | #include "mir/input/device_capability.h" |
234 | 24 | 25 | ||
235 | @@ -60,3 +61,16 @@ | |||
236 | 60 | { | 61 | { |
237 | 61 | // TODO Make use if X11-XInput2 | 62 | // TODO Make use if X11-XInput2 |
238 | 62 | } | 63 | } |
239 | 64 | |||
240 | 65 | mir::optional_value<mi::TouchpadSettings> mix::XInputDevice::get_touchpad_settings() const | ||
241 | 66 | { | ||
242 | 67 | optional_value<TouchpadSettings> ret; | ||
243 | 68 | if (contains(info.capabilities, DeviceCapability::touchpad)) | ||
244 | 69 | ret = TouchpadSettings(); | ||
245 | 70 | |||
246 | 71 | return ret; | ||
247 | 72 | } | ||
248 | 73 | |||
249 | 74 | void mix::XInputDevice::apply_settings(TouchpadSettings const&) | ||
250 | 75 | { | ||
251 | 76 | } | ||
252 | 63 | 77 | ||
253 | === modified file 'src/platforms/mesa/server/x11/input/input_device.h' | |||
254 | --- src/platforms/mesa/server/x11/input/input_device.h 2015-10-20 03:30:00 +0000 | |||
255 | +++ src/platforms/mesa/server/x11/input/input_device.h 2015-10-23 10:50:47 +0000 | |||
256 | @@ -41,8 +41,10 @@ | |||
257 | 41 | void stop() override; | 41 | void stop() override; |
258 | 42 | InputDeviceInfo get_device_info() override; | 42 | InputDeviceInfo get_device_info() override; |
259 | 43 | 43 | ||
261 | 44 | mir::optional_value<PointerSettings> get_pointer_settings() const override; | 44 | optional_value<PointerSettings> get_pointer_settings() const override; |
262 | 45 | void apply_settings(PointerSettings const& settings) override; | 45 | void apply_settings(PointerSettings const& settings) override; |
263 | 46 | optional_value<TouchpadSettings> get_touchpad_settings() const override; | ||
264 | 47 | void apply_settings(TouchpadSettings const& settings) override; | ||
265 | 46 | 48 | ||
266 | 47 | InputSink* sink{nullptr}; | 49 | InputSink* sink{nullptr}; |
267 | 48 | EventBuilder* builder{nullptr}; | 50 | EventBuilder* builder{nullptr}; |
268 | 49 | 51 | ||
269 | === modified file 'tests/mir_test_framework/fake_input_device_impl.cpp' | |||
270 | --- tests/mir_test_framework/fake_input_device_impl.cpp 2015-10-20 03:30:00 +0000 | |||
271 | +++ tests/mir_test_framework/fake_input_device_impl.cpp 2015-10-23 10:50:47 +0000 | |||
272 | @@ -23,6 +23,7 @@ | |||
273 | 23 | #include "mir/input/input_device_info.h" | 23 | #include "mir/input/input_device_info.h" |
274 | 24 | #include "mir/input/input_sink.h" | 24 | #include "mir/input/input_sink.h" |
275 | 25 | #include "mir/input/pointer_settings.h" | 25 | #include "mir/input/pointer_settings.h" |
276 | 26 | #include "mir/input/touchpad_settings.h" | ||
277 | 26 | #include "mir/input/event_builder.h" | 27 | #include "mir/input/event_builder.h" |
278 | 27 | #include "mir/dispatch/action_queue.h" | 28 | #include "mir/dispatch/action_queue.h" |
279 | 28 | #include "mir/geometry/displacement.h" | 29 | #include "mir/geometry/displacement.h" |
280 | @@ -246,6 +247,21 @@ | |||
281 | 246 | this->settings = settings; | 247 | this->settings = settings; |
282 | 247 | } | 248 | } |
283 | 248 | 249 | ||
284 | 250 | mir::optional_value<mi::TouchpadSettings> mtf::FakeInputDeviceImpl::InputDevice::get_touchpad_settings() const | ||
285 | 251 | { | ||
286 | 252 | mir::optional_value<mi::TouchpadSettings> ret; | ||
287 | 253 | if (contains(info.capabilities, mi::DeviceCapability::pointer)) | ||
288 | 254 | ret = mi::TouchpadSettings(); | ||
289 | 255 | |||
290 | 256 | return ret; | ||
291 | 257 | } | ||
292 | 258 | |||
293 | 259 | void mtf::FakeInputDeviceImpl::InputDevice::apply_settings(mi::TouchpadSettings const&) | ||
294 | 260 | { | ||
295 | 261 | // Not applicable for configuration since FakeInputDevice just | ||
296 | 262 | // forwards already interpreted events. | ||
297 | 263 | } | ||
298 | 264 | |||
299 | 249 | void mtf::FakeInputDeviceImpl::InputDevice::map_touch_coordinates(float& x, float& y) | 265 | void mtf::FakeInputDeviceImpl::InputDevice::map_touch_coordinates(float& x, float& y) |
300 | 250 | { | 266 | { |
301 | 251 | // TODO take orientation of input sink into account? | 267 | // TODO take orientation of input sink into account? |
302 | 252 | 268 | ||
303 | === modified file 'tests/mir_test_framework/fake_input_device_impl.h' | |||
304 | --- tests/mir_test_framework/fake_input_device_impl.h 2015-10-20 03:30:00 +0000 | |||
305 | +++ tests/mir_test_framework/fake_input_device_impl.h 2015-10-23 10:50:47 +0000 | |||
306 | @@ -67,6 +67,8 @@ | |||
307 | 67 | 67 | ||
308 | 68 | mir::optional_value<mir::input::PointerSettings> get_pointer_settings() const override; | 68 | mir::optional_value<mir::input::PointerSettings> get_pointer_settings() const override; |
309 | 69 | void apply_settings(mir::input::PointerSettings const& settings) override; | 69 | void apply_settings(mir::input::PointerSettings const& settings) override; |
310 | 70 | mir::optional_value<mir::input::TouchpadSettings> get_touchpad_settings() const override; | ||
311 | 71 | void apply_settings(mir::input::TouchpadSettings const& settings) override; | ||
312 | 70 | 72 | ||
313 | 71 | private: | 73 | private: |
314 | 72 | MirPointerAction update_buttons(synthesis::EventAction action, MirPointerButton button); | 74 | MirPointerAction update_buttons(synthesis::EventAction action, MirPointerButton button); |
315 | 73 | 75 | ||
316 | === modified file 'tests/unit-tests/input/evdev/test_libinput_device.cpp' | |||
317 | --- tests/unit-tests/input/evdev/test_libinput_device.cpp 2015-10-20 03:30:00 +0000 | |||
318 | +++ tests/unit-tests/input/evdev/test_libinput_device.cpp 2015-10-23 10:50:47 +0000 | |||
319 | @@ -23,17 +23,21 @@ | |||
320 | 23 | #include "mir/input/input_device_registry.h" | 23 | #include "mir/input/input_device_registry.h" |
321 | 24 | #include "mir/input/input_sink.h" | 24 | #include "mir/input/input_sink.h" |
322 | 25 | #include "mir/input/pointer_settings.h" | 25 | #include "mir/input/pointer_settings.h" |
323 | 26 | #include "mir/input/touchpad_settings.h" | ||
324 | 27 | #include "mir/flags.h" | ||
325 | 26 | #include "mir/geometry/point.h" | 28 | #include "mir/geometry/point.h" |
326 | 27 | #include "mir/geometry/rectangle.h" | 29 | #include "mir/geometry/rectangle.h" |
327 | 28 | #include "mir/test/event_matchers.h" | 30 | #include "mir/test/event_matchers.h" |
328 | 29 | #include "mir/test/doubles/mock_libinput.h" | 31 | #include "mir/test/doubles/mock_libinput.h" |
329 | 30 | #include "mir/test/gmock_fixes.h" | 32 | #include "mir/test/gmock_fixes.h" |
330 | 33 | #include "mir/udev/wrapper.h" | ||
331 | 31 | #include "mir/cookie_factory.h" | 34 | #include "mir/cookie_factory.h" |
332 | 32 | #include "mir_test_framework/udev_environment.h" | 35 | #include "mir_test_framework/udev_environment.h" |
333 | 33 | 36 | ||
334 | 34 | #include <gmock/gmock.h> | 37 | #include <gmock/gmock.h> |
335 | 35 | #include <gtest/gtest.h> | 38 | #include <gtest/gtest.h> |
336 | 36 | #include <linux/input.h> | 39 | #include <linux/input.h> |
337 | 40 | #include <libinput.h> | ||
338 | 37 | 41 | ||
339 | 38 | #include <chrono> | 42 | #include <chrono> |
340 | 39 | 43 | ||
341 | @@ -125,6 +129,7 @@ | |||
342 | 125 | ::testing::NiceMock<mir::test::doubles::MockLibInput> mock_libinput; | 129 | ::testing::NiceMock<mir::test::doubles::MockLibInput> mock_libinput; |
343 | 126 | ::testing::NiceMock<MockInputSink> mock_sink; | 130 | ::testing::NiceMock<MockInputSink> mock_sink; |
344 | 127 | ::testing::NiceMock<MockEventBuilder> mock_builder; | 131 | ::testing::NiceMock<MockEventBuilder> mock_builder; |
345 | 132 | std::shared_ptr<libinput> lib; | ||
346 | 128 | 133 | ||
347 | 129 | libinput* fake_input = reinterpret_cast<libinput*>(0xF4C3); | 134 | libinput* fake_input = reinterpret_cast<libinput*>(0xF4C3); |
348 | 130 | libinput_device* fake_device = reinterpret_cast<libinput_device*>(0xF4C4); | 135 | libinput_device* fake_device = reinterpret_cast<libinput_device*>(0xF4C4); |
349 | @@ -144,96 +149,186 @@ | |||
350 | 144 | const mi::EventBuilder::Timestamp time_stamp_4{std::chrono::microseconds{event_time_4}}; | 149 | const mi::EventBuilder::Timestamp time_stamp_4{std::chrono::microseconds{event_time_4}}; |
351 | 145 | 150 | ||
352 | 146 | char const* laptop_keyboard_device_path = "/dev/input/event4"; | 151 | char const* laptop_keyboard_device_path = "/dev/input/event4"; |
354 | 147 | char const* path{laptop_keyboard_device_path}; | 152 | char const* trackpad_dev_path = "/dev/input/event13"; |
355 | 153 | char const* touch_screen_dev_path = "/dev/input/event4"; | ||
356 | 154 | char const* usb_mouse_dev_path = "/dev/input/event13"; | ||
357 | 155 | char const* touchpad_dev_path = "/dev/input/event12"; | ||
358 | 148 | 156 | ||
359 | 149 | LibInputDevice() | 157 | LibInputDevice() |
360 | 150 | { | 158 | { |
361 | 151 | setup_device(fake_device, path, "laptop-keyboard", 5252, 3113); | ||
362 | 152 | |||
363 | 153 | ON_CALL(mock_libinput, libinput_path_create_context(_,_)) | 159 | ON_CALL(mock_libinput, libinput_path_create_context(_,_)) |
364 | 154 | .WillByDefault(Return(fake_input)); | 160 | .WillByDefault(Return(fake_input)); |
368 | 155 | } | 161 | lib = mie::make_libinput(); |
369 | 156 | 162 | } | |
370 | 157 | void setup_device(libinput_device* dev, char const* device_path, char const* umock_name, unsigned int vendor_id, unsigned int product_id) | 163 | |
371 | 164 | char const* setup_laptop_keyboard(libinput_device* dev) | ||
372 | 165 | { | ||
373 | 166 | return setup_device(dev, laptop_keyboard_device_path, "laptop-keyboard", 5252, 3113); | ||
374 | 167 | } | ||
375 | 168 | |||
376 | 169 | char const* setup_trackpad(libinput_device* dev) | ||
377 | 170 | { | ||
378 | 171 | return setup_device(dev, trackpad_dev_path, "bluetooth-magic-trackpad", 9663, 1234); | ||
379 | 172 | } | ||
380 | 173 | |||
381 | 174 | char const* setup_touch_screen(libinput_device* dev) | ||
382 | 175 | { | ||
383 | 176 | return setup_device(dev, touch_screen_dev_path, "mt-screen-detection", 858, 484); | ||
384 | 177 | } | ||
385 | 178 | |||
386 | 179 | char const* setup_touchpad(libinput_device* dev) | ||
387 | 180 | { | ||
388 | 181 | return setup_device(dev, touchpad_dev_path, "synaptics-touchpad", 858, 484); | ||
389 | 182 | } | ||
390 | 183 | |||
391 | 184 | char const* setup_mouse(libinput_device* dev) | ||
392 | 185 | { | ||
393 | 186 | return setup_device(dev, usb_mouse_dev_path, "usb-mouse", 858, 484); | ||
394 | 187 | } | ||
395 | 188 | |||
396 | 189 | void remove_devices() | ||
397 | 190 | { | ||
398 | 191 | mir::udev::Enumerator devices{std::make_shared<mir::udev::Context>()}; | ||
399 | 192 | devices.scan_devices(); | ||
400 | 193 | |||
401 | 194 | for (auto& device : devices) | ||
402 | 195 | { | ||
403 | 196 | if (device.devnode() && (std::string(device.devnode()).find("input/event") != std::string::npos)) | ||
404 | 197 | { | ||
405 | 198 | env.remove_device((std::string("/sys") + device.devpath()).c_str()); | ||
406 | 199 | } | ||
407 | 200 | } | ||
408 | 201 | } | ||
409 | 202 | |||
410 | 203 | char const* setup_device(libinput_device* dev, char const* device_path, char const* umock_name, unsigned int vendor_id, unsigned int product_id) | ||
411 | 158 | { | 204 | { |
412 | 159 | env.add_standard_device(umock_name); | 205 | env.add_standard_device(umock_name); |
413 | 160 | mock_libinput.setup_device(fake_input, dev, device_path, umock_name, vendor_id, product_id); | 206 | mock_libinput.setup_device(fake_input, dev, device_path, umock_name, vendor_id, product_id); |
414 | 207 | return device_path; | ||
415 | 161 | } | 208 | } |
416 | 162 | 209 | ||
417 | 163 | void setup_pointer_configuration(libinput_device* dev, double accel_speed, MirPointerHandedness handedness) | 210 | void setup_pointer_configuration(libinput_device* dev, double accel_speed, MirPointerHandedness handedness) |
418 | 164 | { | 211 | { |
423 | 165 | EXPECT_CALL(mock_libinput, libinput_device_config_accel_get_speed(dev)) | 212 | ON_CALL(mock_libinput, libinput_device_config_accel_get_speed(dev)) |
424 | 166 | .WillRepeatedly(Return(accel_speed)); | 213 | .WillByDefault(Return(accel_speed)); |
425 | 167 | EXPECT_CALL(mock_libinput, libinput_device_config_left_handed_get(dev)) | 214 | ON_CALL(mock_libinput, libinput_device_config_left_handed_get(dev)) |
426 | 168 | .WillRepeatedly(Return(handedness == mir_pointer_handedness_left)); | 215 | .WillByDefault(Return(handedness == mir_pointer_handedness_left)); |
427 | 216 | } | ||
428 | 217 | |||
429 | 218 | void setup_touchpad_configuration(libinput_device* dev, | ||
430 | 219 | MirTouchpadClickMode click_mode, | ||
431 | 220 | MirTouchpadScrollMode scroll_mode, | ||
432 | 221 | int scroll_button, | ||
433 | 222 | bool tap_to_click, | ||
434 | 223 | bool disable_while_typing, | ||
435 | 224 | bool disable_with_mouse, | ||
436 | 225 | bool middle_button_emulation) | ||
437 | 226 | { | ||
438 | 227 | mir::Flags<libinput_config_click_method> click_method = LIBINPUT_CONFIG_CLICK_METHOD_NONE; | ||
439 | 228 | if (click_mode & mir_touchpad_click_mode_finger_count) | ||
440 | 229 | click_method |= LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; | ||
441 | 230 | if (click_mode & mir_touchpad_click_mode_area_to_click) | ||
442 | 231 | click_method |= LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; | ||
443 | 232 | |||
444 | 233 | mir::Flags<libinput_config_scroll_method> scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | ||
445 | 234 | if (scroll_mode & mir_touchpad_scroll_mode_two_finger_scroll) | ||
446 | 235 | scroll_method |= LIBINPUT_CONFIG_SCROLL_2FG; | ||
447 | 236 | if (scroll_mode & mir_touchpad_scroll_mode_edge_scroll) | ||
448 | 237 | scroll_method |= LIBINPUT_CONFIG_SCROLL_EDGE; | ||
449 | 238 | if (scroll_mode & mir_touchpad_scroll_mode_button_down_scroll) | ||
450 | 239 | scroll_method |= LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; | ||
451 | 240 | |||
452 | 241 | ON_CALL(mock_libinput, libinput_device_config_click_get_method(dev)) | ||
453 | 242 | .WillByDefault(Return(static_cast<libinput_config_click_method>(click_method.value()))); | ||
454 | 243 | ON_CALL(mock_libinput, libinput_device_config_scroll_get_method(dev)) | ||
455 | 244 | .WillByDefault(Return(static_cast<libinput_config_scroll_method>(scroll_method.value()))); | ||
456 | 245 | ON_CALL(mock_libinput, libinput_device_config_scroll_get_button(dev)) | ||
457 | 246 | .WillByDefault(Return(scroll_button)); | ||
458 | 247 | ON_CALL(mock_libinput, libinput_device_config_tap_get_enabled(dev)) | ||
459 | 248 | .WillByDefault(Return(tap_to_click? | ||
460 | 249 | LIBINPUT_CONFIG_TAP_ENABLED: | ||
461 | 250 | LIBINPUT_CONFIG_TAP_DISABLED)); | ||
462 | 251 | ON_CALL(mock_libinput, libinput_device_config_dwt_get_enabled(dev)) | ||
463 | 252 | .WillByDefault(Return(disable_while_typing? | ||
464 | 253 | LIBINPUT_CONFIG_DWT_ENABLED: | ||
465 | 254 | LIBINPUT_CONFIG_DWT_DISABLED)); | ||
466 | 255 | ON_CALL(mock_libinput, libinput_device_config_send_events_get_mode(dev)) | ||
467 | 256 | .WillByDefault(Return(disable_with_mouse? | ||
468 | 257 | LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE: | ||
469 | 258 | LIBINPUT_CONFIG_SEND_EVENTS_ENABLED)); | ||
470 | 259 | ON_CALL(mock_libinput, libinput_device_config_middle_emulation_get_enabled(dev)) | ||
471 | 260 | .WillByDefault(Return(middle_button_emulation? | ||
472 | 261 | LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED: | ||
473 | 262 | LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED)); | ||
474 | 263 | |||
475 | 169 | } | 264 | } |
476 | 170 | 265 | ||
477 | 171 | void setup_key_event(libinput_event* event, uint64_t event_time, uint32_t key, libinput_key_state state) | 266 | void setup_key_event(libinput_event* event, uint64_t event_time, uint32_t key, libinput_key_state state) |
478 | 172 | { | 267 | { |
479 | 173 | auto key_event = reinterpret_cast<libinput_event_keyboard*>(event); | 268 | auto key_event = reinterpret_cast<libinput_event_keyboard*>(event); |
480 | 174 | 269 | ||
491 | 175 | EXPECT_CALL(mock_libinput, libinput_event_get_type(event)) | 270 | ON_CALL(mock_libinput, libinput_event_get_type(event)) |
492 | 176 | .WillRepeatedly(Return(LIBINPUT_EVENT_KEYBOARD_KEY)); | 271 | .WillByDefault(Return(LIBINPUT_EVENT_KEYBOARD_KEY)); |
493 | 177 | EXPECT_CALL(mock_libinput, libinput_event_get_keyboard_event(event)) | 272 | ON_CALL(mock_libinput, libinput_event_get_keyboard_event(event)) |
494 | 178 | .WillRepeatedly(Return(key_event)); | 273 | .WillByDefault(Return(key_event)); |
495 | 179 | EXPECT_CALL(mock_libinput, libinput_event_keyboard_get_time_usec(key_event)) | 274 | ON_CALL(mock_libinput, libinput_event_keyboard_get_time_usec(key_event)) |
496 | 180 | .WillRepeatedly(Return(event_time)); | 275 | .WillByDefault(Return(event_time)); |
497 | 181 | EXPECT_CALL(mock_libinput, libinput_event_keyboard_get_key(key_event)) | 276 | ON_CALL(mock_libinput, libinput_event_keyboard_get_key(key_event)) |
498 | 182 | .WillRepeatedly(Return(key)); | 277 | .WillByDefault(Return(key)); |
499 | 183 | EXPECT_CALL(mock_libinput, libinput_event_keyboard_get_key_state(key_event)) | 278 | ON_CALL(mock_libinput, libinput_event_keyboard_get_key_state(key_event)) |
500 | 184 | .WillRepeatedly(Return(state)); | 279 | .WillByDefault(Return(state)); |
501 | 185 | } | 280 | } |
502 | 186 | 281 | ||
503 | 187 | void setup_pointer_event(libinput_event* event, uint64_t event_time, float relatve_x, float relatve_y) | 282 | void setup_pointer_event(libinput_event* event, uint64_t event_time, float relatve_x, float relatve_y) |
504 | 188 | { | 283 | { |
505 | 189 | auto pointer_event = reinterpret_cast<libinput_event_pointer*>(event); | 284 | auto pointer_event = reinterpret_cast<libinput_event_pointer*>(event); |
506 | 190 | 285 | ||
517 | 191 | EXPECT_CALL(mock_libinput, libinput_event_get_type(event)) | 286 | ON_CALL(mock_libinput, libinput_event_get_type(event)) |
518 | 192 | .WillRepeatedly(Return(LIBINPUT_EVENT_POINTER_MOTION)); | 287 | .WillByDefault(Return(LIBINPUT_EVENT_POINTER_MOTION)); |
519 | 193 | EXPECT_CALL(mock_libinput, libinput_event_get_pointer_event(event)) | 288 | ON_CALL(mock_libinput, libinput_event_get_pointer_event(event)) |
520 | 194 | .WillRepeatedly(Return(pointer_event)); | 289 | .WillByDefault(Return(pointer_event)); |
521 | 195 | EXPECT_CALL(mock_libinput, libinput_event_pointer_get_time_usec(pointer_event)) | 290 | ON_CALL(mock_libinput, libinput_event_pointer_get_time_usec(pointer_event)) |
522 | 196 | .WillRepeatedly(Return(event_time)); | 291 | .WillByDefault(Return(event_time)); |
523 | 197 | EXPECT_CALL(mock_libinput, libinput_event_pointer_get_dx(pointer_event)) | 292 | ON_CALL(mock_libinput, libinput_event_pointer_get_dx(pointer_event)) |
524 | 198 | .WillRepeatedly(Return(relatve_x)); | 293 | .WillByDefault(Return(relatve_x)); |
525 | 199 | EXPECT_CALL(mock_libinput, libinput_event_pointer_get_dy(pointer_event)) | 294 | ON_CALL(mock_libinput, libinput_event_pointer_get_dy(pointer_event)) |
526 | 200 | .WillRepeatedly(Return(relatve_y)); | 295 | .WillByDefault(Return(relatve_y)); |
527 | 201 | } | 296 | } |
528 | 202 | 297 | ||
529 | 203 | void setup_button_event(libinput_event* event, uint64_t event_time, int button, libinput_button_state state) | 298 | void setup_button_event(libinput_event* event, uint64_t event_time, int button, libinput_button_state state) |
530 | 204 | { | 299 | { |
531 | 205 | auto pointer_event = reinterpret_cast<libinput_event_pointer*>(event); | 300 | auto pointer_event = reinterpret_cast<libinput_event_pointer*>(event); |
532 | 206 | 301 | ||
543 | 207 | EXPECT_CALL(mock_libinput, libinput_event_get_type(event)) | 302 | ON_CALL(mock_libinput, libinput_event_get_type(event)) |
544 | 208 | .WillRepeatedly(Return(LIBINPUT_EVENT_POINTER_BUTTON)); | 303 | .WillByDefault(Return(LIBINPUT_EVENT_POINTER_BUTTON)); |
545 | 209 | EXPECT_CALL(mock_libinput, libinput_event_get_pointer_event(event)) | 304 | ON_CALL(mock_libinput, libinput_event_get_pointer_event(event)) |
546 | 210 | .WillRepeatedly(Return(pointer_event)); | 305 | .WillByDefault(Return(pointer_event)); |
547 | 211 | EXPECT_CALL(mock_libinput, libinput_event_pointer_get_time_usec(pointer_event)) | 306 | ON_CALL(mock_libinput, libinput_event_pointer_get_time_usec(pointer_event)) |
548 | 212 | .WillRepeatedly(Return(event_time)); | 307 | .WillByDefault(Return(event_time)); |
549 | 213 | EXPECT_CALL(mock_libinput, libinput_event_pointer_get_button(pointer_event)) | 308 | ON_CALL(mock_libinput, libinput_event_pointer_get_button(pointer_event)) |
550 | 214 | .WillRepeatedly(Return(button)); | 309 | .WillByDefault(Return(button)); |
551 | 215 | EXPECT_CALL(mock_libinput, libinput_event_pointer_get_button_state(pointer_event)) | 310 | ON_CALL(mock_libinput, libinput_event_pointer_get_button_state(pointer_event)) |
552 | 216 | .WillRepeatedly(Return(state)); | 311 | .WillByDefault(Return(state)); |
553 | 217 | } | 312 | } |
554 | 218 | 313 | ||
555 | 219 | void setup_axis_event(libinput_event* event, uint64_t event_time, double horizontal, double vertical) | 314 | void setup_axis_event(libinput_event* event, uint64_t event_time, double horizontal, double vertical) |
556 | 220 | { | 315 | { |
557 | 221 | auto pointer_event = reinterpret_cast<libinput_event_pointer*>(event); | 316 | auto pointer_event = reinterpret_cast<libinput_event_pointer*>(event); |
558 | 222 | 317 | ||
573 | 223 | EXPECT_CALL(mock_libinput, libinput_event_get_type(event)) | 318 | ON_CALL(mock_libinput, libinput_event_get_type(event)) |
574 | 224 | .WillRepeatedly(Return(LIBINPUT_EVENT_POINTER_AXIS)); | 319 | .WillByDefault(Return(LIBINPUT_EVENT_POINTER_AXIS)); |
575 | 225 | EXPECT_CALL(mock_libinput, libinput_event_get_pointer_event(event)) | 320 | ON_CALL(mock_libinput, libinput_event_get_pointer_event(event)) |
576 | 226 | .WillRepeatedly(Return(pointer_event)); | 321 | .WillByDefault(Return(pointer_event)); |
577 | 227 | EXPECT_CALL(mock_libinput, libinput_event_pointer_get_time_usec(pointer_event)) | 322 | ON_CALL(mock_libinput, libinput_event_pointer_get_time_usec(pointer_event)) |
578 | 228 | .WillRepeatedly(Return(event_time)); | 323 | .WillByDefault(Return(event_time)); |
579 | 229 | EXPECT_CALL(mock_libinput, libinput_event_pointer_has_axis(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) | 324 | ON_CALL(mock_libinput, libinput_event_pointer_has_axis(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) |
580 | 230 | .WillRepeatedly(Return(horizontal!=0.0)); | 325 | .WillByDefault(Return(horizontal!=0.0)); |
581 | 231 | EXPECT_CALL(mock_libinput, libinput_event_pointer_has_axis(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) | 326 | ON_CALL(mock_libinput, libinput_event_pointer_has_axis(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) |
582 | 232 | .WillRepeatedly(Return(vertical!=0.0)); | 327 | .WillByDefault(Return(vertical!=0.0)); |
583 | 233 | EXPECT_CALL(mock_libinput, libinput_event_pointer_get_axis_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) | 328 | ON_CALL(mock_libinput, libinput_event_pointer_get_axis_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) |
584 | 234 | .WillRepeatedly(Return(vertical)); | 329 | .WillByDefault(Return(vertical)); |
585 | 235 | EXPECT_CALL(mock_libinput, libinput_event_pointer_get_axis_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) | 330 | ON_CALL(mock_libinput, libinput_event_pointer_get_axis_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) |
586 | 236 | .WillRepeatedly(Return(horizontal)); | 331 | .WillByDefault(Return(horizontal)); |
587 | 237 | } | 332 | } |
588 | 238 | 333 | ||
589 | 239 | void setup_touch_event(libinput_event* event, libinput_event_type type, uint64_t event_time, int slot, float x, | 334 | void setup_touch_event(libinput_event* event, libinput_event_type type, uint64_t event_time, int slot, float x, |
590 | @@ -241,73 +336,91 @@ | |||
591 | 241 | { | 336 | { |
592 | 242 | auto touch_event = reinterpret_cast<libinput_event_touch*>(event); | 337 | auto touch_event = reinterpret_cast<libinput_event_touch*>(event); |
593 | 243 | 338 | ||
612 | 244 | EXPECT_CALL(mock_libinput, libinput_event_get_type(event)) | 339 | ON_CALL(mock_libinput, libinput_event_get_type(event)) |
613 | 245 | .WillRepeatedly(Return(type)); | 340 | .WillByDefault(Return(type)); |
614 | 246 | EXPECT_CALL(mock_libinput, libinput_event_get_touch_event(event)) | 341 | ON_CALL(mock_libinput, libinput_event_get_touch_event(event)) |
615 | 247 | .WillRepeatedly(Return(touch_event)); | 342 | .WillByDefault(Return(touch_event)); |
616 | 248 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_slot(touch_event)) | 343 | ON_CALL(mock_libinput, libinput_event_touch_get_slot(touch_event)) |
617 | 249 | .WillRepeatedly(Return(slot)); | 344 | .WillByDefault(Return(slot)); |
618 | 250 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_x_transformed(touch_event, _)) | 345 | ON_CALL(mock_libinput, libinput_event_touch_get_x_transformed(touch_event, _)) |
619 | 251 | .WillRepeatedly(Return(x)); | 346 | .WillByDefault(Return(x)); |
620 | 252 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_y_transformed(touch_event, _)) | 347 | ON_CALL(mock_libinput, libinput_event_touch_get_y_transformed(touch_event, _)) |
621 | 253 | .WillRepeatedly(Return(y)); | 348 | .WillByDefault(Return(y)); |
622 | 254 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_time_usec(touch_event)) | 349 | ON_CALL(mock_libinput, libinput_event_touch_get_time_usec(touch_event)) |
623 | 255 | .WillRepeatedly(Return(event_time)); | 350 | .WillByDefault(Return(event_time)); |
624 | 256 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_major_transformed(touch_event, _, _)) | 351 | ON_CALL(mock_libinput, libinput_event_touch_get_major_transformed(touch_event, _, _)) |
625 | 257 | .WillRepeatedly(Return(major)); | 352 | .WillByDefault(Return(major)); |
626 | 258 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_minor_transformed(touch_event, _, _)) | 353 | ON_CALL(mock_libinput, libinput_event_touch_get_minor_transformed(touch_event, _, _)) |
627 | 259 | .WillRepeatedly(Return(minor)); | 354 | .WillByDefault(Return(minor)); |
628 | 260 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_pressure(touch_event)) | 355 | ON_CALL(mock_libinput, libinput_event_touch_get_pressure(touch_event)) |
629 | 261 | .WillRepeatedly(Return(pressure)); | 356 | .WillByDefault(Return(pressure)); |
630 | 262 | } | 357 | } |
631 | 263 | 358 | ||
632 | 264 | void setup_touch_up_event(libinput_event* event, uint64_t event_time, int slot) | 359 | void setup_touch_up_event(libinput_event* event, uint64_t event_time, int slot) |
633 | 265 | { | 360 | { |
634 | 266 | auto touch_event = reinterpret_cast<libinput_event_touch*>(event); | 361 | auto touch_event = reinterpret_cast<libinput_event_touch*>(event); |
635 | 267 | 362 | ||
659 | 268 | EXPECT_CALL(mock_libinput, libinput_event_get_type(event)) | 363 | ON_CALL(mock_libinput, libinput_event_get_type(event)) |
660 | 269 | .WillRepeatedly(Return(LIBINPUT_EVENT_TOUCH_UP)); | 364 | .WillByDefault(Return(LIBINPUT_EVENT_TOUCH_UP)); |
661 | 270 | EXPECT_CALL(mock_libinput, libinput_event_get_touch_event(event)) | 365 | ON_CALL(mock_libinput, libinput_event_get_touch_event(event)) |
662 | 271 | .WillRepeatedly(Return(touch_event)); | 366 | .WillByDefault(Return(touch_event)); |
663 | 272 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_slot(touch_event)) | 367 | ON_CALL(mock_libinput, libinput_event_touch_get_slot(touch_event)) |
664 | 273 | .WillRepeatedly(Return(slot)); | 368 | .WillByDefault(Return(slot)); |
665 | 274 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_x_transformed(touch_event, _)) | 369 | ON_CALL(mock_libinput, libinput_event_touch_get_time_usec(touch_event)) |
666 | 275 | .Times(0); | 370 | .WillByDefault(Return(event_time)); |
644 | 276 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_y_transformed(touch_event, _)) | ||
645 | 277 | .Times(0); | ||
646 | 278 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_x(touch_event)) | ||
647 | 279 | .Times(0); | ||
648 | 280 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_y(touch_event)) | ||
649 | 281 | .Times(0); | ||
650 | 282 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_time_usec(touch_event)) | ||
651 | 283 | .WillRepeatedly(Return(event_time)); | ||
652 | 284 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_major_transformed(touch_event, _, _)) | ||
653 | 285 | .Times(0); | ||
654 | 286 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_minor_transformed(touch_event, _, _)) | ||
655 | 287 | .Times(0); | ||
656 | 288 | EXPECT_CALL(mock_libinput, libinput_event_touch_get_pressure(touch_event)) | ||
657 | 289 | .Times(0); | ||
658 | 290 | |||
667 | 291 | } | 371 | } |
668 | 292 | 372 | ||
669 | 293 | void setup_touch_frame(libinput_event* event) | 373 | void setup_touch_frame(libinput_event* event) |
670 | 294 | { | 374 | { |
673 | 295 | EXPECT_CALL(mock_libinput, libinput_event_get_type(event)) | 375 | ON_CALL(mock_libinput, libinput_event_get_type(event)) |
674 | 296 | .WillRepeatedly(Return(LIBINPUT_EVENT_TOUCH_FRAME)); | 376 | .WillByDefault(Return(LIBINPUT_EVENT_TOUCH_FRAME)); |
675 | 297 | } | 377 | } |
676 | 298 | }; | 378 | }; |
677 | 299 | 379 | ||
678 | 380 | struct LibInputDeviceOnLaptopKeyboard : public LibInputDevice | ||
679 | 381 | { | ||
680 | 382 | char const* keyboard_path = setup_laptop_keyboard(fake_device); | ||
681 | 383 | mie::LibInputDevice keyboard{mir::report::null_input_report(), keyboard_path, mie::make_libinput_device(lib.get(), keyboard_path)}; | ||
682 | 384 | }; | ||
683 | 385 | |||
684 | 386 | struct LibInputDeviceOnMouse : public LibInputDevice | ||
685 | 387 | { | ||
686 | 388 | char const* mouse_path = setup_mouse(fake_device); | ||
687 | 389 | mie::LibInputDevice mouse{mir::report::null_input_report(), mouse_path, mie::make_libinput_device(lib.get(), mouse_path)}; | ||
688 | 390 | }; | ||
689 | 391 | |||
690 | 392 | struct LibInputDeviceOnLaptopKeyboardAndMouse : public LibInputDevice | ||
691 | 393 | { | ||
692 | 394 | char const* mouse_path = setup_mouse(fake_device); | ||
693 | 395 | char const* keyboard_path = setup_laptop_keyboard(fake_device); | ||
694 | 396 | mie::LibInputDevice keyboard{mir::report::null_input_report(), keyboard_path, mie::make_libinput_device(lib.get(), keyboard_path)}; | ||
695 | 397 | mie::LibInputDevice mouse{mir::report::null_input_report(), mouse_path, mie::make_libinput_device(lib.get(), mouse_path)}; | ||
696 | 398 | }; | ||
697 | 399 | |||
698 | 400 | struct LibInputDeviceOnTouchScreen : public LibInputDevice | ||
699 | 401 | { | ||
700 | 402 | char const* touch_screen_path = setup_touch_screen(fake_device); | ||
701 | 403 | mie::LibInputDevice touch_screen{mir::report::null_input_report(), touch_screen_path, mie::make_libinput_device(lib.get(), touch_screen_path)}; | ||
702 | 404 | }; | ||
703 | 405 | |||
704 | 406 | struct LibInputDeviceOnTouchpad : public LibInputDevice | ||
705 | 407 | { | ||
706 | 408 | char const* touchpad_path = setup_touchpad(fake_device); | ||
707 | 409 | mie::LibInputDevice touchpad{mir::report::null_input_report(), touchpad_path, mie::make_libinput_device(lib.get(), touchpad_path)}; | ||
708 | 410 | }; | ||
709 | 300 | } | 411 | } |
710 | 301 | 412 | ||
711 | 302 | TEST_F(LibInputDevice, start_creates_and_unrefs_libinput_device_from_path) | 413 | TEST_F(LibInputDevice, start_creates_and_unrefs_libinput_device_from_path) |
712 | 303 | { | 414 | { |
713 | 415 | char const * path = setup_laptop_keyboard(fake_device); | ||
714 | 416 | |||
715 | 304 | EXPECT_CALL(mock_libinput, libinput_path_add_device(fake_input,StrEq(path))) | 417 | EXPECT_CALL(mock_libinput, libinput_path_add_device(fake_input,StrEq(path))) |
716 | 305 | .Times(1); | 418 | .Times(1); |
717 | 306 | // according to manual libinput_path_add_device creates a temporary device with a ref count 0. | 419 | // according to manual libinput_path_add_device creates a temporary device with a ref count 0. |
718 | 307 | // hence it needs a manual ref call | 420 | // hence it needs a manual ref call |
719 | 308 | EXPECT_CALL(mock_libinput, libinput_device_ref(fake_device)) | 421 | EXPECT_CALL(mock_libinput, libinput_device_ref(fake_device)) |
720 | 309 | .Times(1); | 422 | .Times(1); |
722 | 310 | std::shared_ptr<libinput> lib = mie::make_libinput(); | 423 | |
723 | 311 | mie::LibInputDevice dev(mir::report::null_input_report(), | 424 | mie::LibInputDevice dev(mir::report::null_input_report(), |
724 | 312 | path, | 425 | path, |
725 | 313 | std::move(mie::make_libinput_device(lib.get(), path))); | 426 | std::move(mie::make_libinput_device(lib.get(), path))); |
726 | @@ -316,38 +429,32 @@ | |||
727 | 316 | 429 | ||
728 | 317 | TEST_F(LibInputDevice, open_device_of_group) | 430 | TEST_F(LibInputDevice, open_device_of_group) |
729 | 318 | { | 431 | { |
735 | 319 | std::shared_ptr<libinput> lib = mie::make_libinput(); | 432 | char const* first_path = setup_laptop_keyboard(fake_device); |
736 | 320 | char const* second_dev = "/dev/input/event13"; | 433 | char const* second_path = setup_trackpad(second_fake_device); |
732 | 321 | char const* second_umock_dev_name = "bluetooth-magic-trackpad"; | ||
733 | 322 | |||
734 | 323 | setup_device(second_fake_device, second_dev, second_umock_dev_name, 9663, 1234); | ||
737 | 324 | 434 | ||
738 | 325 | InSequence seq; | 435 | InSequence seq; |
740 | 326 | EXPECT_CALL(mock_libinput, libinput_path_add_device(fake_input,StrEq(path))).Times(1); | 436 | EXPECT_CALL(mock_libinput, libinput_path_add_device(fake_input,StrEq(first_path))).Times(1); |
741 | 327 | // according to manual libinput_path_add_device creates a temporary device with a ref count 0. | 437 | // according to manual libinput_path_add_device creates a temporary device with a ref count 0. |
742 | 328 | // hence it needs a manual ref call | 438 | // hence it needs a manual ref call |
743 | 329 | EXPECT_CALL(mock_libinput, libinput_device_ref(fake_device)).Times(1); | 439 | EXPECT_CALL(mock_libinput, libinput_device_ref(fake_device)).Times(1); |
745 | 330 | EXPECT_CALL(mock_libinput, libinput_path_add_device(fake_input,StrEq(second_dev))).Times(1); | 440 | EXPECT_CALL(mock_libinput, libinput_path_add_device(fake_input,StrEq(second_path))).Times(1); |
746 | 331 | EXPECT_CALL(mock_libinput, libinput_device_ref(second_fake_device)).Times(1); | 441 | EXPECT_CALL(mock_libinput, libinput_device_ref(second_fake_device)).Times(1); |
747 | 332 | 442 | ||
748 | 333 | mie::LibInputDevice dev(mir::report::null_input_report(), | 443 | mie::LibInputDevice dev(mir::report::null_input_report(), |
752 | 334 | path, | 444 | first_path, |
753 | 335 | std::move(mie::make_libinput_device(lib.get(), path))); | 445 | std::move(mie::make_libinput_device(lib.get(), first_path))); |
754 | 336 | dev.add_device_of_group(second_dev, mie::make_libinput_device(lib.get(), second_dev)); | 446 | dev.add_device_of_group(second_path, mie::make_libinput_device(lib.get(), second_path)); |
755 | 337 | dev.start(&mock_sink, &mock_builder); | 447 | dev.start(&mock_sink, &mock_builder); |
756 | 338 | } | 448 | } |
757 | 339 | 449 | ||
758 | 340 | TEST_F(LibInputDevice, input_info_combines_capabilities) | 450 | TEST_F(LibInputDevice, input_info_combines_capabilities) |
759 | 341 | { | 451 | { |
765 | 342 | std::shared_ptr<libinput> lib = mie::make_libinput(); | 452 | char const* first_dev = setup_laptop_keyboard(fake_device); |
766 | 343 | char const* second_dev = "/dev/input/event13"; | 453 | char const* second_dev = setup_trackpad(second_fake_device); |
762 | 344 | char const* second_umock_dev_name = "bluetooth-magic-trackpad"; | ||
763 | 345 | |||
764 | 346 | setup_device(second_fake_device, second_dev, second_umock_dev_name, 9663, 1234); | ||
767 | 347 | 454 | ||
768 | 348 | mie::LibInputDevice dev(mir::report::null_input_report(), | 455 | mie::LibInputDevice dev(mir::report::null_input_report(), |
771 | 349 | path, | 456 | first_dev, |
772 | 350 | mie::make_libinput_device(lib.get(), path)); | 457 | mie::make_libinput_device(lib.get(), first_dev)); |
773 | 351 | dev.add_device_of_group(second_dev, mie::make_libinput_device(lib.get(), second_dev)); | 458 | dev.add_device_of_group(second_dev, mie::make_libinput_device(lib.get(), second_dev)); |
774 | 352 | auto info = dev.get_device_info(); | 459 | auto info = dev.get_device_info(); |
775 | 353 | 460 | ||
776 | @@ -358,7 +465,7 @@ | |||
777 | 358 | 465 | ||
778 | 359 | TEST_F(LibInputDevice, removal_unrefs_libinput_device) | 466 | TEST_F(LibInputDevice, removal_unrefs_libinput_device) |
779 | 360 | { | 467 | { |
781 | 361 | std::shared_ptr<libinput> lib = mie::make_libinput(); | 468 | char const* path = setup_laptop_keyboard(fake_device); |
782 | 362 | 469 | ||
783 | 363 | EXPECT_CALL(mock_libinput, libinput_device_unref(fake_device)) | 470 | EXPECT_CALL(mock_libinput, libinput_device_unref(fake_device)) |
784 | 364 | .Times(1); | 471 | .Times(1); |
785 | @@ -366,12 +473,8 @@ | |||
786 | 366 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | 473 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); |
787 | 367 | } | 474 | } |
788 | 368 | 475 | ||
791 | 369 | 476 | TEST_F(LibInputDeviceOnLaptopKeyboard, process_event_converts_key_event) | |
790 | 370 | TEST_F(LibInputDevice, process_event_converts_key_event) | ||
792 | 371 | { | 477 | { |
793 | 372 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
794 | 373 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | ||
795 | 374 | |||
796 | 375 | setup_key_event(fake_event_1, event_time_1, KEY_A, LIBINPUT_KEY_STATE_PRESSED); | 478 | setup_key_event(fake_event_1, event_time_1, KEY_A, LIBINPUT_KEY_STATE_PRESSED); |
797 | 376 | setup_key_event(fake_event_2, event_time_2, KEY_A, LIBINPUT_KEY_STATE_RELEASED); | 479 | setup_key_event(fake_event_2, event_time_2, KEY_A, LIBINPUT_KEY_STATE_RELEASED); |
798 | 377 | 480 | ||
799 | @@ -380,17 +483,13 @@ | |||
800 | 380 | EXPECT_CALL(mock_builder, key_event(time_stamp_2, mir_keyboard_action_up, _, KEY_A, mir_input_event_modifier_none)); | 483 | EXPECT_CALL(mock_builder, key_event(time_stamp_2, mir_keyboard_action_up, _, KEY_A, mir_input_event_modifier_none)); |
801 | 381 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_A),mt::KeyUpEvent()))); | 484 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_A),mt::KeyUpEvent()))); |
802 | 382 | 485 | ||
806 | 383 | dev.start(&mock_sink, &mock_builder); | 486 | keyboard.start(&mock_sink, &mock_builder); |
807 | 384 | dev.process_event(fake_event_1); | 487 | keyboard.process_event(fake_event_1); |
808 | 385 | dev.process_event(fake_event_2); | 488 | keyboard.process_event(fake_event_2); |
809 | 386 | } | 489 | } |
810 | 387 | 490 | ||
812 | 388 | TEST_F(LibInputDevice, process_event_accumulates_key_state) | 491 | TEST_F(LibInputDeviceOnLaptopKeyboard, process_event_accumulates_key_state) |
813 | 389 | { | 492 | { |
814 | 390 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
815 | 391 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | ||
816 | 392 | |||
817 | 393 | |||
818 | 394 | setup_key_event(fake_event_1, event_time_1, KEY_C, LIBINPUT_KEY_STATE_PRESSED); | 493 | setup_key_event(fake_event_1, event_time_1, KEY_C, LIBINPUT_KEY_STATE_PRESSED); |
819 | 395 | setup_key_event(fake_event_2, event_time_2, KEY_LEFTALT, LIBINPUT_KEY_STATE_PRESSED); | 494 | setup_key_event(fake_event_2, event_time_2, KEY_LEFTALT, LIBINPUT_KEY_STATE_PRESSED); |
820 | 396 | setup_key_event(fake_event_3, event_time_3, KEY_C, LIBINPUT_KEY_STATE_RELEASED); | 495 | setup_key_event(fake_event_3, event_time_3, KEY_C, LIBINPUT_KEY_STATE_RELEASED); |
821 | @@ -400,56 +499,45 @@ | |||
822 | 400 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_C),mt::KeyDownEvent()))); | 499 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_C),mt::KeyDownEvent()))); |
823 | 401 | EXPECT_CALL(mock_builder, key_event(time_stamp_2, mir_keyboard_action_down, _, KEY_LEFTALT, mir_input_event_modifier_none)); | 500 | EXPECT_CALL(mock_builder, key_event(time_stamp_2, mir_keyboard_action_down, _, KEY_LEFTALT, mir_input_event_modifier_none)); |
824 | 402 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_LEFTALT),mt::KeyDownEvent()))); | 501 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_LEFTALT),mt::KeyDownEvent()))); |
826 | 403 | EXPECT_CALL(mock_builder, key_event(time_stamp_3, mir_keyboard_action_up, _, KEY_C, mir_input_event_modifier_alt|mir_input_event_modifier_alt_left)); | 502 | EXPECT_CALL(mock_builder, key_event(time_stamp_3, mir_keyboard_action_up, _, KEY_C, |
827 | 503 | mir_input_event_modifier_alt | mir_input_event_modifier_alt_left)); | ||
828 | 404 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_C), | 504 | EXPECT_CALL(mock_sink, handle_input(AllOf(mt::KeyOfScanCode(KEY_C), |
834 | 405 | mt::KeyWithModifiers( | 505 | mt::KeyWithModifiers(MirInputEventModifiers{ |
835 | 406 | MirInputEventModifiers{ | 506 | mir_input_event_modifier_alt | mir_input_event_modifier_alt_left}), |
831 | 407 | mir_input_event_modifier_alt| | ||
832 | 408 | mir_input_event_modifier_alt_left | ||
833 | 409 | }), | ||
836 | 410 | mt::KeyUpEvent()))); | 507 | mt::KeyUpEvent()))); |
837 | 411 | 508 | ||
842 | 412 | dev.start(&mock_sink, &mock_builder); | 509 | keyboard.start(&mock_sink, &mock_builder); |
843 | 413 | dev.process_event(fake_event_1); | 510 | keyboard.process_event(fake_event_1); |
844 | 414 | dev.process_event(fake_event_2); | 511 | keyboard.process_event(fake_event_2); |
845 | 415 | dev.process_event(fake_event_3); | 512 | keyboard.process_event(fake_event_3); |
846 | 416 | } | 513 | } |
847 | 417 | 514 | ||
849 | 418 | TEST_F(LibInputDevice, process_event_converts_pointer_event) | 515 | TEST_F(LibInputDeviceOnMouse, process_event_converts_pointer_event) |
850 | 419 | { | 516 | { |
851 | 420 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
852 | 421 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | ||
853 | 422 | |||
854 | 423 | float x = 15; | 517 | float x = 15; |
855 | 424 | float y = 17; | 518 | float y = 17; |
856 | 425 | setup_pointer_event(fake_event_1, event_time_1, x, y); | 519 | setup_pointer_event(fake_event_1, event_time_1, x, y); |
857 | 426 | 520 | ||
858 | 427 | EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithPosition(x,y))); | 521 | EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithPosition(x,y))); |
859 | 428 | 522 | ||
862 | 429 | dev.start(&mock_sink, &mock_builder); | 523 | mouse.start(&mock_sink, &mock_builder); |
863 | 430 | dev.process_event(fake_event_1); | 524 | mouse.process_event(fake_event_1); |
864 | 431 | } | 525 | } |
865 | 432 | 526 | ||
867 | 433 | TEST_F(LibInputDevice, process_event_provides_relative_coordinates) | 527 | TEST_F(LibInputDeviceOnMouse, process_event_provides_relative_coordinates) |
868 | 434 | { | 528 | { |
869 | 435 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
870 | 436 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | ||
871 | 437 | |||
872 | 438 | float x = -5; | 529 | float x = -5; |
873 | 439 | float y = 20; | 530 | float y = 20; |
874 | 440 | setup_pointer_event(fake_event_1, event_time_1, x, y); | 531 | setup_pointer_event(fake_event_1, event_time_1, x, y); |
875 | 441 | 532 | ||
876 | 442 | EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithDiff(x,y))); | 533 | EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithDiff(x,y))); |
877 | 443 | 534 | ||
880 | 444 | dev.start(&mock_sink, &mock_builder); | 535 | mouse.start(&mock_sink, &mock_builder); |
881 | 445 | dev.process_event(fake_event_1); | 536 | mouse.process_event(fake_event_1); |
882 | 446 | } | 537 | } |
883 | 447 | 538 | ||
885 | 448 | TEST_F(LibInputDevice, process_event_accumulates_pointer_movement) | 539 | TEST_F(LibInputDeviceOnMouse, process_event_accumulates_pointer_movement) |
886 | 449 | { | 540 | { |
887 | 450 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
888 | 451 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | ||
889 | 452 | |||
890 | 453 | float x1 = 15, x2 = 23; | 541 | float x1 = 15, x2 = 23; |
891 | 454 | float y1 = 17, y2 = 21; | 542 | float y1 = 17, y2 = 21; |
892 | 455 | 543 | ||
893 | @@ -459,18 +547,16 @@ | |||
894 | 459 | EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithPosition(x1,y1))); | 547 | EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithPosition(x1,y1))); |
895 | 460 | EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithPosition(x1+x2,y1+y2))); | 548 | EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithPosition(x1+x2,y1+y2))); |
896 | 461 | 549 | ||
900 | 462 | dev.start(&mock_sink, &mock_builder); | 550 | mouse.start(&mock_sink, &mock_builder); |
901 | 463 | dev.process_event(fake_event_1); | 551 | mouse.process_event(fake_event_1); |
902 | 464 | dev.process_event(fake_event_2); | 552 | mouse.process_event(fake_event_2); |
903 | 465 | } | 553 | } |
904 | 466 | 554 | ||
906 | 467 | TEST_F(LibInputDevice, process_event_handles_press_and_release) | 555 | TEST_F(LibInputDeviceOnMouse, process_event_handles_press_and_release) |
907 | 468 | { | 556 | { |
908 | 469 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
909 | 470 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | ||
910 | 471 | float const x = 0; | 557 | float const x = 0; |
911 | 472 | float const y = 0; | 558 | float const y = 0; |
913 | 473 | geom::Point const pos{x,y}; | 559 | geom::Point const pos{x, y}; |
914 | 474 | 560 | ||
915 | 475 | setup_button_event(fake_event_1, event_time_1, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); | 561 | setup_button_event(fake_event_1, event_time_1, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); |
916 | 476 | setup_button_event(fake_event_2, event_time_2, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED); | 562 | setup_button_event(fake_event_2, event_time_2, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED); |
917 | @@ -483,38 +569,34 @@ | |||
918 | 483 | EXPECT_CALL(mock_sink, handle_input(mt::ButtonUpEventWithButton(pos, mir_pointer_button_secondary))); | 569 | EXPECT_CALL(mock_sink, handle_input(mt::ButtonUpEventWithButton(pos, mir_pointer_button_secondary))); |
919 | 484 | EXPECT_CALL(mock_sink, handle_input(mt::ButtonUpEventWithButton(pos, mir_pointer_button_primary))); | 570 | EXPECT_CALL(mock_sink, handle_input(mt::ButtonUpEventWithButton(pos, mir_pointer_button_primary))); |
920 | 485 | 571 | ||
926 | 486 | dev.start(&mock_sink, &mock_builder); | 572 | mouse.start(&mock_sink, &mock_builder); |
927 | 487 | dev.process_event(fake_event_1); | 573 | mouse.process_event(fake_event_1); |
928 | 488 | dev.process_event(fake_event_2); | 574 | mouse.process_event(fake_event_2); |
929 | 489 | dev.process_event(fake_event_3); | 575 | mouse.process_event(fake_event_3); |
930 | 490 | dev.process_event(fake_event_4); | 576 | mouse.process_event(fake_event_4); |
931 | 491 | } | 577 | } |
932 | 492 | 578 | ||
934 | 493 | TEST_F(LibInputDevice, process_event_handles_scroll) | 579 | TEST_F(LibInputDeviceOnMouse, process_event_handles_scroll) |
935 | 494 | { | 580 | { |
936 | 495 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
937 | 496 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | ||
938 | 497 | |||
939 | 498 | setup_axis_event(fake_event_1, event_time_1, 0.0, 20.0); | 581 | setup_axis_event(fake_event_1, event_time_1, 0.0, 20.0); |
940 | 499 | setup_axis_event(fake_event_2, event_time_2, 5.0, 0.0); | 582 | setup_axis_event(fake_event_2, event_time_2, 5.0, 0.0); |
941 | 500 | 583 | ||
942 | 501 | InSequence seq; | 584 | InSequence seq; |
943 | 502 | // expect two scroll events.. | 585 | // expect two scroll events.. |
945 | 503 | EXPECT_CALL(mock_builder, pointer_event(time_stamp_1, mir_input_event_modifier_none, mir_pointer_action_motion, 0, 0.0f, 0.0f, 0.0f, 20.0f, 0.0f, 0.0f)); | 586 | EXPECT_CALL(mock_builder, pointer_event(time_stamp_1, mir_input_event_modifier_none, mir_pointer_action_motion, 0, |
946 | 587 | 0.0f, 0.0f, 0.0f, 20.0f, 0.0f, 0.0f)); | ||
947 | 504 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, 20.0f))); | 588 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, 20.0f))); |
949 | 505 | EXPECT_CALL(mock_builder, pointer_event(time_stamp_2, mir_input_event_modifier_none, mir_pointer_action_motion, 0, 0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f)); | 589 | EXPECT_CALL(mock_builder, pointer_event(time_stamp_2, mir_input_event_modifier_none, mir_pointer_action_motion, 0, |
950 | 590 | 0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f)); | ||
951 | 506 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_hscroll, 5.0f))); | 591 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_hscroll, 5.0f))); |
952 | 507 | 592 | ||
956 | 508 | dev.start(&mock_sink, &mock_builder); | 593 | mouse.start(&mock_sink, &mock_builder); |
957 | 509 | dev.process_event(fake_event_1); | 594 | mouse.process_event(fake_event_1); |
958 | 510 | dev.process_event(fake_event_2); | 595 | mouse.process_event(fake_event_2); |
959 | 511 | } | 596 | } |
960 | 512 | 597 | ||
962 | 513 | TEST_F(LibInputDevice, process_event_handles_touch_down_events) | 598 | TEST_F(LibInputDeviceOnTouchScreen, process_event_handles_touch_down_events) |
963 | 514 | { | 599 | { |
964 | 515 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
965 | 516 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | ||
966 | 517 | |||
967 | 518 | int slot = 0; | 600 | int slot = 0; |
968 | 519 | float major = 6; | 601 | float major = 6; |
969 | 520 | float minor = 5; | 602 | float minor = 5; |
970 | @@ -529,18 +611,15 @@ | |||
971 | 529 | EXPECT_CALL(mock_builder, touch_event(time_stamp_1, mir_input_event_modifier_none)); | 611 | EXPECT_CALL(mock_builder, touch_event(time_stamp_1, mir_input_event_modifier_none)); |
972 | 530 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{0}, mir_touch_action_down, mir_touch_tooltype_finger, x, y, | 612 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{0}, mir_touch_action_down, mir_touch_tooltype_finger, x, y, |
973 | 531 | pressure, major, minor, major)); | 613 | pressure, major, minor, major)); |
975 | 532 | EXPECT_CALL(mock_sink, handle_input(mt::TouchEvent(x,y))); | 614 | EXPECT_CALL(mock_sink, handle_input(mt::TouchEvent(x, y))); |
976 | 533 | 615 | ||
980 | 534 | dev.start(&mock_sink, &mock_builder); | 616 | touch_screen.start(&mock_sink, &mock_builder); |
981 | 535 | dev.process_event(fake_event_1); | 617 | touch_screen.process_event(fake_event_1); |
982 | 536 | dev.process_event(fake_event_2); | 618 | touch_screen.process_event(fake_event_2); |
983 | 537 | } | 619 | } |
984 | 538 | 620 | ||
986 | 539 | TEST_F(LibInputDevice, process_event_handles_touch_move_events) | 621 | TEST_F(LibInputDeviceOnTouchScreen, process_event_handles_touch_move_events) |
987 | 540 | { | 622 | { |
988 | 541 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
989 | 542 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | ||
990 | 543 | |||
991 | 544 | int slot = 0; | 623 | int slot = 0; |
992 | 545 | float major = 6; | 624 | float major = 6; |
993 | 546 | float minor = 5; | 625 | float minor = 5; |
994 | @@ -557,16 +636,13 @@ | |||
995 | 557 | pressure, major, minor, major)); | 636 | pressure, major, minor, major)); |
996 | 558 | EXPECT_CALL(mock_sink, handle_input(mt::TouchMovementEvent())); | 637 | EXPECT_CALL(mock_sink, handle_input(mt::TouchMovementEvent())); |
997 | 559 | 638 | ||
1001 | 560 | dev.start(&mock_sink, &mock_builder); | 639 | touch_screen.start(&mock_sink, &mock_builder); |
1002 | 561 | dev.process_event(fake_event_1); | 640 | touch_screen.process_event(fake_event_1); |
1003 | 562 | dev.process_event(fake_event_2); | 641 | touch_screen.process_event(fake_event_2); |
1004 | 563 | } | 642 | } |
1005 | 564 | 643 | ||
1007 | 565 | TEST_F(LibInputDevice, process_event_handles_touch_up_events_without_querying_properties) | 644 | TEST_F(LibInputDeviceOnTouchScreen, process_event_handles_touch_up_events_without_querying_properties) |
1008 | 566 | { | 645 | { |
1009 | 567 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
1010 | 568 | mie::LibInputDevice dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | ||
1011 | 569 | |||
1012 | 570 | int slot = 3; | 646 | int slot = 3; |
1013 | 571 | float major = 6; | 647 | float major = 6; |
1014 | 572 | float minor = 5; | 648 | float minor = 5; |
1015 | @@ -583,44 +659,30 @@ | |||
1016 | 583 | EXPECT_CALL(mock_builder, touch_event(time_stamp_1, mir_input_event_modifier_none)); | 659 | EXPECT_CALL(mock_builder, touch_event(time_stamp_1, mir_input_event_modifier_none)); |
1017 | 584 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{slot}, mir_touch_action_down, mir_touch_tooltype_finger, x, y, | 660 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{slot}, mir_touch_action_down, mir_touch_tooltype_finger, x, y, |
1018 | 585 | pressure, major, minor, major)); | 661 | pressure, major, minor, major)); |
1020 | 586 | EXPECT_CALL(mock_sink, handle_input(mt::TouchEvent(x,y))); | 662 | EXPECT_CALL(mock_sink, handle_input(mt::TouchEvent(x, y))); |
1021 | 587 | 663 | ||
1022 | 588 | EXPECT_CALL(mock_builder, touch_event(time_stamp_2, mir_input_event_modifier_none)); | 664 | EXPECT_CALL(mock_builder, touch_event(time_stamp_2, mir_input_event_modifier_none)); |
1023 | 589 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{slot}, mir_touch_action_up, mir_touch_tooltype_finger, x, y, | 665 | EXPECT_CALL(mock_builder, add_touch(_, MirTouchId{slot}, mir_touch_action_up, mir_touch_tooltype_finger, x, y, |
1024 | 590 | pressure, major, minor, major)); | 666 | pressure, major, minor, major)); |
1058 | 591 | EXPECT_CALL(mock_sink, handle_input(mt::TouchUpEvent(x,y))); | 667 | EXPECT_CALL(mock_sink, handle_input(mt::TouchUpEvent(x, y))); |
1059 | 592 | 668 | ||
1060 | 593 | dev.start(&mock_sink, &mock_builder); | 669 | touch_screen.start(&mock_sink, &mock_builder); |
1061 | 594 | dev.process_event(fake_event_1); | 670 | touch_screen.process_event(fake_event_1); |
1062 | 595 | dev.process_event(fake_event_2); | 671 | touch_screen.process_event(fake_event_2); |
1063 | 596 | dev.process_event(fake_event_3); | 672 | touch_screen.process_event(fake_event_3); |
1064 | 597 | dev.process_event(fake_event_4); | 673 | touch_screen.process_event(fake_event_4); |
1065 | 598 | } | 674 | } |
1066 | 599 | 675 | ||
1067 | 600 | TEST_F(LibInputDevice, provides_no_pointer_settings_for_non_pointing_devices) | 676 | TEST_F(LibInputDeviceOnLaptopKeyboard, provides_no_pointer_settings_for_non_pointing_devices) |
1068 | 601 | { | 677 | { |
1069 | 602 | char const keyboard_name[] = "usb-keyboard"; | 678 | auto settings = keyboard.get_pointer_settings(); |
1070 | 603 | char const keyboard_device_path[] = "/dev/input/event14"; | 679 | EXPECT_THAT(settings.is_set(), Eq(false)); |
1071 | 604 | setup_device(second_fake_device, keyboard_device_path, keyboard_name, 1231, 4124); | 680 | } |
1072 | 605 | 681 | ||
1073 | 606 | std::shared_ptr<libinput> lib = mie::make_libinput(); | 682 | TEST_F(LibInputDeviceOnMouse, reads_pointer_settings_from_libinput) |
1074 | 607 | mie::LibInputDevice dev(mir::report::null_input_report(), keyboard_device_path, mie::make_libinput_device(lib.get(), keyboard_device_path)); | 683 | { |
1075 | 608 | 684 | setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right); | |
1076 | 609 | auto ptr = dev.get_pointer_settings(); | 685 | auto optional_settings = mouse.get_pointer_settings(); |
1044 | 610 | EXPECT_THAT(ptr.is_set(), Eq(false)); | ||
1045 | 611 | } | ||
1046 | 612 | |||
1047 | 613 | TEST_F(LibInputDevice, reads_pointer_settings_from_libinput) | ||
1048 | 614 | { | ||
1049 | 615 | char const mouse_device_path[] = "/dev/input/event13"; | ||
1050 | 616 | char const mouse_name[] = "usb-mouse"; | ||
1051 | 617 | setup_device(second_fake_device, mouse_device_path, mouse_name, 1231, 4124); | ||
1052 | 618 | |||
1053 | 619 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
1054 | 620 | mie::LibInputDevice dev(mir::report::null_input_report(), mouse_device_path, mie::make_libinput_device(lib.get(), mouse_device_path)); | ||
1055 | 621 | |||
1056 | 622 | setup_pointer_configuration(dev.device(), 1, mir_pointer_handedness_right); | ||
1057 | 623 | auto optional_settings = dev.get_pointer_settings(); | ||
1077 | 624 | 686 | ||
1078 | 625 | EXPECT_THAT(optional_settings.is_set(), Eq(true)); | 687 | EXPECT_THAT(optional_settings.is_set(), Eq(true)); |
1079 | 626 | 688 | ||
1080 | @@ -630,8 +692,8 @@ | |||
1081 | 630 | EXPECT_THAT(ptr_settings.horizontal_scroll_scale, Eq(1.0)); | 692 | EXPECT_THAT(ptr_settings.horizontal_scroll_scale, Eq(1.0)); |
1082 | 631 | EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0)); | 693 | EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0)); |
1083 | 632 | 694 | ||
1086 | 633 | setup_pointer_configuration(dev.device(), 0.0, mir_pointer_handedness_left); | 695 | setup_pointer_configuration(mouse.device(), 0.0, mir_pointer_handedness_left); |
1087 | 634 | optional_settings = dev.get_pointer_settings(); | 696 | optional_settings = mouse.get_pointer_settings(); |
1088 | 635 | 697 | ||
1089 | 636 | EXPECT_THAT(optional_settings.is_set(), Eq(true)); | 698 | EXPECT_THAT(optional_settings.is_set(), Eq(true)); |
1090 | 637 | 699 | ||
1091 | @@ -642,53 +704,31 @@ | |||
1092 | 642 | EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0)); | 704 | EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0)); |
1093 | 643 | } | 705 | } |
1094 | 644 | 706 | ||
1096 | 645 | TEST_F(LibInputDevice, applies_pointer_settings) | 707 | TEST_F(LibInputDeviceOnMouse, applies_pointer_settings) |
1097 | 646 | { | 708 | { |
1107 | 647 | char const mouse_device_path[] = "/dev/input/event13"; | 709 | setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right); |
1108 | 648 | char const mouse_name[] = "usb-mouse"; | 710 | mi::PointerSettings settings(mouse.get_pointer_settings().value()); |
1100 | 649 | setup_device(second_fake_device, mouse_device_path, mouse_name, 1231, 4124); | ||
1101 | 650 | |||
1102 | 651 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
1103 | 652 | mie::LibInputDevice dev(mir::report::null_input_report(), mouse_device_path, mie::make_libinput_device(lib.get(), path)); | ||
1104 | 653 | |||
1105 | 654 | setup_pointer_configuration(dev.device(), 1, mir_pointer_handedness_right); | ||
1106 | 655 | mi::PointerSettings settings(dev.get_pointer_settings().value()); | ||
1109 | 656 | settings.cursor_acceleration_bias = 1.1; | 711 | settings.cursor_acceleration_bias = 1.1; |
1110 | 657 | settings.handedness = mir_pointer_handedness_left; | 712 | settings.handedness = mir_pointer_handedness_left; |
1111 | 658 | 713 | ||
1114 | 659 | EXPECT_CALL(mock_libinput,libinput_device_config_accel_set_speed(dev.device(), 1.1)).Times(1); | 714 | EXPECT_CALL(mock_libinput,libinput_device_config_accel_set_speed(mouse.device(), 1.1)).Times(1); |
1115 | 660 | EXPECT_CALL(mock_libinput,libinput_device_config_left_handed_set(dev.device(), true)).Times(1); | 715 | EXPECT_CALL(mock_libinput,libinput_device_config_left_handed_set(mouse.device(), true)).Times(1); |
1116 | 661 | 716 | ||
1118 | 662 | dev.apply_settings(settings); | 717 | mouse.apply_settings(settings); |
1119 | 663 | } | 718 | } |
1120 | 664 | 719 | ||
1122 | 665 | TEST_F(LibInputDevice, denies_pointer_settings_on_keyboards) | 720 | TEST_F(LibInputDeviceOnLaptopKeyboardAndMouse, denies_pointer_settings_on_keyboards) |
1123 | 666 | { | 721 | { |
1133 | 667 | char const mouse_device_path[] = "/dev/input/event13"; | 722 | auto settings_from_mouse = mouse.get_pointer_settings(); |
1125 | 668 | char const mouse_name[] = "usb-mouse"; | ||
1126 | 669 | setup_device(second_fake_device, mouse_device_path, mouse_name, 1231, 4124); | ||
1127 | 670 | |||
1128 | 671 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
1129 | 672 | mie::LibInputDevice keyboard_dev(mir::report::null_input_report(), path, mie::make_libinput_device(lib.get(), path)); | ||
1130 | 673 | mie::LibInputDevice mouse_dev(mir::report::null_input_report(), mouse_device_path, mie::make_libinput_device(lib.get(), path)); | ||
1131 | 674 | |||
1132 | 675 | auto settings_from_mouse = mouse_dev.get_pointer_settings(); | ||
1134 | 676 | 723 | ||
1135 | 677 | EXPECT_CALL(mock_libinput,libinput_device_config_accel_set_speed(_, _)).Times(0); | 724 | EXPECT_CALL(mock_libinput,libinput_device_config_accel_set_speed(_, _)).Times(0); |
1136 | 678 | EXPECT_CALL(mock_libinput,libinput_device_config_left_handed_set(_, _)).Times(0); | 725 | EXPECT_CALL(mock_libinput,libinput_device_config_left_handed_set(_, _)).Times(0); |
1137 | 679 | 726 | ||
1139 | 680 | keyboard_dev.apply_settings(settings_from_mouse.value()); | 727 | keyboard.apply_settings(settings_from_mouse.value()); |
1140 | 681 | } | 728 | } |
1141 | 682 | 729 | ||
1143 | 683 | TEST_F(LibInputDevice, scroll_speed_scales_scroll_events) | 730 | TEST_F(LibInputDeviceOnMouse, scroll_speed_scales_scroll_events) |
1144 | 684 | { | 731 | { |
1145 | 685 | char const mouse_device_path[] = "/dev/input/event13"; | ||
1146 | 686 | char const mouse_name[] = "usb-mouse"; | ||
1147 | 687 | setup_device(second_fake_device, mouse_device_path, mouse_name, 1231, 4124); | ||
1148 | 688 | |||
1149 | 689 | std::shared_ptr<libinput> lib = mie::make_libinput(); | ||
1150 | 690 | mie::LibInputDevice dev(mir::report::null_input_report(), mouse_device_path, mie::make_libinput_device(lib.get(), mouse_device_path)); | ||
1151 | 691 | |||
1152 | 692 | setup_axis_event(fake_event_1, event_time_1, 0.0, 3.0); | 732 | setup_axis_event(fake_event_1, event_time_1, 0.0, 3.0); |
1153 | 693 | setup_axis_event(fake_event_2, event_time_2, -2.0, 0.0); | 733 | setup_axis_event(fake_event_2, event_time_2, -2.0, 0.0); |
1154 | 694 | 734 | ||
1155 | @@ -696,13 +736,65 @@ | |||
1156 | 696 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, -3.0f))); | 736 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, -3.0f))); |
1157 | 697 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_hscroll, -10.0f))); | 737 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_hscroll, -10.0f))); |
1158 | 698 | 738 | ||
1161 | 699 | setup_pointer_configuration(dev.device(), 1, mir_pointer_handedness_right); | 739 | setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right); |
1162 | 700 | mi::PointerSettings settings(dev.get_pointer_settings().value()); | 740 | mi::PointerSettings settings(mouse.get_pointer_settings().value()); |
1163 | 701 | settings.vertical_scroll_scale = -1.0; | 741 | settings.vertical_scroll_scale = -1.0; |
1164 | 702 | settings.horizontal_scroll_scale = 5.0; | 742 | settings.horizontal_scroll_scale = 5.0; |
1170 | 703 | dev.apply_settings(settings); | 743 | mouse.apply_settings(settings); |
1171 | 704 | 744 | ||
1172 | 705 | dev.start(&mock_sink, &mock_builder); | 745 | mouse.start(&mock_sink, &mock_builder); |
1173 | 706 | dev.process_event(fake_event_1); | 746 | mouse.process_event(fake_event_1); |
1174 | 707 | dev.process_event(fake_event_2); | 747 | mouse.process_event(fake_event_2); |
1175 | 748 | } | ||
1176 | 749 | |||
1177 | 750 | TEST_F(LibInputDeviceOnLaptopKeyboardAndMouse, provides_no_touchpad_settings_for_non_touchpad_devices) | ||
1178 | 751 | { | ||
1179 | 752 | auto val = keyboard.get_touchpad_settings(); | ||
1180 | 753 | EXPECT_THAT(val.is_set(), Eq(false)); | ||
1181 | 754 | val = mouse.get_touchpad_settings(); | ||
1182 | 755 | EXPECT_THAT(val.is_set(), Eq(false)); | ||
1183 | 756 | } | ||
1184 | 757 | |||
1185 | 758 | TEST_F(LibInputDeviceOnTouchpad, reads_touchpad_settings_from_libinput) | ||
1186 | 759 | { | ||
1187 | 760 | setup_touchpad_configuration(fake_device, mir_touchpad_click_mode_finger_count, | ||
1188 | 761 | mir_touchpad_scroll_mode_edge_scroll, 0, true, false, true, false); | ||
1189 | 762 | |||
1190 | 763 | auto settings = touchpad.get_touchpad_settings().value(); | ||
1191 | 764 | EXPECT_THAT(settings.click_mode, Eq(mir_touchpad_click_mode_finger_count)); | ||
1192 | 765 | EXPECT_THAT(settings.scroll_mode, Eq(mir_touchpad_scroll_mode_edge_scroll)); | ||
1193 | 766 | EXPECT_THAT(settings.tap_to_click, Eq(true)); | ||
1194 | 767 | EXPECT_THAT(settings.disable_while_typing, Eq(false)); | ||
1195 | 768 | EXPECT_THAT(settings.disable_with_mouse, Eq(true)); | ||
1196 | 769 | EXPECT_THAT(settings.middle_mouse_button_emulation, Eq(false)); | ||
1197 | 770 | } | ||
1198 | 771 | |||
1199 | 772 | TEST_F(LibInputDeviceOnTouchpad, applies_touchpad_settings) | ||
1200 | 773 | { | ||
1201 | 774 | setup_touchpad_configuration(fake_device, mir_touchpad_click_mode_finger_count, | ||
1202 | 775 | mir_touchpad_scroll_mode_two_finger_scroll, 0, true, false, true, false); | ||
1203 | 776 | |||
1204 | 777 | mi::TouchpadSettings settings(touchpad.get_touchpad_settings().value()); | ||
1205 | 778 | settings.scroll_mode = mir_touchpad_scroll_mode_button_down_scroll; | ||
1206 | 779 | settings.click_mode = mir_touchpad_click_mode_finger_count; | ||
1207 | 780 | settings.button_down_scroll_button = KEY_A; | ||
1208 | 781 | settings.tap_to_click = true; | ||
1209 | 782 | settings.disable_while_typing = false; | ||
1210 | 783 | settings.disable_with_mouse = true; | ||
1211 | 784 | settings.middle_mouse_button_emulation = true; | ||
1212 | 785 | |||
1213 | 786 | EXPECT_CALL(mock_libinput, | ||
1214 | 787 | libinput_device_config_scroll_set_method(touchpad.device(), LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)); | ||
1215 | 788 | EXPECT_CALL(mock_libinput, | ||
1216 | 789 | libinput_device_config_click_set_method(touchpad.device(), LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER)); | ||
1217 | 790 | EXPECT_CALL(mock_libinput, libinput_device_config_scroll_set_button(touchpad.device(), KEY_A)); | ||
1218 | 791 | EXPECT_CALL(mock_libinput, libinput_device_config_tap_set_enabled(touchpad.device(), LIBINPUT_CONFIG_TAP_ENABLED)); | ||
1219 | 792 | EXPECT_CALL(mock_libinput, | ||
1220 | 793 | libinput_device_config_dwt_set_enabled(touchpad.device(), LIBINPUT_CONFIG_DWT_DISABLED)); | ||
1221 | 794 | EXPECT_CALL(mock_libinput, libinput_device_config_send_events_set_mode( | ||
1222 | 795 | touchpad.device(), LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE)); | ||
1223 | 796 | EXPECT_CALL(mock_libinput, libinput_device_config_middle_emulation_set_enabled( | ||
1224 | 797 | touchpad.device(), LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED)); | ||
1225 | 798 | |||
1226 | 799 | touchpad.apply_settings(settings); | ||
1227 | 708 | } | 800 | } |
1228 | 709 | 801 | ||
1229 | === modified file 'tests/unit-tests/input/test_default_input_device_hub.cpp' | |||
1230 | --- tests/unit-tests/input/test_default_input_device_hub.cpp 2015-10-20 03:30:00 +0000 | |||
1231 | +++ tests/unit-tests/input/test_default_input_device_hub.cpp 2015-10-23 10:50:47 +0000 | |||
1232 | @@ -26,6 +26,7 @@ | |||
1233 | 26 | 26 | ||
1234 | 27 | #include "mir/input/input_device.h" | 27 | #include "mir/input/input_device.h" |
1235 | 28 | #include "mir/input/pointer_settings.h" | 28 | #include "mir/input/pointer_settings.h" |
1236 | 29 | #include "mir/input/touchpad_settings.h" | ||
1237 | 29 | #include "mir/input/device.h" | 30 | #include "mir/input/device.h" |
1238 | 30 | #include "mir/input/touch_visualizer.h" | 31 | #include "mir/input/touch_visualizer.h" |
1239 | 31 | #include "mir/input/input_device_observer.h" | 32 | #include "mir/input/input_device_observer.h" |
1240 | @@ -88,6 +89,8 @@ | |||
1241 | 88 | MOCK_METHOD0(get_device_info, mi::InputDeviceInfo()); | 89 | MOCK_METHOD0(get_device_info, mi::InputDeviceInfo()); |
1242 | 89 | MOCK_CONST_METHOD0(get_pointer_settings, mir::optional_value<mi::PointerSettings>()); | 90 | MOCK_CONST_METHOD0(get_pointer_settings, mir::optional_value<mi::PointerSettings>()); |
1243 | 90 | MOCK_METHOD1(apply_settings, void(mi::PointerSettings const&)); | 91 | MOCK_METHOD1(apply_settings, void(mi::PointerSettings const&)); |
1244 | 92 | MOCK_CONST_METHOD0(get_touchpad_settings, mir::optional_value<mi::TouchpadSettings>()); | ||
1245 | 93 | MOCK_METHOD1(apply_settings, void(mi::TouchpadSettings const&)); | ||
1246 | 91 | }; | 94 | }; |
1247 | 92 | 95 | ||
1248 | 93 | template<typename Type> | 96 | template<typename Type> |
FAILED: Continuous integration, rev:2976 jenkins. qa.ubuntu. com/job/ mir-ci/ 5064/ jenkins. qa.ubuntu. com/job/ mir-android- vivid-i386- build/4183/ console jenkins. qa.ubuntu. com/job/ mir-clang- vivid-amd64- build/3090 jenkins. qa.ubuntu. com/job/ mir-mediumtests -vivid- touch/4125/ console jenkins. qa.ubuntu. com/job/ mir-mediumtests -wily-touch/ 83/console jenkins. qa.ubuntu. com/job/ mir-wily- amd64-ci/ 1215 jenkins. qa.ubuntu. com/job/ mir-wily- amd64-ci/ 1215/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-wily- i386-ci/ 83/console jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 4126/console jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- wily-armhf/ 84/console
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/mir- ci/5064/ rebuild
http://