path: root/osdep
diff options
authorwm4 <wm4@nowhere>2015-06-27 12:20:40 +0200
committerwm4 <wm4@nowhere>2015-06-27 12:20:40 +0200
commit2a67208f4075e65c47772be9ec52371a520d85fd (patch)
tree5fe6d71b48dd988c0591d626055aa67ae95bb6a3 /osdep
parent09695023165f7527c9bd76bba8b4e1f4e330c25a (diff)
terminal-unix: set terminal mode on init
mpv usually sets the terminal to non-canonical mode (which in particular disables line buffering). But the old mode is restored if the process is not foregrounded. This is supposed to make mpv behave nicer when it is backgrounded. getch2_poll() enables canonical mode. Unfortunately, this was only called after the poll timeout elapsed, so non-canonical mode is first enabled after about a second after program start. Fix this by moving the poll call before the timeout. (As far as we're aware, there's no event-based way to determine when the FD's process group changes, thus we're polling.)
Diffstat (limited to 'osdep')
1 files changed, 1 insertions, 1 deletions
diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c
index 478b613999..ca7b59a964 100644
--- a/osdep/terminal-unix.c
+++ b/osdep/terminal-unix.c
@@ -386,6 +386,7 @@ static void *terminal_thread(void *ptr)
bool stdin_ok = read_terminal; // if false, we still wait for SIGTERM
while (1) {
+ getch2_poll();
struct pollfd fds[2] = {
{.events = POLLIN, .fd = death_pipe[0]},
{.events = POLLIN, .fd = STDIN_FILENO},
@@ -396,7 +397,6 @@ static void *terminal_thread(void *ptr)
if (fds[1].revents)
stdin_ok = getch2(input_ctx);
- getch2_poll();
// Important if we received SIGTERM, rather than regular quit.
struct mp_cmd *cmd = mp_input_parse_cmd(input_ctx, bstr0("quit"), "");