touchpad: constify a couple of helper functions

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2016-01-07 13:04:58 +10:00
parent e510bef3f2
commit c96d11e531
6 changed files with 36 additions and 23 deletions

View file

@ -78,47 +78,54 @@ button_event_to_str(enum button_event event) {
} }
static inline bool static inline bool
is_inside_bottom_button_area(struct tp_dispatch *tp, struct tp_touch *t) is_inside_bottom_button_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
{ {
return t->point.y >= tp->buttons.bottom_area.top_edge; return t->point.y >= tp->buttons.bottom_area.top_edge;
} }
static inline bool static inline bool
is_inside_bottom_right_area(struct tp_dispatch *tp, struct tp_touch *t) is_inside_bottom_right_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
{ {
return is_inside_bottom_button_area(tp, t) && return is_inside_bottom_button_area(tp, t) &&
t->point.x > tp->buttons.bottom_area.rightbutton_left_edge; t->point.x > tp->buttons.bottom_area.rightbutton_left_edge;
} }
static inline bool static inline bool
is_inside_bottom_left_area(struct tp_dispatch *tp, struct tp_touch *t) is_inside_bottom_left_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
{ {
return is_inside_bottom_button_area(tp, t) && return is_inside_bottom_button_area(tp, t) &&
!is_inside_bottom_right_area(tp, t); !is_inside_bottom_right_area(tp, t);
} }
static inline bool static inline bool
is_inside_top_button_area(struct tp_dispatch *tp, struct tp_touch *t) is_inside_top_button_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
{ {
return t->point.y <= tp->buttons.top_area.bottom_edge; return t->point.y <= tp->buttons.top_area.bottom_edge;
} }
static inline bool static inline bool
is_inside_top_right_area(struct tp_dispatch *tp, struct tp_touch *t) is_inside_top_right_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
{ {
return is_inside_top_button_area(tp, t) && return is_inside_top_button_area(tp, t) &&
t->point.x > tp->buttons.top_area.rightbutton_left_edge; t->point.x > tp->buttons.top_area.rightbutton_left_edge;
} }
static inline bool static inline bool
is_inside_top_left_area(struct tp_dispatch *tp, struct tp_touch *t) is_inside_top_left_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
{ {
return is_inside_top_button_area(tp, t) && return is_inside_top_button_area(tp, t) &&
t->point.x < tp->buttons.top_area.leftbutton_right_edge; t->point.x < tp->buttons.top_area.leftbutton_right_edge;
} }
static inline bool static inline bool
is_inside_top_middle_area(struct tp_dispatch *tp, struct tp_touch *t) is_inside_top_middle_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
{ {
return is_inside_top_button_area(tp, t) && return is_inside_top_button_area(tp, t) &&
t->point.x >= tp->buttons.top_area.leftbutton_right_edge && t->point.x >= tp->buttons.top_area.leftbutton_right_edge &&
@ -1042,13 +1049,15 @@ tp_post_button_events(struct tp_dispatch *tp, uint64_t time)
} }
int int
tp_button_touch_active(struct tp_dispatch *tp, struct tp_touch *t) tp_button_touch_active(const struct tp_dispatch *tp,
const struct tp_touch *t)
{ {
return t->button.state == BUTTON_STATE_AREA; return t->button.state == BUTTON_STATE_AREA;
} }
bool bool
tp_button_is_inside_softbutton_area(struct tp_dispatch *tp, struct tp_touch *t) tp_button_is_inside_softbutton_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
{ {
return is_inside_top_button_area(tp, t) || return is_inside_top_button_area(tp, t) ||
is_inside_bottom_button_area(tp, t); is_inside_bottom_button_area(tp, t);

View file

@ -73,7 +73,7 @@ edge_event_to_str(enum scroll_event event)
} }
uint32_t uint32_t
tp_touch_get_edge(struct tp_dispatch *tp, struct tp_touch *t) tp_touch_get_edge(const struct tp_dispatch *tp, const struct tp_touch *t)
{ {
uint32_t edge = EDGE_NONE; uint32_t edge = EDGE_NONE;
@ -455,7 +455,8 @@ tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time)
} }
int int
tp_edge_scroll_touch_active(struct tp_dispatch *tp, struct tp_touch *t) tp_edge_scroll_touch_active(const struct tp_dispatch *tp,
const struct tp_touch *t)
{ {
return t->scroll.edge_state == EDGE_SCROLL_TOUCH_STATE_AREA; return t->scroll.edge_state == EDGE_SCROLL_TOUCH_STATE_AREA;
} }

View file

@ -148,7 +148,7 @@ tp_gesture_post_pointer_motion(struct tp_dispatch *tp, uint64_t time)
} }
static unsigned int static unsigned int
tp_gesture_get_active_touches(struct tp_dispatch *tp, tp_gesture_get_active_touches(const struct tp_dispatch *tp,
struct tp_touch **touches, struct tp_touch **touches,
unsigned int count) unsigned int count)
{ {

View file

@ -1022,7 +1022,7 @@ tp_tap_resume(struct tp_dispatch *tp, uint64_t time)
} }
bool bool
tp_tap_dragging(struct tp_dispatch *tp) tp_tap_dragging(const struct tp_dispatch *tp)
{ {
switch (tp->tap.state) { switch (tp->tap.state) {
case TAP_STATE_DRAGGING: case TAP_STATE_DRAGGING:

View file

@ -510,7 +510,7 @@ tp_pin_fingers(struct tp_dispatch *tp)
} }
int int
tp_touch_active(struct tp_dispatch *tp, struct tp_touch *t) 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 &&
@ -521,7 +521,7 @@ tp_touch_active(struct tp_dispatch *tp, struct tp_touch *t)
} }
bool bool
tp_palm_tap_is_palm(struct tp_dispatch *tp, struct tp_touch *t) tp_palm_tap_is_palm(const struct tp_dispatch *tp, const struct tp_touch *t)
{ {
if (t->state != TOUCH_BEGIN) if (t->state != TOUCH_BEGIN)
return false; return false;

View file

@ -358,7 +358,7 @@ struct tp_dispatch {
for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++) for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++)
static inline struct libinput* static inline struct libinput*
tp_libinput_context(struct tp_dispatch *tp) tp_libinput_context(const struct tp_dispatch *tp)
{ {
return tp->device->base.seat->libinput; return tp->device->base.seat->libinput;
} }
@ -402,7 +402,7 @@ tp_filter_motion_unaccelerated(struct tp_dispatch *tp,
uint64_t time); uint64_t time);
int int
tp_touch_active(struct tp_dispatch *tp, struct tp_touch *t); tp_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t);
int int
tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time); tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time);
@ -440,10 +440,12 @@ int
tp_button_handle_state(struct tp_dispatch *tp, uint64_t time); tp_button_handle_state(struct tp_dispatch *tp, uint64_t time);
int int
tp_button_touch_active(struct tp_dispatch *tp, struct tp_touch *t); tp_button_touch_active(const struct tp_dispatch *tp,
const struct tp_touch *t);
bool bool
tp_button_is_inside_softbutton_area(struct tp_dispatch *tp, struct tp_touch *t); tp_button_is_inside_softbutton_area(const struct tp_dispatch *tp,
const struct tp_touch *t);
void void
tp_release_all_taps(struct tp_dispatch *tp, tp_release_all_taps(struct tp_dispatch *tp,
@ -456,7 +458,7 @@ void
tp_tap_resume(struct tp_dispatch *tp, uint64_t time); tp_tap_resume(struct tp_dispatch *tp, uint64_t time);
bool bool
tp_tap_dragging(struct tp_dispatch *tp); tp_tap_dragging(const struct tp_dispatch *tp);
int int
tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device); tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device);
@ -474,10 +476,11 @@ void
tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time); tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time);
int int
tp_edge_scroll_touch_active(struct tp_dispatch *tp, struct tp_touch *t); tp_edge_scroll_touch_active(const struct tp_dispatch *tp,
const struct tp_touch *t);
uint32_t uint32_t
tp_touch_get_edge(struct tp_dispatch *tp, struct tp_touch *t); tp_touch_get_edge(const struct tp_dispatch *tp, const struct tp_touch *t);
int int
tp_init_gesture(struct tp_dispatch *tp); tp_init_gesture(struct tp_dispatch *tp);
@ -501,6 +504,6 @@ void
tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time); tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time);
bool bool
tp_palm_tap_is_palm(struct tp_dispatch *tp, struct tp_touch *t); tp_palm_tap_is_palm(const struct tp_dispatch *tp, const struct tp_touch *t);
#endif #endif