about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-07-04 19:06:44 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-07-04 19:06:44 +0300
commitf0793cd8ad7855f1c45725f3ef7df31ef5fdd9eb (patch)
treef7db691c6187261b63f0d774b65a5d92f80927a5
parentae753da6f8f9a2fb1b0c84ee29c4110690c49ffd (diff)
downloadfungus-launcher-f0793cd8ad7855f1c45725f3ef7df31ef5fdd9eb.tar.gz
fungus-launcher-f0793cd8ad7855f1c45725f3ef7df31ef5fdd9eb.tar.xz
also properly deal with window [x] button
-rw-r--r--fungus/splash_window.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/fungus/splash_window.py b/fungus/splash_window.py
index bc9559b..cf8a7bc 100644
--- a/fungus/splash_window.py
+++ b/fungus/splash_window.py
@@ -89,6 +89,9 @@ class SplashWindow:
         grid.attach(self._close_button, 0, 2, 1, 1)
 
         self._window.add(frame)
+
+        # Handle window manager close (X button)
+        self._window.connect("delete_event", self._on_delete_event)
         self._window.show_all()
 
     # ── Public API ────────────────────────────────────────────────────────
@@ -183,12 +186,22 @@ class SplashWindow:
 
     # ── Internal ──────────────────────────────────────────────────────────
 
+    def _on_delete_event(self, _widget: Gtk.Widget, _event: object) -> bool:
+        """Handle window manager close (X button).
+
+        Returns ``True`` to prevent further destruction (we handle it
+        ourselves).  Quits GTK in error mode, hides the splash
+        otherwise.
+        """
+        if self._close_button is not None and self._close_button.get_visible():
+            GLib.idle_add(Gtk.main_quit)
+        self.close()
+        return True  # prevent default destruction
+
     def _on_close_clicked(self, _widget: Gtk.Widget) -> None:
         """Handle the Close button click.
 
         When the Close button is visible (error mode), quit GTK — the
         game process is already dead and there is nothing left to do.
         """
-        if self._close_button is not None and self._close_button.get_visible():
-            GLib.idle_add(Gtk.main_quit)
-        self.close()
+        self._on_delete_event(None, None)