[PATCH weston 16/19] client: Add support for pressure, distance, and tilt into libtoytoolkit

Stephen Chandler Paul thatslyude at gmail.com
Wed Aug 6 16:08:06 PDT 2014


Signed-off-by: Stephen Chandler Paul <thatslyude at gmail.com>
---
 clients/window.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
 clients/window.h | 25 +++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 3 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 7b844f8..3896b31 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -315,6 +315,9 @@ struct widget {
 	widget_touch_cancel_handler_t touch_cancel_handler;
 	widget_axis_handler_t axis_handler;
 	widget_tablet_motion_handler_t tablet_motion_handler;
+	widget_tablet_pressure_handler_t tablet_pressure_handler;
+	widget_tablet_distance_handler_t tablet_distance_handler;
+	widget_tablet_tilt_handler_t tablet_tilt_handler;
 	widget_tablet_proximity_in_handler_t tablet_proximity_in_handler;
 	widget_tablet_proximity_out_handler_t tablet_proximity_out_handler;
 	widget_tablet_button_handler_t tablet_button_handler;
@@ -3469,6 +3472,42 @@ tablet_handle_motion(void *data, struct wl_tablet *wl_tablet, uint32_t time,
 }
 
 static void
+tablet_handle_pressure(void *data, struct wl_tablet *wl_tablet, uint32_t time,
+		       wl_fixed_t pressure)
+{
+	struct tablet *tablet = data;
+	struct widget *widget = tablet->focus_widget;
+
+	if (widget && widget->tablet_pressure_handler)
+		widget->tablet_pressure_handler(widget, tablet, time, pressure,
+						widget->user_data);
+}
+
+static void
+tablet_handle_distance(void *data, struct wl_tablet *wl_tablet, uint32_t time,
+		       wl_fixed_t distance)
+{
+	struct tablet *tablet = data;
+	struct widget *widget = tablet->focus_widget;
+
+	if (widget && widget->tablet_distance_handler)
+		widget->tablet_distance_handler(widget, tablet, time, distance,
+						widget->user_data);
+}
+
+static void
+tablet_handle_tilt(void *data, struct wl_tablet *wl_tablet, uint32_t time,
+		   wl_fixed_t tilt_x, wl_fixed_t tilt_y)
+{
+	struct tablet *tablet = data;
+	struct widget *widget = tablet->focus_widget;
+
+	if (widget && widget->tablet_tilt_handler)
+		widget->tablet_tilt_handler(widget, tablet, time,
+					    tilt_x, tilt_y, widget->user_data);
+}
+
+static void
 tablet_handle_removed(void *data, struct wl_tablet *wl_tablet)
 {
 	struct tablet *tablet = data;
@@ -3534,9 +3573,9 @@ static const struct wl_tablet_listener tablet_listener = {
 	tablet_handle_motion,
 	tablet_handle_down,
 	tablet_handle_up,
-	NULL,
-	NULL,
-	NULL,
+	tablet_handle_pressure,
+	tablet_handle_distance,
+	tablet_handle_tilt,
 	tablet_handle_button,
 	tablet_handle_frame,
 	tablet_handle_removed,
diff --git a/clients/window.h b/clients/window.h
index 7d2b6bf..203a7fe 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -279,6 +279,22 @@ typedef int (*widget_tablet_motion_handler_t)(struct widget *widget,
 					      float y,
 					      uint32_t time,
 					      void *data);
+typedef void (*widget_tablet_pressure_handler_t)(struct widget *widget,
+						 struct tablet *tablet,
+						 uint32_t time,
+						 wl_fixed_t pressure,
+						 void *data);
+typedef void (*widget_tablet_distance_handler_t)(struct widget *widget,
+						 struct tablet *tablet,
+						 uint32_t time,
+						 wl_fixed_t distance,
+						 void *data);
+typedef void (*widget_tablet_tilt_handler_t)(struct widget *widget,
+					     struct tablet *tablet,
+					     uint32_t time,
+					     wl_fixed_t tilt_x,
+					     wl_fixed_t tilt_y,
+					     void *data);
 typedef void (*widget_tablet_proximity_in_handler_t)(struct widget *widget,
 						     struct tablet *tablet,
 						     struct tablet_tool *tool,
@@ -559,6 +575,15 @@ void
 widget_set_tablet_motion_handler(struct widget *widget,
 				 widget_tablet_motion_handler_t handler);
 void
+widget_set_tablet_pressure_handler(struct widget *widget,
+				   widget_tablet_pressure_handler_t handler);
+void
+widget_set_tablet_distance_handler(struct widget *widget,
+				   widget_tablet_distance_handler_t handler);
+void
+widget_set_tablet_tilt_handler(struct widget *widget,
+			       widget_tablet_tilt_handler_t handler);
+void
 widget_set_tablet_proximity_in_handler(struct widget *widget,
 				       widget_tablet_proximity_in_handler_t handler);
 void
-- 
1.8.5.5



More information about the wayland-devel mailing list