mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 03:20:46 -05:00
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
This commit is contained in:
parent
df45c50d0b
commit
e60dfd5b23
@ -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 *
|
||||
|
Loading…
Reference in New Issue
Block a user