terminal: fswait3 returns fd count on timeout; fix cursor blinks

This commit is contained in:
K. Lange 2019-12-17 20:24:08 +09:00
parent 18389b62c7
commit b8d297e86d
2 changed files with 4 additions and 13 deletions

View File

@ -1194,21 +1194,20 @@ int main(int argc, char ** argv) {
while (!exit_application) {
int res[] = {0,0,0,0};
int index = fswait3(amfd == -1 ? 3 : 4,fds,200,res);
fswait3(amfd == -1 ? 3 : 4,fds,200,res);
check_for_exit();
if (input_stopped) continue;
maybe_flip_cursor();
if (res[0]) {
maybe_flip_cursor();
int r = read(fd_master, buf, BUF_SIZE);
for (int i = 0; i < r; ++i) {
ansi_put(ansi_state, buf[i]);
}
}
if (res[1]) {
maybe_flip_cursor();
int r = read(kfd, buf, BUF_SIZE);
for (int i = 0; i < r; ++i) {
int ret = kbd_scancode(&kbd_state, buf[i], &event);
@ -1234,9 +1233,6 @@ int main(int argc, char ** argv) {
handle_mouse_abs(&packet);
}
}
if (index < 0) {
maybe_flip_cursor();
}
}
}

View File

@ -2373,14 +2373,14 @@ int main(int argc, char ** argv) {
/* Wait for something to happen. */
int res[] = {0,0};
int index = fswait3(2,fds,200,res);
fswait3(2,fds,200,res);
/* Check if the child application has closed. */
check_for_exit();
maybe_flip_cursor();
if (res[1]) {
/* Read from PTY */
maybe_flip_cursor();
int r = read(fd_master, buf, 4096);
for (int i = 0; i < r; ++i) {
ansi_put(ansi_state, buf[i]);
@ -2389,13 +2389,8 @@ int main(int argc, char ** argv) {
}
if (res[0]) {
/* Handle Yutani events. */
maybe_flip_cursor();
handle_incoming();
}
if (index < 0) {
/* Timeout, flip the cursor. */
maybe_flip_cursor();
}
}
}