[termdesc] send XTVERSION as our very first query to better race ConPTY #2248

This commit is contained in:
nick black 2021-12-08 06:59:59 -05:00
parent 41ef5e4790
commit 9507052606

View File

@ -352,7 +352,6 @@ init_terminfo_esc(tinfo* ti, const char* name, escape_e idx,
// terminal to which we are talking. if we already know what we're talking // terminal to which we are talking. if we already know what we're talking
// to, there's no point in sending them. // to, there's no point in sending them.
#define IDQUERIES TRIDEVATTR \ #define IDQUERIES TRIDEVATTR \
XTVERSION \
XTGETTCAP \ XTGETTCAP \
SECDEVATTR SECDEVATTR
@ -415,9 +414,11 @@ init_terminfo_esc(tinfo* ti, const char* name, escape_e idx,
// maybe that works, maybe it doesn't. then query both color registers // maybe that works, maybe it doesn't. then query both color registers
// and geometry. send XTGETTCAP for terminal name. if 'minimal' is set, don't // and geometry. send XTGETTCAP for terminal name. if 'minimal' is set, don't
// send any identification queries (we've already identified the terminal). // send any identification queries (we've already identified the terminal).
// write DSRCPR as early as possible, so that it precedes any query material // write DSRCPR as early as possible following SMCUP, so that it precedes any
// that's bled onto stdin and echoed. if 'noaltscreen' is set, do not send // query material that's bled onto stdin and echoed. if 'noaltscreen' is set,
// an smcup. if 'draininput' is set, do not send any keyboard modifiers. // do not send an smcup. if 'draininput' is set, do not send any keyboard
// modifiers. sent XTVERSION first of all, since ConPTY passes that through to
// the real terminal, and thus it takes a bit longer to get the response.
static int static int
send_initial_queries(int fd, unsigned minimal, unsigned noaltscreen, send_initial_queries(int fd, unsigned minimal, unsigned noaltscreen,
unsigned draininput){ unsigned draininput){
@ -431,9 +432,9 @@ send_initial_queries(int fd, unsigned minimal, unsigned noaltscreen,
} }
}else{ }else{
if(draininput){ if(draininput){
queries = DSRCPR IDQUERIES DIRECTIVES; queries = XTVERSION DSRCPR IDQUERIES DIRECTIVES;
}else{ }else{
queries = DSRCPR KKBDENTER IDQUERIES DIRECTIVES; queries = XTVERSION DSRCPR IDQUERIES KKBDENTER DIRECTIVES;
} }
} }
}else{ }else{
@ -445,9 +446,9 @@ send_initial_queries(int fd, unsigned minimal, unsigned noaltscreen,
} }
}else{ }else{
if(draininput){ if(draininput){
queries = SMCUP DSRCPR IDQUERIES DIRECTIVES; queries = XTVERSION SMCUP DSRCPR IDQUERIES DIRECTIVES;
}else{ }else{
queries = SMCUP DSRCPR KKBDENTER IDQUERIES DIRECTIVES; queries = XTVERSION SMCUP DSRCPR IDQUERIES KKBDENTER DIRECTIVES;
} }
} }
} }