2 * Copyright © 2014 Red Hat, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31 #include "libinput-util.h"
34 START_TEST(touchpad_1fg_motion)
36 struct litest_device *dev = litest_current_device();
37 struct libinput *li = dev->libinput;
38 struct libinput_event *event;
39 struct libinput_event_pointer *ptrev;
41 litest_drain_events(li);
43 litest_touch_down(dev, 0, 50, 50);
44 litest_touch_move_to(dev, 0, 50, 50, 80, 50, 5);
45 litest_touch_up(dev, 0);
47 libinput_dispatch(li);
49 event = libinput_get_event(li);
50 ck_assert(event != NULL);
53 ck_assert_int_eq(libinput_event_get_type(event),
54 LIBINPUT_EVENT_POINTER_MOTION);
56 ptrev = libinput_event_get_pointer_event(event);
57 ck_assert_int_ge(libinput_event_pointer_get_dx(ptrev), 0);
58 ck_assert_int_eq(libinput_event_pointer_get_dy(ptrev), 0);
59 libinput_event_destroy(event);
60 event = libinput_get_event(li);
65 START_TEST(touchpad_2fg_no_motion)
67 struct litest_device *dev = litest_current_device();
68 struct libinput *li = dev->libinput;
69 struct libinput_event *event;
71 litest_drain_events(li);
73 litest_touch_down(dev, 0, 20, 20);
74 litest_touch_down(dev, 1, 70, 20);
75 litest_touch_move_to(dev, 0, 20, 20, 80, 80, 5);
76 litest_touch_move_to(dev, 1, 70, 20, 80, 50, 5);
77 litest_touch_up(dev, 1);
78 litest_touch_up(dev, 0);
80 libinput_dispatch(li);
82 event = libinput_get_event(li);
84 ck_assert_int_ne(libinput_event_get_type(event),
85 LIBINPUT_EVENT_POINTER_MOTION);
86 libinput_event_destroy(event);
87 event = libinput_get_event(li);
93 assert_button_event(struct libinput *li, unsigned int button,
94 enum libinput_button_state state)
96 struct libinput_event *event;
97 struct libinput_event_pointer *ptrev;
99 libinput_dispatch(li);
100 event = libinput_get_event(li);
102 ck_assert(event != NULL);
103 ck_assert_int_eq(libinput_event_get_type(event),
104 LIBINPUT_EVENT_POINTER_BUTTON);
105 ptrev = libinput_event_get_pointer_event(event);
106 ck_assert_int_eq(libinput_event_pointer_get_button(ptrev),
108 ck_assert_int_eq(libinput_event_pointer_get_button_state(ptrev),
110 libinput_event_destroy(event);
113 START_TEST(touchpad_1fg_tap)
115 struct litest_device *dev = litest_current_device();
116 struct libinput *li = dev->libinput;
117 struct libinput_event *event;
119 libinput_device_config_tap_set_enabled(dev->libinput_device,
120 LIBINPUT_CONFIG_TAP_ENABLED);
122 litest_drain_events(li);
124 litest_touch_down(dev, 0, 50, 50);
125 litest_touch_up(dev, 0);
127 libinput_dispatch(li);
129 assert_button_event(li, BTN_LEFT,
130 LIBINPUT_BUTTON_STATE_PRESSED);
131 msleep(300); /* tap-n-drag timeout */
132 assert_button_event(li, BTN_LEFT,
133 LIBINPUT_BUTTON_STATE_RELEASED);
135 libinput_dispatch(li);
136 event = libinput_get_event(li);
137 ck_assert(event == NULL);
141 START_TEST(touchpad_1fg_tap_n_drag)
143 struct litest_device *dev = litest_current_device();
144 struct libinput *li = dev->libinput;
145 struct libinput_event *event;
147 libinput_device_config_tap_set_enabled(dev->libinput_device,
148 LIBINPUT_CONFIG_TAP_ENABLED);
150 litest_drain_events(li);
152 litest_touch_down(dev, 0, 50, 50);
153 litest_touch_up(dev, 0);
154 litest_touch_down(dev, 0, 50, 50);
155 litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5);
156 litest_touch_up(dev, 0);
158 libinput_dispatch(li);
160 assert_button_event(li, BTN_LEFT,
161 LIBINPUT_BUTTON_STATE_PRESSED);
163 libinput_dispatch(li);
164 while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION) {
165 event = libinput_get_event(li);
166 libinput_event_destroy(event);
167 libinput_dispatch(li);
170 ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
172 /* lift finger, set down again, should continue dragging */
173 litest_touch_down(dev, 0, 50, 50);
174 litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5);
175 litest_touch_up(dev, 0);
177 libinput_dispatch(li);
178 while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION) {
179 event = libinput_get_event(li);
180 libinput_event_destroy(event);
181 libinput_dispatch(li);
184 ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
186 msleep(300); /* tap-n-drag timeout */
188 assert_button_event(li, BTN_LEFT,
189 LIBINPUT_BUTTON_STATE_RELEASED);
191 litest_assert_empty_queue(li);
195 START_TEST(touchpad_2fg_tap)
197 struct litest_device *dev = litest_current_device();
198 struct libinput *li = dev->libinput;
200 libinput_device_config_tap_set_enabled(dev->libinput_device,
201 LIBINPUT_CONFIG_TAP_ENABLED);
203 litest_drain_events(dev->libinput);
205 litest_touch_down(dev, 0, 50, 50);
206 litest_touch_down(dev, 1, 70, 70);
207 litest_touch_up(dev, 0);
208 litest_touch_up(dev, 1);
210 libinput_dispatch(li);
212 assert_button_event(li, BTN_RIGHT,
213 LIBINPUT_BUTTON_STATE_PRESSED);
214 msleep(300); /* tap-n-drag timeout */
215 assert_button_event(li, BTN_RIGHT,
216 LIBINPUT_BUTTON_STATE_RELEASED);
218 litest_assert_empty_queue(li);
222 START_TEST(touchpad_2fg_tap_inverted)
224 struct litest_device *dev = litest_current_device();
225 struct libinput *li = dev->libinput;
227 libinput_device_config_tap_set_enabled(dev->libinput_device,
228 LIBINPUT_CONFIG_TAP_ENABLED);
230 litest_drain_events(dev->libinput);
232 litest_touch_down(dev, 0, 50, 50);
233 litest_touch_down(dev, 1, 70, 70);
234 litest_touch_up(dev, 1);
235 litest_touch_up(dev, 0);
237 libinput_dispatch(li);
239 assert_button_event(li, BTN_RIGHT,
240 LIBINPUT_BUTTON_STATE_PRESSED);
241 msleep(300); /* tap-n-drag timeout */
242 assert_button_event(li, BTN_RIGHT,
243 LIBINPUT_BUTTON_STATE_RELEASED);
245 litest_assert_empty_queue(li);
249 START_TEST(touchpad_1fg_tap_click)
251 struct litest_device *dev = litest_current_device();
252 struct libinput *li = dev->libinput;
254 libinput_device_config_tap_set_enabled(dev->libinput_device,
255 LIBINPUT_CONFIG_TAP_ENABLED);
257 litest_drain_events(dev->libinput);
259 /* finger down, button click, finger up
260 -> only one button left event pair */
261 litest_touch_down(dev, 0, 50, 50);
262 litest_event(dev, EV_KEY, BTN_LEFT, 1);
263 litest_event(dev, EV_SYN, SYN_REPORT, 0);
264 litest_event(dev, EV_KEY, BTN_LEFT, 0);
265 litest_event(dev, EV_SYN, SYN_REPORT, 0);
266 litest_touch_up(dev, 0);
268 libinput_dispatch(li);
270 assert_button_event(li, BTN_LEFT,
271 LIBINPUT_BUTTON_STATE_PRESSED);
272 assert_button_event(li, BTN_LEFT,
273 LIBINPUT_BUTTON_STATE_RELEASED);
275 litest_assert_empty_queue(li);
279 START_TEST(touchpad_2fg_tap_click)
281 struct litest_device *dev = litest_current_device();
282 struct libinput *li = dev->libinput;
284 libinput_device_config_tap_set_enabled(dev->libinput_device,
285 LIBINPUT_CONFIG_TAP_ENABLED);
287 litest_drain_events(dev->libinput);
289 /* two fingers down, button click, fingers up
290 -> only one button left event pair */
291 litest_touch_down(dev, 0, 50, 50);
292 litest_touch_down(dev, 1, 70, 50);
293 litest_event(dev, EV_KEY, BTN_LEFT, 1);
294 litest_event(dev, EV_SYN, SYN_REPORT, 0);
295 litest_event(dev, EV_KEY, BTN_LEFT, 0);
296 litest_event(dev, EV_SYN, SYN_REPORT, 0);
297 litest_touch_up(dev, 1);
298 litest_touch_up(dev, 0);
300 libinput_dispatch(li);
302 assert_button_event(li, BTN_LEFT,
303 LIBINPUT_BUTTON_STATE_PRESSED);
304 assert_button_event(li, BTN_LEFT,
305 LIBINPUT_BUTTON_STATE_RELEASED);
307 litest_assert_empty_queue(li);
311 START_TEST(touchpad_2fg_tap_click_apple)
313 struct litest_device *dev = litest_current_device();
314 struct libinput *li = dev->libinput;
316 libinput_device_config_tap_set_enabled(dev->libinput_device,
317 LIBINPUT_CONFIG_TAP_ENABLED);
319 litest_drain_events(dev->libinput);
321 /* two fingers down, button click, fingers up
322 -> only one button right event pair
323 (apple have clickfinger enabled by default) */
324 litest_touch_down(dev, 0, 50, 50);
325 litest_touch_down(dev, 1, 70, 50);
326 litest_event(dev, EV_KEY, BTN_LEFT, 1);
327 litest_event(dev, EV_SYN, SYN_REPORT, 0);
328 litest_event(dev, EV_KEY, BTN_LEFT, 0);
329 litest_event(dev, EV_SYN, SYN_REPORT, 0);
330 litest_touch_up(dev, 1);
331 litest_touch_up(dev, 0);
333 libinput_dispatch(li);
335 assert_button_event(li, BTN_RIGHT,
336 LIBINPUT_BUTTON_STATE_PRESSED);
337 assert_button_event(li, BTN_RIGHT,
338 LIBINPUT_BUTTON_STATE_RELEASED);
340 litest_assert_empty_queue(li);
344 START_TEST(touchpad_no_2fg_tap_after_move)
346 struct litest_device *dev = litest_current_device();
347 struct libinput *li = dev->libinput;
349 litest_drain_events(dev->libinput);
351 /* one finger down, move past threshold,
352 second finger down, first finger up
355 litest_touch_down(dev, 0, 50, 50);
356 litest_touch_move_to(dev, 0, 50, 50, 90, 90, 10);
357 litest_drain_events(dev->libinput);
359 litest_touch_down(dev, 1, 70, 50);
360 litest_touch_up(dev, 0);
362 litest_assert_empty_queue(li);
366 START_TEST(touchpad_no_2fg_tap_after_timeout)
368 struct litest_device *dev = litest_current_device();
369 struct libinput *li = dev->libinput;
371 litest_drain_events(dev->libinput);
373 /* one finger down, wait past tap timeout,
374 second finger down, first finger up
377 litest_touch_down(dev, 0, 50, 50);
378 libinput_dispatch(dev->libinput);
380 libinput_dispatch(dev->libinput);
381 litest_drain_events(dev->libinput);
383 litest_touch_down(dev, 1, 70, 50);
384 litest_touch_up(dev, 0);
386 litest_assert_empty_queue(li);
390 START_TEST(touchpad_no_first_fg_tap_after_move)
392 struct litest_device *dev = litest_current_device();
393 struct libinput *li = dev->libinput;
394 struct libinput_event *event;
396 litest_drain_events(dev->libinput);
398 /* one finger down, second finger down,
399 second finger moves beyond threshold,
403 litest_touch_down(dev, 0, 50, 50);
404 litest_touch_down(dev, 1, 70, 50);
405 libinput_dispatch(dev->libinput);
406 litest_touch_move_to(dev, 1, 70, 50, 90, 90, 10);
407 libinput_dispatch(dev->libinput);
408 litest_touch_up(dev, 0);
409 litest_touch_up(dev, 1);
410 libinput_dispatch(dev->libinput);
412 while ((event = libinput_get_event(li))) {
413 ck_assert_int_ne(libinput_event_get_type(event),
414 LIBINPUT_EVENT_POINTER_BUTTON);
415 libinput_event_destroy(event);
420 START_TEST(touchpad_1fg_double_tap_click)
422 struct litest_device *dev = litest_current_device();
423 struct libinput *li = dev->libinput;
425 libinput_device_config_tap_set_enabled(dev->libinput_device,
426 LIBINPUT_CONFIG_TAP_ENABLED);
428 litest_drain_events(dev->libinput);
430 /* one finger down, up, down, button click, finger up
431 -> two button left event pairs */
432 litest_touch_down(dev, 0, 50, 50);
433 litest_touch_up(dev, 0);
434 litest_touch_down(dev, 0, 50, 50);
435 litest_event(dev, EV_KEY, BTN_LEFT, 1);
436 litest_event(dev, EV_SYN, SYN_REPORT, 0);
437 litest_event(dev, EV_KEY, BTN_LEFT, 0);
438 litest_event(dev, EV_SYN, SYN_REPORT, 0);
439 litest_touch_up(dev, 0);
441 libinput_dispatch(li);
443 assert_button_event(li, BTN_LEFT,
444 LIBINPUT_BUTTON_STATE_PRESSED);
445 assert_button_event(li, BTN_LEFT,
446 LIBINPUT_BUTTON_STATE_RELEASED);
447 assert_button_event(li, BTN_LEFT,
448 LIBINPUT_BUTTON_STATE_PRESSED);
449 assert_button_event(li, BTN_LEFT,
450 LIBINPUT_BUTTON_STATE_RELEASED);
452 litest_assert_empty_queue(li);
456 START_TEST(touchpad_1fg_tap_n_drag_click)
458 struct litest_device *dev = litest_current_device();
459 struct libinput *li = dev->libinput;
460 struct libinput_event *event;
462 libinput_device_config_tap_set_enabled(dev->libinput_device,
463 LIBINPUT_CONFIG_TAP_ENABLED);
465 litest_drain_events(dev->libinput);
467 /* one finger down, up, down, move, button click, finger up
468 -> two button left event pairs, motion allowed */
469 litest_touch_down(dev, 0, 50, 50);
470 litest_touch_up(dev, 0);
471 litest_touch_down(dev, 0, 50, 50);
472 litest_touch_move_to(dev, 0, 50, 50, 80, 50, 10);
474 assert_button_event(li, BTN_LEFT,
475 LIBINPUT_BUTTON_STATE_PRESSED);
477 libinput_dispatch(li);
479 ck_assert_int_eq(libinput_next_event_type(li),
480 LIBINPUT_EVENT_POINTER_MOTION);
481 while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION) {
482 event = libinput_get_event(li);
483 libinput_event_destroy(event);
484 libinput_dispatch(li);
487 litest_event(dev, EV_KEY, BTN_LEFT, 1);
488 litest_event(dev, EV_SYN, SYN_REPORT, 0);
490 assert_button_event(li, BTN_LEFT,
491 LIBINPUT_BUTTON_STATE_RELEASED);
492 assert_button_event(li, BTN_LEFT,
493 LIBINPUT_BUTTON_STATE_PRESSED);
495 litest_event(dev, EV_KEY, BTN_LEFT, 0);
496 litest_event(dev, EV_SYN, SYN_REPORT, 0);
497 litest_touch_up(dev, 0);
499 libinput_dispatch(li);
501 assert_button_event(li, BTN_LEFT,
502 LIBINPUT_BUTTON_STATE_RELEASED);
504 litest_assert_empty_queue(li);
508 START_TEST(touchpad_3fg_tap)
510 struct litest_device *dev = litest_current_device();
511 struct libinput *li = dev->libinput;
512 struct libinput_event *event;
515 libinput_device_config_tap_set_enabled(dev->libinput_device,
516 LIBINPUT_CONFIG_TAP_ENABLED);
518 for (i = 0; i < 3; i++) {
519 litest_drain_events(li);
521 litest_touch_down(dev, 0, 50, 50);
522 litest_touch_down(dev, 1, 70, 50);
523 litest_touch_down(dev, 2, 80, 50);
525 litest_touch_up(dev, (i + 2) % 3);
526 litest_touch_up(dev, (i + 1) % 3);
527 litest_touch_up(dev, (i + 0) % 3);
529 libinput_dispatch(li);
531 assert_button_event(li, BTN_MIDDLE,
532 LIBINPUT_BUTTON_STATE_PRESSED);
533 msleep(300); /* tap-n-drag timeout */
534 assert_button_event(li, BTN_MIDDLE,
535 LIBINPUT_BUTTON_STATE_RELEASED);
537 libinput_dispatch(li);
538 event = libinput_get_event(li);
539 ck_assert(event == NULL);
544 START_TEST(touchpad_3fg_tap_btntool)
546 struct litest_device *dev = litest_current_device();
547 struct libinput *li = dev->libinput;
548 struct libinput_event *event;
550 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
552 litest_drain_events(li);
554 litest_touch_down(dev, 0, 50, 50);
555 litest_touch_down(dev, 1, 70, 50);
556 litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1);
557 litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
558 litest_event(dev, EV_SYN, SYN_REPORT, 0);
559 litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 0);
560 litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 1);
561 litest_event(dev, EV_SYN, SYN_REPORT, 0);
562 litest_touch_up(dev, 1);
563 litest_touch_up(dev, 0);
565 libinput_dispatch(li);
567 assert_button_event(li, BTN_MIDDLE,
568 LIBINPUT_BUTTON_STATE_PRESSED);
569 msleep(300); /* tap-n-drag timeout */
570 assert_button_event(li, BTN_MIDDLE,
571 LIBINPUT_BUTTON_STATE_RELEASED);
573 libinput_dispatch(li);
574 event = libinput_get_event(li);
575 ck_assert(event == NULL);
579 START_TEST(touchpad_3fg_tap_btntool_inverted)
581 struct litest_device *dev = litest_current_device();
582 struct libinput *li = dev->libinput;
583 struct libinput_event *event;
585 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
587 litest_drain_events(li);
589 litest_touch_down(dev, 0, 50, 50);
590 litest_touch_down(dev, 1, 70, 50);
591 litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1);
592 litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
593 litest_event(dev, EV_SYN, SYN_REPORT, 0);
594 litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 0);
595 litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 1);
596 litest_event(dev, EV_SYN, SYN_REPORT, 0);
597 litest_touch_up(dev, 0);
598 litest_touch_up(dev, 1);
600 libinput_dispatch(li);
602 assert_button_event(li, BTN_MIDDLE,
603 LIBINPUT_BUTTON_STATE_PRESSED);
604 msleep(300); /* tap-n-drag timeout */
605 assert_button_event(li, BTN_MIDDLE,
606 LIBINPUT_BUTTON_STATE_RELEASED);
608 libinput_dispatch(li);
609 event = libinput_get_event(li);
610 ck_assert(event == NULL);
614 START_TEST(touchpad_1fg_clickfinger)
616 struct litest_device *dev = litest_create_device(LITEST_BCM5974);
617 struct libinput *li = dev->libinput;
619 litest_drain_events(li);
621 litest_touch_down(dev, 0, 50, 50);
622 litest_event(dev, EV_KEY, BTN_LEFT, 1);
623 litest_event(dev, EV_SYN, SYN_REPORT, 0);
624 litest_event(dev, EV_KEY, BTN_LEFT, 0);
625 litest_event(dev, EV_SYN, SYN_REPORT, 0);
626 litest_touch_up(dev, 0);
628 libinput_dispatch(li);
630 assert_button_event(li, BTN_LEFT,
631 LIBINPUT_BUTTON_STATE_PRESSED);
632 assert_button_event(li, BTN_LEFT,
633 LIBINPUT_BUTTON_STATE_RELEASED);
635 litest_delete_device(dev);
639 START_TEST(touchpad_2fg_clickfinger)
641 struct litest_device *dev = litest_create_device(LITEST_BCM5974);
642 struct libinput *li = dev->libinput;
644 litest_drain_events(li);
646 litest_touch_down(dev, 0, 50, 50);
647 litest_touch_down(dev, 1, 70, 70);
648 litest_event(dev, EV_KEY, BTN_LEFT, 1);
649 litest_event(dev, EV_SYN, SYN_REPORT, 0);
650 litest_event(dev, EV_KEY, BTN_LEFT, 0);
651 litest_event(dev, EV_SYN, SYN_REPORT, 0);
652 litest_touch_up(dev, 0);
653 litest_touch_up(dev, 1);
655 libinput_dispatch(li);
657 assert_button_event(li, BTN_RIGHT,
658 LIBINPUT_BUTTON_STATE_PRESSED);
659 assert_button_event(li, BTN_RIGHT,
660 LIBINPUT_BUTTON_STATE_RELEASED);
662 litest_delete_device(dev);
666 START_TEST(touchpad_btn_left)
668 struct litest_device *dev = litest_current_device();
669 struct libinput *li = dev->libinput;
671 litest_drain_events(li);
673 litest_event(dev, EV_KEY, BTN_LEFT, 1);
674 litest_event(dev, EV_SYN, SYN_REPORT, 0);
675 litest_event(dev, EV_KEY, BTN_LEFT, 0);
676 litest_event(dev, EV_SYN, SYN_REPORT, 0);
678 libinput_dispatch(li);
680 assert_button_event(li, BTN_LEFT,
681 LIBINPUT_BUTTON_STATE_PRESSED);
682 assert_button_event(li, BTN_LEFT,
683 LIBINPUT_BUTTON_STATE_RELEASED);
687 START_TEST(clickpad_btn_left)
689 struct litest_device *dev = litest_current_device();
690 struct libinput *li = dev->libinput;
692 litest_drain_events(li);
694 /* A clickpad always needs a finger down to tell where the
696 litest_event(dev, EV_KEY, BTN_LEFT, 1);
697 litest_event(dev, EV_SYN, SYN_REPORT, 0);
698 litest_event(dev, EV_KEY, BTN_LEFT, 0);
699 litest_event(dev, EV_SYN, SYN_REPORT, 0);
701 libinput_dispatch(li);
702 ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
706 START_TEST(clickpad_click_n_drag)
708 struct litest_device *dev = litest_current_device();
709 struct libinput *li = dev->libinput;
710 struct libinput_event *event;
712 litest_drain_events(li);
714 litest_touch_down(dev, 0, 50, 50);
715 litest_event(dev, EV_KEY, BTN_LEFT, 1);
716 litest_event(dev, EV_SYN, SYN_REPORT, 0);
718 libinput_dispatch(li);
719 assert_button_event(li, BTN_LEFT,
720 LIBINPUT_BUTTON_STATE_PRESSED);
722 libinput_dispatch(li);
723 ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
725 /* now put a second finger down */
726 litest_touch_down(dev, 1, 70, 70);
727 litest_touch_move_to(dev, 1, 70, 70, 80, 50, 5);
728 litest_touch_up(dev, 1);
730 libinput_dispatch(li);
731 ck_assert_int_eq(libinput_next_event_type(li),
732 LIBINPUT_EVENT_POINTER_MOTION);
734 event = libinput_get_event(li);
735 libinput_event_destroy(event);
736 libinput_dispatch(li);
737 } while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION);
739 litest_event(dev, EV_KEY, BTN_LEFT, 0);
740 litest_event(dev, EV_SYN, SYN_REPORT, 0);
741 litest_touch_up(dev, 0);
743 assert_button_event(li, BTN_LEFT,
744 LIBINPUT_BUTTON_STATE_RELEASED);
748 START_TEST(clickpad_softbutton_left)
750 struct litest_device *dev = litest_current_device();
751 struct libinput *li = dev->libinput;
753 litest_drain_events(li);
755 litest_touch_down(dev, 0, 10, 90);
756 litest_event(dev, EV_KEY, BTN_LEFT, 1);
757 litest_event(dev, EV_SYN, SYN_REPORT, 0);
759 assert_button_event(li,
761 LIBINPUT_BUTTON_STATE_PRESSED);
763 litest_event(dev, EV_KEY, BTN_LEFT, 0);
764 litest_event(dev, EV_SYN, SYN_REPORT, 0);
765 litest_touch_up(dev, 0);
767 assert_button_event(li,
769 LIBINPUT_BUTTON_STATE_RELEASED);
771 libinput_dispatch(li);
773 litest_assert_empty_queue(li);
777 START_TEST(clickpad_softbutton_right)
779 struct litest_device *dev = litest_current_device();
780 struct libinput *li = dev->libinput;
782 litest_drain_events(li);
784 litest_touch_down(dev, 0, 90, 90);
785 litest_event(dev, EV_KEY, BTN_LEFT, 1);
786 litest_event(dev, EV_SYN, SYN_REPORT, 0);
788 assert_button_event(li,
790 LIBINPUT_BUTTON_STATE_PRESSED);
792 litest_event(dev, EV_KEY, BTN_LEFT, 0);
793 litest_event(dev, EV_SYN, SYN_REPORT, 0);
794 litest_touch_up(dev, 0);
796 assert_button_event(li,
798 LIBINPUT_BUTTON_STATE_RELEASED);
800 libinput_dispatch(li);
802 litest_assert_empty_queue(li);
806 START_TEST(clickpad_softbutton_left_tap_n_drag)
808 struct litest_device *dev = litest_current_device();
809 struct libinput *li = dev->libinput;
811 libinput_device_config_tap_set_enabled(dev->libinput_device,
812 LIBINPUT_CONFIG_TAP_ENABLED);
814 litest_drain_events(li);
816 /* Tap in left button area, then finger down, button click
817 -> expect left button press/release and left button press
818 Release button, finger up
819 -> expect right button release
821 litest_touch_down(dev, 0, 20, 90);
822 litest_touch_up(dev, 0);
823 litest_touch_down(dev, 0, 20, 90);
824 litest_event(dev, EV_KEY, BTN_LEFT, 1);
825 litest_event(dev, EV_SYN, SYN_REPORT, 0);
827 assert_button_event(li,
829 LIBINPUT_BUTTON_STATE_PRESSED);
830 assert_button_event(li,
832 LIBINPUT_BUTTON_STATE_RELEASED);
833 assert_button_event(li,
835 LIBINPUT_BUTTON_STATE_PRESSED);
836 litest_assert_empty_queue(li);
838 litest_event(dev, EV_KEY, BTN_LEFT, 0);
839 litest_event(dev, EV_SYN, SYN_REPORT, 0);
840 litest_touch_up(dev, 0);
842 assert_button_event(li,
844 LIBINPUT_BUTTON_STATE_RELEASED);
845 litest_assert_empty_queue(li);
849 START_TEST(clickpad_softbutton_right_tap_n_drag)
851 struct litest_device *dev = litest_current_device();
852 struct libinput *li = dev->libinput;
854 libinput_device_config_tap_set_enabled(dev->libinput_device,
855 LIBINPUT_CONFIG_TAP_ENABLED);
857 litest_drain_events(li);
859 /* Tap in right button area, then finger down, button click
860 -> expect left button press/release and right button press
861 Release button, finger up
862 -> expect right button release
864 litest_touch_down(dev, 0, 90, 90);
865 litest_touch_up(dev, 0);
866 litest_touch_down(dev, 0, 90, 90);
867 litest_event(dev, EV_KEY, BTN_LEFT, 1);
868 litest_event(dev, EV_SYN, SYN_REPORT, 0);
870 assert_button_event(li,
872 LIBINPUT_BUTTON_STATE_PRESSED);
873 assert_button_event(li,
875 LIBINPUT_BUTTON_STATE_RELEASED);
876 assert_button_event(li,
878 LIBINPUT_BUTTON_STATE_PRESSED);
879 litest_assert_empty_queue(li);
881 litest_event(dev, EV_KEY, BTN_LEFT, 0);
882 litest_event(dev, EV_SYN, SYN_REPORT, 0);
883 litest_touch_up(dev, 0);
885 assert_button_event(li,
887 LIBINPUT_BUTTON_STATE_RELEASED);
888 litest_assert_empty_queue(li);
892 START_TEST(clickpad_softbutton_left_1st_fg_move)
894 struct litest_device *dev = litest_current_device();
895 struct libinput *li = dev->libinput;
896 struct libinput_event *event;
900 litest_drain_events(li);
902 /* One finger down in the left button area, button press
903 -> expect a button event
904 Move finger up out of the area, wait for timeout
905 Move finger around diagonally down left
906 -> expect motion events down left
908 -> expect a button event */
910 /* finger down, press in left button */
911 litest_touch_down(dev, 0, 20, 90);
912 litest_event(dev, EV_KEY, BTN_LEFT, 1);
913 litest_event(dev, EV_SYN, SYN_REPORT, 0);
915 assert_button_event(li,
917 LIBINPUT_BUTTON_STATE_PRESSED);
918 litest_assert_empty_queue(li);
920 /* move out of the area, then wait for softbutton timer */
921 litest_touch_move_to(dev, 0, 20, 90, 90, 20, 10);
922 libinput_dispatch(li);
924 libinput_dispatch(li);
925 litest_drain_events(li);
927 /* move down left, expect motion */
928 litest_touch_move_to(dev, 0, 90, 20, 20, 90, 10);
930 libinput_dispatch(li);
931 event = libinput_get_event(li);
932 ck_assert(event != NULL);
934 struct libinput_event_pointer *p;
936 ck_assert_int_eq(libinput_event_get_type(event),
937 LIBINPUT_EVENT_POINTER_MOTION);
938 p = libinput_event_get_pointer_event(event);
940 /* we moved up/right, now down/left so the pointer accel
941 code may lag behind with the dx/dy vectors. Hence, add up
942 the x/y movements and expect that on average we moved
944 x += libinput_event_pointer_get_dx(p);
945 y += libinput_event_pointer_get_dy(p);
948 libinput_event_destroy(event);
949 libinput_dispatch(li);
950 event = libinput_get_event(li);
953 ck_assert(x/nevents < 0);
954 ck_assert(y/nevents > 0);
956 litest_event(dev, EV_KEY, BTN_LEFT, 0);
957 litest_event(dev, EV_SYN, SYN_REPORT, 0);
958 litest_touch_up(dev, 0);
960 assert_button_event(li,
962 LIBINPUT_BUTTON_STATE_RELEASED);
964 litest_assert_empty_queue(li);
968 START_TEST(clickpad_softbutton_left_2nd_fg_move)
970 struct litest_device *dev = litest_current_device();
971 struct libinput *li = dev->libinput;
972 struct libinput_event *event;
974 litest_drain_events(li);
976 /* One finger down in the left button area, button press
977 -> expect a button event
978 Put a second finger down in the area, move it right, release
979 -> expect motion events right
980 Put a second finger down in the area, move it down, release
981 -> expect motion events down
982 Release second finger, release first finger
983 -> expect a button event */
984 litest_touch_down(dev, 0, 20, 90);
985 litest_event(dev, EV_KEY, BTN_LEFT, 1);
986 litest_event(dev, EV_SYN, SYN_REPORT, 0);
988 assert_button_event(li,
990 LIBINPUT_BUTTON_STATE_PRESSED);
991 litest_assert_empty_queue(li);
993 litest_touch_down(dev, 1, 20, 20);
994 litest_touch_move_to(dev, 1, 20, 20, 80, 20, 10);
996 libinput_dispatch(li);
997 event = libinput_get_event(li);
998 ck_assert(event != NULL);
1000 struct libinput_event_pointer *p;
1003 ck_assert_int_eq(libinput_event_get_type(event),
1004 LIBINPUT_EVENT_POINTER_MOTION);
1005 p = libinput_event_get_pointer_event(event);
1007 x = libinput_event_pointer_get_dx(p);
1008 y = libinput_event_pointer_get_dy(p);
1013 libinput_event_destroy(event);
1014 libinput_dispatch(li);
1015 event = libinput_get_event(li);
1017 litest_touch_up(dev, 1);
1019 /* second finger down */
1020 litest_touch_down(dev, 1, 20, 20);
1021 litest_touch_move_to(dev, 1, 20, 20, 20, 80, 10);
1023 libinput_dispatch(li);
1024 event = libinput_get_event(li);
1025 ck_assert(event != NULL);
1027 struct libinput_event_pointer *p;
1030 ck_assert_int_eq(libinput_event_get_type(event),
1031 LIBINPUT_EVENT_POINTER_MOTION);
1032 p = libinput_event_get_pointer_event(event);
1034 x = libinput_event_pointer_get_dx(p);
1035 y = libinput_event_pointer_get_dy(p);
1040 libinput_event_destroy(event);
1041 libinput_dispatch(li);
1042 event = libinput_get_event(li);
1045 litest_touch_up(dev, 1);
1047 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1048 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1049 litest_touch_up(dev, 0);
1051 assert_button_event(li,
1053 LIBINPUT_BUTTON_STATE_RELEASED);
1055 litest_assert_empty_queue(li);
1059 START_TEST(clickpad_softbutton_left_to_right)
1061 struct litest_device *dev = litest_current_device();
1062 struct libinput *li = dev->libinput;
1064 litest_drain_events(li);
1066 /* One finger down in left software button area,
1067 move to right button area immediately, click
1068 -> expect right button event
1071 litest_touch_down(dev, 0, 20, 90);
1072 litest_touch_move_to(dev, 0, 20, 90, 90, 90, 10);
1073 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1074 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1076 assert_button_event(li,
1078 LIBINPUT_BUTTON_STATE_PRESSED);
1079 litest_assert_empty_queue(li);
1081 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1082 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1083 litest_touch_up(dev, 0);
1085 assert_button_event(li,
1087 LIBINPUT_BUTTON_STATE_RELEASED);
1089 litest_assert_empty_queue(li);
1093 START_TEST(clickpad_softbutton_right_to_left)
1095 struct litest_device *dev = litest_current_device();
1096 struct libinput *li = dev->libinput;
1098 litest_drain_events(li);
1100 /* One finger down in right software button area,
1101 move to left button area immediately, click
1102 -> expect left button event
1105 litest_touch_down(dev, 0, 90, 90);
1106 litest_touch_move_to(dev, 0, 90, 90, 20, 90, 10);
1107 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1108 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1110 assert_button_event(li,
1112 LIBINPUT_BUTTON_STATE_PRESSED);
1113 litest_assert_empty_queue(li);
1115 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1116 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1117 litest_touch_up(dev, 0);
1119 assert_button_event(li,
1121 LIBINPUT_BUTTON_STATE_RELEASED);
1123 litest_assert_empty_queue(li);
1127 START_TEST(clickpad_topsoftbuttons_left)
1129 struct litest_device *dev = litest_current_device();
1130 struct libinput *li = dev->libinput;
1132 litest_drain_events(li);
1134 litest_touch_down(dev, 0, 10, 5);
1135 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1136 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1138 assert_button_event(li,
1140 LIBINPUT_BUTTON_STATE_PRESSED);
1141 litest_assert_empty_queue(li);
1143 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1144 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1145 litest_touch_up(dev, 0);
1147 assert_button_event(li,
1149 LIBINPUT_BUTTON_STATE_RELEASED);
1151 litest_assert_empty_queue(li);
1155 START_TEST(clickpad_topsoftbuttons_right)
1157 struct litest_device *dev = litest_current_device();
1158 struct libinput *li = dev->libinput;
1160 litest_drain_events(li);
1162 litest_touch_down(dev, 0, 90, 5);
1163 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1164 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1166 assert_button_event(li,
1168 LIBINPUT_BUTTON_STATE_PRESSED);
1169 litest_assert_empty_queue(li);
1171 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1172 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1173 litest_touch_up(dev, 0);
1175 assert_button_event(li,
1177 LIBINPUT_BUTTON_STATE_RELEASED);
1179 litest_assert_empty_queue(li);
1183 START_TEST(clickpad_topsoftbuttons_middle)
1185 struct litest_device *dev = litest_current_device();
1186 struct libinput *li = dev->libinput;
1188 litest_drain_events(li);
1190 litest_touch_down(dev, 0, 50, 5);
1191 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1192 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1194 assert_button_event(li,
1196 LIBINPUT_BUTTON_STATE_PRESSED);
1197 litest_assert_empty_queue(li);
1199 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1200 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1201 litest_touch_up(dev, 0);
1203 assert_button_event(li,
1205 LIBINPUT_BUTTON_STATE_RELEASED);
1207 litest_assert_empty_queue(li);
1211 START_TEST(clickpad_topsoftbuttons_move_out_ignore)
1213 struct litest_device *dev = litest_current_device();
1214 struct libinput *li = dev->libinput;
1216 /* Finger down in top button area, wait past enter timeout
1217 Move into main area, wait past leave timeout
1222 litest_drain_events(li);
1224 litest_touch_down(dev, 0, 50, 5);
1225 libinput_dispatch(li);
1227 libinput_dispatch(li);
1228 litest_assert_empty_queue(li);
1230 litest_touch_move_to(dev, 0, 50, 5, 80, 90, 20);
1231 libinput_dispatch(li);
1233 libinput_dispatch(li);
1235 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1236 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1237 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1238 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1240 litest_touch_up(dev, 0);
1242 litest_assert_empty_queue(li);
1247 test_2fg_scroll(struct litest_device *dev, double dx, double dy, int sleep)
1249 struct libinput *li = dev->libinput;
1251 litest_touch_down(dev, 0, 47, 50);
1252 litest_touch_down(dev, 1, 53, 50);
1254 litest_touch_move_to(dev, 0, 47, 50, 47 + dx, 50 + dy, 5);
1255 litest_touch_move_to(dev, 1, 53, 50, 53 + dx, 50 + dy, 5);
1257 /* Avoid a small scroll being seen as a tap */
1259 libinput_dispatch(li);
1261 libinput_dispatch(li);
1264 litest_touch_up(dev, 1);
1265 litest_touch_up(dev, 0);
1267 libinput_dispatch(li);
1271 check_2fg_scroll(struct litest_device *dev, unsigned int axis, int dir)
1273 struct libinput *li = dev->libinput;
1274 struct libinput_event *event, *next_event;
1275 struct libinput_event_pointer *ptrev;
1277 event = libinput_get_event(li);
1278 next_event = libinput_get_event(li);
1279 ck_assert(next_event != NULL); /* At least 1 scroll + stop scroll */
1282 ck_assert_int_eq(libinput_event_get_type(event),
1283 LIBINPUT_EVENT_POINTER_AXIS);
1284 ptrev = libinput_event_get_pointer_event(event);
1285 ck_assert(ptrev != NULL);
1286 ck_assert_int_eq(libinput_event_pointer_get_axis(ptrev), axis);
1289 /* Normal scroll event, check dir */
1292 libinput_event_pointer_get_axis_value(ptrev),
1296 libinput_event_pointer_get_axis_value(ptrev),
1300 /* Last scroll event, must be 0 */
1302 libinput_event_pointer_get_axis_value(ptrev),
1305 libinput_event_destroy(event);
1307 next_event = libinput_get_event(li);
1311 START_TEST(touchpad_2fg_scroll)
1313 struct litest_device *dev = litest_current_device();
1314 struct libinput *li = dev->libinput;
1316 litest_drain_events(li);
1318 test_2fg_scroll(dev, 0.1, 40, 0);
1319 check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 10);
1320 test_2fg_scroll(dev, 0.1, -40, 0);
1321 check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -10);
1322 test_2fg_scroll(dev, 40, 0.1, 0);
1323 check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, 10);
1324 test_2fg_scroll(dev, -40, 0.1, 0);
1325 check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -10);
1327 /* 2fg scroll smaller than the threshold should not generate events */
1328 test_2fg_scroll(dev, 0.1, 0.1, 200);
1329 litest_assert_empty_queue(li);
1333 START_TEST(touchpad_tap_is_available)
1335 struct litest_device *dev = litest_current_device();
1337 ck_assert_int_ge(libinput_device_config_tap_get_finger_count(dev->libinput_device), 1);
1338 ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device),
1339 LIBINPUT_CONFIG_TAP_DISABLED);
1343 START_TEST(touchpad_tap_is_not_available)
1345 struct litest_device *dev = litest_current_device();
1347 ck_assert_int_eq(libinput_device_config_tap_get_finger_count(dev->libinput_device), 0);
1348 ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device),
1349 LIBINPUT_CONFIG_TAP_DISABLED);
1350 ck_assert_int_eq(libinput_device_config_tap_set_enabled(dev->libinput_device,
1351 LIBINPUT_CONFIG_TAP_ENABLED),
1352 LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
1356 START_TEST(touchpad_tap_default)
1358 struct litest_device *dev = litest_current_device();
1360 ck_assert_int_eq(libinput_device_config_tap_get_default_enabled(dev->libinput_device),
1361 LIBINPUT_CONFIG_TAP_DISABLED);
1365 START_TEST(touchpad_tap_invalid)
1367 struct litest_device *dev = litest_current_device();
1369 ck_assert_int_eq(libinput_device_config_tap_set_enabled(dev->libinput_device, 2),
1370 LIBINPUT_CONFIG_STATUS_INVALID);
1371 ck_assert_int_eq(libinput_device_config_tap_set_enabled(dev->libinput_device, -1),
1372 LIBINPUT_CONFIG_STATUS_INVALID);
1377 touchpad_has_palm_detect_size(struct litest_device *dev)
1379 double width, height;
1382 if (libinput_device_get_id_vendor(dev->libinput_device) == 0x5ac) /* Apple */
1385 rc = libinput_device_get_size(dev->libinput_device, &width, &height);
1387 return rc == 0 && width >= 80;
1390 START_TEST(touchpad_palm_detect_at_edge)
1392 struct litest_device *dev = litest_current_device();
1393 struct libinput *li = dev->libinput;
1395 if (!touchpad_has_palm_detect_size(dev))
1398 litest_drain_events(li);
1400 litest_touch_down(dev, 0, 99, 50);
1401 litest_touch_move_to(dev, 0, 99, 50, 99, 70, 5);
1402 litest_touch_up(dev, 0);
1404 litest_assert_empty_queue(li);
1406 litest_touch_down(dev, 0, 5, 50);
1407 litest_touch_move_to(dev, 0, 5, 50, 5, 70, 5);
1408 litest_touch_up(dev, 0);
1412 START_TEST(touchpad_palm_detect_at_bottom_corners)
1414 struct litest_device *dev = litest_current_device();
1415 struct libinput *li = dev->libinput;
1417 if (!touchpad_has_palm_detect_size(dev))
1420 /* Run for non-clickpads only: make sure the bottom corners trigger
1421 palm detection too */
1422 litest_drain_events(li);
1424 litest_touch_down(dev, 0, 99, 95);
1425 litest_touch_move_to(dev, 0, 99, 95, 99, 99, 10);
1426 litest_touch_up(dev, 0);
1428 litest_assert_empty_queue(li);
1430 litest_touch_down(dev, 0, 5, 95);
1431 litest_touch_move_to(dev, 0, 5, 95, 5, 99, 5);
1432 litest_touch_up(dev, 0);
1436 START_TEST(touchpad_palm_detect_at_top_corners)
1438 struct litest_device *dev = litest_current_device();
1439 struct libinput *li = dev->libinput;
1441 if (!touchpad_has_palm_detect_size(dev))
1444 /* Run for non-clickpads only: make sure the bottom corners trigger
1445 palm detection too */
1446 litest_drain_events(li);
1448 litest_touch_down(dev, 0, 99, 5);
1449 litest_touch_move_to(dev, 0, 99, 5, 99, 9, 10);
1450 litest_touch_up(dev, 0);
1452 litest_assert_empty_queue(li);
1454 litest_touch_down(dev, 0, 5, 5);
1455 litest_touch_move_to(dev, 0, 5, 5, 5, 9, 5);
1456 litest_touch_up(dev, 0);
1460 START_TEST(touchpad_palm_detect_palm_stays_palm)
1462 struct litest_device *dev = litest_current_device();
1463 struct libinput *li = dev->libinput;
1465 if (!touchpad_has_palm_detect_size(dev))
1468 litest_drain_events(li);
1470 litest_touch_down(dev, 0, 99, 20);
1471 litest_touch_move_to(dev, 0, 99, 20, 75, 99, 5);
1472 litest_touch_up(dev, 0);
1473 litest_assert_empty_queue(li);
1477 START_TEST(touchpad_palm_detect_palm_becomes_pointer)
1479 struct litest_device *dev = litest_current_device();
1480 struct libinput *li = dev->libinput;
1481 struct libinput_event *ev;
1482 enum libinput_event_type type;
1484 if (!touchpad_has_palm_detect_size(dev))
1487 litest_drain_events(li);
1489 litest_touch_down(dev, 0, 99, 50);
1490 litest_touch_move_to(dev, 0, 99, 70, 0, 70, 5);
1491 litest_touch_up(dev, 0);
1493 libinput_dispatch(li);
1495 ev = libinput_get_event(li);
1496 ck_assert_notnull(ev);
1498 type = libinput_event_get_type(ev);
1499 ck_assert_int_eq(type, LIBINPUT_EVENT_POINTER_MOTION);
1501 libinput_event_destroy(ev);
1502 ev = libinput_get_event(li);
1505 litest_assert_empty_queue(li);
1509 START_TEST(touchpad_palm_detect_no_palm_moving_into_edges)
1511 struct litest_device *dev = litest_current_device();
1512 struct libinput *li = dev->libinput;
1513 struct libinput_event *ev;
1514 enum libinput_event_type type;
1516 if (!touchpad_has_palm_detect_size(dev))
1519 /* moving non-palm into the edge does not label it as palm */
1520 litest_drain_events(li);
1522 litest_touch_down(dev, 0, 50, 50);
1523 litest_touch_move_to(dev, 0, 50, 50, 99, 50, 5);
1525 litest_drain_events(li);
1527 litest_touch_move_to(dev, 0, 99, 50, 99, 90, 5);
1528 libinput_dispatch(li);
1530 type = libinput_next_event_type(li);
1533 ck_assert_int_eq(type, LIBINPUT_EVENT_POINTER_MOTION);
1534 ev = libinput_get_event(li);
1535 libinput_event_destroy(ev);
1537 type = libinput_next_event_type(li);
1538 libinput_dispatch(li);
1539 } while (type != LIBINPUT_EVENT_NONE);
1541 litest_touch_up(dev, 0);
1542 libinput_dispatch(li);
1543 litest_assert_empty_queue(li);
1547 int main(int argc, char **argv) {
1549 litest_add("touchpad:motion", touchpad_1fg_motion, LITEST_TOUCHPAD, LITEST_ANY);
1550 litest_add("touchpad:motion", touchpad_2fg_no_motion, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1552 litest_add("touchpad:tap", touchpad_1fg_tap, LITEST_TOUCHPAD, LITEST_ANY);
1553 litest_add("touchpad:tap", touchpad_1fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_ANY);
1554 litest_add("touchpad:tap", touchpad_2fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1555 litest_add("touchpad:tap", touchpad_2fg_tap_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1556 litest_add("touchpad:tap", touchpad_1fg_tap_click, LITEST_TOUCHPAD, LITEST_ANY);
1557 litest_add("touchpad:tap", touchpad_2fg_tap_click, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
1558 litest_add("touchpad:tap", touchpad_2fg_tap_click_apple, LITEST_APPLE_CLICKPAD, LITEST_ANY);
1559 litest_add("touchpad:tap", touchpad_no_2fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1560 litest_add("touchpad:tap", touchpad_no_2fg_tap_after_timeout, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1561 litest_add("touchpad:tap", touchpad_no_first_fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1562 litest_add("touchpad:tap", touchpad_no_first_fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1563 /* apple is the only one with real 3-finger support */
1564 litest_add("touchpad:tap", touchpad_3fg_tap_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
1565 litest_add("touchpad:tap", touchpad_3fg_tap_btntool_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
1566 litest_add("touchpad:tap", touchpad_3fg_tap, LITEST_APPLE_CLICKPAD, LITEST_ANY);
1568 /* Real buttons don't interfere with tapping, so don't run those for
1569 pads with buttons */
1570 litest_add("touchpad:tap", touchpad_1fg_double_tap_click, LITEST_CLICKPAD, LITEST_ANY);
1571 litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_click, LITEST_CLICKPAD, LITEST_ANY);
1573 litest_add("touchpad:tap", touchpad_tap_default, LITEST_TOUCHPAD, LITEST_ANY);
1574 litest_add("touchpad:tap", touchpad_tap_invalid, LITEST_TOUCHPAD, LITEST_ANY);
1575 litest_add("touchpad:tap", touchpad_tap_is_available, LITEST_TOUCHPAD, LITEST_ANY);
1576 litest_add("touchpad:tap", touchpad_tap_is_not_available, LITEST_ANY, LITEST_TOUCHPAD);
1578 litest_add_no_device("touchpad:clickfinger", touchpad_1fg_clickfinger);
1579 litest_add_no_device("touchpad:clickfinger", touchpad_2fg_clickfinger);
1581 litest_add("touchpad:click", touchpad_btn_left, LITEST_TOUCHPAD, LITEST_CLICKPAD);
1582 litest_add("touchpad:click", clickpad_btn_left, LITEST_CLICKPAD, LITEST_ANY);
1583 litest_add("touchpad:click", clickpad_click_n_drag, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH);
1585 litest_add("touchpad:softbutton", clickpad_softbutton_left, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1586 litest_add("touchpad:softbutton", clickpad_softbutton_right, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1587 litest_add("touchpad:softbutton", clickpad_softbutton_left_tap_n_drag, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1588 litest_add("touchpad:softbutton", clickpad_softbutton_right_tap_n_drag, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1589 litest_add("touchpad:softbutton", clickpad_softbutton_left_1st_fg_move, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1590 litest_add("touchpad:softbutton", clickpad_softbutton_left_2nd_fg_move, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1591 litest_add("touchpad:softbutton", clickpad_softbutton_left_to_right, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1592 litest_add("touchpad:softbutton", clickpad_softbutton_right_to_left, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1594 litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_left, LITEST_TOPBUTTONPAD, LITEST_ANY);
1595 litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_right, LITEST_TOPBUTTONPAD, LITEST_ANY);
1596 litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_middle, LITEST_TOPBUTTONPAD, LITEST_ANY);
1597 litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_move_out_ignore, LITEST_TOPBUTTONPAD, LITEST_ANY);
1599 litest_add("touchpad:scroll", touchpad_2fg_scroll, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1601 litest_add("touchpad:palm", touchpad_palm_detect_at_edge, LITEST_TOUCHPAD, LITEST_ANY);
1602 litest_add("touchpad:palm", touchpad_palm_detect_at_bottom_corners, LITEST_TOUCHPAD, LITEST_CLICKPAD);
1603 litest_add("touchpad:palm", touchpad_palm_detect_at_top_corners, LITEST_TOUCHPAD, LITEST_TOPBUTTONPAD);
1604 litest_add("touchpad:palm", touchpad_palm_detect_palm_becomes_pointer, LITEST_TOUCHPAD, LITEST_ANY);
1605 litest_add("touchpad:palm", touchpad_palm_detect_palm_stays_palm, LITEST_TOUCHPAD, LITEST_ANY);
1606 litest_add("touchpad:palm", touchpad_palm_detect_no_palm_moving_into_edges, LITEST_TOUCHPAD, LITEST_ANY);
1608 return litest_run(argc, argv);