[PATCH weston 13/19] client: Add up/down event support into libtoytoolkit

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


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

diff --git a/clients/window.c b/clients/window.c
index dd9b822..83459eb 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -318,6 +318,8 @@ struct widget {
 	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;
+	widget_tablet_down_handler_t tablet_down_handler;
+	widget_tablet_up_handler_t tablet_up_handler;
 	void *user_data;
 	int opaque;
 	int tooltip_count;
@@ -1977,6 +1979,20 @@ widget_set_tablet_button_handler(struct widget *widget,
 	widget->tablet_button_handler = handler;
 }
 
+void
+widget_set_tablet_down_handler(struct widget *widget,
+			       widget_tablet_down_handler_t handler)
+{
+	widget->tablet_down_handler = handler;
+}
+
+void
+widget_set_tablet_up_handler(struct widget *widget,
+			     widget_tablet_up_handler_t handler)
+{
+	widget->tablet_up_handler = handler;
+}
+
 static void
 window_schedule_redraw_task(struct window *window);
 
@@ -3462,12 +3478,35 @@ tablet_handle_button(void *data, struct wl_tablet *wl_tablet, uint32_t serial,
 					     focus->user_data);
 }
 
+static void
+tablet_handle_down(void *data, struct wl_tablet *wl_tablet, uint32_t serial,
+		   uint32_t time)
+{
+	struct tablet *tablet = data;
+	struct widget *focus = tablet->focus_widget;
+
+	tablet->input->display->serial = serial;
+
+	if (focus && focus->tablet_down_handler)
+		focus->tablet_down_handler(focus, tablet, time, focus->user_data);
+}
+
+static void
+tablet_handle_up(void *data, struct wl_tablet *wl_tablet, uint32_t time)
+{
+	struct tablet *tablet = data;
+	struct widget *focus = tablet->focus_widget;
+
+	if (focus && focus->tablet_up_handler)
+		focus->tablet_up_handler(focus, tablet, time, focus->user_data);
+}
+
 static const struct wl_tablet_listener tablet_listener = {
 	tablet_handle_proximity_in,
 	tablet_handle_proximity_out,
 	tablet_handle_motion,
-	NULL,
-	NULL,
+	tablet_handle_down,
+	tablet_handle_up,
 	NULL,
 	NULL,
 	NULL,
diff --git a/clients/window.h b/clients/window.h
index 82f46f3..7d2b6bf 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -292,6 +292,14 @@ typedef void (*widget_tablet_button_handler_t)(struct widget *widget,
 					       enum wl_tablet_button_state state,
 					       uint32_t time,
 					       void *data);
+typedef void (*widget_tablet_down_handler_t)(struct widget *widget,
+					     struct tablet *tablet,
+					     uint32_t time,
+					     void *data);
+typedef void (*widget_tablet_up_handler_t)(struct widget *widget,
+					   struct tablet *tablet,
+					   uint32_t time,
+					   void *data);
 
 struct window *
 window_create(struct display *display);
@@ -560,6 +568,12 @@ void
 widget_set_tablet_button_handler(struct widget *widget,
 				 widget_tablet_button_handler_t handler);
 void
+widget_set_tablet_down_handler(struct widget *widget,
+			       widget_tablet_down_handler_t handler);
+void
+widget_set_tablet_up_handler(struct widget *widget,
+			     widget_tablet_up_handler_t handler);
+void
 widget_schedule_redraw(struct widget *widget);
 void
 widget_set_use_cairo(struct widget *widget, int use_cairo);
-- 
1.8.5.5



More information about the wayland-devel mailing list