[mutter] backends/native: Scale relative input motions with monitor scale
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] backends/native: Scale relative input motions with monitor scale
- Date: Mon, 27 Mar 2017 11:02:26 +0000 (UTC)
commit e60dfd5b2325b87f76468b4f3a29baef4c94e273
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Fri Feb 3 13:12:01 2017 +0800
backends/native: Scale relative input motions with monitor scale
To allow for more natural pointer movements from relative pointer
devices (e.g. mouse, touchpad, tablet tool in relative mode, etc), scale
the relative motion from libinput with the scale of the monitor. In
effect, this means that the pointer movement is twice as fast (physical
movement vs numbers of pixels passed) as before, but it also means that
the same physical movement crosses the distance in a GUI no matter if
it is on a HiDPI monitor or not.
https://bugzilla.gnome.org/show_bug.cgi?id=778119
src/backends/native/meta-backend-native.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 3cd1d11..90ab1e2 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -255,6 +255,25 @@ pointer_constrain_callback (ClutterInputDevice *device,
constrain_all_screen_monitors (device, monitor_manager, new_x, new_y);
}
+static void
+relative_motion_filter (ClutterInputDevice *device,
+ float x,
+ float y,
+ float *dx,
+ float *dy,
+ gpointer user_data)
+{
+ MetaMonitorManager *monitor_manager = user_data;
+
+ logical_monitor = meta_monitor_manager_get_logical_monitor_at (monitor_manager,
+ x, y);
+ if (!logical_monitor)
+ return;
+
+ *dx *= logical_monitor->scale;
+ *dy *= logical_monitor->scale;
+}
+
static ClutterBackend *
meta_backend_native_create_clutter_backend (MetaBackend *backend)
{
@@ -270,6 +289,8 @@ meta_backend_native_post_init (MetaBackend *backend)
clutter_evdev_set_pointer_constrain_callback (manager, pointer_constrain_callback,
NULL, NULL);
+ clutter_evdev_set_relative_motion_filter (manager, relative_motion_filter,
+ meta_backend_get_monitor_manager (backend));
}
static MetaIdleMonitor *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]