Merge branch 'wip/mbiggio/quartz-device-axes-reset' into 'gtk-3-24'

quartz: mimic source device axes

See merge request GNOME/gtk!2208
This commit is contained in:
Emmanuele Bassi 2020-07-10 15:48:18 +00:00
commit e0da315783

View File

@ -197,6 +197,50 @@ create_core_device (GdkDeviceManager *device_manager,
return device;
}
static void
mimic_device_axes (GdkDevice *logical,
GdkDevice *physical)
{
double axis_min, axis_max, axis_resolution;
GdkAtom axis_label;
GdkAxisUse axis_use;
int axis_count;
int i;
axis_count = gdk_device_get_n_axes (physical);
for (i = 0; i < axis_count; i++)
{
_gdk_device_get_axis_info (physical, i, &axis_label, &axis_use, &axis_min,
&axis_max, &axis_resolution);
_gdk_device_add_axis (logical, axis_label, axis_use, axis_min,
axis_max, axis_resolution);
}
}
static void
translate_device_axes (GdkDevice *source_device,
gboolean active)
{
GdkSeat *seat = gdk_display_get_default_seat (_gdk_display);
GdkDevice *core_pointer = gdk_seat_get_pointer (seat);
g_object_freeze_notify (G_OBJECT (core_pointer));
_gdk_device_reset_axes (core_pointer);
if (active && source_device)
{
mimic_device_axes (core_pointer, source_device);
}
else
{
_gdk_device_add_axis (core_pointer, GDK_NONE, GDK_AXIS_X, 0, 0, 1);
_gdk_device_add_axis (core_pointer, GDK_NONE, GDK_AXIS_Y, 0, 0, 1);
}
g_object_thaw_notify (G_OBJECT (core_pointer));
}
void
_gdk_quartz_device_manager_register_device_for_ns_event (GdkDeviceManager *device_manager,
NSEvent *nsevent)
@ -290,6 +334,8 @@ _gdk_quartz_device_manager_register_device_for_ns_event (GdkDeviceManager *devic
}
}
translate_device_axes (device, [nsevent isEnteringProximity]);
if (self->num_active_devices)
[NSEvent setMouseCoalescingEnabled: FALSE];
else