From 8f3e503c04e248c5614dfa66a11277089c17f985 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 4 Aug 2023 12:34:35 +0200 Subject: [PATCH] backends: Use ClutterEvent getter methods Part-of: --- src/backends/meta-backend.c | 9 ++++++--- src/backends/meta-input-capture-session.c | 18 +++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 51e1e590c..d7e6cf371 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -1032,10 +1032,13 @@ update_last_device_from_event (MetaBackend *backend, ClutterEvent *event) { ClutterInputDevice *source; + ClutterEventType event_type; + + event_type = clutter_event_type (event); /* Handled elsewhere */ - if (event->type == CLUTTER_DEVICE_ADDED || - event->type == CLUTTER_DEVICE_REMOVED) + if (event_type == CLUTTER_DEVICE_ADDED || + event_type == CLUTTER_DEVICE_REMOVED) return; source = clutter_event_get_source_device (event); @@ -1097,7 +1100,7 @@ dispatch_clutter_event (MetaBackend *backend) if (event) { g_warn_if_fail (!priv->in_init || - event->type == CLUTTER_DEVICE_ADDED); + clutter_event_type (event) == CLUTTER_DEVICE_ADDED); clutter_stage_handle_event (stage, event); meta_backend_update_from_event (backend, event); diff --git a/src/backends/meta-input-capture-session.c b/src/backends/meta-input-capture-session.c index faaf11b84..03b2324d8 100644 --- a/src/backends/meta-input-capture-session.c +++ b/src/backends/meta-input-capture-session.c @@ -1385,15 +1385,20 @@ gboolean meta_input_capture_session_process_event (MetaInputCaptureSession *session, const ClutterEvent *event) { - switch (event->type) + double dx, dy, dx_constrained, dy_constrained; + + switch (clutter_event_type (event)) { case CLUTTER_MOTION: if (!session->eis_pointer) return TRUE; + clutter_event_get_relative_motion (event, &dx, &dy, NULL, NULL, + &dx_constrained, &dy_constrained); + eis_device_pointer_motion (session->eis_pointer, - event->motion.dx - event->motion.dx_constrained, - event->motion.dy - event->motion.dy_constrained); + dx - dx_constrained, + dy - dy_constrained); eis_device_frame (session->eis_pointer, eis_now (session->eis)); break; case CLUTTER_BUTTON_PRESS: @@ -1420,6 +1425,7 @@ meta_input_capture_session_process_event (MetaInputCaptureSession *session, break; case CLUTTER_SCROLL: { + ClutterScrollFinishFlags finish_flags; const double factor = 10.0; bool stop_x = false, stop_y = false; double dx, dy; @@ -1427,9 +1433,11 @@ meta_input_capture_session_process_event (MetaInputCaptureSession *session, if (!session->eis_pointer) return TRUE; - if ((event->scroll.finish_flags & CLUTTER_SCROLL_FINISHED_HORIZONTAL)) + finish_flags = clutter_event_get_scroll_finish_flags (event); + + if ((finish_flags & CLUTTER_SCROLL_FINISHED_HORIZONTAL)) stop_x = true; - if ((event->scroll.finish_flags & CLUTTER_SCROLL_FINISHED_HORIZONTAL)) + if ((finish_flags & CLUTTER_SCROLL_FINISHED_HORIZONTAL)) stop_y = true; if (stop_x || stop_y)