[PATCH v2 weston 1/2] clients: hook up touch shape/orientation

Peter Hutterer peter.hutterer at who-t.net
Wed Jan 18 03:03:52 UTC 2017


This is merely the client implementation, the compositor one is missing.
libinput does not yet forward any additional shape implementation for touch
points, so right now we cannot hook up the compositor-side bits.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Changes to v1:
- new in this series

I tested this by hardcoding the wl_touch_shape etc calls into the compositor
and printing them, that's about all I can do here. This needs to be
implemented though because if wheel tilt support is added, we have to be
able to handle shape/orientation for touch points.

 clients/window.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 clients/window.h | 17 +++++++++++++
 configure.ac     |  2 +-
 3 files changed, 92 insertions(+), 2 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 59fc07e..b735cc3 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -311,6 +311,8 @@ struct widget {
 	widget_touch_motion_handler_t touch_motion_handler;
 	widget_touch_frame_handler_t touch_frame_handler;
 	widget_touch_cancel_handler_t touch_cancel_handler;
+	widget_touch_shape_handler_t touch_shape_handler;
+	widget_touch_orientation_handler_t touch_orientation_handler;
 	widget_axis_handler_t axis_handler;
 	widget_pointer_frame_handler_t pointer_frame_handler;
 	widget_axis_source_handler_t axis_source_handler;
@@ -1980,6 +1982,20 @@ widget_set_touch_cancel_handler(struct widget *widget,
 }
 
 void
+widget_set_touch_shape_handler(struct widget *widget,
+			       widget_touch_shape_handler_t handler)
+{
+	widget->touch_shape_handler = handler;
+}
+
+void
+widget_set_touch_orientation_handler(struct widget *widget,
+				     widget_touch_orientation_handler_t handler)
+{
+	widget->touch_orientation_handler = handler;
+}
+
+void
 widget_set_axis_handler(struct widget *widget,
 			widget_axis_handler_t handler)
 {
@@ -3425,12 +3441,69 @@ touch_handle_cancel(void *data, struct wl_touch *wl_touch)
 	}
 }
 
+static void
+touch_handle_shape(void *data, struct wl_touch *wl_touch,
+		   int32_t id, wl_fixed_t major_w, wl_fixed_t minor_w)
+{
+	struct input *input = data;
+	struct touch_point *tp;
+	float major = wl_fixed_to_double(major_w);
+	float minor = wl_fixed_to_double(minor_w);
+
+	DBG("touch_handle_shape: %i %i\n", id, wl_list_length(&input->touch_point_list));
+
+	if (!input->touch_focus) {
+		DBG("No touch focus found for touch shape event!\n");
+		return;
+	}
+
+	wl_list_for_each(tp, &input->touch_point_list, link) {
+		if (tp->id != id)
+			continue;
+
+		if (tp->widget->touch_shape_handler)
+			(*tp->widget->touch_shape_handler)(tp->widget, input,
+							   id, major, minor,
+							   tp->widget->user_data);
+		return;
+	}
+}
+
+static void
+touch_handle_orientation(void *data, struct wl_touch *wl_touch,
+			 int32_t id, wl_fixed_t orientation_w)
+{
+	struct input *input = data;
+	struct touch_point *tp;
+	float orientation = wl_fixed_to_double(orientation_w);
+
+	DBG("touch_handle_orientation: %i %i\n", id, wl_list_length(&input->touch_point_list));
+
+	if (!input->touch_focus) {
+		DBG("No touch focus found for touch orientation event!\n");
+		return;
+	}
+
+	wl_list_for_each(tp, &input->touch_point_list, link) {
+		if (tp->id != id)
+			continue;
+
+		if (tp->widget->touch_orientation_handler)
+			(*tp->widget->touch_orientation_handler)(tp->widget, input,
+								 id, orientation,
+								 tp->widget->user_data);
+		return;
+	}
+}
+
 static const struct wl_touch_listener touch_listener = {
 	touch_handle_down,
 	touch_handle_up,
 	touch_handle_motion,
 	touch_handle_frame,
 	touch_handle_cancel,
+	touch_handle_shape,
+	touch_handle_orientation,
 };
 
 static void
@@ -5849,7 +5922,7 @@ static void
 display_add_input(struct display *d, uint32_t id, int display_seat_version)
 {
 	struct input *input;
-	int seat_version = MIN(display_seat_version, 5);
+	int seat_version = MIN(display_seat_version, 6);
 
 	input = xzalloc(sizeof *input);
 	input->display = d;
diff --git a/clients/window.h b/clients/window.h
index 1ec9eac..7dad58b 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -280,6 +280,17 @@ typedef void (*widget_touch_frame_handler_t)(struct widget *widget,
 					     struct input *input, void *data);
 typedef void (*widget_touch_cancel_handler_t)(struct widget *widget,
 					      struct input *input, void *data);
+typedef void (*widget_touch_shape_handler_t)(struct widget *widget,
+					     struct input *input,
+					     int32_t id,
+					     float major,
+					     float minor,
+					     void *data);
+typedef void (*widget_touch_orientation_handler_t)(struct widget *widget,
+						   struct input *input,
+						   int32_t id,
+						   float orientation,
+						   void *data);
 typedef void (*widget_axis_handler_t)(struct widget *widget,
 				      struct input *input, uint32_t time,
 				      uint32_t axis,
@@ -591,6 +602,12 @@ void
 widget_set_touch_cancel_handler(struct widget *widget,
 				widget_touch_cancel_handler_t handler);
 void
+widget_set_touch_shape_handler(struct widget *widget,
+			       widget_touch_shape_handler_t handler);
+void
+widget_set_touch_orientation_handler(struct widget *widget,
+				     widget_touch_orientation_handler_t handler);
+void
 widget_set_axis_handler(struct widget *widget,
 			widget_axis_handler_t handler);
 void
diff --git a/configure.ac b/configure.ac
index 2011759..45c6d2b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,7 +14,7 @@ AC_INIT([weston],
         [weston],
         [http://wayland.freedesktop.org])
 
-WAYLAND_PREREQ_VERSION="1.12.0"
+WAYLAND_PREREQ_VERSION="1.12.90"
 
 AC_SUBST([WESTON_VERSION_MAJOR], [weston_major_version])
 AC_SUBST([WESTON_VERSION_MINOR], [weston_minor_version])
-- 
2.9.3



More information about the wayland-devel mailing list