shell/platform/glfw/flutter_glfw.cc
// Sends a pointer event to the Flutter engine based on the given data.
//
// Any coordinate/distance values in |event_data| should be in screen
// coordinates; they will be adjusted to pixel values before being sent.
Sends a pointer event to the Flutter engine based on the given data.
Any coordinate/distance values in |event_data| should be in screen
coordinates; they will be adjusted to pixel values before being sent.
Sends a pointer event to the Flutter engine based on the given data . Any coordinate / distance values in |event_data| should be in screen coordinates ; they will be adjusted to pixel values before being sent .
static void SendPointerEventWithData(GLFWwindow* window,
                                     const FlutterPointerEvent& event_data) {
  auto* state = GetSavedWindowState(window);
  if (!state->pointer_currently_added &&
      event_data.phase != FlutterPointerPhase::kAdd) {
    FlutterPointerEvent event = {};
    event.phase = FlutterPointerPhase::kAdd;
    event.x = event_data.x;
    event.y = event_data.y;
    SendPointerEventWithData(window, event);
  }
  if (state->pointer_currently_added &&
      event_data.phase == FlutterPointerPhase::kAdd) {
    return;
  }
  FlutterPointerEvent event = event_data;
  event.struct_size = sizeof(event);
  event.timestamp =
      std::chrono::duration_cast<std::chrono::microseconds>(
          std::chrono::high_resolution_clock::now().time_since_epoch())
          .count();
  event.x *= state->window_pixels_per_screen_coordinate;
  event.y *= state->window_pixels_per_screen_coordinate;
  event.scroll_delta_x *= state->window_pixels_per_screen_coordinate;
  event.scroll_delta_y *= state->window_pixels_per_screen_coordinate;
  FlutterEngineSendPointerEvent(state->engine, &event, 1);
  if (event_data.phase == FlutterPointerPhase::kAdd) {
    state->pointer_currently_added = true;
  } else if (event_data.phase == FlutterPointerPhase::kRemove) {
    state->pointer_currently_added = false;
  }
}
static void SendPointerEventWithData ( GLFWwindow * window , const FlutterPointerEvent & event_data ) { auto * state = GetSavedWindowState ( window ) ; if ( ! state -> pointer_currently_added && event_data . phase != FlutterPointerPhase :: kAdd ) { FlutterPointerEvent event = { } ; event . phase = FlutterPointerPhase :: kAdd ; event . x = event_data . x ; event . y = event_data . y ; SendPointerEventWithData ( window , event ) ; } if ( state -> pointer_currently_added && event_data . phase == FlutterPointerPhase :: kAdd ) { return ; } FlutterPointerEvent event = event_data ; event . struct_size = sizeof ( event ) ; event . timestamp = std :: chrono :: duration_cast < std :: chrono :: microseconds > ( std :: chrono :: high_resolution_clock :: now ( ) . time_since_epoch ( ) ) . count ( ) ; event . x *= state -> window_pixels_per_screen_coordinate ; event . y *= state -> window_pixels_per_screen_coordinate ; event . scroll_delta_x *= state -> window_pixels_per_screen_coordinate ; event . scroll_delta_y *= state -> window_pixels_per_screen_coordinate ; FlutterEngineSendPointerEvent ( state -> engine , & event , 1 ) ; if ( event_data . phase == FlutterPointerPhase :: kAdd ) { state -> pointer_currently_added = true ; } else if ( event_data . phase == FlutterPointerPhase :: kRemove ) { state -> pointer_currently_added = false ; } }
Sends a pointer event to the Flutter engine based on the given data.
Sends a pointer event to the Flutter engine based on the given data .
// If sending anything other than an add, and the pointer isn't already added, // synthesize an add to satisfy Flutter's expectations about events. // Don't double-add (e.g., if events are delivered out of order, so an add has // already been synthesized). // Set metadata that's always the same regardless of the event. // Convert all screen coordinates to pixel coordinates.