shell/platform/glfw/flutter_glfw.cc
// Reports mouse button press to the Flutter engine.
Reports mouse button press to the Flutter engine.
Reports mouse button press to the Flutter engine .
static void GLFWMouseButtonCallback(GLFWwindow* window,
                                    int key,
                                    int action,
                                    int mods) {
  if (key != GLFW_MOUSE_BUTTON_LEFT) {
    return;
  }
  FlutterPointerEvent event = {};
  event.phase = (action == GLFW_PRESS) ? FlutterPointerPhase::kDown
                                       : FlutterPointerPhase::kUp;
  SetEventLocationFromCursorPosition(window, &event);
  SendPointerEventWithData(window, event);
  bool hover_enabled = GetSavedWindowState(window)->hover_tracking_enabled;
  if (!hover_enabled) {
    glfwSetCursorPosCallback(
        window, (action == GLFW_PRESS) ? GLFWCursorPositionCallback : nullptr);
  }
  if (hover_enabled) {
    glfwSetCursorEnterCallback(
        window, (action == GLFW_PRESS) ? nullptr : GLFWCursorEnterCallback);
  }
}
static void GLFWMouseButtonCallback ( GLFWwindow * window , int key , int action , int mods ) { if ( key != GLFW_MOUSE_BUTTON_LEFT ) { return ; } FlutterPointerEvent event = { } ; event . phase = ( action == GLFW_PRESS ) ? FlutterPointerPhase :: kDown : FlutterPointerPhase :: kUp ; SetEventLocationFromCursorPosition ( window , & event ) ; SendPointerEventWithData ( window , event ) ; bool hover_enabled = GetSavedWindowState ( window ) -> hover_tracking_enabled ; if ( ! hover_enabled ) { glfwSetCursorPosCallback ( window , ( action == GLFW_PRESS ) ? GLFWCursorPositionCallback : nullptr ) ; } if ( hover_enabled ) { glfwSetCursorEnterCallback ( window , ( action == GLFW_PRESS ) ? nullptr : GLFWCursorEnterCallback ) ; } }
Reports mouse button press to the Flutter engine.
Reports mouse button press to the Flutter engine .
// Flutter currently doesn't understand other buttons, so ignore anything // other than left. // If mouse tracking isn't already enabled, turn it on for the duration of // the drag to generate kMove events. // Disable enter/exit events while the mouse button is down; GLFW will send // an exit event when the mouse button is released, and the pointer should // stay valid until then.