diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2021-07-19 18:58:48 +0300 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2021-07-19 23:08:06 +0300 |
commit | df44cd1c225238a8ac2ef24909c9fe9b27ec9a95 (patch) | |
tree | b6bf1153be867df50b0f28c3373d80d7c84c7709 | |
parent | 8dfb6317ecfd324700438f6cd2a5063d6258e657 (diff) | |
download | metacity-df44cd1c225238a8ac2ef24909c9fe9b27ec9a95.tar.gz |
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
-rw-r--r-- | src/core/main.c | 15 |
1 files changed, 14 insertions, 1 deletions
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 (); |