Flutter Engine
 
Loading...
Searching...
No Matches
flutter_glfw.cc File Reference

Go to the source code of this file.

Classes

struct  FlutterDesktopWindowControllerState
 
struct  FlutterDesktopWindow
 
struct  AOTDataDeleter
 
struct  FlutterDesktopEngineState
 
struct  FlutterDesktopPluginRegistrar
 
struct  FlutterDesktopMessenger
 

Macros

#define GLFW_TRUE   1
 
#define GLFW_FALSE   0
 

Typedefs

using UniqueGLFWwindowPtr = std::unique_ptr< GLFWwindow, void(*)(GLFWwindow *)>
 
using UniqueAotDataPtr = std::unique_ptr< _FlutterEngineAOTData, AOTDataDeleter >
 
using FlutterDesktopMessengerReferenceOwner = std::unique_ptr< FlutterDesktopMessenger, decltype(&FlutterDesktopMessengerRelease)>
 Maintains one ref on the FlutterDesktopMessenger's internal reference count.
 

Functions

FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef (FlutterDesktopMessengerRef messenger)
 
void FlutterDesktopMessengerRelease (FlutterDesktopMessengerRef messenger)
 
bool FlutterDesktopMessengerIsAvailable (FlutterDesktopMessengerRef messenger)
 
FlutterDesktopMessengerRef FlutterDesktopMessengerLock (FlutterDesktopMessengerRef messenger)
 
void FlutterDesktopMessengerUnlock (FlutterDesktopMessengerRef messenger)
 
static FlutterDesktopWindowControllerStateGetWindowController (GLFWwindow *window)
 
static UniqueGLFWwindowPtr CreateShareWindowForWindow (GLFWwindow *window)
 
static FlutterDesktopMessage ConvertToDesktopMessage (const FlutterPlatformMessage &engine_message)
 
static double GetScreenCoordinatesPerInch ()
 
static void SendWindowMetrics (FlutterDesktopWindowControllerState *controller, int width, int height)
 
static void ConfigurePlatformTaskRunner (FlutterTaskRunnerDescription *task_runner, FlutterDesktopEngineState *engine_state)
 
static void GLFWFramebufferSizeCallback (GLFWwindow *window, int width_px, int height_px)
 
void GLFWWindowRefreshCallback (GLFWwindow *window)
 
static void SendPointerEventWithData (GLFWwindow *window, const FlutterPointerEvent &event_data)
 
static void SetEventLocationFromCursorPosition (GLFWwindow *window, FlutterPointerEvent *event_data)
 
static void SetEventPhaseFromCursorButtonState (GLFWwindow *window, FlutterPointerEvent *event_data, int64_t buttons)
 
static void GLFWCursorEnterCallback (GLFWwindow *window, int entered)
 
static void GLFWCursorPositionCallback (GLFWwindow *window, double x, double y)
 
static void GLFWMouseButtonCallback (GLFWwindow *window, int key, int action, int mods)
 
static void GLFWScrollCallback (GLFWwindow *window, double delta_x, double delta_y)
 
static void GLFWCharCallback (GLFWwindow *window, unsigned int code_point)
 
static void GLFWKeyCallback (GLFWwindow *window, int key, int scancode, int action, int mods)
 
static void SetHoverCallbacksEnabled (GLFWwindow *window, bool enabled)
 
static void GLFWAssignEventCallbacks (GLFWwindow *window)
 
static void GLFWClearEventCallbacks (GLFWwindow *window)
 
static void EngineOnFlutterPlatformMessage (const FlutterPlatformMessage *engine_message, void *user_data)
 
static bool EngineMakeContextCurrent (void *user_data)
 
static bool EngineMakeResourceContextCurrent (void *user_data)
 
static bool EngineClearContext (void *user_data)
 
static bool EnginePresent (void *user_data)
 
static uint32_t EngineGetActiveFbo (void *user_data)
 
static void * EngineProcResolver (void *user_data, const char *name)
 
static void GLFWClearCanvas (GLFWwindow *window)
 
static void GLFWErrorCallback (int error_code, const char *description)
 
UniqueAotDataPtr LoadAotData (const std::filesystem::path &aot_data_path)
 
static bool RunFlutterEngine (FlutterDesktopEngineState *engine_state, const FlutterDesktopEngineProperties &engine_properties, std::unique_ptr< flutter::EventLoop > event_loop)
 
static void SetUpLocales (FlutterDesktopEngineState *state)
 
static void SetUpCommonEngineState (FlutterDesktopEngineState *state, GLFWwindow *window)
 
bool FlutterDesktopInit ()
 
void FlutterDesktopTerminate ()
 
FlutterDesktopWindowControllerRef FlutterDesktopCreateWindow (const FlutterDesktopWindowProperties &window_properties, const FlutterDesktopEngineProperties &engine_properties)
 
void FlutterDesktopDestroyWindow (FlutterDesktopWindowControllerRef controller)
 
void FlutterDesktopWindowSetHoverEnabled (FlutterDesktopWindowRef flutter_window, bool enabled)
 
void FlutterDesktopWindowSetTitle (FlutterDesktopWindowRef flutter_window, const char *title)
 
void FlutterDesktopWindowSetIcon (FlutterDesktopWindowRef flutter_window, uint8_t *pixel_data, int width, int height)
 
void FlutterDesktopWindowGetFrame (FlutterDesktopWindowRef flutter_window, int *x, int *y, int *width, int *height)
 
void FlutterDesktopWindowSetFrame (FlutterDesktopWindowRef flutter_window, int x, int y, int width, int height)
 
double FlutterDesktopWindowGetScaleFactor (FlutterDesktopWindowRef flutter_window)
 
void FlutterDesktopWindowSetPixelRatioOverride (FlutterDesktopWindowRef flutter_window, double pixel_ratio)
 
void FlutterDesktopWindowSetSizeLimits (FlutterDesktopWindowRef flutter_window, FlutterDesktopSize minimum_size, FlutterDesktopSize maximum_size)
 
bool FlutterDesktopRunWindowEventLoopWithTimeout (FlutterDesktopWindowControllerRef controller, uint32_t timeout_milliseconds)
 
FlutterDesktopWindowRef FlutterDesktopGetWindow (FlutterDesktopWindowControllerRef controller)
 
FlutterDesktopEngineRef FlutterDesktopGetEngine (FlutterDesktopWindowControllerRef controller)
 
FlutterDesktopPluginRegistrarRef FlutterDesktopGetPluginRegistrar (FlutterDesktopEngineRef engine, const char *plugin_name)
 
FlutterDesktopEngineRef FlutterDesktopRunEngine (const FlutterDesktopEngineProperties &properties)
 
void FlutterDesktopRunEngineEventLoopWithTimeout (FlutterDesktopEngineRef engine, uint32_t timeout_milliseconds)
 
bool FlutterDesktopShutDownEngine (FlutterDesktopEngineRef engine)
 
void FlutterDesktopPluginRegistrarEnableInputBlocking (FlutterDesktopPluginRegistrarRef registrar, const char *channel)
 
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger (FlutterDesktopPluginRegistrarRef registrar)
 
void FlutterDesktopPluginRegistrarSetDestructionHandler (FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopOnPluginRegistrarDestroyed callback)
 
FlutterDesktopWindowRef FlutterDesktopPluginRegistrarGetWindow (FlutterDesktopPluginRegistrarRef registrar)
 
bool FlutterDesktopMessengerSendWithReply (FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
 
bool FlutterDesktopMessengerSend (FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size)
 
void FlutterDesktopMessengerSendResponse (FlutterDesktopMessengerRef messenger, const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
 
void FlutterDesktopMessengerSetCallback (FlutterDesktopMessengerRef messenger, const char *channel, FlutterDesktopMessageCallback callback, void *user_data)
 
FlutterDesktopTextureRegistrarRef FlutterDesktopRegistrarGetTextureRegistrar (FlutterDesktopPluginRegistrarRef registrar)
 
int64_t FlutterDesktopTextureRegistrarRegisterExternalTexture (FlutterDesktopTextureRegistrarRef texture_registrar, const FlutterDesktopTextureInfo *texture_info)
 
void FlutterDesktopTextureRegistrarUnregisterExternalTexture (FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id, void(*callback)(void *user_data), void *user_data)
 
bool FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable (FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id)
 

Variables

const int kFlutterDesktopDontCare = GLFW_DONT_CARE
 
static constexpr double kDpPerInch = 160.0
 

Macro Definition Documentation

◆ GLFW_FALSE

#define GLFW_FALSE   0

Definition at line 37 of file flutter_glfw.cc.

◆ GLFW_TRUE

#define GLFW_TRUE   1

Definition at line 34 of file flutter_glfw.cc.

Typedef Documentation

◆ FlutterDesktopMessengerReferenceOwner

Maintains one ref on the FlutterDesktopMessenger's internal reference count.

Definition at line 113 of file flutter_glfw.cc.

◆ UniqueAotDataPtr

Definition at line 111 of file flutter_glfw.cc.

◆ UniqueGLFWwindowPtr

using UniqueGLFWwindowPtr = std::unique_ptr<GLFWwindow, void (*)(GLFWwindow*)>

Definition at line 40 of file flutter_glfw.cc.

Function Documentation

◆ ConfigurePlatformTaskRunner()

static void ConfigurePlatformTaskRunner ( FlutterTaskRunnerDescription task_runner,
FlutterDesktopEngineState engine_state 
)
static

Definition at line 310 of file flutter_glfw.cc.

312 {
313 task_runner->struct_size = sizeof(FlutterTaskRunnerDescription);
314 task_runner->user_data = engine_state;
315 task_runner->runs_task_on_current_thread_callback = [](void* state) -> bool {
316 return reinterpret_cast<FlutterDesktopEngineState*>(state)
317 ->event_loop->RunsTasksOnCurrentThread();
318 };
319 task_runner->post_task_callback =
320 [](FlutterTask task, uint64_t target_time_nanos, void* state) -> void {
321 reinterpret_cast<FlutterDesktopEngineState*>(state)->event_loop->PostTask(
322 task, target_time_nanos);
323 };
324}
size_t struct_size
The size of this struct. Must be sizeof(FlutterTaskRunnerDescription).
Definition embedder.h:1864
BoolCallback runs_task_on_current_thread_callback
Definition embedder.h:1870
FlutterTaskRunnerPostTaskCallback post_task_callback
Definition embedder.h:1881

References FlutterTaskRunnerDescription::post_task_callback, FlutterTaskRunnerDescription::runs_task_on_current_thread_callback, FlutterTaskRunnerDescription::struct_size, and FlutterTaskRunnerDescription::user_data.

Referenced by RunFlutterEngine().

◆ ConvertToDesktopMessage()

static FlutterDesktopMessage ConvertToDesktopMessage ( const FlutterPlatformMessage engine_message)
static

Definition at line 252 of file flutter_glfw.cc.

253 {
255 message.struct_size = sizeof(message);
256 message.channel = engine_message.channel;
257 message.message = engine_message.message;
258 message.message_size = engine_message.message_size;
259 message.response_handle = engine_message.response_handle;
260 return message;
261}
G_BEGIN_DECLS GBytes * message
const FlutterPlatformMessageResponseHandle * response_handle
Definition embedder.h:1446
const char * channel
Definition embedder.h:1437
const uint8_t * message
Definition embedder.h:1438

References FlutterPlatformMessage::channel, FlutterPlatformMessage::message, message, FlutterPlatformMessage::message_size, FlutterPlatformMessage::response_handle, and FlutterDesktopMessage::struct_size.

Referenced by EngineOnFlutterPlatformMessage(), and flutter::FlutterWindowsEngine::HandlePlatformMessage().

◆ CreateShareWindowForWindow()

static UniqueGLFWwindowPtr CreateShareWindowForWindow ( GLFWwindow *  window)
static

Definition at line 238 of file flutter_glfw.cc.

238 {
239 glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
240 glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
241#if defined(__linux__)
242 glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
243 glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
244 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
245#endif
246 GLFWwindow* share_window = glfwCreateWindow(1, 1, "", NULL, window);
247 glfwDefaultWindowHints();
248 return UniqueGLFWwindowPtr(share_window, glfwDestroyWindow);
249}
GLFWwindow * window
Definition main.cc:60
std::unique_ptr< GLFWwindow, void(*)(GLFWwindow *)> UniqueGLFWwindowPtr
#define GLFW_FALSE

References GLFW_FALSE, and window.

Referenced by FlutterDesktopCreateWindow().

◆ EngineClearContext()

static bool EngineClearContext ( void *  user_data)
static

Definition at line 622 of file flutter_glfw.cc.

622 {
623 FlutterDesktopEngineState* engine_state =
625 FlutterDesktopWindowControllerState* window_controller =
626 engine_state->window_controller;
627 if (!window_controller) {
628 return false;
629 }
630 glfwMakeContextCurrent(nullptr);
631 return true;
632}
FlutterDesktopWindowControllerState * window_controller

References user_data, and FlutterDesktopEngineState::window_controller.

Referenced by RunFlutterEngine().

◆ EngineGetActiveFbo()

static uint32_t EngineGetActiveFbo ( void *  user_data)
static

Definition at line 646 of file flutter_glfw.cc.

646 {
647 return 0;
648}

Referenced by RunFlutterEngine().

◆ EngineMakeContextCurrent()

static bool EngineMakeContextCurrent ( void *  user_data)
static

Definition at line 598 of file flutter_glfw.cc.

598 {
599 FlutterDesktopEngineState* engine_state =
601 FlutterDesktopWindowControllerState* window_controller =
602 engine_state->window_controller;
603 if (!window_controller) {
604 return false;
605 }
606 glfwMakeContextCurrent(window_controller->window.get());
607 return true;
608}

References user_data, FlutterDesktopWindowControllerState::window, and FlutterDesktopEngineState::window_controller.

Referenced by RunFlutterEngine().

◆ EngineMakeResourceContextCurrent()

static bool EngineMakeResourceContextCurrent ( void *  user_data)
static

Definition at line 610 of file flutter_glfw.cc.

610 {
611 FlutterDesktopEngineState* engine_state =
613 FlutterDesktopWindowControllerState* window_controller =
614 engine_state->window_controller;
615 if (!window_controller) {
616 return false;
617 }
618 glfwMakeContextCurrent(window_controller->resource_window.get());
619 return true;
620}

References FlutterDesktopWindowControllerState::resource_window, user_data, and FlutterDesktopEngineState::window_controller.

Referenced by RunFlutterEngine().

◆ EngineOnFlutterPlatformMessage()

static void EngineOnFlutterPlatformMessage ( const FlutterPlatformMessage engine_message,
void *  user_data 
)
static

Definition at line 567 of file flutter_glfw.cc.

569 {
570 if (engine_message->struct_size != sizeof(FlutterPlatformMessage)) {
571 std::cerr << "Invalid message size received. Expected: "
572 << sizeof(FlutterPlatformMessage) << " but received "
573 << engine_message->struct_size << std::endl;
574 return;
575 }
576
577 FlutterDesktopEngineState* engine_state =
579 GLFWwindow* window = engine_state->window_controller == nullptr
580 ? nullptr
581 : engine_state->window_controller->window.get();
582
583 auto message = ConvertToDesktopMessage(*engine_message);
584 engine_state->message_dispatcher->HandleMessage(
585 message,
586 [window] {
587 if (window) {
589 }
590 },
591 [window] {
592 if (window) {
594 }
595 });
596}
static FlutterDesktopMessage ConvertToDesktopMessage(const FlutterPlatformMessage &engine_message)
static void GLFWAssignEventCallbacks(GLFWwindow *window)
static void GLFWClearEventCallbacks(GLFWwindow *window)
std::unique_ptr< flutter::IncomingMessageDispatcher > message_dispatcher
size_t struct_size
The size of this struct. Must be sizeof(FlutterPlatformMessage).
Definition embedder.h:1436

References ConvertToDesktopMessage(), GLFWAssignEventCallbacks(), GLFWClearEventCallbacks(), message, FlutterDesktopEngineState::message_dispatcher, FlutterPlatformMessage::struct_size, user_data, window, FlutterDesktopWindowControllerState::window, and FlutterDesktopEngineState::window_controller.

Referenced by RunFlutterEngine().

◆ EnginePresent()

static bool EnginePresent ( void *  user_data)
static

Definition at line 634 of file flutter_glfw.cc.

634 {
635 FlutterDesktopEngineState* engine_state =
637 FlutterDesktopWindowControllerState* window_controller =
638 engine_state->window_controller;
639 if (!window_controller) {
640 return false;
641 }
642 glfwSwapBuffers(window_controller->window.get());
643 return true;
644}

References user_data, FlutterDesktopWindowControllerState::window, and FlutterDesktopEngineState::window_controller.

Referenced by RunFlutterEngine().

◆ EngineProcResolver()

static void * EngineProcResolver ( void *  user_data,
const char *  name 
)
static

Definition at line 652 of file flutter_glfw.cc.

652 {
653 return reinterpret_cast<void*>(glfwGetProcAddress(name));
654}
const char * name
Definition fuchsia.cc:49

References name.

Referenced by RunFlutterEngine().

◆ FlutterDesktopCreateWindow()

FlutterDesktopWindowControllerRef FlutterDesktopCreateWindow ( const FlutterDesktopWindowProperties window_properties,
const FlutterDesktopEngineProperties engine_properties 
)

Definition at line 860 of file flutter_glfw.cc.

862 {
863 auto state = std::make_unique<FlutterDesktopWindowControllerState>();
864
865 // Create the window, and set the state as its user data.
866 if (window_properties.prevent_resize) {
867 glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
868 }
869#if defined(__linux__)
870 glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
871#endif
872 state->window = UniqueGLFWwindowPtr(
873 glfwCreateWindow(window_properties.width, window_properties.height,
874 window_properties.title, NULL, NULL),
875 glfwDestroyWindow);
876 glfwDefaultWindowHints();
877 GLFWwindow* window = state->window.get();
878 if (window == nullptr) {
879 return nullptr;
880 }
882 glfwSetWindowUserPointer(window, state.get());
883
884 // Create the share window before starting the engine, since it may call
885 // EngineMakeResourceContextCurrent immediately.
886 state->resource_window = CreateShareWindowForWindow(window);
887
888 state->engine = std::make_unique<FlutterDesktopEngineState>();
889 state->engine->window_controller = state.get();
890
891 // Create an event loop for the window. It is not running yet.
892 auto event_loop = std::make_unique<flutter::GLFWEventLoop>(
893 std::this_thread::get_id(), // main GLFW thread
894 [engine_state = state->engine.get()](const auto* task) {
895 if (FlutterEngineRunTask(engine_state->flutter_engine, task) !=
896 kSuccess) {
897 std::cerr << "Could not post an engine task." << std::endl;
898 }
899 });
900
901 // Start the engine.
902 if (!RunFlutterEngine(state->engine.get(), engine_properties,
903 std::move(event_loop))) {
904 return nullptr;
905 }
906 SetUpCommonEngineState(state->engine.get(), window);
907
908 state->window_wrapper = std::make_unique<FlutterDesktopWindow>();
909 state->window_wrapper->window = window;
910
911 // Set up the keyboard handlers
912 auto internal_plugin_messenger =
913 state->engine->internal_plugin_registrar->messenger();
914 state->keyboard_hook_handlers.push_back(
915 std::make_unique<flutter::KeyEventHandler>(internal_plugin_messenger));
916 state->keyboard_hook_handlers.push_back(
917 std::make_unique<flutter::TextInputPlugin>(internal_plugin_messenger));
918
919 // Trigger an initial size callback to send size information to Flutter.
920 state->monitor_screen_coordinates_per_inch = GetScreenCoordinatesPerInch();
921 int width_px, height_px;
922 glfwGetFramebufferSize(window, &width_px, &height_px);
923 GLFWFramebufferSizeCallback(window, width_px, height_px);
924
925 // Set up GLFW callbacks for the window.
926 glfwSetFramebufferSizeCallback(window, GLFWFramebufferSizeCallback);
927 glfwSetWindowRefreshCallback(window, GLFWWindowRefreshCallback);
929
930 return state.release();
931}
void GLFWWindowRefreshCallback(GLFWwindow *window)
static UniqueGLFWwindowPtr CreateShareWindowForWindow(GLFWwindow *window)
static bool RunFlutterEngine(FlutterDesktopEngineState *engine_state, const FlutterDesktopEngineProperties &engine_properties, std::unique_ptr< flutter::EventLoop > event_loop)
static void GLFWFramebufferSizeCallback(GLFWwindow *window, int width_px, int height_px)
static void SetUpCommonEngineState(FlutterDesktopEngineState *state, GLFWwindow *window)
static double GetScreenCoordinatesPerInch()
static void GLFWClearCanvas(GLFWwindow *window)

References CreateShareWindowForWindow(), GLFW_FALSE, GLFWClearCanvas(), FlutterDesktopWindowProperties::height, FlutterDesktopWindowProperties::prevent_resize, FlutterDesktopWindowProperties::title, FlutterDesktopWindowProperties::width, and window.

◆ FlutterDesktopDestroyWindow()

void FlutterDesktopDestroyWindow ( FlutterDesktopWindowControllerRef  controller)

Definition at line 933 of file flutter_glfw.cc.

933 {
934 controller->engine->messenger->SetEngine(nullptr);
936 controller->engine->plugin_registrar.get();
937 if (registrar->destruction_handler) {
938 registrar->destruction_handler(registrar);
939 }
940 FlutterEngineShutdown(controller->engine->flutter_engine);
941 delete controller;
942}
FlutterEngineResult FlutterEngineShutdown(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Shuts down a Flutter engine instance. The engine handle is no longer valid for any calls in the embed...
Definition embedder.cc:2649
FlutterDesktopOnPluginRegistrarDestroyed destruction_handler
std::unique_ptr< FlutterDesktopEngineState > engine

References FlutterDesktopPluginRegistrar::destruction_handler, FlutterDesktopWindowControllerState::engine, and FlutterEngineShutdown().

◆ FlutterDesktopGetEngine()

FlutterDesktopEngineRef FlutterDesktopGetEngine ( FlutterDesktopWindowControllerRef  controller)

Definition at line 1047 of file flutter_glfw.cc.

1048 {
1049 return controller->engine.get();
1050}

References FlutterDesktopWindowControllerState::engine.

◆ FlutterDesktopGetPluginRegistrar()

FlutterDesktopPluginRegistrarRef FlutterDesktopGetPluginRegistrar ( FlutterDesktopEngineRef  engine,
const char *  plugin_name 
)

Definition at line 1052 of file flutter_glfw.cc.

1054 {
1055 // Currently, one registrar acts as the registrar for all plugins, so the
1056 // name is ignored. It is part of the API to reduce churn in the future when
1057 // aligning more closely with the Flutter registrar system.
1058 return engine->plugin_registrar.get();
1059}
FlutterEngine engine
Definition main.cc:84

References engine.

◆ FlutterDesktopGetWindow()

FlutterDesktopWindowRef FlutterDesktopGetWindow ( FlutterDesktopWindowControllerRef  controller)

Definition at line 1039 of file flutter_glfw.cc.

1040 {
1041 // Currently, one registrar acts as the registrar for all plugins, so the
1042 // name is ignored. It is part of the API to reduce churn in the future when
1043 // aligning more closely with the Flutter registrar system.
1044 return controller->window_wrapper.get();
1045}
std::unique_ptr< FlutterDesktopWindow > window_wrapper

References FlutterDesktopWindowControllerState::window_wrapper.

◆ FlutterDesktopInit()

bool FlutterDesktopInit ( )

Definition at line 850 of file flutter_glfw.cc.

850 {
851 // Before making any GLFW calls, set up a logging error handler.
852 glfwSetErrorCallback(GLFWErrorCallback);
853 return glfwInit();
854}
static void GLFWErrorCallback(int error_code, const char *description)

References GLFWErrorCallback().

◆ FlutterDesktopMessengerAddRef()

FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef ( FlutterDesktopMessengerRef  messenger)

Definition at line 205 of file flutter_glfw.cc.

206 {
207 messenger->AddRef();
208 return messenger;
209}

References FlutterDesktopMessenger::AddRef().

Referenced by SetUpCommonEngineState().

◆ FlutterDesktopMessengerIsAvailable()

bool FlutterDesktopMessengerIsAvailable ( FlutterDesktopMessengerRef  messenger)

Definition at line 215 of file flutter_glfw.cc.

215 {
216 return messenger->GetEngine() != nullptr;
217}
FlutterDesktopEngineState * GetEngine() const
Getter for the engine field.

References FlutterDesktopMessenger::GetEngine().

◆ FlutterDesktopMessengerLock()

FlutterDesktopMessengerRef FlutterDesktopMessengerLock ( FlutterDesktopMessengerRef  messenger)

Definition at line 219 of file flutter_glfw.cc.

220 {
221 messenger->GetMutex().lock();
222 return messenger;
223}

References FlutterDesktopMessenger::GetMutex().

◆ FlutterDesktopMessengerRelease()

void FlutterDesktopMessengerRelease ( FlutterDesktopMessengerRef  messenger)

Definition at line 211 of file flutter_glfw.cc.

211 {
212 messenger->Release();
213}

References FlutterDesktopMessenger::Release().

Referenced by SetUpCommonEngineState().

◆ FlutterDesktopMessengerSend()

bool FlutterDesktopMessengerSend ( FlutterDesktopMessengerRef  messenger,
const char *  channel,
const uint8_t *  message,
const size_t  message_size 
)

Definition at line 1161 of file flutter_glfw.cc.

1164 {
1166 message_size, nullptr, nullptr);
1167}
const gchar * channel
bool FlutterDesktopMessengerSendWithReply(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)

References channel, FlutterDesktopMessengerSendWithReply(), and message.

◆ FlutterDesktopMessengerSendResponse()

void FlutterDesktopMessengerSendResponse ( FlutterDesktopMessengerRef  messenger,
const FlutterDesktopMessageResponseHandle handle,
const uint8_t *  data,
size_t  data_length 
)

Definition at line 1169 of file flutter_glfw.cc.

1173 {
1175 messenger->GetEngine()->flutter_engine, handle, data, data_length);
1176}
FlutterEngineResult FlutterEngineSendPlatformMessageResponse(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
Send a response from the native side to a platform message from the Dart Flutter application.
Definition embedder.cc:3078
std::shared_ptr< const fml::Mapping > data

References data, FlutterEngineSendPlatformMessageResponse(), and FlutterDesktopMessenger::GetEngine().

◆ FlutterDesktopMessengerSendWithReply()

bool FlutterDesktopMessengerSendWithReply ( FlutterDesktopMessengerRef  messenger,
const char *  channel,
const uint8_t *  message,
const size_t  message_size,
const FlutterDesktopBinaryReply  reply,
void *  user_data 
)

Definition at line 1125 of file flutter_glfw.cc.

1130 {
1131 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
1132 if (reply != nullptr && user_data != nullptr) {
1134 messenger->GetEngine()->flutter_engine, reply, user_data,
1135 &response_handle);
1136 if (result != kSuccess) {
1137 std::cout << "Failed to create response handle\n";
1138 return false;
1139 }
1140 }
1141
1142 FlutterPlatformMessage platform_message = {
1143 sizeof(FlutterPlatformMessage),
1144 channel,
1145 message,
1146 message_size,
1147 response_handle,
1148 };
1149
1151 messenger->GetEngine()->flutter_engine, &platform_message);
1152
1153 if (response_handle != nullptr) {
1155 messenger->GetEngine()->flutter_engine, response_handle);
1156 }
1157
1158 return message_result == kSuccess;
1159}
FlutterEngineResult FlutterPlatformMessageCreateResponseHandle(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterDataCallback data_callback, void *user_data, FlutterPlatformMessageResponseHandle **response_out)
Creates a platform message response handle that allows the embedder to set a native callback for a re...
Definition embedder.cc:3028
FlutterEngineResult FlutterEngineSendPlatformMessage(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessage *flutter_message)
Definition embedder.cc:2977
FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterPlatformMessageResponseHandle *response)
Collects the handle created using FlutterPlatformMessageCreateResponseHandle.
Definition embedder.cc:3063
FlutterEngineResult
Definition embedder.h:72
@ kSuccess
Definition embedder.h:73

References channel, FlutterEngineSendPlatformMessage(), FlutterPlatformMessageCreateResponseHandle(), FlutterPlatformMessageReleaseResponseHandle(), FlutterDesktopMessenger::GetEngine(), kSuccess, message, and user_data.

Referenced by FlutterDesktopMessengerSend().

◆ FlutterDesktopMessengerSetCallback()

void FlutterDesktopMessengerSetCallback ( FlutterDesktopMessengerRef  messenger,
const char *  channel,
FlutterDesktopMessageCallback  callback,
void *  user_data 
)

Definition at line 1178 of file flutter_glfw.cc.

1181 {
1182 messenger->GetEngine()->message_dispatcher->SetMessageCallback(
1184}
FlutterDesktopBinaryReply callback

References callback, channel, FlutterDesktopMessenger::GetEngine(), FlutterDesktopEngineState::message_dispatcher, and user_data.

◆ FlutterDesktopMessengerUnlock()

void FlutterDesktopMessengerUnlock ( FlutterDesktopMessengerRef  messenger)

Definition at line 225 of file flutter_glfw.cc.

225 {
226 messenger->GetMutex().unlock();
227}

References FlutterDesktopMessenger::GetMutex().

◆ FlutterDesktopPluginRegistrarEnableInputBlocking()

void FlutterDesktopPluginRegistrarEnableInputBlocking ( FlutterDesktopPluginRegistrarRef  registrar,
const char *  channel 
)

Definition at line 1098 of file flutter_glfw.cc.

1100 {
1101 registrar->engine->message_dispatcher->EnableInputBlockingForChannel(channel);
1102}
FlutterDesktopEngineState * engine

References channel, FlutterDesktopPluginRegistrar::engine, and FlutterDesktopEngineState::message_dispatcher.

◆ FlutterDesktopPluginRegistrarGetMessenger()

FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger ( FlutterDesktopPluginRegistrarRef  registrar)

Definition at line 1104 of file flutter_glfw.cc.

1105 {
1106 return registrar->engine->messenger.get();
1107}
FlutterDesktopMessengerReferenceOwner messenger

References FlutterDesktopPluginRegistrar::engine, and FlutterDesktopEngineState::messenger.

◆ FlutterDesktopPluginRegistrarGetWindow()

FlutterDesktopWindowRef FlutterDesktopPluginRegistrarGetWindow ( FlutterDesktopPluginRegistrarRef  registrar)

Definition at line 1115 of file flutter_glfw.cc.

1116 {
1118 registrar->engine->window_controller;
1119 if (!controller) {
1120 return nullptr;
1121 }
1122 return controller->window_wrapper.get();
1123}

References FlutterDesktopPluginRegistrar::engine, FlutterDesktopEngineState::window_controller, and FlutterDesktopWindowControllerState::window_wrapper.

◆ FlutterDesktopPluginRegistrarSetDestructionHandler()

void FlutterDesktopPluginRegistrarSetDestructionHandler ( FlutterDesktopPluginRegistrarRef  registrar,
FlutterDesktopOnPluginRegistrarDestroyed  callback 
)

Definition at line 1109 of file flutter_glfw.cc.

1111 {
1112 registrar->destruction_handler = callback;
1113}

References callback, and FlutterDesktopPluginRegistrar::destruction_handler.

◆ FlutterDesktopRegistrarGetTextureRegistrar()

FlutterDesktopTextureRegistrarRef FlutterDesktopRegistrarGetTextureRegistrar ( FlutterDesktopPluginRegistrarRef  registrar)

Definition at line 1186 of file flutter_glfw.cc.

1187 {
1188 std::cerr << "GLFW Texture support is not implemented yet." << std::endl;
1189 return nullptr;
1190}

◆ FlutterDesktopRunEngine()

FlutterDesktopEngineRef FlutterDesktopRunEngine ( const FlutterDesktopEngineProperties properties)

Definition at line 1061 of file flutter_glfw.cc.

1062 {
1063 auto engine_state = std::make_unique<FlutterDesktopEngineState>();
1064
1065 auto event_loop = std::make_unique<flutter::HeadlessEventLoop>(
1066 std::this_thread::get_id(),
1067 [state = engine_state.get()](const auto* task) {
1068 if (FlutterEngineRunTask(state->flutter_engine, task) != kSuccess) {
1069 std::cerr << "Could not post an engine task." << std::endl;
1070 }
1071 });
1072
1073 if (!RunFlutterEngine(engine_state.get(), properties,
1074 std::move(event_loop))) {
1075 return nullptr;
1076 }
1077 SetUpCommonEngineState(engine_state.get(), nullptr);
1078
1079 return engine_state.release();
1080}

◆ FlutterDesktopRunEngineEventLoopWithTimeout()

void FlutterDesktopRunEngineEventLoopWithTimeout ( FlutterDesktopEngineRef  engine,
uint32_t  timeout_milliseconds 
)

Definition at line 1082 of file flutter_glfw.cc.

1084 {
1085 std::chrono::nanoseconds wait_duration =
1086 timeout_milliseconds == 0
1087 ? std::chrono::nanoseconds::max()
1088 : std::chrono::milliseconds(timeout_milliseconds);
1089 engine->event_loop->WaitForEvents(wait_duration);
1090}
Definition ref_ptr.h:261

References engine.

Referenced by FlutterDesktopRunWindowEventLoopWithTimeout().

◆ FlutterDesktopRunWindowEventLoopWithTimeout()

bool FlutterDesktopRunWindowEventLoopWithTimeout ( FlutterDesktopWindowControllerRef  controller,
uint32_t  timeout_milliseconds 
)

Definition at line 1031 of file flutter_glfw.cc.

1033 {
1035 timeout_milliseconds);
1036 return !glfwWindowShouldClose(controller->window.get());
1037}
void FlutterDesktopRunEngineEventLoopWithTimeout(FlutterDesktopEngineRef engine, uint32_t timeout_milliseconds)

References FlutterDesktopWindowControllerState::engine, FlutterDesktopRunEngineEventLoopWithTimeout(), and FlutterDesktopWindowControllerState::window.

◆ FlutterDesktopShutDownEngine()

bool FlutterDesktopShutDownEngine ( FlutterDesktopEngineRef  engine)

Definition at line 1092 of file flutter_glfw.cc.

1092 {
1093 auto result = FlutterEngineShutdown(engine->flutter_engine);
1094 delete engine;
1095 return (result == kSuccess);
1096}

References engine, FlutterEngineShutdown(), and kSuccess.

◆ FlutterDesktopTerminate()

void FlutterDesktopTerminate ( )

Definition at line 856 of file flutter_glfw.cc.

856 {
857 glfwTerminate();
858}

◆ FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable()

bool FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable ( FlutterDesktopTextureRegistrarRef  texture_registrar,
int64_t  texture_id 
)

Definition at line 1207 of file flutter_glfw.cc.

1209 {
1210 std::cerr << "GLFW Texture support is not implemented yet." << std::endl;
1211 return false;
1212}

◆ FlutterDesktopTextureRegistrarRegisterExternalTexture()

int64_t FlutterDesktopTextureRegistrarRegisterExternalTexture ( FlutterDesktopTextureRegistrarRef  texture_registrar,
const FlutterDesktopTextureInfo texture_info 
)

Definition at line 1192 of file flutter_glfw.cc.

1194 {
1195 std::cerr << "GLFW Texture support is not implemented yet." << std::endl;
1196 return -1;
1197}

◆ FlutterDesktopTextureRegistrarUnregisterExternalTexture()

void FlutterDesktopTextureRegistrarUnregisterExternalTexture ( FlutterDesktopTextureRegistrarRef  texture_registrar,
int64_t  texture_id,
void(*)(void *user_data callback,
void *  user_data 
)

Definition at line 1199 of file flutter_glfw.cc.

1203 {
1204 std::cerr << "GLFW Texture support is not implemented yet." << std::endl;
1205}

◆ FlutterDesktopWindowGetFrame()

void FlutterDesktopWindowGetFrame ( FlutterDesktopWindowRef  flutter_window,
int *  x,
int *  y,
int *  width,
int *  height 
)

Definition at line 964 of file flutter_glfw.cc.

968 {
969 glfwGetWindowPos(flutter_window->window, x, y);
970 glfwGetWindowSize(flutter_window->window, width, height);
971 // The above gives content area size and position; adjust for the window
972 // decoration to give actual window frame.
973 int frame_left, frame_top, frame_right, frame_bottom;
974 glfwGetWindowFrameSize(flutter_window->window, &frame_left, &frame_top,
975 &frame_right, &frame_bottom);
976 if (x) {
977 *x -= frame_left;
978 }
979 if (y) {
980 *y -= frame_top;
981 }
982 if (width) {
983 *width += frame_left + frame_right;
984 }
985 if (height) {
986 *height += frame_top + frame_bottom;
987 }
988}
int32_t x
double y
int32_t height
int32_t width

References height, width, FlutterDesktopWindow::window, x, and y.

◆ FlutterDesktopWindowGetScaleFactor()

double FlutterDesktopWindowGetScaleFactor ( FlutterDesktopWindowRef  flutter_window)

Definition at line 1005 of file flutter_glfw.cc.

1006 {
1007 return flutter_window->pixels_per_screen_coordinate;
1008}
double pixels_per_screen_coordinate

References FlutterDesktopWindow::pixels_per_screen_coordinate.

◆ FlutterDesktopWindowSetFrame()

void FlutterDesktopWindowSetFrame ( FlutterDesktopWindowRef  flutter_window,
int  x,
int  y,
int  width,
int  height 
)

Definition at line 990 of file flutter_glfw.cc.

994 {
995 // Get the window decoration sizes to adjust, since the GLFW setters take
996 // content position and size.
997 int frame_left, frame_top, frame_right, frame_bottom;
998 glfwGetWindowFrameSize(flutter_window->window, &frame_left, &frame_top,
999 &frame_right, &frame_bottom);
1000 glfwSetWindowPos(flutter_window->window, x + frame_left, y + frame_top);
1001 glfwSetWindowSize(flutter_window->window, width - frame_left - frame_right,
1002 height - frame_top - frame_bottom);
1003}

References height, width, FlutterDesktopWindow::window, x, and y.

◆ FlutterDesktopWindowSetHoverEnabled()

void FlutterDesktopWindowSetHoverEnabled ( FlutterDesktopWindowRef  flutter_window,
bool  enabled 
)

Definition at line 944 of file flutter_glfw.cc.

945 {
946 flutter_window->hover_tracking_enabled = enabled;
947 SetHoverCallbacksEnabled(flutter_window->window, enabled);
948}
static void SetHoverCallbacksEnabled(GLFWwindow *window, bool enabled)

References FlutterDesktopWindow::hover_tracking_enabled, SetHoverCallbacksEnabled(), and FlutterDesktopWindow::window.

◆ FlutterDesktopWindowSetIcon()

void FlutterDesktopWindowSetIcon ( FlutterDesktopWindowRef  flutter_window,
uint8_t *  pixel_data,
int  width,
int  height 
)

Definition at line 956 of file flutter_glfw.cc.

959 {
960 GLFWimage image = {width, height, static_cast<unsigned char*>(pixel_data)};
961 glfwSetWindowIcon(flutter_window->window, pixel_data ? 1 : 0, &image);
962}
FlutterVulkanImage * image

References height, image, width, and FlutterDesktopWindow::window.

◆ FlutterDesktopWindowSetPixelRatioOverride()

void FlutterDesktopWindowSetPixelRatioOverride ( FlutterDesktopWindowRef  flutter_window,
double  pixel_ratio 
)

Definition at line 1010 of file flutter_glfw.cc.

1012 {
1013 flutter_window->pixel_ratio_override = pixel_ratio;
1014 // Send a metrics update using the new pixel ratio.
1015 int width_px, height_px;
1016 glfwGetFramebufferSize(flutter_window->window, &width_px, &height_px);
1017 if (width_px > 0 && height_px > 0) {
1018 auto* controller = GetWindowController(flutter_window->window);
1019 SendWindowMetrics(controller, width_px, height_px);
1020 }
1021}
static FlutterDesktopWindowControllerState * GetWindowController(GLFWwindow *window)
static void SendWindowMetrics(FlutterDesktopWindowControllerState *controller, int width, int height)

References GetWindowController(), FlutterDesktopWindow::pixel_ratio_override, SendWindowMetrics(), and FlutterDesktopWindow::window.

◆ FlutterDesktopWindowSetSizeLimits()

void FlutterDesktopWindowSetSizeLimits ( FlutterDesktopWindowRef  flutter_window,
FlutterDesktopSize  minimum_size,
FlutterDesktopSize  maximum_size 
)

Definition at line 1023 of file flutter_glfw.cc.

1025 {
1026 glfwSetWindowSizeLimits(flutter_window->window, minimum_size.width,
1027 minimum_size.height, maximum_size.width,
1028 maximum_size.height);
1029}

References FlutterDesktopSize::height, FlutterDesktopSize::width, and FlutterDesktopWindow::window.

◆ FlutterDesktopWindowSetTitle()

void FlutterDesktopWindowSetTitle ( FlutterDesktopWindowRef  flutter_window,
const char *  title 
)

Definition at line 950 of file flutter_glfw.cc.

951 {
952 GLFWwindow* window = flutter_window->window;
953 glfwSetWindowTitle(window, title);
954}

References window, and FlutterDesktopWindow::window.

◆ GetScreenCoordinatesPerInch()

static double GetScreenCoordinatesPerInch ( )
static

Definition at line 266 of file flutter_glfw.cc.

266 {
267 auto* primary_monitor = glfwGetPrimaryMonitor();
268 if (primary_monitor == nullptr) {
269 return kDpPerInch;
270 }
271 auto* primary_monitor_mode = glfwGetVideoMode(primary_monitor);
272 int primary_monitor_width_mm;
273 glfwGetMonitorPhysicalSize(primary_monitor, &primary_monitor_width_mm,
274 nullptr);
275 if (primary_monitor_width_mm == 0) {
276 return kDpPerInch;
277 }
278 return primary_monitor_mode->width / (primary_monitor_width_mm / 25.4);
279}
static constexpr double kDpPerInch

References kDpPerInch.

◆ GetWindowController()

◆ GLFWAssignEventCallbacks()

static void GLFWAssignEventCallbacks ( GLFWwindow *  window)
static

Definition at line 545 of file flutter_glfw.cc.

545 {
546 glfwPollEvents();
547 glfwSetKeyCallback(window, GLFWKeyCallback);
548 glfwSetCharCallback(window, GLFWCharCallback);
549 glfwSetMouseButtonCallback(window, GLFWMouseButtonCallback);
550 glfwSetScrollCallback(window, GLFWScrollCallback);
551 if (GetWindowController(window)->window_wrapper->hover_tracking_enabled) {
553 }
554}
static void GLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
static void GLFWCharCallback(GLFWwindow *window, unsigned int code_point)
static void GLFWMouseButtonCallback(GLFWwindow *window, int key, int action, int mods)
static void GLFWScrollCallback(GLFWwindow *window, double delta_x, double delta_y)

References GetWindowController(), GLFWCharCallback(), GLFWKeyCallback(), GLFWMouseButtonCallback(), GLFWScrollCallback(), SetHoverCallbacksEnabled(), and window.

Referenced by EngineOnFlutterPlatformMessage().

◆ GLFWCharCallback()

static void GLFWCharCallback ( GLFWwindow *  window,
unsigned int  code_point 
)
static

Definition at line 517 of file flutter_glfw.cc.

517 {
518 for (const auto& handler :
519 GetWindowController(window)->keyboard_hook_handlers) {
520 handler->CharHook(window, code_point);
521 }
522}
const gchar FlBinaryMessengerMessageHandler handler

References GetWindowController(), handler, FlutterDesktopWindowControllerState::keyboard_hook_handlers, and window.

Referenced by GLFWAssignEventCallbacks().

◆ GLFWClearCanvas()

static void GLFWClearCanvas ( GLFWwindow *  window)
static

Definition at line 664 of file flutter_glfw.cc.

664 {
665 glfwMakeContextCurrent(window);
666 // This color is Material Blue Grey.
667 glClearColor(236.0f / 255.0f, 239.0f / 255.0f, 241.0f / 255.0f, 0.0f);
668 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
669 glFlush();
670 glfwSwapBuffers(window);
671 glfwMakeContextCurrent(nullptr);
672}

References window.

Referenced by FlutterDesktopCreateWindow().

◆ GLFWClearEventCallbacks()

static void GLFWClearEventCallbacks ( GLFWwindow *  window)
static

Definition at line 557 of file flutter_glfw.cc.

557 {
558 glfwSetKeyCallback(window, nullptr);
559 glfwSetCharCallback(window, nullptr);
560 glfwSetMouseButtonCallback(window, nullptr);
561 glfwSetScrollCallback(window, nullptr);
563}

References SetHoverCallbacksEnabled(), and window.

Referenced by EngineOnFlutterPlatformMessage().

◆ GLFWCursorEnterCallback()

static void GLFWCursorEnterCallback ( GLFWwindow *  window,
int  entered 
)
static

Definition at line 440 of file flutter_glfw.cc.

440 {
441 FlutterPointerEvent event = {};
442 event.phase =
446}
@ kRemove
Definition embedder.h:1267
@ kAdd
Definition embedder.h:1262
static void SendPointerEventWithData(GLFWwindow *window, const FlutterPointerEvent &event_data)
static void SetEventLocationFromCursorPosition(GLFWwindow *window, FlutterPointerEvent *event_data)
FlutterPointerPhase phase
Definition embedder.h:1309

References kAdd, kRemove, FlutterPointerEvent::phase, SendPointerEventWithData(), SetEventLocationFromCursorPosition(), and window.

Referenced by GLFWMouseButtonCallback(), and SetHoverCallbacksEnabled().

◆ GLFWCursorPositionCallback()

static void GLFWCursorPositionCallback ( GLFWwindow *  window,
double  x,
double  y 
)
static

Definition at line 449 of file flutter_glfw.cc.

449 {
450 FlutterPointerEvent event = {};
451 event.x = x;
452 event.y = y;
453 auto* controller = GetWindowController(window);
454 SetEventPhaseFromCursorButtonState(window, &event, controller->buttons);
456}
static void SetEventPhaseFromCursorButtonState(GLFWwindow *window, FlutterPointerEvent *event_data, int64_t buttons)
double x
The x coordinate of the pointer event in physical pixels.
Definition embedder.h:1315

References GetWindowController(), SendPointerEventWithData(), SetEventPhaseFromCursorButtonState(), window, x, FlutterPointerEvent::x, and y.

Referenced by GLFWMouseButtonCallback(), and SetHoverCallbacksEnabled().

◆ GLFWErrorCallback()

static void GLFWErrorCallback ( int  error_code,
const char *  description 
)
static

Definition at line 674 of file flutter_glfw.cc.

674 {
675 std::cerr << "GLFW error " << error_code << ": " << description << std::endl;
676}

Referenced by FlutterDesktopInit().

◆ GLFWFramebufferSizeCallback()

static void GLFWFramebufferSizeCallback ( GLFWwindow *  window,
int  width_px,
int  height_px 
)
static

Definition at line 328 of file flutter_glfw.cc.

330 {
331 int width;
332 glfwGetWindowSize(window, &width, nullptr);
333 auto* controller = GetWindowController(window);
334 controller->window_wrapper->pixels_per_screen_coordinate =
335 width > 0 ? width_px / width : 1;
336
337 SendWindowMetrics(controller, width_px, height_px);
338 controller->window_wrapper->skip_next_window_refresh = true;
339}

References GetWindowController(), SendWindowMetrics(), width, and window.

◆ GLFWKeyCallback()

static void GLFWKeyCallback ( GLFWwindow *  window,
int  key,
int  scancode,
int  action,
int  mods 
)
static

Definition at line 525 of file flutter_glfw.cc.

529 {
530 for (const auto& handler :
531 GetWindowController(window)->keyboard_hook_handlers) {
532 handler->KeyboardHook(window, key, scancode, action, mods);
533 }
534}

References action, GetWindowController(), handler, key, FlutterDesktopWindowControllerState::keyboard_hook_handlers, scancode, and window.

Referenced by GLFWAssignEventCallbacks().

◆ GLFWMouseButtonCallback()

static void GLFWMouseButtonCallback ( GLFWwindow *  window,
int  key,
int  action,
int  mods 
)
static

Definition at line 459 of file flutter_glfw.cc.

462 {
463 int64_t button;
464 if (key == GLFW_MOUSE_BUTTON_LEFT) {
466 } else if (key == GLFW_MOUSE_BUTTON_RIGHT) {
468 } else {
469 return;
470 }
471
472 auto* controller = GetWindowController(window);
473 controller->buttons = (action == GLFW_PRESS) ? controller->buttons | button
474 : controller->buttons & ~button;
475
476 FlutterPointerEvent event = {};
477 SetEventPhaseFromCursorButtonState(window, &event, controller->buttons);
480
481 // If mouse tracking isn't already enabled, turn it on for the duration of
482 // the drag to generate kMove events.
483 bool hover_enabled =
484 GetWindowController(window)->window_wrapper->hover_tracking_enabled;
485 if (!hover_enabled) {
486 glfwSetCursorPosCallback(window, (controller->buttons != 0)
488 : nullptr);
489 }
490 // Disable enter/exit events while the mouse button is down; GLFW will send
491 // an exit event when the mouse button is released, and the pointer should
492 // stay valid until then.
493 if (hover_enabled) {
494 glfwSetCursorEnterCallback(
495 window, (controller->buttons != 0) ? nullptr : GLFWCursorEnterCallback);
496 }
497}
@ kFlutterPointerButtonMousePrimary
Definition embedder.h:1289
@ kFlutterPointerButtonMouseSecondary
Definition embedder.h:1290
static void GLFWCursorPositionCallback(GLFWwindow *window, double x, double y)
static void GLFWCursorEnterCallback(GLFWwindow *window, int entered)

References action, GetWindowController(), GLFWCursorEnterCallback(), GLFWCursorPositionCallback(), key, kFlutterPointerButtonMousePrimary, kFlutterPointerButtonMouseSecondary, SendPointerEventWithData(), SetEventLocationFromCursorPosition(), SetEventPhaseFromCursorButtonState(), window, and FlutterDesktopWindowControllerState::window_wrapper.

Referenced by GLFWAssignEventCallbacks().

◆ GLFWScrollCallback()

static void GLFWScrollCallback ( GLFWwindow *  window,
double  delta_x,
double  delta_y 
)
static

Definition at line 500 of file flutter_glfw.cc.

502 {
503 FlutterPointerEvent event = {};
505 auto* controller = GetWindowController(window);
506 SetEventPhaseFromCursorButtonState(window, &event, controller->buttons);
508 // TODO(chrome-bot): See if this can be queried from the OS; this value is
509 // chosen arbitrarily to get something that feels reasonable.
510 const int kScrollOffsetMultiplier = 20;
511 event.scroll_delta_x = delta_x * kScrollOffsetMultiplier;
512 event.scroll_delta_y = -delta_y * kScrollOffsetMultiplier;
514}
@ kFlutterPointerSignalKindScroll
Definition embedder.h:1301

References GetWindowController(), kFlutterPointerSignalKindScroll, SendPointerEventWithData(), SetEventLocationFromCursorPosition(), SetEventPhaseFromCursorButtonState(), and window.

Referenced by GLFWAssignEventCallbacks().

◆ GLFWWindowRefreshCallback()

void GLFWWindowRefreshCallback ( GLFWwindow *  window)

Definition at line 342 of file flutter_glfw.cc.

342 {
343 auto* controller = GetWindowController(window);
344 if (controller->window_wrapper->skip_next_window_refresh) {
345 controller->window_wrapper->skip_next_window_refresh = false;
346 return;
347 }
348 // There's no engine API to request a redraw explicitly, so instead send a
349 // window metrics event with the current size to trigger it.
350 int width_px, height_px;
351 glfwGetFramebufferSize(window, &width_px, &height_px);
352 if (width_px > 0 && height_px > 0) {
353 SendWindowMetrics(controller, width_px, height_px);
354 }
355}

References GetWindowController(), SendWindowMetrics(), and window.

◆ LoadAotData()

UniqueAotDataPtr LoadAotData ( const std::filesystem::path &  aot_data_path)

Definition at line 680 of file flutter_glfw.cc.

680 {
681 if (aot_data_path.empty()) {
682 std::cerr
683 << "Attempted to load AOT data, but no aot_data_path was provided."
684 << std::endl;
685 return nullptr;
686 }
687 std::string path_string = aot_data_path.string();
688 if (!std::filesystem::exists(aot_data_path)) {
689 std::cerr << "Can't load AOT data from " << path_string << "; no such file."
690 << std::endl;
691 return nullptr;
692 }
693 FlutterEngineAOTDataSource source = {};
695 source.elf_path = path_string.c_str();
696 FlutterEngineAOTData data = nullptr;
697 auto result = FlutterEngineCreateAOTData(&source, &data);
698 if (result != kSuccess) {
699 std::cerr << "Failed to load AOT data from: " << path_string << std::endl;
700 return nullptr;
701 }
702 return UniqueAotDataPtr(data);
703}
FlutterEngineResult FlutterEngineCreateAOTData(const FlutterEngineAOTDataSource *source, FlutterEngineAOTData *data_out)
Creates the necessary data structures to launch a Flutter Dart application in AOT mode....
Definition embedder.cc:1682
@ kFlutterEngineAOTDataSourceTypeElfPath
Definition embedder.h:2428
std::unique_ptr< _FlutterEngineAOTData, AOTDataDeleter > UniqueAotDataPtr
FlutterEngineAOTDataSourceType type
Definition embedder.h:2434
const char * elf_path
Absolute path to an ELF library file.
Definition embedder.h:2437

References data, FlutterEngineAOTDataSource::elf_path, FlutterEngineCreateAOTData(), kFlutterEngineAOTDataSourceTypeElfPath, kSuccess, and FlutterEngineAOTDataSource::type.

Referenced by RunFlutterEngine().

◆ RunFlutterEngine()

static bool RunFlutterEngine ( FlutterDesktopEngineState engine_state,
const FlutterDesktopEngineProperties engine_properties,
std::unique_ptr< flutter::EventLoop event_loop 
)
static

Definition at line 712 of file flutter_glfw.cc.

715 {
716 // FlutterProjectArgs is expecting a full argv, so when processing it for
717 // flags the first item is treated as the executable and ignored. Add a dummy
718 // value so that all provided arguments are used.
719 std::vector<const char*> argv = {"placeholder"};
720 if (engine_properties.switches_count > 0) {
721 argv.insert(argv.end(), &engine_properties.switches[0],
722 &engine_properties.switches[engine_properties.switches_count]);
723 }
724
725 std::filesystem::path assets_path =
726 std::filesystem::u8path(engine_properties.assets_path);
727 std::filesystem::path icu_path =
728 std::filesystem::u8path(engine_properties.icu_data_path);
729 std::filesystem::path aot_library_path =
730 std::filesystem::u8path(engine_properties.aot_library_path);
731 if (assets_path.is_relative() || icu_path.is_relative() ||
732 (!aot_library_path.empty() && aot_library_path.is_relative())) {
733 // Treat relative paths as relative to the directory of this executable.
734 std::filesystem::path executable_location =
736 if (executable_location.empty()) {
737 std::cerr << "Unable to find executable location to resolve paths."
738 << std::endl;
739 return false;
740 }
741 assets_path = std::filesystem::path(executable_location) / assets_path;
742 icu_path = std::filesystem::path(executable_location) / icu_path;
743 if (!aot_library_path.empty()) {
744 aot_library_path =
745 std::filesystem::path(executable_location) / aot_library_path;
746 }
747 }
748 // Configure a task runner using the event loop.
749 engine_state->event_loop = std::move(event_loop);
750 FlutterTaskRunnerDescription platform_task_runner = {};
751 ConfigurePlatformTaskRunner(&platform_task_runner, engine_state);
752 FlutterCustomTaskRunners task_runners = {};
753 task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
754 task_runners.platform_task_runner = &platform_task_runner;
755
756 FlutterRendererConfig config = {};
757 config.type = kOpenGL;
758 config.open_gl.struct_size = sizeof(config.open_gl);
764 // Don't provide a resolver in headless mode, since headless mode should
765 // work even if GLFW initialization failed.
766 if (engine_state->window_controller != nullptr) {
768 }
769 const std::string assets_path_string = assets_path.string();
770 const std::string icu_path_string = icu_path.string();
773 args.assets_path = assets_path_string.c_str();
774 args.icu_data_path = icu_path_string.c_str();
775 args.command_line_argc = static_cast<int>(argv.size());
776 args.command_line_argv = &argv[0];
777 args.platform_message_callback = EngineOnFlutterPlatformMessage;
778 args.custom_task_runners = &task_runners;
779
781 engine_state->aot_data = LoadAotData(aot_library_path);
782 if (!engine_state->aot_data) {
783 std::cerr << "Unable to start engine without AOT data." << std::endl;
784 return false;
785 }
786 args.aot_data = engine_state->aot_data.get();
787 }
788
790 auto result = FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, &args,
791 engine_state, &engine);
792 if (result != kSuccess || engine == nullptr) {
793 std::cerr << "Failed to start Flutter engine: error " << result
794 << std::endl;
795 return false;
796 }
797 engine_state->flutter_engine = engine;
798 return true;
799}
FlutterEngineResult FlutterEngineRun(size_t version, const FlutterRendererConfig *config, const FlutterProjectArgs *args, void *user_data, FLUTTER_API_SYMBOL(FlutterEngine) *engine_out)
Initialize and run a Flutter engine instance and return a handle to it. This is a convenience method ...
Definition embedder.cc:1971
bool FlutterEngineRunsAOTCompiledDartCode(void)
Returns if the Flutter engine instance will run AOT compiled Dart code. This call has no threading re...
Definition embedder.cc:3424
#define FLUTTER_API_SYMBOL(symbol)
Definition embedder.h:67
@ kOpenGL
Definition embedder.h:80
#define FLUTTER_ENGINE_VERSION
Definition embedder.h:70
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
UniqueAotDataPtr LoadAotData(const std::filesystem::path &aot_data_path)
static bool EngineClearContext(void *user_data)
static void EngineOnFlutterPlatformMessage(const FlutterPlatformMessage *engine_message, void *user_data)
static bool EngineMakeResourceContextCurrent(void *user_data)
static void ConfigurePlatformTaskRunner(FlutterTaskRunnerDescription *task_runner, FlutterDesktopEngineState *engine_state)
static bool EngineMakeContextCurrent(void *user_data)
static uint32_t EngineGetActiveFbo(void *user_data)
static bool EnginePresent(void *user_data)
static void * EngineProcResolver(void *user_data, const char *name)
char ** argv
Definition library.h:9
std::filesystem::path GetExecutableDirectory()
Definition path_utils.cc:16
const FlutterTaskRunnerDescription * platform_task_runner
Definition embedder.h:1896
size_t struct_size
The size of this struct. Must be sizeof(FlutterCustomTaskRunners).
Definition embedder.h:1891
UniqueAotDataPtr aot_data
std::unique_ptr< flutter::EventLoop > event_loop
ProcResolver gl_proc_resolver
Definition embedder.h:758
size_t struct_size
The size of this struct. Must be sizeof(FlutterOpenGLRendererConfig).
Definition embedder.h:719
BoolCallback make_resource_current
Definition embedder.h:741
size_t struct_size
The size of this struct. Must be sizeof(FlutterProjectArgs).
Definition embedder.h:2458
FlutterOpenGLRendererConfig open_gl
Definition embedder.h:1033
FlutterRendererType type
Definition embedder.h:1031

References FlutterDesktopEngineState::aot_data, FlutterDesktopEngineProperties::aot_library_path, args, argv, FlutterDesktopEngineProperties::assets_path, FlutterOpenGLRendererConfig::clear_current, ConfigurePlatformTaskRunner(), engine, EngineClearContext(), EngineGetActiveFbo(), EngineMakeContextCurrent(), EngineMakeResourceContextCurrent(), EngineOnFlutterPlatformMessage(), EnginePresent(), EngineProcResolver(), FlutterDesktopEngineState::event_loop, FlutterOpenGLRendererConfig::fbo_callback, FLUTTER_API_SYMBOL, FLUTTER_ENGINE_VERSION, FlutterEngineRun(), FlutterEngineRunsAOTCompiledDartCode(), flutter::GetExecutableDirectory(), FlutterOpenGLRendererConfig::gl_proc_resolver, FlutterDesktopEngineProperties::icu_data_path, kOpenGL, kSuccess, LoadAotData(), FlutterOpenGLRendererConfig::make_current, FlutterOpenGLRendererConfig::make_resource_current, FlutterRendererConfig::open_gl, FlutterCustomTaskRunners::platform_task_runner, FlutterOpenGLRendererConfig::present, FlutterOpenGLRendererConfig::struct_size, FlutterCustomTaskRunners::struct_size, FlutterProjectArgs::struct_size, FlutterDesktopEngineProperties::switches, FlutterDesktopEngineProperties::switches_count, FlutterRendererConfig::type, and FlutterDesktopEngineState::window_controller.

◆ SendPointerEventWithData()

static void SendPointerEventWithData ( GLFWwindow *  window,
const FlutterPointerEvent event_data 
)
static

Definition at line 361 of file flutter_glfw.cc.

362 {
363 auto* controller = GetWindowController(window);
364 // If sending anything other than an add, and the pointer isn't already added,
365 // synthesize an add to satisfy Flutter's expectations about events.
366 if (!controller->pointer_currently_added &&
367 event_data.phase != FlutterPointerPhase::kAdd) {
368 FlutterPointerEvent event = {};
370 event.x = event_data.x;
371 event.y = event_data.y;
373 }
374 // Don't double-add (e.g., if events are delivered out of order, so an add has
375 // already been synthesized).
376 if (controller->pointer_currently_added &&
377 event_data.phase == FlutterPointerPhase::kAdd) {
378 return;
379 }
380
381 FlutterPointerEvent event = event_data;
382 // Set metadata that's always the same regardless of the event.
383 event.struct_size = sizeof(event);
384 event.timestamp =
385 std::chrono::duration_cast<std::chrono::microseconds>(
386 std::chrono::high_resolution_clock::now().time_since_epoch())
387 .count();
389 event.buttons =
390 (event.phase == FlutterPointerPhase::kAdd) ? 0 : controller->buttons;
391
392 // Convert all screen coordinates to pixel coordinates.
393 double pixels_per_coordinate =
394 controller->window_wrapper->pixels_per_screen_coordinate;
395 event.x *= pixels_per_coordinate;
396 event.y *= pixels_per_coordinate;
397 event.scroll_delta_x *= pixels_per_coordinate;
398 event.scroll_delta_y *= pixels_per_coordinate;
399 // The GLFW embedder doesn't support multiple views. We assume all pointer
400 // events come from the only view, the implicit view.
401 event.view_id = flutter::kFlutterImplicitViewId;
402
403 FlutterEngineSendPointerEvent(controller->engine->flutter_engine, &event, 1);
404
405 if (event_data.phase == FlutterPointerPhase::kAdd) {
406 controller->pointer_currently_added = true;
407 } else if (event_data.phase == FlutterPointerPhase::kRemove) {
408 controller->pointer_currently_added = false;
409 } else if (event_data.phase == FlutterPointerPhase::kDown) {
410 controller->pointer_currently_down = true;
411 } else if (event_data.phase == FlutterPointerPhase::kUp) {
412 controller->pointer_currently_down = false;
413 }
414}
FlutterEngineResult FlutterEngineSendPointerEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPointerEvent *pointers, size_t events_count)
Definition embedder.cc:2769
@ kUp
Definition embedder.h:1245
@ kDown
Definition embedder.h:1252
@ kFlutterPointerDeviceKindMouse
Definition embedder.h:1280
constexpr int64_t kFlutterImplicitViewId
Definition constants.h:35
size_t struct_size
The size of this struct. Must be sizeof(FlutterPointerEvent).
Definition embedder.h:1308
double y
The y coordinate of the pointer event in physical pixels.
Definition embedder.h:1317

References FlutterEngineSendPointerEvent(), GetWindowController(), kAdd, kDown, flutter::kFlutterImplicitViewId, kFlutterPointerDeviceKindMouse, kRemove, kUp, FlutterPointerEvent::phase, SendPointerEventWithData(), FlutterPointerEvent::struct_size, window, FlutterPointerEvent::x, and FlutterPointerEvent::y.

Referenced by GLFWCursorEnterCallback(), GLFWCursorPositionCallback(), GLFWMouseButtonCallback(), GLFWScrollCallback(), and SendPointerEventWithData().

◆ SendWindowMetrics()

static void SendWindowMetrics ( FlutterDesktopWindowControllerState controller,
int  width,
int  height 
)
static

Definition at line 283 of file flutter_glfw.cc.

285 {
286 double dpi = controller->window_wrapper->pixels_per_screen_coordinate *
288
289 FlutterWindowMetricsEvent event = {};
290 event.struct_size = sizeof(event);
291 event.width = width;
292 event.height = height;
293 if (controller->window_wrapper->pixel_ratio_override == 0.0) {
294 // The Flutter pixel_ratio is defined as DPI/dp. Limit the ratio to a
295 // minimum of 1 to avoid rendering a smaller UI on standard resolution
296 // monitors.
297 event.pixel_ratio = std::max(dpi / kDpPerInch, 1.0);
298 } else {
299 event.pixel_ratio = controller->window_wrapper->pixel_ratio_override;
300 }
301 // The GLFW embedder doesn't support multiple views. We assume all pointer
302 // events come from the only view, the implicit view.
303 event.view_id = flutter::kFlutterImplicitViewId;
304 FlutterEngineSendWindowMetricsEvent(controller->engine->flutter_engine,
305 &event);
306}
FlutterEngineResult FlutterEngineSendWindowMetricsEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterWindowMetricsEvent *flutter_metrics)
Definition embedder.cc:2660
size_t struct_size
The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).
Definition embedder.h:1047

References FlutterDesktopWindowControllerState::engine, FlutterEngineSendWindowMetricsEvent(), height, kDpPerInch, flutter::kFlutterImplicitViewId, FlutterDesktopWindowControllerState::monitor_screen_coordinates_per_inch, FlutterWindowMetricsEvent::struct_size, width, and FlutterDesktopWindowControllerState::window_wrapper.

Referenced by FlutterDesktopWindowSetPixelRatioOverride(), GLFWFramebufferSizeCallback(), and GLFWWindowRefreshCallback().

◆ SetEventLocationFromCursorPosition()

static void SetEventLocationFromCursorPosition ( GLFWwindow *  window,
FlutterPointerEvent event_data 
)
static

Definition at line 417 of file flutter_glfw.cc.

419 {
420 glfwGetCursorPos(window, &event_data->x, &event_data->y);
421}

References window, FlutterPointerEvent::x, and FlutterPointerEvent::y.

Referenced by GLFWCursorEnterCallback(), GLFWMouseButtonCallback(), and GLFWScrollCallback().

◆ SetEventPhaseFromCursorButtonState()

static void SetEventPhaseFromCursorButtonState ( GLFWwindow *  window,
FlutterPointerEvent event_data,
int64_t  buttons 
)
static

Definition at line 427 of file flutter_glfw.cc.

429 {
430 auto* controller = GetWindowController(window);
431 event_data->phase =
432 (buttons == 0)
433 ? (controller->pointer_currently_down ? FlutterPointerPhase::kUp
435 : (controller->pointer_currently_down ? FlutterPointerPhase::kMove
437}
FlutterPointerPhase
The phase of the pointer event.
Definition embedder.h:1237
@ kHover
The pointer moved while up.
Definition embedder.h:1269
@ kMove
Definition embedder.h:1257

References GetWindowController(), kDown, kHover, kMove, kUp, FlutterPointerEvent::phase, and window.

Referenced by GLFWCursorPositionCallback(), GLFWMouseButtonCallback(), and GLFWScrollCallback().

◆ SetHoverCallbacksEnabled()

static void SetHoverCallbacksEnabled ( GLFWwindow *  window,
bool  enabled 
)
static

Definition at line 537 of file flutter_glfw.cc.

537 {
538 glfwSetCursorEnterCallback(window,
539 enabled ? GLFWCursorEnterCallback : nullptr);
540 glfwSetCursorPosCallback(window,
541 enabled ? GLFWCursorPositionCallback : nullptr);
542}

References GLFWCursorEnterCallback(), GLFWCursorPositionCallback(), and window.

Referenced by FlutterDesktopWindowSetHoverEnabled(), GLFWAssignEventCallbacks(), and GLFWClearEventCallbacks().

◆ SetUpCommonEngineState()

static void SetUpCommonEngineState ( FlutterDesktopEngineState state,
GLFWwindow *  window 
)
static

Definition at line 826 of file flutter_glfw.cc.

827 {
828 // Messaging.
832 state->messenger->SetEngine(state);
833 state->message_dispatcher =
834 std::make_unique<flutter::IncomingMessageDispatcher>(
835 state->messenger.get());
836
837 // Plugins.
838 state->plugin_registrar = std::make_unique<FlutterDesktopPluginRegistrar>();
839 state->plugin_registrar->engine = state;
841 std::make_unique<flutter::PluginRegistrar>(state->plugin_registrar.get());
842
843 // System channel handler.
844 state->platform_handler = std::make_unique<flutter::PlatformHandler>(
845 state->internal_plugin_registrar->messenger(), window);
846
847 SetUpLocales(state);
848}
static void SetUpLocales(FlutterDesktopEngineState *state)
std::unique_ptr< FlutterDesktopMessenger, decltype(&FlutterDesktopMessengerRelease)> FlutterDesktopMessengerReferenceOwner
Maintains one ref on the FlutterDesktopMessenger's internal reference count.
void FlutterDesktopMessengerRelease(FlutterDesktopMessengerRef messenger)
FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef(FlutterDesktopMessengerRef messenger)
std::unique_ptr< FlutterDesktopPluginRegistrar > plugin_registrar
std::unique_ptr< flutter::PluginRegistrar > internal_plugin_registrar
std::unique_ptr< flutter::PlatformHandler > platform_handler

References FlutterDesktopMessengerAddRef(), FlutterDesktopMessengerRelease(), FlutterDesktopEngineState::internal_plugin_registrar, FlutterDesktopEngineState::message_dispatcher, FlutterDesktopEngineState::messenger, FlutterDesktopEngineState::platform_handler, FlutterDesktopEngineState::plugin_registrar, SetUpLocales(), and window.

◆ SetUpLocales()

static void SetUpLocales ( FlutterDesktopEngineState state)
static

Definition at line 802 of file flutter_glfw.cc.

802 {
803 std::vector<flutter::LanguageInfo> languages =
805 std::vector<FlutterLocale> flutter_locales =
807 // Convert the locale list to the locale pointer list that must be provided.
808 std::vector<const FlutterLocale*> flutter_locale_list;
809 flutter_locale_list.reserve(flutter_locales.size());
810 std::transform(flutter_locales.begin(), flutter_locales.end(),
811 std::back_inserter(flutter_locale_list),
812 [](const auto& arg) -> const auto* { return &arg; });
814 state->flutter_engine, flutter_locale_list.data(),
815 flutter_locale_list.size());
816 if (result != kSuccess) {
817 std::cerr << "Failed to set up Flutter locales." << std::endl;
818 }
819}
FlutterEngineResult FlutterEngineUpdateLocales(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterLocale **locales, size_t locales_count)
Notify a running engine instance that the locale has been updated. The preferred locale must be the f...
Definition embedder.cc:3365
std::vector< FlutterLocale > ConvertToFlutterLocale(const std::vector< LanguageInfo > &languages)
std::vector< LanguageInfo > GetPreferredLanguageInfo()

References flutter::ConvertToFlutterLocale(), FlutterEngineUpdateLocales(), flutter::GetPreferredLanguageInfo(), and kSuccess.

Referenced by SetUpCommonEngineState().

Variable Documentation

◆ kDpPerInch

constexpr double kDpPerInch = 160.0
staticconstexpr

Definition at line 46 of file flutter_glfw.cc.

Referenced by GetScreenCoordinatesPerInch(), and SendWindowMetrics().

◆ kFlutterDesktopDontCare

const int kFlutterDesktopDontCare = GLFW_DONT_CARE

Definition at line 44 of file flutter_glfw.cc.