[PATCH weston 11/19] client: Add support for handling button presses to libtoytoolkit

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


Signed-off-by: Stephen Chandler Paul <thatslyude at gmail.com>
---
 clients/window.c | 24 +++++++++++++++++++++++-
 clients/window.h | 10 ++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/clients/window.c b/clients/window.c
index 727e3f0..dd9b822 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -317,6 +317,7 @@ struct widget {
 	widget_tablet_motion_handler_t tablet_motion_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;
 	void *user_data;
 	int opaque;
 	int tooltip_count;
@@ -1969,6 +1970,13 @@ widget_set_tablet_proximity_out_handler(struct widget *widget,
 	widget->tablet_proximity_out_handler = handler;
 }
 
+void
+widget_set_tablet_button_handler(struct widget *widget,
+				 widget_tablet_button_handler_t handler)
+{
+	widget->tablet_button_handler = handler;
+}
+
 static void
 window_schedule_redraw_task(struct window *window);
 
@@ -3440,6 +3448,20 @@ tablet_handle_frame(void *data, struct wl_tablet *wl_tablet)
 
 }
 
+static void
+tablet_handle_button(void *data, struct wl_tablet *wl_tablet, uint32_t serial,
+		     uint32_t time, uint32_t button, uint32_t state)
+{
+	struct tablet *tablet = data;
+	struct widget *focus = tablet->focus_widget;
+
+	tablet->input->display->serial = serial;
+
+	if (focus && focus->tablet_button_handler)
+		focus->tablet_button_handler(focus, tablet, button, state, time,
+					     focus->user_data);
+}
+
 static const struct wl_tablet_listener tablet_listener = {
 	tablet_handle_proximity_in,
 	tablet_handle_proximity_out,
@@ -3449,7 +3471,7 @@ static const struct wl_tablet_listener tablet_listener = {
 	NULL,
 	NULL,
 	NULL,
-	NULL,
+	tablet_handle_button,
 	tablet_handle_frame,
 	tablet_handle_removed,
 };
diff --git a/clients/window.h b/clients/window.h
index 6ef7792..82f46f3 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -27,6 +27,7 @@
 
 #include <xkbcommon/xkbcommon.h>
 #include <wayland-client.h>
+#include <wayland-tablet-client-protocol.h>
 #include <cairo.h>
 #include "../shared/config-parser.h"
 #include "../shared/zalloc.h"
@@ -285,6 +286,12 @@ typedef void (*widget_tablet_proximity_in_handler_t)(struct widget *widget,
 typedef void (*widget_tablet_proximity_out_handler_t)(struct widget *widget,
 						      struct tablet *tablet,
 						      void *data);
+typedef void (*widget_tablet_button_handler_t)(struct widget *widget,
+					       struct tablet *tablet,
+					       uint32_t button,
+					       enum wl_tablet_button_state state,
+					       uint32_t time,
+					       void *data);
 
 struct window *
 window_create(struct display *display);
@@ -550,6 +557,9 @@ void
 widget_set_tablet_proximity_out_handler(struct widget *widget,
 					widget_tablet_proximity_out_handler_t handler);
 void
+widget_set_tablet_button_handler(struct widget *widget,
+				 widget_tablet_button_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