-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: desktopRunning on desktopRunning on desktopc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterplatform-linuxBuilding on or for Linux specificallyBuilding on or for Linux specificallyteam-linuxOwned by the Linux platform teamOwned by the Linux platform teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-linuxTriaged by the Linux platform teamTriaged by the Linux platform team
Description
Use case
The Flutter Linux application template shows the window before registering plugins:
static void my_application_activate(GApplication* application) {
MyApplication* self = MY_APPLICATION(application);
GtkWindow* window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
// ...
gtk_window_set_default_size(window, 1280, 720);
gtk_widget_show(GTK_WIDGET(window));
// ...
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
// ...
}
Showing the window creates a native window and starts the engine and renderer (see fl_view_realize). This makes it impossible for plugins to e.g. reparent the FlView
, which is what the handy_window package needs to do. As a workaround, users must manually modify my_application.cc
to show the window after plugin registration.
Proposal
Change the order so that plugins are registered first, and then the window is shown. If a plugin requires a native window, it has the possibility to call gtk_widget_realize
on the view. Going the other way around is not possible because the renderer is already running.
diff --git a/linux/my_application.cc b/linux/my_application.cc
index 2b06103..6fc73a1 100644
--- a/linux/my_application.cc
+++ b/linux/my_application.cc
@@ -48,7 +48,6 @@ static void my_application_activate(GApplication* application) {
}
gtk_window_set_default_size(window, 1280, 720);
- gtk_widget_show(GTK_WIDGET(window));
g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
@@ -59,6 +58,7 @@ static void my_application_activate(GApplication* application) {
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
+ gtk_widget_show(GTK_WIDGET(window));
gtk_widget_grab_focus(GTK_WIDGET(view));
}
See also ubuntu/handy_window.dart#14.
kenvandine, Feichtmeier, whiskeyPeak, Npepperlinux and Merrit
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: desktopRunning on desktopRunning on desktopc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterplatform-linuxBuilding on or for Linux specificallyBuilding on or for Linux specificallyteam-linuxOwned by the Linux platform teamOwned by the Linux platform teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-linuxTriaged by the Linux platform teamTriaged by the Linux platform team
Type
Projects
Status
Done