From aa422c07c455a73ce1940494d1610d5a3a0aa51e Mon Sep 17 00:00:00 2001 From: Axel Wagner Date: Thu, 30 Dec 2010 21:43:34 +0100 Subject: [PATCH] Add forgetful restart to sighandler --- include/util.h | 2 +- src/cmdparse.y | 2 +- src/sighandler.c | 14 +++++++++----- src/util.c | 5 +++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/util.h b/include/util.h index 46a15655..91b533a1 100644 --- a/include/util.h +++ b/include/util.h @@ -122,6 +122,6 @@ bool path_exists(const char *path); * appends -a to argument list to disable autostart * */ -void i3_restart(); +void i3_restart(bool forget_layout); #endif diff --git a/src/cmdparse.y b/src/cmdparse.y index 28cff60c..98819183 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -340,7 +340,7 @@ restart: TOK_RESTART { printf("restarting i3\n"); - i3_restart(); + i3_restart(false); } ; diff --git a/src/sighandler.c b/src/sighandler.c index 1cc4548d..ea2bf9fe 100644 --- a/src/sighandler.c +++ b/src/sighandler.c @@ -40,11 +40,12 @@ static int raised_signal; static char *crash_text[] = { "i3 just crashed.", "To debug this problem, either attach gdb now", - "or press 'e' to exit and get a core-dump.", - "If you want to keep your session,", - "press 'r' to restart i3 in-place." + "or press", + "- 'e' to exit and get a core-dump,", + "- 'r' to restart i3 in-place or", + "- 'f' to forget the current layout and restart" }; -static int crash_text_longest = 1; +static int crash_text_longest = 5; /* * Draw the window containing the info text @@ -99,7 +100,10 @@ static int sig_handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_p } if (sym == 'r') - i3_restart(); + i3_restart(false); + + if (sym == 'f') + i3_restart(true); return 1; } diff --git a/src/util.c b/src/util.c index b8c314c7..1ecce922 100644 --- a/src/util.c +++ b/src/util.c @@ -321,8 +321,9 @@ char *store_restart_layout() { * appends -a to argument list to disable autostart * */ -void i3_restart() { - char *restart_filename = store_restart_layout(); +void i3_restart(bool forget_layout) { + char *restart_filename = forget_layout ? NULL : store_restart_layout(); + restore_geometry(); ipc_shutdown();