-
Notifications
You must be signed in to change notification settings - Fork 6k
Add platform channel System.exitApplication and System.requestAppExit support #40033
Changes from all commits
ce2137f
6edd300
a963135
e03d5b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,15 @@ G_DEFINE_TYPE_WITH_CODE( | |
| G_IMPLEMENT_INTERFACE(fl_text_input_view_delegate_get_type(), | ||
| fl_view_text_input_delegate_iface_init)) | ||
|
|
||
| // Signal handler for GtkWidget::delete-event | ||
| static gboolean window_delete_event_cb(GtkWidget* widget, | ||
| GdkEvent* event, | ||
| FlView* self) { | ||
| fl_platform_plugin_request_app_exit(self->platform_plugin); | ||
| // Stop the event from propagating. | ||
| return TRUE; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line totally blocks the additional listener provided by plugins, such like
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree, it does, but the alternative is returning FALSE, which would not give the app a chance to stop the exit when the last window goes away. Perhaps this should only make the exit request and return TRUE if there is only one window open. That would still block the plugin listeners on the last window, though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found the change prevents The |
||
| } | ||
|
|
||
| // Initialize keyboard manager. | ||
| static void init_keyboard(FlView* self) { | ||
| FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine); | ||
|
|
@@ -475,6 +484,11 @@ static void realize_cb(GtkWidget* widget) { | |
| FlView* self = FL_VIEW(widget); | ||
| g_autoptr(GError) error = nullptr; | ||
|
|
||
| // Handle requests by the user to close the application. | ||
| GtkWidget* toplevel_window = gtk_widget_get_toplevel(GTK_WIDGET(self)); | ||
| g_signal_connect(toplevel_window, "delete-event", | ||
| G_CALLBACK(window_delete_event_cb), self); | ||
|
|
||
| init_keyboard(self); | ||
|
|
||
| if (!fl_renderer_start(self->renderer, self, &error)) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.