[metacity/wip/muktupavels/issue-21: 2/3] main: add SIGINT handler




commit df44cd1c225238a8ac2ef24909c9fe9b27ec9a95
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Jul 19 18:58:48 2021 +0300

    main: add SIGINT handler
    
    With this metacity will exit cleanly when hitting Ctrl + C.
    
    To preserve existing behaviour with XSMP do not change restart
    style hint to IfRunning.
    
    https://gitlab.gnome.org/GNOME/metacity/-/issues/21

 src/core/main.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/src/core/main.c b/src/core/main.c
index cc5cd612..10f80021 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -81,6 +81,8 @@ static GMainLoop *meta_main_loop = NULL;
  */
 static gboolean meta_restart_after_quit = FALSE;
 
+static gboolean meta_shutdown_session = TRUE;
+
 /**
  * Prints the version notice. This is shown when Metacity is called
  * with the --version switch.
@@ -399,7 +401,8 @@ meta_finalize (void)
     meta_display_close (display,
                         CurrentTime); /* I doubt correct timestamps matter here */
 
-  meta_session_shutdown ();
+  if (meta_shutdown_session)
+    meta_session_shutdown ();
 }
 
 static gboolean
@@ -410,6 +413,15 @@ sigterm_cb (gpointer user_data)
   return G_SOURCE_REMOVE;
 }
 
+static gboolean
+sigint_cb (gpointer user_data)
+{
+  meta_shutdown_session = FALSE;
+  meta_quit ();
+
+  return G_SOURCE_REMOVE;
+}
+
 /**
  * This is where the story begins. It parses commandline options and
  * environment variables, sets up the screen, hands control off to
@@ -446,6 +458,7 @@ main (int argc, char **argv)
 #endif
 
   g_unix_signal_add (SIGTERM, sigterm_cb, NULL);
+  g_unix_signal_add (SIGINT, sigint_cb, NULL);
 
   meta_init_debug ();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]