0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

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.)
This commit is contained in:
wm4 2015-06-27 12:20:40 +02:00
parent 0969502316
commit 2a67208f40

View File

@ -386,6 +386,7 @@ static void *terminal_thread(void *ptr)
mpthread_set_name("terminal");
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)
break;
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"), "");