Skip to content

Commit dff8405

Browse files
authored
[desktop_multi_window] handle close button click and destroy sub-window explicitly (#269)
1 parent d103dc3 commit dff8405

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/desktop_multi_window/linux/flutter_window.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ WindowCreatedCallback _g_window_created_callback = nullptr;
1515

1616
}
1717

18+
gboolean on_close_clicked(GtkWidget *widget, GdkEvent *event, gpointer user_data) {
19+
gtk_widget_destroy(widget);
20+
return TRUE;
21+
}
22+
1823
FlutterWindow::FlutterWindow(
1924
int64_t id,
2025
const std::string &args,
@@ -26,6 +31,7 @@ FlutterWindow::FlutterWindow(
2631
gtk_window_set_position(GTK_WINDOW(window_), GTK_WIN_POS_CENTER);
2732
gtk_widget_show(GTK_WIDGET(window_));
2833

34+
g_signal_connect(G_OBJECT(window_), "delete-event", G_CALLBACK(on_close_clicked), NULL);
2935
g_signal_connect(window_, "destroy", G_CALLBACK(+[](GtkWidget *, gpointer arg) {
3036
auto *self = static_cast<FlutterWindow *>(arg);
3137
if (auto callback = self->callback_.lock()) {

0 commit comments

Comments
 (0)