mirror of
https://github.com/wizbright/waybox.git
synced 2025-10-29 05:40:20 -04:00
Signal handling to exit and reconfigure the compositor
This commit is contained in:
parent
94e23a28f3
commit
357cd843dd
4 changed files with 29 additions and 9 deletions
|
|
@ -1,10 +1,6 @@
|
||||||
#ifndef _WB_OUTPUT_H
|
#ifndef _WB_OUTPUT_H
|
||||||
#define _WB_OUTPUT_H
|
#define _WB_OUTPUT_H
|
||||||
|
|
||||||
#ifndef _POSIX_C_SOURCE
|
|
||||||
#define _POSIX_C_SOURCE 200112L
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
#ifndef _WB_SERVER_H
|
#ifndef _WB_SERVER_H
|
||||||
#define _WB_SERVER_H
|
#define _WB_SERVER_H
|
||||||
|
|
||||||
#ifndef _POSIX_C_SOURCE
|
|
||||||
#define _POSIX_C_SOURCE 200112L
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <wlr/backend.h>
|
#include <wlr/backend.h>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ project(
|
||||||
|
|
||||||
add_project_arguments(
|
add_project_arguments(
|
||||||
'-Wno-unused-parameter',
|
'-Wno-unused-parameter',
|
||||||
|
'-D_POSIX_C_SOURCE=200112L',
|
||||||
'-DWL_HIDE_DEPRECATED', # Hide the deprecated parts of the Wayland API
|
'-DWL_HIDE_DEPRECATED', # Hide the deprecated parts of the Wayland API
|
||||||
'-DWLR_USE_UNSTABLE',
|
'-DWLR_USE_UNSTABLE',
|
||||||
'-DPACKAGE_NAME="' + meson.project_name() + '"',
|
'-DPACKAGE_NAME="' + meson.project_name() + '"',
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
@ -20,6 +21,26 @@ bool show_help(char *name)
|
||||||
return true;
|
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) {
|
int main(int argc, char **argv) {
|
||||||
#ifdef USE_NLS
|
#ifdef USE_NLS
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
|
@ -28,7 +49,6 @@ int main(int argc, char **argv) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *startup_cmd = NULL;
|
char *startup_cmd = NULL;
|
||||||
struct wb_server server = {0};
|
|
||||||
enum wlr_log_importance debuglevel = WLR_ERROR;
|
enum wlr_log_importance debuglevel = WLR_ERROR;
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
int i;
|
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);
|
wl_display_run(server.wl_display);
|
||||||
|
|
||||||
wb_terminate(&server);
|
wb_terminate(&server);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue