mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-25 03:30:05 +01:00
touchpad: add helper function to get from tp to the libinput context
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
parent
7248ffbd66
commit
08fbfe52d2
5 changed files with 25 additions and 19 deletions
|
|
@ -392,7 +392,7 @@ tp_button_handle_event(struct tp_dispatch *tp,
|
|||
enum button_event event,
|
||||
uint64_t time)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
enum button_state current = t->button.state;
|
||||
|
||||
switch(t->button.state) {
|
||||
|
|
@ -478,7 +478,7 @@ tp_process_button(struct tp_dispatch *tp,
|
|||
const struct input_event *e,
|
||||
uint64_t time)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
uint32_t mask = 1 << (e->code - BTN_LEFT);
|
||||
|
||||
/* Ignore other buttons on clickpads */
|
||||
|
|
@ -680,7 +680,7 @@ int
|
|||
tp_init_buttons(struct tp_dispatch *tp,
|
||||
struct evdev_device *device)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
struct tp_touch *t;
|
||||
int width, height;
|
||||
double diagonal;
|
||||
|
|
@ -731,7 +731,7 @@ tp_init_buttons(struct tp_dispatch *tp,
|
|||
tp_for_each_touch(tp, t) {
|
||||
t->button.state = BUTTON_STATE_NONE;
|
||||
libinput_timer_init(&t->button.timer,
|
||||
tp->device->base.seat->libinput,
|
||||
tp_libinput_context(tp),
|
||||
tp_button_handle_timeout, t);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ tp_edge_scroll_handle_none(struct tp_dispatch *tp,
|
|||
struct tp_touch *t,
|
||||
enum scroll_event event)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
|
||||
switch (event) {
|
||||
case SCROLL_EVENT_TOUCH:
|
||||
|
|
@ -149,7 +149,7 @@ tp_edge_scroll_handle_edge_new(struct tp_dispatch *tp,
|
|||
struct tp_touch *t,
|
||||
enum scroll_event event)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
|
||||
switch (event) {
|
||||
case SCROLL_EVENT_TOUCH:
|
||||
|
|
@ -178,7 +178,7 @@ tp_edge_scroll_handle_edge(struct tp_dispatch *tp,
|
|||
struct tp_touch *t,
|
||||
enum scroll_event event)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
|
||||
switch (event) {
|
||||
case SCROLL_EVENT_TOUCH:
|
||||
|
|
@ -209,7 +209,7 @@ tp_edge_scroll_handle_area(struct tp_dispatch *tp,
|
|||
struct tp_touch *t,
|
||||
enum scroll_event event)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
|
||||
switch (event) {
|
||||
case SCROLL_EVENT_TOUCH:
|
||||
|
|
@ -232,7 +232,7 @@ tp_edge_scroll_handle_event(struct tp_dispatch *tp,
|
|||
struct tp_touch *t,
|
||||
enum scroll_event event)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
enum tp_edge_scroll_touch_state current = t->scroll.edge_state;
|
||||
|
||||
switch (current) {
|
||||
|
|
@ -301,7 +301,7 @@ tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device)
|
|||
tp_for_each_touch(tp, t) {
|
||||
t->scroll.direction = -1;
|
||||
libinput_timer_init(&t->scroll.timer,
|
||||
device->base.seat->libinput,
|
||||
tp_libinput_context(tp),
|
||||
tp_edge_scroll_handle_timeout, t);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp,
|
|||
struct tp_touch *t,
|
||||
enum tap_event event, uint64_t time)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
|
||||
switch (event) {
|
||||
case TAP_EVENT_TOUCH:
|
||||
|
|
@ -223,7 +223,7 @@ tp_tap_tapped_handle_event(struct tp_dispatch *tp,
|
|||
struct tp_touch *t,
|
||||
enum tap_event event, uint64_t time)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
|
||||
switch (event) {
|
||||
case TAP_EVENT_MOTION:
|
||||
|
|
@ -483,7 +483,7 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp,
|
|||
struct tp_touch *t,
|
||||
enum tap_event event, uint64_t time)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
|
||||
switch (event) {
|
||||
case TAP_EVENT_RELEASE:
|
||||
|
|
@ -576,7 +576,7 @@ tp_tap_handle_event(struct tp_dispatch *tp,
|
|||
enum tap_event event,
|
||||
uint64_t time)
|
||||
{
|
||||
struct libinput *libinput = tp->device->base.seat->libinput;
|
||||
struct libinput *libinput = tp_libinput_context(tp);
|
||||
enum tp_tap_state current;
|
||||
|
||||
current = tp->tap.state;
|
||||
|
|
@ -857,7 +857,7 @@ tp_init_tap(struct tp_dispatch *tp)
|
|||
tp->tap.enabled = tp_tap_default(tp->device);
|
||||
|
||||
libinput_timer_init(&tp->tap.timer,
|
||||
tp->device->base.seat->libinput,
|
||||
tp_libinput_context(tp),
|
||||
tp_tap_handle_timeout, tp);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -810,7 +810,7 @@ tp_release_fake_touches(struct tp_dispatch *tp)
|
|||
static void
|
||||
tp_clear_state(struct tp_dispatch *tp)
|
||||
{
|
||||
uint64_t now = libinput_now(tp->device->base.seat->libinput);
|
||||
uint64_t now = libinput_now(tp_libinput_context(tp));
|
||||
struct tp_touch *t;
|
||||
|
||||
/* Unroll the touchpad state.
|
||||
|
|
@ -1251,7 +1251,7 @@ tp_scroll_config_scroll_method_set_method(struct libinput_device *device,
|
|||
{
|
||||
struct evdev_device *evdev = (struct evdev_device*)device;
|
||||
struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch;
|
||||
uint64_t time = libinput_now(device->seat->libinput);
|
||||
uint64_t time = libinput_now(tp_libinput_context(tp));
|
||||
|
||||
if (method == tp->scroll.method)
|
||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
|
|
@ -1352,11 +1352,11 @@ tp_init_sendevents(struct tp_dispatch *tp,
|
|||
struct evdev_device *device)
|
||||
{
|
||||
libinput_timer_init(&tp->sendevents.trackpoint_timer,
|
||||
tp->device->base.seat->libinput,
|
||||
tp_libinput_context(tp),
|
||||
tp_trackpoint_timeout, tp);
|
||||
|
||||
libinput_timer_init(&tp->dwt.keyboard_timer,
|
||||
tp->device->base.seat->libinput,
|
||||
tp_libinput_context(tp),
|
||||
tp_keyboard_timeout, tp);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,6 +295,12 @@ struct tp_dispatch {
|
|||
#define tp_for_each_touch(_tp, _t) \
|
||||
for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++)
|
||||
|
||||
static inline struct libinput*
|
||||
tp_libinput_context(struct tp_dispatch *tp)
|
||||
{
|
||||
return tp->device->base.seat->libinput;
|
||||
}
|
||||
|
||||
static inline struct normalized_coords
|
||||
tp_normalize_delta(struct tp_dispatch *tp, struct device_float_coords delta)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue