diff --git a/include/waybox/output.h b/include/waybox/output.h index de1bb83..fcc4850 100644 --- a/include/waybox/output.h +++ b/include/waybox/output.h @@ -1,10 +1,6 @@ #ifndef _WB_OUTPUT_H #define _WB_OUTPUT_H -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200112L -#endif - #include #include diff --git a/include/waybox/server.h b/include/waybox/server.h index de83864..8e9ae14 100644 --- a/include/waybox/server.h +++ b/include/waybox/server.h @@ -1,10 +1,6 @@ #ifndef _WB_SERVER_H #define _WB_SERVER_H -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200112L -#endif - #include #include diff --git a/meson.build b/meson.build index 05bbb9b..024aa5a 100644 --- a/meson.build +++ b/meson.build @@ -13,6 +13,7 @@ project( add_project_arguments( '-Wno-unused-parameter', + '-D_POSIX_C_SOURCE=200112L', '-DWL_HIDE_DEPRECATED', # Hide the deprecated parts of the Wayland API '-DWLR_USE_UNSTABLE', '-DPACKAGE_NAME="' + meson.project_name() + '"', diff --git a/waybox/main.c b/waybox/main.c index be20abb..7575007 100644 --- a/waybox/main.c +++ b/waybox/main.c @@ -1,3 +1,4 @@ +#include #include #include @@ -20,6 +21,26 @@ bool show_help(char *name) return true; } +struct wb_server server = {0}; +void signal_handler(int sig) +{ + switch (sig) + { + case SIGINT: + case SIGTERM: + wl_display_terminate(server.wl_display); + break; + case SIGUSR1: + /* Openbox uses SIGUSR1 to restart. I'm not sure of the + * difference between restarting and reconfiguring. + */ + case SIGUSR2: + deinit_config(server.config); + init_config(&server); + break; + } +} + int main(int argc, char **argv) { #ifdef USE_NLS setlocale(LC_ALL, ""); @@ -28,7 +49,6 @@ int main(int argc, char **argv) { #endif char *startup_cmd = NULL; - struct wb_server server = {0}; enum wlr_log_importance debuglevel = WLR_ERROR; if (argc > 1) { int i; @@ -88,6 +108,13 @@ int main(int argc, char **argv) { } } + struct sigaction sa; + sigemptyset(&sa.sa_mask); + sa.sa_handler = signal_handler; + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + sigaction(SIGUSR1, &sa, NULL); + sigaction(SIGUSR2, &sa, NULL); wl_display_run(server.wl_display); wb_terminate(&server);