mirror of
https://github.com/rkd77/elinks.git
synced 2025-06-30 22:19:29 -04:00
[xterm] Assume that if WAYLAND_DISPLAY or DISPLAY is set it must be xterm
This commit is contained in:
parent
4305880128
commit
bda0a3d1b7
@ -308,62 +308,26 @@ is_gnuscreen(void)
|
||||
|
||||
#if defined(CONFIG_OS_UNIX) || defined(CONFIG_OS_WIN32)
|
||||
|
||||
static int
|
||||
check_more_envs(void)
|
||||
{
|
||||
const char *envs[] = { "WINDOWID",
|
||||
"KONSOLE_DCOP_SESSION",
|
||||
"GNOME_TERMINAL_SERVICE",
|
||||
"XDG_SESSION_DESKTOP",
|
||||
NULL
|
||||
};
|
||||
const char **v;
|
||||
|
||||
for (v = envs; *v; ++v)
|
||||
{
|
||||
char *value = getenv(*v);
|
||||
|
||||
if (value && *value) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
is_xterm(void)
|
||||
{
|
||||
static int xt = -1;
|
||||
|
||||
if (xt == -1) {
|
||||
/* Paraphrased from debian bug 228977:
|
||||
*
|
||||
* It is not enough to simply check the DISPLAY env variable,
|
||||
* as it is pretty legal to have a DISPLAY set. While these
|
||||
* days this practice is pretty uncommon, it still makes sense
|
||||
* sometimes, especially for people who prefer the text mode
|
||||
* for some reason. Only relying on DISPLAY will results in bad
|
||||
* codes being written to the terminal.
|
||||
*
|
||||
* Any real xterm derivative sets WINDOWID as well.
|
||||
* Unfortunately, konsole is an exception, and it needs to be
|
||||
* checked for separately.
|
||||
*
|
||||
* FIXME: The code below still fails to detect some terminals
|
||||
* that do support a title (like the popular PuTTY ssh client).
|
||||
* In general, proper xterm detection is a nightmarish task...
|
||||
*
|
||||
* -- Adam Borowski <kilobyte@mimuw.edu.pl> */
|
||||
|
||||
char *term = getenv("TERM");
|
||||
|
||||
if (term && !strncmp("xterm", term, 5)) {
|
||||
xt = 1;
|
||||
} else {
|
||||
char *display = getenv("DISPLAY");
|
||||
char *wayland = getenv("WAYLAND_DISPLAY");
|
||||
|
||||
xt = (display && *display && check_more_envs());
|
||||
if (wayland && *wayland) {
|
||||
xt = 1;
|
||||
} else {
|
||||
char *display = getenv("DISPLAY");
|
||||
|
||||
xt = display && *display;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user