From 5d149c626cc6a22ab707f6784755bca6bb8ae353 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 19 Mar 2017 11:04:08 +0100 Subject: [PATCH] main: do_input_event() returns bool --- src/keyboard.c | 2 +- src/lirc.c | 2 +- src/main.c | 7 ++++--- src/ncmpc.h | 9 ++++++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/keyboard.c b/src/keyboard.c index 226306c..5bd43e5 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -35,7 +35,7 @@ keyboard_event(gcc_unused GIOChannel *source, command_t cmd = get_keyboard_command(); if (cmd != CMD_NONE) - if (do_input_event(cmd) != 0) + if (!do_input_event(cmd)) return FALSE; end_input_event(); diff --git a/src/lirc.c b/src/lirc.c index ce8f928..965037b 100644 --- a/src/lirc.c +++ b/src/lirc.c @@ -39,7 +39,7 @@ lirc_event(gcc_unused GIOChannel *source, if (lirc_nextcode(&code) == 0) { while (lirc_code2char(lc, code, &txt) == 0 && txt != NULL) { cmd = get_key_command_from_name(txt); - if (do_input_event(cmd) != 0) + if (!do_input_event(cmd)) return FALSE; } } diff --git a/src/main.c b/src/main.c index fe696c4..47a5670 100644 --- a/src/main.c +++ b/src/main.c @@ -362,11 +362,12 @@ void end_input_event(void) auto_update_timer(); } -int do_input_event(command_t cmd) +bool +do_input_event(command_t cmd) { if (cmd == CMD_QUIT) { g_main_loop_quit(main_loop); - return -1; + return false; } screen_cmd(mpd, cmd); @@ -375,7 +376,7 @@ int do_input_event(command_t cmd) /* make sure we don't update the volume yet */ disable_update_timer(); - return 0; + return true; } #ifndef NCMPC_MINI diff --git a/src/ncmpc.h b/src/ncmpc.h index a2f3aed..5ac3ce5 100644 --- a/src/ncmpc.h +++ b/src/ncmpc.h @@ -22,12 +22,19 @@ #include "command.h" +#include + /** put the terminal in a sane mode and stop/suspend ncmpc */ void sigstop(void); void begin_input_event(void); void end_input_event(void); -int do_input_event(command_t cmd); + +/** + * @return false if the application shall quit + */ +bool +do_input_event(command_t cmd); #endif /* NCMPC_H */ -- 2.30.2