backends/native: Refactor LIBINPUT_EVENT_POINTER_AXIS handling

Move the logic to handle LIBINPUT_EVENT_POINTER_AXIS events to its own
function (handle_pointer_scroll).

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
This commit is contained in:
José Expósito 2021-09-20 19:52:59 +02:00 committed by Marge Bot
parent 364902de2d
commit 2e8aef6f8a

View File

@ -1959,6 +1959,45 @@ notify_discrete_axis (MetaSeatImpl *seat_impl,
scroll_source);
}
static void
handle_pointer_scroll (MetaSeatImpl *seat_impl,
struct libinput_event *event)
{
struct libinput_device *libinput_device = libinput_event_get_device (event);
ClutterInputDevice *device;
uint64_t time_us;
enum libinput_pointer_axis_source source;
struct libinput_event_pointer *axis_event =
libinput_event_get_pointer_event (event);
ClutterScrollSource scroll_source;
device = libinput_device_get_user_data (libinput_device);
time_us = libinput_event_pointer_get_time_usec (axis_event);
source = libinput_event_pointer_get_axis_source (axis_event);
scroll_source = translate_scroll_source (source);
/* libinput < 0.8 sent wheel click events with value 10. Since 0.8
* the value is the angle of the click in degrees. To keep
* backwards-compat with existing clients, we just send multiples of
* the click count.
*/
switch (scroll_source)
{
case CLUTTER_SCROLL_SOURCE_WHEEL:
notify_discrete_axis (seat_impl, device, time_us, scroll_source,
axis_event);
break;
case CLUTTER_SCROLL_SOURCE_FINGER:
case CLUTTER_SCROLL_SOURCE_CONTINUOUS:
case CLUTTER_SCROLL_SOURCE_UNKNOWN:
notify_continuous_axis (seat_impl, device, time_us, scroll_source,
axis_event);
break;
}
}
static void
process_tablet_axis (MetaSeatImpl *seat_impl,
struct libinput_event *event)
@ -2135,36 +2174,7 @@ process_device_event (MetaSeatImpl *seat_impl,
case LIBINPUT_EVENT_POINTER_AXIS:
{
uint64_t time_us;
enum libinput_pointer_axis_source source;
struct libinput_event_pointer *axis_event =
libinput_event_get_pointer_event (event);
ClutterScrollSource scroll_source;
device = libinput_device_get_user_data (libinput_device);
time_us = libinput_event_pointer_get_time_usec (axis_event);
source = libinput_event_pointer_get_axis_source (axis_event);
scroll_source = translate_scroll_source (source);
/* libinput < 0.8 sent wheel click events with value 10. Since 0.8
the value is the angle of the click in degrees. To keep
backwards-compat with existing clients, we just send multiples of
the click count. */
switch (scroll_source)
{
case CLUTTER_SCROLL_SOURCE_WHEEL:
notify_discrete_axis (seat_impl, device, time_us, scroll_source,
axis_event);
break;
case CLUTTER_SCROLL_SOURCE_FINGER:
case CLUTTER_SCROLL_SOURCE_CONTINUOUS:
case CLUTTER_SCROLL_SOURCE_UNKNOWN:
notify_continuous_axis (seat_impl, device, time_us, scroll_source,
axis_event);
break;
}
handle_pointer_scroll (seat_impl, event);
break;
}