[RFC weston 3/3] eventdemo: add logging of relative motion
Philipp Brüschweiler
blei42 at gmail.com
Sat Sep 1 08:50:57 PDT 2012
---
clients/eventdemo.c | 33 +++++++++++++++++++++++++++++----
1 Datei geändert, 29 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
diff --git a/clients/eventdemo.c b/clients/eventdemo.c
index 569a8c1..db807ec 100644
--- a/clients/eventdemo.c
+++ b/clients/eventdemo.c
@@ -76,6 +76,9 @@ static int log_axis = 0;
/** set to log motion events */
static int log_motion = 0;
+/** set to log relative motion events */
+static int log_relative_motion = 0;
+
/**
* \struct eventdemo
* \brief Holds all data the program needs per window
@@ -260,10 +263,8 @@ axis_handler(struct widget *widget, struct input *input, uint32_t time,
* \param widget widget
* \param input input device that caused the motion event
* \param time time the event happend
- * \param x absolute x position
- * \param y absolute y position
- * \param sx x position relative to the window
- * \param sy y position relative to the window
+ * \param x position relative to the window
+ * \param y position relative to the window
* \param data user data associated to the window
*
* Demonstrates the use of different cursors
@@ -286,6 +287,25 @@ motion_handler(struct widget *widget, struct input *input, uint32_t time,
}
/**
+ * \brief CALLBACK function, Waylands informs about relative pointer motion
+ * \param widget widget
+ * \param input input device that caused the motion event
+ * \param time time the event happend
+ * \param dx absolute x movement
+ * \param dy absolute y movement
+ * \param data user data associated to the window
+ */
+static void
+relative_motion_handler(struct widget *widget, struct input *input,
+ uint32_t time, float dx, float dy, void *data)
+{
+ if (log_relative_motion) {
+ printf("relative motion time: %d, x: %f, y: %f\n",
+ time, dx, dy);
+ }
+}
+
+/**
* \brief Create and initialise a new eventdemo window.
* The returned eventdemo instance should be destroyed using \c eventdemo_destroy().
* \param d associated display
@@ -343,6 +363,9 @@ eventdemo_create(struct display *d)
/* Set the callback motion handler for the window */
widget_set_motion_handler(e->widget, motion_handler);
+ /* Set the callback relative motion handler for the window */
+ widget_set_relative_motion_handler(e->widget, relative_motion_handler);
+
/* Set the callback axis handler for the window */
widget_set_axis_handler(e->widget, axis_handler);
@@ -378,6 +401,8 @@ static const struct weston_option eventdemo_options[] = {
{ WESTON_OPTION_BOOLEAN, "log-button", '0', &log_button },
{ WESTON_OPTION_BOOLEAN, "log-axis", '0', &log_axis },
{ WESTON_OPTION_BOOLEAN, "log-motion", '0', &log_motion },
+ { WESTON_OPTION_BOOLEAN, "log-relative-motion", '0',
+ &log_relative_motion },
};
/**
--
1.7.12
More information about the wayland-devel
mailing list