aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-18 01:49:53 +0200
committerMax Kellermann <max@duempel.org>2008-09-18 01:49:53 +0200
commitf0aa88e5c18de0b1e4f5d85dd5c3ae5d9be76bc3 (patch)
treeead2fd90d2a19b39c5e1a7a0942df9be77c02831 /src/command.c
parente54533bd1fad95b149e87918dffca06b0afb5074 (diff)
downloadmpd-f0aa88e5c18de0b1e4f5d85dd5c3ae5d9be76bc3.tar.gz
mpd-f0aa88e5c18de0b1e4f5d85dd5c3ae5d9be76bc3.tar.xz
mpd-f0aa88e5c18de0b1e4f5d85dd5c3ae5d9be76bc3.zip
use the glib main event loop
This big patch replaces our custom main loop with the event based glib main loop. This has several advantages: we can make all the tiny code bits in the main loop independent from each others, we can add additional file descriptors for polling (e.g. the mpdclient socket). We don't need the ncurses timeout() anymore, because glib will poll stdin for us.
Diffstat (limited to '')
-rw-r--r--src/command.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/command.c b/src/command.c
index 881df278a..151d46535 100644
--- a/src/command.c
+++ b/src/command.c
@@ -30,6 +30,7 @@
#include <ctype.h>
#include <glib.h>
#include <signal.h>
+#include <unistd.h>
#undef DEBUG_KEYS
@@ -420,23 +421,18 @@ my_wgetch(WINDOW *w)
sigstop();
/* handle SIGINT (Ctrl-C) */
if (c == 3)
- exit(EXIT_SUCCESS);
+ kill(getpid(), SIGTERM);
#endif
return c;
}
command_t
-get_keyboard_command_with_timeout(int ms)
+get_keyboard_command(void)
{
int key;
- if (ms != SCREEN_TIMEOUT)
- timeout(ms);
key = my_wgetch(stdscr);
- if (ms != SCREEN_TIMEOUT)
- timeout(SCREEN_TIMEOUT);
-
if (key == ERR)
return CMD_NONE;
@@ -448,12 +444,6 @@ get_keyboard_command_with_timeout(int ms)
return get_key_command(key);
}
-command_t
-get_keyboard_command(void)
-{
- return get_keyboard_command_with_timeout(SCREEN_TIMEOUT);
-}
-
int
assign_keys(command_t command, int keys[MAX_COMMAND_KEYS])
{