@@ -89,9 +89,9 @@ static FlutterEmbedderState *GetSavedEmbedderState(GLFWwindow *window) {
89
89
}
90
90
91
91
// Converts a FlutterPlatformMessage to an equivalent FlutterEmbedderMessage.
92
- static flutter_desktop_embedding:: FlutterEmbedderMessage
93
- ConvertToEmbedderMessage ( const FlutterPlatformMessage &engine_message) {
94
- flutter_desktop_embedding:: FlutterEmbedderMessage embedder_message = {};
92
+ static FlutterEmbedderMessage ConvertToEmbedderMessage (
93
+ const FlutterPlatformMessage &engine_message) {
94
+ FlutterEmbedderMessage embedder_message = {};
95
95
embedder_message.struct_size = sizeof (embedder_message);
96
96
embedder_message.channel = engine_message.channel ;
97
97
embedder_message.message = engine_message.message ;
@@ -284,17 +284,18 @@ static void GLFWErrorCallback(int error_code, const char *description) {
284
284
// the necessary callbacks for rendering within a GLFWwindow.
285
285
//
286
286
// Returns a caller-owned pointer to the engine.
287
- static FlutterEngine RunFlutterEngine (
288
- GLFWwindow *window, const std::string &assets_path,
289
- const std::string &icu_data_path,
290
- const std::vector<std::string> &arguments) {
287
+ static FlutterEngine RunFlutterEngine (GLFWwindow *window,
288
+ const char *assets_path,
289
+ const char *icu_data_path,
290
+ const char **arguments,
291
+ size_t arguments_count) {
291
292
// FlutterProjectArgs is expecting a full argv, so when processing it for
292
293
// flags the first item is treated as the executable and ignored. Add a dummy
293
294
// value so that all provided arguments are used.
294
295
std::vector<const char *> argv = {" placeholder" };
295
- std::transform (
296
- arguments. begin (), arguments .end (), std::back_inserter (argv),
297
- []( const std::string &arg) -> const char * { return arg. c_str (); });
296
+ if (arguments_count > 0 ) {
297
+ argv. insert (argv .end (), &arguments[ 0 ], &arguments[arguments_count]);
298
+ }
298
299
299
300
FlutterRendererConfig config = {};
300
301
config.type = kOpenGL ;
@@ -306,8 +307,8 @@ static FlutterEngine RunFlutterEngine(
306
307
config.open_gl .gl_proc_resolver = GLFWProcResolver;
307
308
FlutterProjectArgs args = {};
308
309
args.struct_size = sizeof (FlutterProjectArgs);
309
- args.assets_path = assets_path. c_str () ;
310
- args.icu_data_path = icu_data_path. c_str () ;
310
+ args.assets_path = assets_path;
311
+ args.icu_data_path = icu_data_path;
311
312
args.command_line_argc = argv.size ();
312
313
args.command_line_argv = &argv[0 ];
313
314
args.platform_message_callback = GLFWOnFlutterPlatformMessage;
@@ -322,20 +323,17 @@ static FlutterEngine RunFlutterEngine(
322
323
return engine;
323
324
}
324
325
325
- namespace flutter_desktop_embedding {
326
-
327
- bool FlutterInit () {
326
+ bool FlutterEmbedderInit () {
328
327
// Before making any GLFW calls, set up a logging error handler.
329
328
glfwSetErrorCallback (GLFWErrorCallback);
330
329
return glfwInit ();
331
330
}
332
331
333
- void FlutterTerminate () { glfwTerminate (); }
332
+ void FlutterEmbedderTerminate () { glfwTerminate (); }
334
333
335
- FlutterWindowRef CreateFlutterWindow (
336
- size_t initial_width, size_t initial_height, const std::string &assets_path,
337
- const std::string &icu_data_path,
338
- const std::vector<std::string> &arguments) {
334
+ FlutterWindowRef FlutterEmbedderCreateWindow (
335
+ size_t initial_width, size_t initial_height, const char *assets_path,
336
+ const char *icu_data_path, const char **arguments, size_t argument_count) {
339
337
#ifdef __linux__
340
338
gtk_init (0 , nullptr );
341
339
#endif
@@ -348,7 +346,8 @@ FlutterWindowRef CreateFlutterWindow(
348
346
GLFWClearCanvas (window);
349
347
350
348
// Start the engine.
351
- auto engine = RunFlutterEngine (window, assets_path, icu_data_path, arguments);
349
+ auto engine = RunFlutterEngine (window, assets_path, icu_data_path, arguments,
350
+ argument_count);
352
351
if (engine == nullptr ) {
353
352
glfwDestroyWindow (window);
354
353
return nullptr ;
@@ -360,14 +359,18 @@ FlutterWindowRef CreateFlutterWindow(
360
359
glfwSetWindowUserPointer (window, state);
361
360
state->engine = engine;
362
361
state->message_dispatcher =
363
- std::make_unique<IncomingMessageDispatcher>(state);
364
- state->plugin_handler = std::make_unique<PluginHandler>(state);
362
+ std::make_unique<flutter_desktop_embedding::IncomingMessageDispatcher>(
363
+ state);
364
+ state->plugin_handler =
365
+ std::make_unique<flutter_desktop_embedding::PluginHandler>(state);
365
366
366
367
// Set up the keyboard handlers.
367
368
state->keyboard_hook_handlers .push_back (
368
- std::make_unique<KeyEventHandler>(state->plugin_handler .get ()));
369
+ std::make_unique<flutter_desktop_embedding::KeyEventHandler>(
370
+ state->plugin_handler .get ()));
369
371
state->keyboard_hook_handlers .push_back (
370
- std::make_unique<TextInputPlugin>(state->plugin_handler .get ()));
372
+ std::make_unique<flutter_desktop_embedding::TextInputPlugin>(
373
+ state->plugin_handler .get ()));
371
374
372
375
// Trigger an initial size callback to send size information to Flutter.
373
376
state->monitor_screen_coordinates_per_inch = GetScreenCoordinatesPerInch ();
@@ -382,7 +385,7 @@ FlutterWindowRef CreateFlutterWindow(
382
385
return state;
383
386
}
384
387
385
- void FlutterWindowLoop (FlutterWindowRef flutter_window) {
388
+ void FlutterEmbedderRunWindowLoop (FlutterWindowRef flutter_window) {
386
389
GLFWwindow *window = flutter_window->window ;
387
390
#ifdef __linux__
388
391
// Necessary for GTK thread safety.
@@ -438,5 +441,3 @@ void FlutterEmbedderEnableInputBlocking(FlutterWindowRef flutter_window,
438
441
const char *channel) {
439
442
flutter_window->message_dispatcher ->EnableInputBlockingForChannel (channel);
440
443
}
441
-
442
- } // namespace flutter_desktop_embedding
0 commit comments