[session][input] Use event_time in pointer hacks

event_time is now being propagated through the input pipeline so the
pointer hacks should use those values rather than creating new
timestamps.

Bug: 44910

Change-Id: I8e6ece3d449371c03f4639c4e57bfb4ef9187fc9
diff --git a/session_shells/ermine/session/src/mouse_pointer_hack.rs b/session_shells/ermine/session/src/mouse_pointer_hack.rs
index 7e5f3b7..751657d 100644
--- a/session_shells/ermine/session/src/mouse_pointer_hack.rs
+++ b/session_shells/ermine/session/src/mouse_pointer_hack.rs
@@ -3,16 +3,10 @@
 // found in the LICENSE file.
 
 use {
-    async_trait::async_trait,
-    fidl_fuchsia_ui_input as fidl_ui_input,
-    fidl_fuchsia_ui_policy::PointerCaptureListenerHackProxy,
-    fuchsia_zircon::{ClockId, Time},
-    futures::lock::Mutex,
-    input::input_device,
-    input::input_handler::InputHandler,
-    input::mouse,
-    std::collections::HashSet,
-    std::sync::Arc,
+    async_trait::async_trait, fidl_fuchsia_ui_input as fidl_ui_input,
+    fidl_fuchsia_ui_policy::PointerCaptureListenerHackProxy, futures::lock::Mutex,
+    input::input_device, input::input_handler::InputHandler, input::mouse,
+    std::collections::HashSet, std::sync::Arc,
 };
 
 /// The location of a mouse cursor.
@@ -57,12 +51,13 @@
             input_device::InputEvent {
                 device_event: input_device::InputDeviceEvent::Mouse(mouse_event),
                 device_descriptor: input_device::InputDeviceDescriptor::Mouse(mouse_descriptor),
-                ..
+                event_time,
             } => {
                 self.update_cursor_position(&mouse_event).await;
                 self.send_event_to_listeners(
                     mouse_event.phase,
                     &mouse_event.buttons,
+                    *event_time,
                     &mouse_descriptor,
                 )
                 .await;
@@ -127,17 +122,19 @@
     /// # Parameters
     /// - `phase`: The phase of the buttons associated with the mouse event.
     /// - `buttons`: The buttons associated with the event.
+    /// - `event_time`: The time the event was first reported.
     /// - `device_descriptor`: The descriptor for the device that generated the event.
     async fn send_event_to_listeners(
         &self,
         phase: fidl_ui_input::PointerEventPhase,
         buttons: &HashSet<mouse::MouseButton>,
+        event_time: input_device::EventTime,
         device_descriptor: &mouse::MouseDeviceDescriptor,
     ) {
         let buttons = mouse::get_u32_from_buttons(buttons);
 
         let mut pointer = fidl_ui_input::PointerEvent {
-            event_time: Time::get(ClockId::Monotonic).into_nanos() as u64,
+            event_time: event_time,
             device_id: device_descriptor.device_id,
             pointer_id: 0,
             type_: fidl_ui_input::PointerEventType::Mouse,
diff --git a/session_shells/ermine/session/src/touch_pointer_hack.rs b/session_shells/ermine/session/src/touch_pointer_hack.rs
index 8e3f367..3296e36 100644
--- a/session_shells/ermine/session/src/touch_pointer_hack.rs
+++ b/session_shells/ermine/session/src/touch_pointer_hack.rs
@@ -3,15 +3,9 @@
 // found in the LICENSE file.
 
 use {
-    async_trait::async_trait,
-    fidl_fuchsia_ui_input as fidl_ui_input,
-    fidl_fuchsia_ui_policy::PointerCaptureListenerHackProxy,
-    fuchsia_zircon::{ClockId, Time},
-    futures::lock::Mutex,
-    input::input_device,
-    input::input_handler::InputHandler,
-    input::touch,
-    std::sync::Arc,
+    async_trait::async_trait, fidl_fuchsia_ui_input as fidl_ui_input,
+    fidl_fuchsia_ui_policy::PointerCaptureListenerHackProxy, futures::lock::Mutex,
+    input::input_device, input::input_handler::InputHandler, input::touch, std::sync::Arc,
 };
 
 /// A [`TouchPointerHack`] observes touch events and sends them to observers.
@@ -47,9 +41,9 @@
                 device_event: input_device::InputDeviceEvent::Touch(touch_event),
                 device_descriptor:
                     input_device::InputDeviceDescriptor::Touch(touch_device_descriptor),
-                ..
+                event_time,
             } => {
-                self.handle_touch_event(touch_event, touch_device_descriptor).await;
+                self.handle_touch_event(touch_event, touch_device_descriptor, *event_time).await;
             }
             _ => {}
         }
@@ -71,6 +65,7 @@
         &self,
         touch_event: &touch::TouchEvent,
         touch_descriptor: &touch::TouchDeviceDescriptor,
+        event_time: input_device::EventTime,
     ) {
         // The order in which events are sent to clients.
         let ordered_phases = vec![
@@ -85,8 +80,12 @@
             let contacts: Vec<touch::TouchContact> =
                 touch_event.contacts.get(&phase).map_or(vec![], |contacts| contacts.to_vec());
             for contact in contacts {
-                let mut command =
-                    self.create_pointer_input_command(phase, contact, &touch_descriptor);
+                let mut command = self.create_pointer_input_command(
+                    phase,
+                    contact,
+                    event_time,
+                    &touch_descriptor,
+                );
                 let listeners = self.listeners.lock().await;
                 for listener in &mut listeners.iter() {
                     let listener = listener;
@@ -101,12 +100,13 @@
         &self,
         phase: fidl_ui_input::PointerEventPhase,
         contact: touch::TouchContact,
+        event_time: input_device::EventTime,
         touch_descriptor: &touch::TouchDeviceDescriptor,
     ) -> fidl_ui_input::PointerEvent {
         let (x, y) = self.device_coordinate_from_contact(&contact, &touch_descriptor);
 
         fidl_ui_input::PointerEvent {
-            event_time: Time::get(ClockId::Monotonic).into_nanos() as u64,
+            event_time: event_time,
             device_id: touch_descriptor.device_id,
             pointer_id: contact.id,
             type_: fidl_ui_input::PointerEventType::Touch,