[mutter] clutter: Add API for filtering relative motion events
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] clutter: Add API for filtering relative motion events
- Date: Mon, 27 Mar 2017 11:02:16 +0000 (UTC)
commit 8f691c28f30a5605471b81a5fb933e1b1222c06a
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Fri Feb 3 13:02:50 2017 +0800
clutter: Add API for filtering relative motion events
Add an API that allows the owner of the clutter context to alter the
relative motion events (so far relative pointer events).
https://bugzilla.gnome.org/show_bug.cgi?id=778119
.../clutter/evdev/clutter-device-manager-evdev.c | 36 ++++++++++++++++++++
.../clutter/evdev/clutter-device-manager-evdev.h | 7 ++++
clutter/clutter/evdev/clutter-evdev.h | 12 ++++++
clutter/clutter/evdev/clutter-seat-evdev.c | 7 ++++
4 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter/evdev/clutter-device-manager-evdev.c
b/clutter/clutter/evdev/clutter-device-manager-evdev.c
index 47df1a6..e3269b9 100644
--- a/clutter/clutter/evdev/clutter-device-manager-evdev.c
+++ b/clutter/clutter/evdev/clutter-device-manager-evdev.c
@@ -102,6 +102,9 @@ struct _ClutterDeviceManagerEvdevPrivate
gpointer constrain_data;
GDestroyNotify constrain_data_notify;
+ ClutterRelativeMotionFilter relative_motion_filter;
+ gpointer relative_motion_filter_user_data;
+
ClutterStageManager *stage_manager;
guint stage_added_handler;
guint stage_removed_handler;
@@ -264,6 +267,22 @@ _clutter_device_manager_evdev_constrain_pointer (ClutterDeviceManagerEvdev *mana
}
}
+void
+_clutter_device_manager_evdev_filter_relative_motion (ClutterDeviceManagerEvdev *manager_evdev,
+ ClutterInputDevice *device,
+ float x,
+ float y,
+ float *dx,
+ float *dy)
+{
+ ClutterDeviceManagerEvdevPrivate *priv = manager_evdev->priv;
+
+ if (!priv->relative_motion_filter)
+ return;
+
+ priv->relative_motion_filter (device, x, y, dx, dy,
+ priv->relative_motion_filter_user_data);
+}
static ClutterEvent *
new_absolute_motion_event (ClutterInputDevice *input_device,
@@ -2661,6 +2680,23 @@ clutter_evdev_set_pointer_constrain_callback (ClutterDeviceManager *e
priv->constrain_data_notify = user_data_notify;
}
+void
+clutter_evdev_set_relative_motion_filter (ClutterDeviceManager *evdev,
+ ClutterRelativeMotionFilter filter,
+ gpointer user_data)
+{
+ ClutterDeviceManagerEvdev *manager_evdev;
+ ClutterDeviceManagerEvdevPrivate *priv;
+
+ g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER_EVDEV (evdev));
+
+ manager_evdev = CLUTTER_DEVICE_MANAGER_EVDEV (evdev);
+ priv = manager_evdev->priv;
+
+ priv->relative_motion_filter = filter;
+ priv->relative_motion_filter_user_data = user_data;
+}
+
/**
* clutter_evdev_set_keyboard_repeat:
* @evdev: the #ClutterDeviceManager created by the evdev backend
diff --git a/clutter/clutter/evdev/clutter-device-manager-evdev.h
b/clutter/clutter/evdev/clutter-device-manager-evdev.h
index c2dbe31..2b87a44 100644
--- a/clutter/clutter/evdev/clutter-device-manager-evdev.h
+++ b/clutter/clutter/evdev/clutter-device-manager-evdev.h
@@ -76,6 +76,13 @@ void _clutter_device_manager_evdev_constrain_pointer (ClutterDeviceManagerEvdev
float *new_x,
float *new_y);
+void _clutter_device_manager_evdev_filter_relative_motion (ClutterDeviceManagerEvdev *manager_evdev,
+ ClutterInputDevice *device,
+ float x,
+ float y,
+ float *dx,
+ float *dy);
+
void _clutter_device_manager_evdev_dispatch (ClutterDeviceManagerEvdev *manager_evdev);
static inline guint64
diff --git a/clutter/clutter/evdev/clutter-evdev.h b/clutter/clutter/evdev/clutter-evdev.h
index e17ec12..b64b136 100644
--- a/clutter/clutter/evdev/clutter-evdev.h
+++ b/clutter/clutter/evdev/clutter-evdev.h
@@ -97,6 +97,18 @@ void clutter_evdev_set_pointer_constrain_callback (ClutterDeviceManager
gpointer user_data,
GDestroyNotify user_data_notify);
+typedef void (*ClutterRelativeMotionFilter) (ClutterInputDevice *device,
+ float x,
+ float y,
+ float *dx,
+ float *dy,
+ gpointer user_data);
+
+CLUTTER_AVAILABLE_IN_MUTTER
+void clutter_evdev_set_relative_motion_filter (ClutterDeviceManager *evdev,
+ ClutterRelativeMotionFilter filter,
+ gpointer user_data);
+
CLUTTER_AVAILABLE_IN_1_16
void clutter_evdev_set_keyboard_map (ClutterDeviceManager *evdev,
struct xkb_keymap *keymap);
diff --git a/clutter/clutter/evdev/clutter-seat-evdev.c b/clutter/clutter/evdev/clutter-seat-evdev.c
index a15f17c..f6fdf9b 100644
--- a/clutter/clutter/evdev/clutter-seat-evdev.c
+++ b/clutter/clutter/evdev/clutter-seat-evdev.c
@@ -405,6 +405,13 @@ clutter_seat_evdev_notify_relative_motion (ClutterSeatEvdev *seat,
if (!_clutter_input_device_get_stage (input_device))
return;
+ _clutter_device_manager_evdev_filter_relative_motion (seat->manager_evdev,
+ input_device,
+ seat->pointer_x,
+ seat->pointer_y,
+ &dx,
+ &dy);
+
new_x = seat->pointer_x + dx;
new_y = seat->pointer_y + dy;
event = new_absolute_motion_event (seat, input_device,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]