From bda0a3d1b7db27708d02d0ff537d5f7138dad6d7 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Thu, 20 Jul 2023 10:10:07 +0200 Subject: [PATCH] [xterm] Assume that if WAYLAND_DISPLAY or DISPLAY is set it must be xterm --- src/osdep/osdep.c | 52 ++++++++--------------------------------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/src/osdep/osdep.c b/src/osdep/osdep.c index 3b1024c4e..3accda827 100644 --- a/src/osdep/osdep.c +++ b/src/osdep/osdep.c @@ -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 */ - 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; + } } }