| Flutter Linux Embedder |

Typedefs | Enumerations | Functions
fl_engine_private.h File Reference
`#include <glib-object.h>`
`#include "flutter/shell/platform/embedder/embedder.h"`
`#include "flutter/shell/platform/linux/fl_display_monitor.h"`
`#include "flutter/shell/platform/linux/fl_keyboard_manager.h"`
`#include "flutter/shell/platform/linux/fl_mouse_cursor_handler.h"`
`#include "flutter/shell/platform/linux/fl_opengl_manager.h"`
`#include "flutter/shell/platform/linux/fl_renderable.h"`
`#include "flutter/shell/platform/linux/fl_task_runner.h"`
`#include "flutter/shell/platform/linux/fl_text_input_handler.h"`
`#include "flutter/shell/platform/linux/fl_windowing_handler.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_dart_project.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"`

Go to the source code of this file.

## Typedefs
typedef gboolean(* | FlEnginePlatformMessageHandler) (FlEngine *engine, const gchar *channel, GBytes *message, const FlutterPlatformMessageResponseHandle *response_handle, gpointer user_data)

## Enumerations
enum | FlEngineError { FL_ENGINE_ERROR_FAILED }

## Functions
GQuark | fl_engine_error_quark (void) G_GNUC_CONST
FlEngine * | fl_engine_new_with_binary_messenger (FlBinaryMessenger *binary_messenger)
FlutterRendererType | fl_engine_get_renderer_type (FlEngine *engine)
FlOpenGLManager * | fl_engine_get_opengl_manager (FlEngine *engine)
FlDisplayMonitor * | fl_engine_get_display_monitor (FlEngine *engine)
gboolean | fl_engine_start (FlEngine *engine, GError **error)
FlutterEngineProcTable * | fl_engine_get_embedder_api (FlEngine *engine)
void | fl_engine_notify_display_update (FlEngine *engine, const FlutterEngineDisplay *displays, size_t displays_length)
void | fl_engine_set_implicit_view (FlEngine *engine, FlRenderable *renderable)
FlutterViewId | fl_engine_add_view (FlEngine *engine, FlRenderable *renderable, size_t width, size_t height, double pixel_ratio, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
gboolean | fl_engine_add_view_finish (FlEngine *engine, GAsyncResult *result, GError **error)
FlRenderable * | fl_engine_get_renderable (FlEngine *engine, FlutterViewId view_id)
void | fl_engine_remove_view (FlEngine *engine, FlutterViewId view_id, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
gboolean | fl_engine_remove_view_finish (FlEngine *engine, GAsyncResult *result, GError **error)
void | fl_engine_set_platform_message_handler (FlEngine *engine, FlEnginePlatformMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
void | fl_engine_send_window_metrics_event (FlEngine *engine, FlutterEngineDisplayId display_id, FlutterViewId view_id, size_t width, size_t height, double pixel_ratio)
void | fl_engine_send_mouse_pointer_event (FlEngine *engine, FlutterViewId view_id, FlutterPointerPhase phase, size_t timestamp, double x, double y, FlutterPointerDeviceKind device_kind, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
void | fl_engine_send_touch_up_event (FlEngine *engine, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void | fl_engine_send_touch_down_event (FlEngine *engine, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void | fl_engine_send_touch_move_event (FlEngine *engine, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void | fl_engine_send_touch_add_event (FlEngine *engine, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void | fl_engine_send_touch_remove_event (FlEngine *engine, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void | fl_engine_send_pointer_pan_zoom_event (FlEngine *engine, FlutterViewId view_id, size_t timestamp, double x, double y, FlutterPointerPhase phase, double pan_x, double pan_y, double scale, double rotation)
void | fl_engine_send_key_event (FlEngine *engine, const FlutterKeyEvent *event, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
gboolean | fl_engine_send_key_event_finish (FlEngine *engine, GAsyncResult *result, gboolean *handled, GError **error)
void | fl_engine_dispatch_semantics_action (FlEngine *engine, FlutterViewId view_id, uint64_t node_id, FlutterSemanticsAction action, GBytes *data)
gboolean | fl_engine_send_platform_message_response (FlEngine *engine, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
void | fl_engine_send_platform_message (FlEngine *engine, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
GBytes * | fl_engine_send_platform_message_finish (FlEngine *engine, GAsyncResult *result, GError **error)
FlTaskRunner * | fl_engine_get_task_runner (FlEngine *engine)
void | fl_engine_execute_task (FlEngine *engine, FlutterTask *task)
gboolean | fl_engine_mark_texture_frame_available (FlEngine *engine, int64_t texture_id)
gboolean | fl_engine_register_external_texture (FlEngine *engine, int64_t texture_id)
gboolean | fl_engine_unregister_external_texture (FlEngine *engine, int64_t texture_id)
void | fl_engine_update_accessibility_features (FlEngine *engine, int32_t flags)
void | fl_engine_request_app_exit (FlEngine *engine)
FlWindowingHandler * | fl_engine_get_windowing_handler (FlEngine *engine)
FlKeyboardManager * | fl_engine_get_keyboard_manager (FlEngine *engine)
FlTextInputHandler * | fl_engine_get_text_input_handler (FlEngine *engine)
FlMouseCursorHandler * | fl_engine_get_mouse_cursor_handler (FlEngine *engine)
FlEngine * | fl_engine_for_id (int64_t handle)

## Typedef Documentation

## ◆ FlEnginePlatformMessageHandler

typedef gboolean(* FlEnginePlatformMessageHandler) (FlEngine *engine, const gchar *channel, GBytes *message, const FlutterPlatformMessageResponseHandle *response_handle, gpointer user_data)

FlEnginePlatformMessageHandler: @engine: an #FlEngine. @channel: channel message received on. @message: message content received from Dart. @response_handle: a handle to respond to the message with. @user_data: (closure): data provided when registering this handler.

Function called when platform messages are received.

Returns: TRUE if message has been accepted.

Definition at line 47 of file fl_engine_private.h.

## Enumeration Type Documentation

## ◆ FlEngineError

enum FlEngineError

FlEngineError: Errors for #FlEngine objects to set on failures.

Enumerator
FL_ENGINE_ERROR_FAILED |

Definition at line 29 of file fl_engine_private.h.

29 {
30 FL_ENGINE_ERROR_FAILED,
31 } FlEngineError;
FlEngineError
FlEngineError
Definition: fl_engine_private.h:29
FL_ENGINE_ERROR_FAILED
@ FL_ENGINE_ERROR_FAILED
Definition: fl_engine_private.h:30

## Function Documentation

## ◆ fl_engine_add_view()

FlutterViewId fl_engine_add_view | ( | FlEngine * | engine,
|  | FlRenderable * | renderable,
|  | size_t | width,
|  | size_t | height,
|  | double | pixel_ratio,
|  | GCancellable * | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data
| ) |  |

fl_engine_add_view: @engine: an #FlEngine. @renderable: the object that will render this view. @width: width of view in pixels. @height: height of view in pixels. @pixel_ratio: scale factor for view. @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the view is added. @user_data: (closure): user data to pass to @callback.

Asynchronously add a new view. The returned view ID should not be used until this function completes.

Returns: the ID for the view.

Definition at line 884 of file fl_engine.cc.

891 {
892 g_return_val_if_fail(FL_IS_ENGINE(self), -1);
893
894 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
895
896 FlutterViewId view_id = self->next_view_id;
897 self->next_view_id++;
898
899 GWeakRef* ref = g_new(GWeakRef, 1);
900 g_weak_ref_init(ref, G_OBJECT(renderable));
901 g_hash_table_insert(self->renderables_by_view_id, GINT_TO_POINTER(view_id),
902 ref);
903
904 // We don't know which display this view will open on, so set to zero and this
905 // will be updated in a following FlutterWindowMetricsEvent
906 FlutterEngineDisplayId display_id = 0;
907
908 FlutterWindowMetricsEvent metrics = {};
909 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
910 metrics.width = width;
911 metrics.height = height;
912 metrics.pixel_ratio = pixel_ratio;
913 metrics.display_id = display_id;
914 metrics.view_id = view_id;
915 FlutterAddViewInfo info;
916 info.struct_size = sizeof(FlutterAddViewInfo);
917 info.view_id = view_id;
918 info.view_metrics = &metrics;
919 info.user_data = g_object_ref(task);
920 info.add_view_callback = view_added_cb;
921 FlutterEngineResult result = self->embedder_api.AddView(self->engine, &info);
922 if (result != kSuccess) {
923 g_task_return_new_error(task, fl_engine_error_quark(),
924 FL_ENGINE_ERROR_FAILED, "AddView returned %d",
925 result);
926 // This would have been done in the callback, but that won't occur now.
927 g_object_unref(task);
928 }
929
930 return view_id;
931 }
height
self height
Definition: fl_compositor_software.cc:43
g_autoptr
g_autoptr(GMutexLocker) locker
width
self width
Definition: fl_compositor_software.cc:42
view_added_cb
static void view_added_cb(const FlutterAddViewResult *result)
Definition: fl_engine.cc:171
fl_engine_error_quark
GQuark fl_engine_error_quark(void) G_GNUC_CONST
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
view_id
G_BEGIN_DECLS FlutterViewId view_id
Definition: fl_view_accessible.h:49

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), height, user_data, view_added_cb(), view_id, and width.

Referenced by fl_view_new_for_engine(), and TEST().

## ◆ fl_engine_add_view_finish()

gboolean fl_engine_add_view_finish | ( | FlEngine * | engine,
|  | GAsyncResult * | result,
|  | GError ** | error
| ) |  |

fl_engine_add_view_finish: @engine: an #FlEngine.

Returns
  : a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_add_view().

Returns: TRUE on success.

Definition at line 933 of file fl_engine.cc.

935 {
936 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
937 return g_task_propagate_boolean(G_TASK(result), error);
938 }
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40

References error.

Referenced by add_view_cb(), add_view_engine_error_cb(), add_view_error_cb(), and view_added_cb().

## ◆ fl_engine_dispatch_semantics_action()

void fl_engine_dispatch_semantics_action | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | uint64_t | node_id,
|  | FlutterSemanticsAction | action,
|  | GBytes * | data
| ) |  |

fl_engine_dispatch_semantics_action: @engine: an #FlEngine. @view_id: the view that the event occured on. @node_id: the semantics action identifier. @action: the action being dispatched. @data: (allow-none): data associated with the action.

Definition at line 1366 of file fl_engine.cc.

1370 {
1371 g_return_if_fail(FL_IS_ENGINE(self));
1372
1373 if (self->engine == nullptr) {
1374 return;
1375 }
1376
1377 const uint8_t* action_data = nullptr;
1378 size_t action_data_length = 0;
1379 if (data != nullptr) {
1380 action_data = static_cast<const uint8_t*>(
1381 g_bytes_get_data(data, &action_data_length));
1382 }
1383
1384 FlutterSendSemanticsActionInfo info;
1385 info.struct_size = sizeof(FlutterSendSemanticsActionInfo);
1386 info.view_id = view_id;
1387 info.node_id = node_id;
1388 info.action = action;
1389 info.data = action_data;
1390 info.data_length = action_data_length;
1391 self->embedder_api.SendSemanticsAction(self->engine, &info);
1392 }
action
FlutterSemanticsAction action
Definition: fl_accessible_node.cc:86

References action, and view_id.

Referenced by fl_accessible_node_perform_action_impl(), and TEST().

## ◆ fl_engine_error_quark()

GQuark fl_engine_error_quark | ( | void |  | ) |

Referenced by fl_engine_add_view(), fl_engine_remove_view(), fl_engine_send_key_event(), fl_engine_send_platform_message(), fl_engine_send_platform_message_response(), fl_engine_start(), view_added_cb(), and view_removed_cb().

## ◆ fl_engine_execute_task()

void fl_engine_execute_task | ( | FlEngine * | engine,
|  | FlutterTask * | task
| ) |  |

fl_engine_execute_task: @engine: an #FlEngine. @task: a #FlutterTask to execute.

Executes given Flutter task.

Definition at line 1426 of file fl_engine.cc.

1426 {
1427 g_return_if_fail(FL_IS_ENGINE(self));
1428 self->embedder_api.RunTask(self->engine, task);
1429 }

Referenced by fl_task_runner_process_expired_tasks_locked().

## ◆ fl_engine_for_id()

FlEngine* fl_engine_for_id | ( | int64_t | handle | ) |

fl_engine_for_id: @handle: an engine identifier obtained through PlatformDispatcher.instance.engineId.

Returns Flutter engine associated with the identifier. The identifier must be valid and for a running engine otherwise the behavior is undefined. Must be called from the main thread.

Returns: a #FlEngine or NULL.

Definition at line 687 of file fl_engine.cc.

687 {
688 void* engine = reinterpret_cast<void*>(id);
689 g_return_val_if_fail(FL_IS_ENGINE(engine), nullptr);
690 return FL_ENGINE(engine);
691 }
id
int64_t id
Definition: fl_pixel_buffer_texture.cc:28

References id.

Referenced by TEST().

## ◆ fl_engine_get_display_monitor()

FlDisplayMonitor* fl_engine_get_display_monitor | ( | FlEngine * | engine | ) |

fl_engine_get_display_monitor: @engine: an #FlEngine.

Gets the display monitor used by this engine.

Returns: an #FlDisplayMonitor.

Definition at line 717 of file fl_engine.cc.

717 {
718 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
719 return self->display_monitor;
720 }

Referenced by handle_geometry_changed(), and TEST().

## ◆ fl_engine_get_embedder_api()

FlutterEngineProcTable* fl_engine_get_embedder_api | ( | FlEngine * | engine | ) |

fl_engine_get_embedder_api: @engine: an #FlEngine.

Gets the embedder API proc table, allowing modificiations for unit testing.

Returns: a mutable pointer to the embedder API proc table.

Definition at line 860 of file fl_engine.cc.

860 {
861 return &(self->embedder_api);
862 }

Referenced by TEST().

## ◆ fl_engine_get_keyboard_manager()

FlKeyboardManager* fl_engine_get_keyboard_manager | ( | FlEngine * | engine | ) |

fl_engine_get_keyboard_manager: @engine: an #FlEngine.

Gets the keyboard manager used by this engine.

Returns: an #FlKeyboardManager.

Definition at line 1458 of file fl_engine.cc.

1458 {
1459 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1460 return self->keyboard_manager;
1461 }

Referenced by handle_key_event(), sync_modifier_if_needed(), and TEST().

## ◆ fl_engine_get_mouse_cursor_handler()

FlMouseCursorHandler* fl_engine_get_mouse_cursor_handler | ( | FlEngine * | engine | ) |

fl_engine_get_mouse_cursor_handler: @engine: an #FlEngine.

Gets the mouse cursor handler used by this engine.

Returns: an #FlMouseCursorHandler.

Definition at line 1468 of file fl_engine.cc.

1468 {
1469 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1470 return self->mouse_cursor_handler;
1471 }

Referenced by cursor_changed_cb(), fl_view_dispose(), setup_cursor(), and TEST().

## ◆ fl_engine_get_opengl_manager()

FlOpenGLManager* fl_engine_get_opengl_manager | ( | FlEngine * | engine | ) |

fl_engine_get_opengl_manager: @engine: an #FlEngine.

Gets the OpenGL manager used by this engine.

Returns: an #FlOpenGLManager.

Definition at line 712 of file fl_engine.cc.

712 {
713 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
714 return self->opengl_manager;
715 }

Referenced by realize_cb(), and setup_opengl().

## ◆ fl_engine_get_renderable()

FlRenderable* fl_engine_get_renderable | ( | FlEngine * | engine,
|  | FlutterViewId | view_id
| ) |  |

fl_engine_get_renderable: @engine: an #FlEngine. @view_id: ID to check.

Gets the renderable associated with the give view ID.

Returns: (transfer full): a reference to an #FlRenderable or NULL if none for this ID.

Definition at line 940 of file fl_engine.cc.

940 {
941 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
942
943 GWeakRef* ref = static_cast<GWeakRef*>(g_hash_table_lookup(
944 self->renderables_by_view_id, GINT_TO_POINTER(view_id)));
945 return FL_RENDERABLE(g_weak_ref_get(ref));
946 }

References view_id.

## ◆ fl_engine_get_renderer_type()

FlutterRendererType fl_engine_get_renderer_type | ( | FlEngine * | engine | ) |

fl_engine_get_renderer_type: @engine: an #FlEngine.

Gets the rendering type used by this engine.

Returns: type of rendering used.

Definition at line 707 of file fl_engine.cc.

707 {
708 g_return_val_if_fail(FL_IS_ENGINE(self), static_cast<FlutterRendererType>(0));
709 return self->renderer_type;
710 }

Referenced by realize_cb().

## ◆ fl_engine_get_task_runner()

FlTaskRunner* fl_engine_get_task_runner | ( | FlEngine * | engine | ) |

fl_engine_get_task_runner: @engine: an #FlEngine.

Returns
  : a #FlTaskRunner.

Returns: task runner responsible for scheduling Flutter tasks.

Definition at line 1421 of file fl_engine.cc.

1421 {
1422 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1423 return self->task_runner;
1424 }

Referenced by setup_opengl(), setup_software(), and TEST().

## ◆ fl_engine_get_text_input_handler()

FlTextInputHandler* fl_engine_get_text_input_handler | ( | FlEngine * | engine | ) |

fl_engine_get_text_input_handler: @engine: an #FlEngine.

Gets the text input handler used by this engine.

Returns: an #FlTextInputHandler.

Definition at line 1463 of file fl_engine.cc.

1463 {
1464 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1465 return self->text_input_handler;
1466 }

Referenced by fl_view_focus_in_event(), and handle_key_event().

## ◆ fl_engine_get_windowing_handler()

FlWindowingHandler* fl_engine_get_windowing_handler | ( | FlEngine * | engine | ) |

fl_engine_get_windowing_handler: @engine: an #FlEngine.

Gets the windowing handler used by this engine.

Returns: an #FlWindowingHandler.

Definition at line 1453 of file fl_engine.cc.

1453 {
1454 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1455 return self->windowing_handler;
1456 }

Referenced by fl_application_activate(), and TEST().

## ◆ fl_engine_mark_texture_frame_available()

gboolean fl_engine_mark_texture_frame_available | ( | FlEngine * | engine,
|  | int64_t | texture_id
| ) |  |

fl_engine_mark_texture_frame_available: @engine: an #FlEngine. @texture_id: the identifier of the texture whose frame has been updated.

Tells the Flutter engine that a new texture frame is available for the given texture.

Returns: TRUE on success.

Definition at line 1394 of file fl_engine.cc.

1395 {
1396 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1397 return self->embedder_api.MarkExternalTextureFrameAvailable(
1398 self->engine, texture_id) == kSuccess;
1399 }
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24

References texture_id.

Referenced by mark_texture_frame_available().

## ◆ fl_engine_new_with_binary_messenger()

FlEngine* fl_engine_new_with_binary_messenger | ( | FlBinaryMessenger * | binary_messenger | ) |

fl_engine_new_with_binary_messenger: @binary_messenger: an #FlBinaryMessenger.

Creates a new engine with a custom binary messenger. Used for testing.

Returns: a new #FlEngine.

Definition at line 697 of file fl_engine.cc.

698 {
699 g_autoptr(FlDartProject) project = fl_dart_project_new();
700 return fl_engine_new_full(project, binary_messenger);
701 }
fl_dart_project_new
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
Definition: fl_dart_project.cc:52
fl_engine_new_full
static FlEngine * fl_engine_new_full(FlDartProject *project, FlBinaryMessenger *binary_messenger)
Definition: fl_engine.cc:650

References fl_dart_project_new(), fl_engine_new_full(), and g_autoptr().

Referenced by TEST().

## ◆ fl_engine_notify_display_update()

void fl_engine_notify_display_update | ( | FlEngine * | engine,
|  | const FlutterEngineDisplay * | displays,
|  | size_t | displays_length
| ) |  |

fl_engine_notify_display_update: @engine: an #FlEngine. @displays: displays present on the system. @displays_length: length of @displays.

Notify the current displays that are in the system.

Definition at line 864 of file fl_engine.cc.

866 {
867 g_return_if_fail(FL_IS_ENGINE(self));
868
869 FlutterEngineResult result = self->embedder_api.NotifyDisplayUpdate(
870 self->engine, kFlutterEngineDisplaysUpdateTypeStartup, displays,
871 displays_length);
872 if (result != kSuccess) {
873 g_warning("Failed to notify display update to Flutter engine: %d", result);
874 }
875 }

Referenced by notify_display_update(), and TEST().

## ◆ fl_engine_register_external_texture()

gboolean fl_engine_register_external_texture | ( | FlEngine * | engine,
|  | int64_t | texture_id
| ) |  |

fl_engine_register_external_texture: @engine: an #FlEngine. @texture_id: the identifier of the texture that is available.

Tells the Flutter engine that a new external texture is available.

Returns: TRUE on success.

Definition at line 1401 of file fl_engine.cc.

1402 {
1403 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1404 return self->embedder_api.RegisterExternalTexture(self->engine, texture_id) ==
1405 kSuccess;
1406 }

References texture_id.

Referenced by register_texture().

## ◆ fl_engine_remove_view()

void fl_engine_remove_view | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | GCancellable * | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data
| ) |  |

fl_engine_remove_view: @engine: an #FlEngine. @view_id: ID to remove. @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the view is added. @user_data: (closure): user data to pass to @callback.

Removes a view previously added with fl_engine_add_view().

Definition at line 948 of file fl_engine.cc.

952 {
953 g_return_if_fail(FL_IS_ENGINE(self));
954
955 g_hash_table_remove(self->renderables_by_view_id, GINT_TO_POINTER(view_id));
956
957 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
958
959 FlutterRemoveViewInfo info;
960 info.struct_size = sizeof(FlutterRemoveViewInfo);
961 info.view_id = view_id;
962 info.user_data = g_object_ref(task);
963 info.remove_view_callback = view_removed_cb;
964 FlutterEngineResult result =
965 self->embedder_api.RemoveView(self->engine, &info);
966 if (result != kSuccess) {
967 g_task_return_new_error(task, fl_engine_error_quark(),
968 FL_ENGINE_ERROR_FAILED, "RemoveView returned %d",
969 result);
970 // This would have been done in the callback, but that won't occur now.
971 g_object_unref(task);
972 }
973 }
view_removed_cb
static void view_removed_cb(const FlutterRemoveViewResult *result)
Definition: fl_engine.cc:182

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), user_data, view_id, and view_removed_cb().

Referenced by fl_view_dispose(), and TEST().

## ◆ fl_engine_remove_view_finish()

gboolean fl_engine_remove_view_finish | ( | FlEngine * | engine,
|  | GAsyncResult * | result,
|  | GError ** | error
| ) |  |

fl_engine_remove_view_finish: @engine: an #FlEngine.

Returns
  : a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_remove_view().

Returns: TRUE on succcess.

Definition at line 975 of file fl_engine.cc.

977 {
978 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
979 return g_task_propagate_boolean(G_TASK(result), error);
980 }

References error.

Referenced by remove_view_cb(), remove_view_engine_error_cb(), and remove_view_error_cb().

## ◆ fl_engine_request_app_exit()

void fl_engine_request_app_exit | ( | FlEngine * | engine | ) |

fl_engine_request_app_exit: @engine: an #FlEngine.

Request the application exits.

Definition at line 1448 of file fl_engine.cc.

1448 {
1449 g_return_if_fail(FL_IS_ENGINE(self));
1450 fl_platform_handler_request_app_exit(self->platform_handler);
1451 }
fl_platform_handler_request_app_exit
void fl_platform_handler_request_app_exit(FlPlatformHandler *self)
Definition: fl_platform_handler.cc:267

References fl_platform_handler_request_app_exit().

Referenced by window_delete_event_cb().

## ◆ fl_engine_send_key_event()

void fl_engine_send_key_event | ( | FlEngine * | engine,
|  | const FlutterKeyEvent * | event,
|  | GCancellable * | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data
| ) |  |

fl_engine_send_key_event: @engine: an #FlEngine. @event: key event to send. @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied. @user_data: (closure): user data to pass to @callback.

Send a key event to the engine.

Definition at line 1326 of file fl_engine.cc.

1330 {
1331 g_return_if_fail(FL_IS_ENGINE(self));
1332
1333 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
1334
1335 if (self->engine == nullptr) {
1336 g_task_return_new_error(task, fl_engine_error_quark(),
1337 FL_ENGINE_ERROR_FAILED, "No engine");
1338 return;
1339 }
1340
1341 if (self->embedder_api.SendKeyEvent(self->engine, event, send_key_event_cb,
1342 g_object_ref(task)) != kSuccess) {
1343 g_task_return_new_error(task, fl_engine_error_quark(),
1344 FL_ENGINE_ERROR_FAILED, "Failed to send key event");
1345 g_object_unref(task);
1346 }
1347 }
send_key_event_cb
static void send_key_event_cb(bool handled, void *user_data)
Definition: fl_engine.cc:1319

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), send_key_event_cb(), and user_data.

Referenced by fl_key_embedder_responder_handle_event(), fl_key_embedder_responder_handle_event_impl(), synthesize_simple_event(), and TEST().

## ◆ fl_engine_send_key_event_finish()

gboolean fl_engine_send_key_event_finish | ( | FlEngine * | engine,
|  | GAsyncResult * | result,
|  | gboolean * | handled,
|  | GError ** | error
| ) |  |

fl_engine_send_key_event_finish: @engine: an #FlEngine.

Returns
  : a #GAsyncResult. @handled: location to write if this event was handled by the engine. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_send_key_event().

Returns: TRUE on success.

Definition at line 1349 of file fl_engine.cc.

1352 {
1353 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1354 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1355
1356 g_autofree gboolean* return_value =
1357 static_cast<gboolean*>(g_task_propagate_pointer(G_TASK(result), error));
1358 if (return_value == nullptr) {
1359 return FALSE;
1360 }
1361
1362 *handled = *return_value;
1363 return TRUE;
1364 }
TRUE
return TRUE
Definition: fl_compositor_software.cc:68

References error, and TRUE.

Referenced by TEST().

## ◆ fl_engine_send_mouse_pointer_event()

void fl_engine_send_mouse_pointer_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | FlutterPointerPhase | phase,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | FlutterPointerDeviceKind | device_kind,
|  | double | scroll_delta_x,
|  | double | scroll_delta_y,
|  | int64_t | buttons
| ) |  |

fl_engine_send_mouse_pointer_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @phase: mouse phase. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device_kind: kind of pointing device. @scroll_delta_x: x offset of scroll. @scroll_delta_y: y offset of scroll. @buttons: buttons that are pressed.

Sends a mouse pointer event to the engine.

Definition at line 1123 of file fl_engine.cc.

1132 {
1133 g_return_if_fail(FL_IS_ENGINE(self));
1134
1135 if (self->engine == nullptr) {
1136 return;
1137 }
1138
1139 FlutterPointerEvent fl_event = {};
1140 fl_event.struct_size = sizeof(fl_event);
1141 fl_event.phase = phase;
1142 fl_event.timestamp = timestamp;
1143 fl_event.x = x;
1144 fl_event.y = y;
1145 if (scroll_delta_x != 0 || scroll_delta_y != 0) {
1146 fl_event.signal_kind = kFlutterPointerSignalKindScroll;
1147 }
1148 fl_event.scroll_delta_x = scroll_delta_x;
1149 fl_event.scroll_delta_y = scroll_delta_y;
1150 fl_event.device_kind = device_kind;
1151 fl_event.buttons = buttons;
1152 fl_event.device = kMousePointerDeviceId;
1153 fl_event.view_id = view_id;
1154 self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
1155 }
kMousePointerDeviceId
static constexpr int32_t kMousePointerDeviceId
Definition: fl_engine.cc:36

References kMousePointerDeviceId, and view_id.

Referenced by ensure_pointer_added(), fl_pointer_manager_handle_button_press(), fl_pointer_manager_handle_button_release(), fl_pointer_manager_handle_leave(), fl_pointer_manager_handle_motion(), fl_scrolling_manager_handle_scroll_event(), and TEST().

## ◆ fl_engine_send_platform_message()

void fl_engine_send_platform_message | ( | FlEngine * | engine,
|  | const gchar * | channel,
|  | GBytes * | message,
|  | GCancellable * | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data
| ) |  |

fl_engine_send_platform_message: @engine: an #FlEngine. @channel: channel to send to. @message: (allow-none): message buffer to send or NULL for an empty message @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied. @user_data: (closure): user data to pass to @callback.

Asynchronously sends a platform message.

Definition at line 1033 of file fl_engine.cc.

1038 {
1039 g_return_if_fail(FL_IS_ENGINE(self));
1040
1041 GTask* task = nullptr;
1042 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
1043 if (callback != nullptr) {
1044 task = g_task_new(self, cancellable, callback, user_data);
1045
1046 if (self->engine == nullptr) {
1047 g_task_return_new_error(task, fl_engine_error_quark(),
1048 FL_ENGINE_ERROR_FAILED, "No engine to send to");
1049 return;
1050 }
1051
1052 FlutterEngineResult result =
1053 self->embedder_api.PlatformMessageCreateResponseHandle(
1054 self->engine, fl_engine_platform_message_response_cb, task,
1055 &response_handle);
1056 if (result != kSuccess) {
1057 g_task_return_new_error(task, fl_engine_error_quark(),
1058 FL_ENGINE_ERROR_FAILED,
1059 "Failed to create response handle");
1060 g_object_unref(task);
1061 return;
1062 }
1063 } else if (self->engine == nullptr) {
1064 return;
1065 }
1066
1067 FlutterPlatformMessage fl_message = {};
1068 fl_message.struct_size = sizeof(fl_message);
1069 fl_message.channel = channel;
1070 fl_message.message =
1071 message != nullptr
1072 ? static_cast<const uint8_t*>(g_bytes_get_data(message, nullptr))
1073 : nullptr;
1074 fl_message.message_size = message != nullptr ? g_bytes_get_size(message) : 0;
1075 fl_message.response_handle = response_handle;
1076 FlutterEngineResult result =
1077 self->embedder_api.SendPlatformMessage(self->engine, &fl_message);
1078
1079 if (result != kSuccess && task != nullptr) {
1080 g_task_return_new_error(task, fl_engine_error_quark(),
1081 FL_ENGINE_ERROR_FAILED,
1082 "Failed to send platform messages");
1083 g_object_unref(task);
1084 }
1085
1086 if (response_handle != nullptr) {
1087 self->embedder_api.PlatformMessageReleaseResponseHandle(self->engine,
1088 response_handle);
1089 }
1090 }
fl_engine_platform_message_response_cb
static void fl_engine_platform_message_response_cb(const uint8_t *data, size_t data_length, void *user_data)
Definition: fl_engine.cc:524

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), fl_engine_platform_message_response_cb(), and user_data.

Referenced by send_on_channel(), and TEST().

## ◆ fl_engine_send_platform_message_finish()

GBytes* fl_engine_send_platform_message_finish | ( | FlEngine * | engine,
|  | GAsyncResult * | result,
|  | GError ** | error
| ) |  |

fl_engine_send_platform_message_finish: @engine: an #FlEngine.

Returns
  : a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_send_platform_message().

Returns: message response on success or NULL on error.

Definition at line 1092 of file fl_engine.cc.

1094 {
1095 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1096 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1097
1098 return static_cast<GBytes*>(g_task_propagate_pointer(G_TASK(result), error));
1099 }

References error.

Referenced by send_on_channel_finish().

## ◆ fl_engine_send_platform_message_response()

gboolean fl_engine_send_platform_message_response | ( | FlEngine * | engine,
|  | const FlutterPlatformMessageResponseHandle * | handle,
|  | GBytes * | response,
|  | GError ** | error
| ) |  |

fl_engine_send_platform_message_response: @engine: an #FlEngine. @handle: handle that was provided in FlEnginePlatformMessageHandler. @response: (allow-none): response to send or NULL for an empty response. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Responds to a platform message.

Returns: TRUE on success.

Definition at line 1001 of file fl_engine.cc.

1005 {
1006 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1007 g_return_val_if_fail(handle != nullptr, FALSE);
1008
1009 if (self->engine == nullptr) {
1010 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
1011 "No engine to send response to");
1012 return FALSE;
1013 }
1014
1015 gsize data_length = 0;
1016 const uint8_t* data = nullptr;
1017 if (response != nullptr) {
1018 data =
1019 static_cast<const uint8_t*>(g_bytes_get_data(response, &data_length));
1020 }
1021 FlutterEngineResult result = self->embedder_api.SendPlatformMessageResponse(
1022 self->engine, handle, data, data_length);
1023
1024 if (result != kSuccess) {
1025 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
1026 "Failed to send platform message response");
1027 return FALSE;
1028 }
1029
1030 return TRUE;
1031 }

References error, FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), and TRUE.

Referenced by fl_engine_platform_message_cb(), send_response(), and TEST().

## ◆ fl_engine_send_pointer_pan_zoom_event()

void fl_engine_send_pointer_pan_zoom_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | FlutterPointerPhase | phase,
|  | double | pan_x,
|  | double | pan_y,
|  | double | scale,
|  | double | rotation
| ) |  |

fl_engine_send_pointer_pan_zoom_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @phase: mouse phase. @pan_x: x offset of the pan/zoom in pixels. @pan_y: y offset of the pan/zoom in pixels. @scale: scale of the pan/zoom. @rotation: rotation of the pan/zoom in radians.

Sends a pan/zoom pointer event to the engine.

Definition at line 1287 of file fl_engine.cc.

1296 {
1297 g_return_if_fail(FL_IS_ENGINE(self));
1298
1299 if (self->engine == nullptr) {
1300 return;
1301 }
1302
1303 FlutterPointerEvent fl_event = {};
1304 fl_event.struct_size = sizeof(fl_event);
1305 fl_event.timestamp = timestamp;
1306 fl_event.x = x;
1307 fl_event.y = y;
1308 fl_event.phase = phase;
1309 fl_event.pan_x = pan_x;
1310 fl_event.pan_y = pan_y;
1311 fl_event.scale = scale;
1312 fl_event.rotation = rotation;
1313 fl_event.device = kPointerPanZoomDeviceId;
1314 fl_event.device_kind = kFlutterPointerDeviceKindTrackpad;
1315 fl_event.view_id = view_id;
1316 self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
1317 }
kPointerPanZoomDeviceId
static constexpr int32_t kPointerPanZoomDeviceId
Definition: fl_engine.cc:37

References kPointerPanZoomDeviceId, and view_id.

Referenced by fl_scrolling_manager_handle_rotation_begin(), fl_scrolling_manager_handle_rotation_end(), fl_scrolling_manager_handle_rotation_update(), fl_scrolling_manager_handle_scroll_event(), fl_scrolling_manager_handle_zoom_begin(), fl_scrolling_manager_handle_zoom_end(), fl_scrolling_manager_handle_zoom_update(), and TEST().

## ◆ fl_engine_send_touch_add_event()

void fl_engine_send_touch_add_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | int32_t | device
| ) |  |

fl_engine_send_touch_add_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device: device id.

Sends a touch add event to the engine.

Definition at line 1235 of file fl_engine.cc.

1240 {
1241 g_return_if_fail(FL_IS_ENGINE(self));
1242
1243 if (self->engine == nullptr) {
1244 return;
1245 }
1246
1247 FlutterPointerEvent event;
1248 event.timestamp = timestamp;
1249 event.x = x;
1250 event.y = y;
1251 event.device_kind = kFlutterPointerDeviceKindTouch;
1252 event.device = device;
1253 event.buttons = 0;
1254 event.view_id = view_id;
1255 event.phase = FlutterPointerPhase::kAdd;
1256 event.struct_size = sizeof(event);
1257
1258 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1259 }

References view_id.

Referenced by ensure_touch_added().

## ◆ fl_engine_send_touch_down_event()

void fl_engine_send_touch_down_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | int32_t | device
| ) |  |

fl_engine_send_touch_down_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device: device id.

Sends a touch down event to the engine.

Definition at line 1183 of file fl_engine.cc.

1188 {
1189 g_return_if_fail(FL_IS_ENGINE(self));
1190
1191 if (self->engine == nullptr) {
1192 return;
1193 }
1194
1195 FlutterPointerEvent event;
1196 event.timestamp = timestamp;
1197 event.x = x;
1198 event.y = y;
1199 event.device_kind = kFlutterPointerDeviceKindTouch;
1200 event.device = device;
1201 event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1202 event.view_id = view_id;
1203 event.phase = FlutterPointerPhase::kDown;
1204 event.struct_size = sizeof(event);
1205
1206 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1207 }

References view_id.

Referenced by fl_touch_manager_handle_touch_event().

## ◆ fl_engine_send_touch_move_event()

void fl_engine_send_touch_move_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | int32_t | device
| ) |  |

fl_engine_send_touch_move_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device: device id.

Sends a touch move event to the engine.

Definition at line 1209 of file fl_engine.cc.

1214 {
1215 g_return_if_fail(FL_IS_ENGINE(self));
1216
1217 if (self->engine == nullptr) {
1218 return;
1219 }
1220
1221 FlutterPointerEvent event;
1222 event.timestamp = timestamp;
1223 event.x = x;
1224 event.y = y;
1225 event.device_kind = kFlutterPointerDeviceKindTouch;
1226 event.device = device;
1227 event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1228 event.view_id = view_id;
1229 event.phase = FlutterPointerPhase::kMove;
1230 event.struct_size = sizeof(event);
1231
1232 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1233 }

References view_id.

Referenced by fl_touch_manager_handle_touch_event().

## ◆ fl_engine_send_touch_remove_event()

void fl_engine_send_touch_remove_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | int32_t | device
| ) |  |

fl_engine_send_touch_remove_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device: device id.

Sends a touch remove event to the engine.

Definition at line 1261 of file fl_engine.cc.

1266 {
1267 g_return_if_fail(FL_IS_ENGINE(self));
1268
1269 if (self->engine == nullptr) {
1270 return;
1271 }
1272
1273 FlutterPointerEvent event;
1274 event.timestamp = timestamp;
1275 event.x = x;
1276 event.y = y;
1277 event.device_kind = kFlutterPointerDeviceKindTouch;
1278 event.device = device;
1279 event.buttons = 0;
1280 event.view_id = view_id;
1281 event.phase = FlutterPointerPhase::kRemove;
1282 event.struct_size = sizeof(event);
1283
1284 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1285 }

References view_id.

Referenced by fl_touch_manager_handle_touch_event().

## ◆ fl_engine_send_touch_up_event()

void fl_engine_send_touch_up_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | int32_t | device
| ) |  |

fl_engine_send_touch_up_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device: device id.

Sends a touch up event to the engine.

Definition at line 1157 of file fl_engine.cc.

1162 {
1163 g_return_if_fail(FL_IS_ENGINE(self));
1164
1165 if (self->engine == nullptr) {
1166 return;
1167 }
1168
1169 FlutterPointerEvent event;
1170 event.timestamp = timestamp;
1171 event.x = x;
1172 event.y = y;
1173 event.device_kind = kFlutterPointerDeviceKindTouch;
1174 event.device = device;
1175 event.buttons = 0;
1176 event.view_id = view_id;
1177 event.phase = FlutterPointerPhase::kUp;
1178 event.struct_size = sizeof(event);
1179
1180 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1181 }

References view_id.

Referenced by fl_touch_manager_handle_touch_event().

## ◆ fl_engine_send_window_metrics_event()

void fl_engine_send_window_metrics_event | ( | FlEngine * | engine,
|  | FlutterEngineDisplayId | display_id,
|  | FlutterViewId | view_id,
|  | size_t | width,
|  | size_t | height,
|  | double | pixel_ratio
| ) |  |

fl_engine_send_window_metrics_event: @engine: an #FlEngine. @display_id: the display this view is rendering on. @view_id: the view that the event occured on. @width: width of the window in pixels. @height: height of the window in pixels. @pixel_ratio: scale factor for window.

Sends a window metrics event to the engine.

Definition at line 1101 of file fl_engine.cc.

1106 {
1107 g_return_if_fail(FL_IS_ENGINE(self));
1108
1109 if (self->engine == nullptr) {
1110 return;
1111 }
1112
1113 FlutterWindowMetricsEvent event = {};
1114 event.struct_size = sizeof(FlutterWindowMetricsEvent);
1115 event.width = width;
1116 event.height = height;
1117 event.pixel_ratio = pixel_ratio;
1118 event.display_id = display_id;
1119 event.view_id = view_id;
1120 self->embedder_api.SendWindowMetricsEvent(self->engine, &event);
1121 }

References height, view_id, and width.

Referenced by handle_geometry_changed(), and TEST().

## ◆ fl_engine_set_implicit_view()

void fl_engine_set_implicit_view | ( | FlEngine * | engine,
|  | FlRenderable * | renderable
| ) |  |

fl_engine_set_implicit_view: @engine: an #FlEngine. @renderable: the object that will render the implicit view.

Sets the object to render the implicit view.

Definition at line 877 of file fl_engine.cc.

877 {
878 GWeakRef* ref = g_new(GWeakRef, 1);
879 g_weak_ref_init(ref, G_OBJECT(renderable));
880 g_hash_table_insert(self->renderables_by_view_id,
881 GINT_TO_POINTER(flutter::kFlutterImplicitViewId), ref);
882 }

Referenced by fl_view_new(), and TEST().

## ◆ fl_engine_set_platform_message_handler()

void fl_engine_set_platform_message_handler | ( | FlEngine * | engine,
|  | FlEnginePlatformMessageHandler | handler,
|  | gpointer | user_data,
|  | GDestroyNotify | destroy_notify
| ) |  |

fl_engine_set_platform_message_handler: @engine: an #FlEngine. @handler: function to call when a platform message is received. @user_data: (closure): user data to pass to @handler. @destroy_notify: (allow-none): a function which gets called to free @user_data, or NULL.

Registers the function called when a platform message is received. Call fl_engine_send_platform_message_response() with the response to this message. Ownership of #FlutterPlatformMessageResponseHandle is transferred to the caller, and the message must be responded to avoid memory leaks.

Definition at line 982 of file fl_engine.cc.

986 {
987 g_return_if_fail(FL_IS_ENGINE(self));
988 g_return_if_fail(handler != nullptr);
989
990 if (self->platform_message_handler_destroy_notify) {
991 self->platform_message_handler_destroy_notify(
992 self->platform_message_handler_data);
993 }
994
995 self->platform_message_handler = handler;
996 self->platform_message_handler_data = user_data;
997 self->platform_message_handler_destroy_notify = destroy_notify;
998 }

References user_data.

Referenced by fl_binary_messenger_new().

## ◆ fl_engine_start()

gboolean fl_engine_start | ( | FlEngine * | engine,
|  | GError ** | error
| ) |  |

fl_engine_start: @engine: an #FlEngine. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Starts the Flutter engine.

Returns: TRUE on success.

Definition at line 722 of file fl_engine.cc.

722 {
723 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
724
725 FlutterRendererConfig config = {};
726 config.type = self->renderer_type;
727 switch (config.type) {
728 case kSoftware:
729 config.software.struct_size = sizeof(FlutterSoftwareRendererConfig);
730 // No action required, as this is handled in
731 // compositor_present_view_callback.
732 config.software.surface_present_callback =
733 [](void* user_data, const void* allocation, size_t row_bytes,
734 size_t height) { return true; };
735 break;
736 case kOpenGL:
737 config.open_gl.struct_size = sizeof(FlutterOpenGLRendererConfig);
738 config.open_gl.gl_proc_resolver = fl_engine_gl_proc_resolver;
739 config.open_gl.make_current = fl_engine_gl_make_current;
740 config.open_gl.clear_current = fl_engine_gl_clear_current;
741 config.open_gl.fbo_callback = fl_engine_gl_get_fbo;
742 // No action required, as this is handled in
743 // compositor_present_view_callback.
744 config.open_gl.present = [](void* user_data) { return true; };
745 config.open_gl.make_resource_current = fl_engine_gl_make_resource_current;
746 config.open_gl.gl_external_texture_frame_callback =
747 fl_engine_gl_external_texture_frame_callback;
748 break;
749 case kMetal:
750 case kVulkan:
751 default:
752 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
753 "Unsupported renderer type");
754 return FALSE;
755 }
756
757 FlutterTaskRunnerDescription platform_task_runner = {};
758 platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
759 platform_task_runner.user_data = self;
760 platform_task_runner.runs_task_on_current_thread_callback =
761 fl_engine_runs_task_on_current_thread;
762 platform_task_runner.post_task_callback = fl_engine_post_task;
763 platform_task_runner.identifier = kPlatformTaskRunnerIdentifier;
764
765 FlutterCustomTaskRunners custom_task_runners = {};
766 custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
767 custom_task_runners.platform_task_runner = &platform_task_runner;
768
769 if (fl_dart_project_get_ui_thread_policy(self->project) ==
770 FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD) {
771 custom_task_runners.ui_task_runner = &platform_task_runner;
772 }
773
774 g_autoptr(GPtrArray) command_line_args =
775 g_ptr_array_new_with_free_func(g_free);
776 g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
777 for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) {
778 g_ptr_array_add(command_line_args, g_strdup(env_switch.c_str()));
779 }
780
781 gchar** dart_entrypoint_args =
782 fl_dart_project_get_dart_entrypoint_arguments(self->project);
783
784 FlutterProjectArgs args = {};
785 args.struct_size = sizeof(FlutterProjectArgs);
786 args.assets_path = fl_dart_project_get_assets_path(self->project);
787 args.icu_data_path = fl_dart_project_get_icu_data_path(self->project);
788 args.command_line_argc = command_line_args->len;
789 args.command_line_argv =
790 reinterpret_cast<const char* const*>(command_line_args->pdata);
791 args.platform_message_callback = fl_engine_platform_message_cb;
792 args.update_semantics_callback2 = fl_engine_update_semantics_cb;
793 args.custom_task_runners = &custom_task_runners;
794 args.shutdown_dart_vm_when_done = true;
795 args.on_pre_engine_restart_callback = fl_engine_on_pre_engine_restart_cb;
796 args.dart_entrypoint_argc =
797 dart_entrypoint_args != nullptr ? g_strv_length(dart_entrypoint_args) : 0;
798 args.dart_entrypoint_argv =
799 reinterpret_cast<const char* const*>(dart_entrypoint_args);
800 args.engine_id = reinterpret_cast<int64_t>(self);
801
802 FlutterCompositor compositor = {};
803 compositor.struct_size = sizeof(FlutterCompositor);
804 compositor.user_data = self;
805 compositor.create_backing_store_callback =
806 compositor_create_backing_store_callback;
807 compositor.collect_backing_store_callback =
808 compositor_collect_backing_store_callback;
809 compositor.present_view_callback = compositor_present_view_callback;
810 args.compositor = &compositor;
811
812 if (self->embedder_api.RunsAOTCompiledDartCode()) {
813 FlutterEngineAOTDataSource source = {};
814 source.type = kFlutterEngineAOTDataSourceTypeElfPath;
815 source.elf_path = fl_dart_project_get_aot_library_path(self->project);
816 if (self->embedder_api.CreateAOTData(&source, &self->aot_data) !=
817 kSuccess) {
818 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
819 "Failed to create AOT data");
820 return FALSE;
821 }
822 args.aot_data = self->aot_data;
823 }
824
825 FlutterEngineResult result = self->embedder_api.Initialize(
826 FLUTTER_ENGINE_VERSION, &config, &args, self, &self->engine);
827 if (result != kSuccess) {
828 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
829 "Failed to initialize Flutter engine");
830 return FALSE;
831 }
832
833 result = self->embedder_api.RunInitialized(self->engine);
834 if (result != kSuccess) {
835 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
836 "Failed to run Flutter engine");
837 return FALSE;
838 }
839
840 setup_locales(self);
841
842 g_autoptr(FlSettings) settings = fl_settings_new();
843 self->settings_handler = fl_settings_handler_new(self);
844 fl_settings_handler_start(self->settings_handler, settings);
845
846 self->platform_handler = fl_platform_handler_new(self->binary_messenger);
847
848 setup_keyboard(self);
849
850 result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE);
851 if (result != kSuccess) {
852 g_warning("Failed to enable accessibility features on Flutter engine");
853 }
854
855 fl_display_monitor_start(self->display_monitor);
856
857 return TRUE;
858 }
fl_dart_project_get_aot_library_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path(FlDartProject *self)
Definition: fl_dart_project.cc:74
fl_dart_project_get_dart_entrypoint_arguments
G_MODULE_EXPORT gchar ** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject *self)
Definition: fl_dart_project.cc:106
fl_dart_project_get_icu_data_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_icu_data_path(FlDartProject *self)
Definition: fl_dart_project.cc:100
fl_dart_project_get_assets_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path(FlDartProject *self)
Definition: fl_dart_project.cc:87
fl_dart_project_get_ui_thread_policy
G_MODULE_EXPORT FlUIThreadPolicy fl_dart_project_get_ui_thread_policy(FlDartProject *project)
Definition: fl_dart_project.cc:128
FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD
@ FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD
Definition: fl_dart_project.h:143
fl_display_monitor_start
void fl_display_monitor_start(FlDisplayMonitor *self)
Definition: fl_display_monitor.cc:103
fl_engine_gl_external_texture_frame_callback
static bool fl_engine_gl_external_texture_frame_callback(void *user_data, int64_t texture_id, size_t width, size_t height, FlutterOpenGLTexture *opengl_texture)
Definition: fl_engine.cc:407
fl_engine_runs_task_on_current_thread
static bool fl_engine_runs_task_on_current_thread(void *user_data)
Definition: fl_engine.cc:448
fl_engine_on_pre_engine_restart_cb
static void fl_engine_on_pre_engine_restart_cb(void *user_data)
Definition: fl_engine.cc:514
compositor_create_backing_store_callback
static bool compositor_create_backing_store_callback(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
Definition: fl_engine.cc:331
fl_engine_gl_make_current
static bool fl_engine_gl_make_current(void *user_data)
Definition: fl_engine.cc:386
compositor_present_view_callback
static bool compositor_present_view_callback(const FlutterPresentViewInfo *info)
Definition: fl_engine.cc:362
compositor_collect_backing_store_callback
static bool compositor_collect_backing_store_callback(const FlutterBackingStore *backing_store, void *user_data)
Definition: fl_engine.cc:347
fl_engine_post_task
static void fl_engine_post_task(FlutterTask task, uint64_t target_time_nanos, void *user_data)
Definition: fl_engine.cc:454
fl_engine_gl_get_fbo
static uint32_t fl_engine_gl_get_fbo(void *user_data)
Definition: fl_engine.cc:396
fl_engine_gl_proc_resolver
static void * fl_engine_gl_proc_resolver(void *user_data, const char *name)
Definition: fl_engine.cc:382
setup_keyboard
static void setup_keyboard(FlEngine *self)
Definition: fl_engine.cc:490
setup_locales
static void setup_locales(FlEngine *self)
Definition: fl_engine.cc:200
fl_engine_update_semantics_cb
static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2 *update, void *user_data)
Definition: fl_engine.cc:483
fl_engine_gl_make_resource_current
static bool fl_engine_gl_make_resource_current(void *user_data)
Definition: fl_engine.cc:401
fl_engine_platform_message_cb
static void fl_engine_platform_message_cb(const FlutterPlatformMessage *message, void *user_data)
Definition: fl_engine.cc:463
kPlatformTaskRunnerIdentifier
static constexpr size_t kPlatformTaskRunnerIdentifier
Definition: fl_engine.cc:32
fl_engine_gl_clear_current
static bool fl_engine_gl_clear_current(void *user_data)
Definition: fl_engine.cc:391
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
fl_platform_handler_new
FlPlatformHandler * fl_platform_handler_new(FlBinaryMessenger *messenger)
Definition: fl_platform_handler.cc:254
fl_settings_new
FlSettings * fl_settings_new()
Definition: fl_settings.cc:55
fl_settings_handler_start
void fl_settings_handler_start(FlSettingsHandler *self, FlSettings *settings)
Definition: fl_settings_handler.cc:88
fl_settings_handler_new
FlSettingsHandler * fl_settings_handler_new(FlEngine *engine)
Definition: fl_settings_handler.cc:74
flutter::GetSwitchesFromEnvironment
std::vector< std::string > GetSwitchesFromEnvironment()
Definition: engine_switches.cc:14

References args, compositor_collect_backing_store_callback(), compositor_create_backing_store_callback(), compositor_present_view_callback(), error, fl_dart_project_get_aot_library_path(), fl_dart_project_get_assets_path(), fl_dart_project_get_dart_entrypoint_arguments(), fl_dart_project_get_icu_data_path(), fl_dart_project_get_ui_thread_policy(), fl_display_monitor_start(), FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), fl_engine_gl_clear_current(), fl_engine_gl_external_texture_frame_callback(), fl_engine_gl_get_fbo(), fl_engine_gl_make_current(), fl_engine_gl_make_resource_current(), fl_engine_gl_proc_resolver(), fl_engine_on_pre_engine_restart_cb(), fl_engine_platform_message_cb(), fl_engine_post_task(), fl_engine_runs_task_on_current_thread(), fl_engine_update_semantics_cb(), fl_platform_handler_new(), fl_settings_handler_new(), fl_settings_handler_start(), fl_settings_new(), FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD, g_autoptr(), flutter::GetSwitchesFromEnvironment(), height, kPlatformTaskRunnerIdentifier, setup_keyboard(), setup_locales(), TRUE, and user_data.

Referenced by realize_cb(), and TEST().

## ◆ fl_engine_unregister_external_texture()

gboolean fl_engine_unregister_external_texture | ( | FlEngine * | engine,
|  | int64_t | texture_id
| ) |  |

fl_engine_unregister_external_texture: @engine: an #FlEngine. @texture_id: the identifier of the texture that is not available anymore.

Tells the Flutter engine that an existing external texture is not available anymore.

Returns: TRUE on success.

Definition at line 1408 of file fl_engine.cc.

1409 {
1410 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1411 return self->embedder_api.UnregisterExternalTexture(self->engine,
1412 texture_id) == kSuccess;
1413 }

References texture_id.

Referenced by unregister_texture().

## ◆ fl_engine_update_accessibility_features()

void fl_engine_update_accessibility_features | ( | FlEngine * | engine,
|  | int32_t | flags
| ) |  |

fl_engine_update_accessibility_features: @engine: an #FlEngine. @flags: the features to enable in the accessibility tree.

Tells the Flutter engine to update the flags on the accessibility tree.

Definition at line 1437 of file fl_engine.cc.

1437 {
1438 g_return_if_fail(FL_IS_ENGINE(self));
1439
1440 if (self->engine == nullptr) {
1441 return;
1442 }
1443
1444 self->embedder_api.UpdateAccessibilityFeatures(
1445 self->engine, static_cast<FlutterAccessibilityFeature>(flags));
1446 }

Referenced by update_settings().