mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-24 14:40:07 +01:00
touchpad: add a helper function for checking thumb state
No functional changes Extracted from Matt Mayfield's thumb detection patches. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
7e89e43c74
commit
6e27a100b5
7 changed files with 42 additions and 8 deletions
|
|
@ -325,6 +325,7 @@ src_libinput = src_libfilter + [
|
||||||
'src/evdev-mt-touchpad.c',
|
'src/evdev-mt-touchpad.c',
|
||||||
'src/evdev-mt-touchpad.h',
|
'src/evdev-mt-touchpad.h',
|
||||||
'src/evdev-mt-touchpad-tap.c',
|
'src/evdev-mt-touchpad-tap.c',
|
||||||
|
'src/evdev-mt-touchpad-thumb.c',
|
||||||
'src/evdev-mt-touchpad-buttons.c',
|
'src/evdev-mt-touchpad-buttons.c',
|
||||||
'src/evdev-mt-touchpad-edge-scroll.c',
|
'src/evdev-mt-touchpad-edge-scroll.c',
|
||||||
'src/evdev-mt-touchpad-gestures.c',
|
'src/evdev-mt-touchpad-gestures.c',
|
||||||
|
|
|
||||||
|
|
@ -1042,8 +1042,7 @@ tp_clickfinger_within_distance(struct tp_dispatch *tp,
|
||||||
if (!t1 || !t2)
|
if (!t1 || !t2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (t1->thumb.state == THUMB_STATE_YES ||
|
if (tp_thumb_ignored(tp, t1) || tp_thumb_ignored(tp, t2))
|
||||||
t2->thumb.state == THUMB_STATE_YES)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
x = abs(t1->point.x - t2->point.x);
|
x = abs(t1->point.x - t2->point.x);
|
||||||
|
|
@ -1098,7 +1097,7 @@ tp_clickfinger_set_button(struct tp_dispatch *tp)
|
||||||
if (t->state != TOUCH_BEGIN && t->state != TOUCH_UPDATE)
|
if (t->state != TOUCH_BEGIN && t->state != TOUCH_UPDATE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (t->thumb.state == THUMB_STATE_YES)
|
if (tp_thumb_ignored(tp, t))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (t->palm.state != PALM_NONE)
|
if (t->palm.state != PALM_NONE)
|
||||||
|
|
|
||||||
|
|
@ -398,8 +398,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
|
||||||
if (!t->dirty)
|
if (!t->dirty)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (t->palm.state != PALM_NONE ||
|
if (t->palm.state != PALM_NONE || tp_thumb_ignored(tp, t))
|
||||||
t->thumb.state == THUMB_STATE_YES)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* only scroll with the finger in the previous edge */
|
/* only scroll with the finger in the previous edge */
|
||||||
|
|
|
||||||
|
|
@ -1015,7 +1015,7 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
|
||||||
/* The simple version: if a touch is a thumb on
|
/* The simple version: if a touch is a thumb on
|
||||||
* begin we ignore it. All other thumb touches
|
* begin we ignore it. All other thumb touches
|
||||||
* follow the normal tap state for now */
|
* follow the normal tap state for now */
|
||||||
if (t->thumb.state == THUMB_STATE_YES) {
|
if (tp_thumb_ignored(tp, t)) {
|
||||||
t->tap.is_thumb = true;
|
t->tap.is_thumb = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -1040,7 +1040,7 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
t->tap.state = TAP_TOUCH_STATE_IDLE;
|
t->tap.state = TAP_TOUCH_STATE_IDLE;
|
||||||
} else if (tp->tap.state != TAP_STATE_IDLE &&
|
} else if (tp->tap.state != TAP_STATE_IDLE &&
|
||||||
t->thumb.state == THUMB_STATE_YES) {
|
tp_thumb_ignored(tp, t)) {
|
||||||
tp_tap_handle_event(tp, t, TAP_EVENT_THUMB, time);
|
tp_tap_handle_event(tp, t, TAP_EVENT_THUMB, time);
|
||||||
} else if (tp->tap.state != TAP_STATE_IDLE &&
|
} else if (tp->tap.state != TAP_STATE_IDLE &&
|
||||||
tp_tap_exceeds_motion_threshold(tp, t)) {
|
tp_tap_exceeds_motion_threshold(tp, t)) {
|
||||||
|
|
|
||||||
32
src/evdev-mt-touchpad-thumb.c
Normal file
32
src/evdev-mt-touchpad-thumb.c
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2019 Matt Mayfield
|
||||||
|
* Copyright © 2019 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the next
|
||||||
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "evdev-mt-touchpad.h"
|
||||||
|
|
||||||
|
bool
|
||||||
|
tp_thumb_ignored(const struct tp_dispatch *tp, const struct tp_touch *t)
|
||||||
|
{
|
||||||
|
return t->thumb.state == THUMB_STATE_YES;
|
||||||
|
}
|
||||||
|
|
@ -774,7 +774,7 @@ tp_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t)
|
||||||
return (t->state == TOUCH_BEGIN || t->state == TOUCH_UPDATE) &&
|
return (t->state == TOUCH_BEGIN || t->state == TOUCH_UPDATE) &&
|
||||||
t->palm.state == PALM_NONE &&
|
t->palm.state == PALM_NONE &&
|
||||||
!t->pinned.is_pinned &&
|
!t->pinned.is_pinned &&
|
||||||
t->thumb.state != THUMB_STATE_YES &&
|
!tp_thumb_ignored(tp, t) &&
|
||||||
tp_button_touch_active(tp, t) &&
|
tp_button_touch_active(tp, t) &&
|
||||||
tp_edge_scroll_touch_active(tp, t);
|
tp_edge_scroll_touch_active(tp, t);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -677,4 +677,7 @@ tp_palm_tap_is_palm(const struct tp_dispatch *tp, const struct tp_touch *t);
|
||||||
void
|
void
|
||||||
tp_clickpad_middlebutton_apply_config(struct evdev_device *device);
|
tp_clickpad_middlebutton_apply_config(struct evdev_device *device);
|
||||||
|
|
||||||
|
bool
|
||||||
|
tp_thumb_ignored(const struct tp_dispatch *tp, const struct tp_touch *t);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue