[PATCH libinput 03/14] touchpad: constify a couple of helper functions

Peter Hutterer peter.hutterer at who-t.net
Thu Jan 7 20:11:07 PST 2016


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev-mt-touchpad-buttons.c     | 27 ++++++++++++++++++---------
 src/evdev-mt-touchpad-edge-scroll.c |  5 +++--
 src/evdev-mt-touchpad-gestures.c    |  2 +-
 src/evdev-mt-touchpad-tap.c         |  2 +-
 src/evdev-mt-touchpad.c             |  4 ++--
 src/evdev-mt-touchpad.h             | 19 +++++++++++--------
 6 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index 8822e08..82c99c7 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -78,47 +78,54 @@ button_event_to_str(enum button_event event) {
 }
 
 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;
 }
 
 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) &&
 	       t->point.x > tp->buttons.bottom_area.rightbutton_left_edge;
 }
 
 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) &&
 	       !is_inside_bottom_right_area(tp, t);
 }
 
 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;
 }
 
 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) &&
 	       t->point.x > tp->buttons.top_area.rightbutton_left_edge;
 }
 
 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) &&
 	       t->point.x < tp->buttons.top_area.leftbutton_right_edge;
 }
 
 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) &&
 	       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
-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;
 }
 
 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) ||
 	       is_inside_bottom_button_area(tp, t);
diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c
index b572a9f..fcc0512 100644
--- a/src/evdev-mt-touchpad-edge-scroll.c
+++ b/src/evdev-mt-touchpad-edge-scroll.c
@@ -73,7 +73,7 @@ edge_event_to_str(enum scroll_event event)
 }
 
 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;
 
@@ -455,7 +455,8 @@ tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time)
 }
 
 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;
 }
diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
index a7ef72f..fc51c54 100644
--- a/src/evdev-mt-touchpad-gestures.c
+++ b/src/evdev-mt-touchpad-gestures.c
@@ -148,7 +148,7 @@ tp_gesture_post_pointer_motion(struct tp_dispatch *tp, uint64_t time)
 }
 
 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,
 			      unsigned int count)
 {
diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index dda528a..a4c38a8 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -1022,7 +1022,7 @@ tp_tap_resume(struct tp_dispatch *tp, uint64_t time)
 }
 
 bool
-tp_tap_dragging(struct tp_dispatch *tp)
+tp_tap_dragging(const struct tp_dispatch *tp)
 {
 	switch (tp->tap.state) {
 	case TAP_STATE_DRAGGING:
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index aa123cd..b227eb9 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -510,7 +510,7 @@ tp_pin_fingers(struct tp_dispatch *tp)
 }
 
 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) &&
 		t->palm.state == PALM_NONE &&
@@ -521,7 +521,7 @@ tp_touch_active(struct tp_dispatch *tp, struct tp_touch *t)
 }
 
 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)
 		return false;
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 9cc11ac..690feb5 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -358,7 +358,7 @@ struct tp_dispatch {
 	for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++)
 
 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;
 }
@@ -402,7 +402,7 @@ tp_filter_motion_unaccelerated(struct tp_dispatch *tp,
 			       uint64_t time);
 
 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
 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);
 
 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
-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
 tp_release_all_taps(struct tp_dispatch *tp,
@@ -456,7 +458,7 @@ void
 tp_tap_resume(struct tp_dispatch *tp, uint64_t time);
 
 bool
-tp_tap_dragging(struct tp_dispatch *tp);
+tp_tap_dragging(const struct tp_dispatch *tp);
 
 int
 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);
 
 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
-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
 tp_init_gesture(struct tp_dispatch *tp);
@@ -501,6 +504,6 @@ void
 tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time);
 
 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
-- 
2.5.0



More information about the wayland-devel mailing list