mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
fix: resolve Linux window close handler to prevent app hang (#1795)
- Add delete-event callback that properly quits the application when window is closed
This commit is contained in:
@@ -20,6 +20,18 @@ static void first_frame_cb(MyApplication* self, FlView *view)
|
||||
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
|
||||
}
|
||||
|
||||
// Called when window is requested to be closed.
|
||||
static gboolean window_delete_event_cb(GtkWidget *widget, GdkEvent *event,
|
||||
gpointer data) {
|
||||
// Get the application and quit it.
|
||||
GtkApplication *app = gtk_window_get_application(GTK_WINDOW(widget));
|
||||
if (app != nullptr) {
|
||||
g_application_quit(G_APPLICATION(app));
|
||||
}
|
||||
// Return TRUE to prevent further processing of the delete event.
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Implements GApplication::activate.
|
||||
static void my_application_activate(GApplication* application) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
@@ -71,6 +83,9 @@ static void my_application_activate(GApplication* application) {
|
||||
g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), self);
|
||||
gtk_widget_realize(GTK_WIDGET(view));
|
||||
|
||||
// Connect the delete-event signal to handle window close.
|
||||
g_signal_connect(window, "delete-event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
|
||||
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
|
||||
|
||||
gtk_widget_grab_focus(GTK_WIDGET(view));
|
||||
|
||||
Reference in New Issue
Block a user