patch 9.0.1080: the "kitty" terminfo entry is not widespread

Problem:    The "kitty" terminfo entry is not widespread, resulting in the
            kitty terminal not working properly.
Solution:   Go back to using "xterm-kitty" and avoid the problems it causes in
            another way.
diff --git a/src/term.c b/src/term.c
index 7a70af4..cd6b3b9 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1675,6 +1675,12 @@
 #endif
 
 #ifdef HAVE_TGETENT
+/*
+ * Get the termcap entries we need with tgetstr(), tgetflag() and tgetnum().
+ * "invoke_tgetent()" must have been called before.
+ * If "*height" or "*width" are not zero then use the "li" and "col" entries to
+ * get their value.
+ */
     static void
 get_term_entries(int *height, int *width)
 {
@@ -2033,14 +2039,6 @@
 #endif
 	    parse_builtin_tcap(term);
 
-	    // Use the 'keyprotocol' option to adjust the t_TE and t_TI
-	    // termcap entries if there is an entry maching "term".
-	    keyprot_T kpc = match_keyprotocol(term);
-	    if (kpc == KEYPROTOCOL_KITTY)
-		apply_builtin_tcap(term, builtin_kitty, TRUE);
-	    else if (kpc == KEYPROTOCOL_MOK2)
-		apply_builtin_tcap(term, builtin_mok2, TRUE);
-
 #ifdef FEAT_GUI
 	    if (term_is_gui(term))
 	    {
@@ -2060,6 +2058,19 @@
     }
 #endif
 
+#ifdef FEAT_GUI
+    if (!gui.in_use)
+#endif
+    {
+	// Use the 'keyprotocol' option to adjust the t_TE and t_TI
+	// termcap entries if there is an entry maching "term".
+	keyprot_T kpc = match_keyprotocol(term);
+	if (kpc == KEYPROTOCOL_KITTY)
+	    apply_builtin_tcap(term, builtin_kitty, TRUE);
+	else if (kpc == KEYPROTOCOL_MOK2)
+	    apply_builtin_tcap(term, builtin_mok2, TRUE);
+    }
+
 /*
  * special: There is no info in the termcap about whether the cursor
  * positioning is relative to the start of the screen or to the start of the
@@ -2611,28 +2622,8 @@
 	term = NULL;	    // empty name is equal to no name
 
 #ifndef MSWIN
-    char_u	*tofree = NULL;
     if (term == NULL)
-    {
 	term = mch_getenv((char_u *)"TERM");
-
-	// "xterm-kitty" is used for Kitty, but it is not actually compatible
-	// with xterm.  Remove the "xterm-" part to avoid trouble.
-	if (term != NULL && STRNCMP(term, "xterm-kitty", 11) == 0)
-	{
-#ifdef FEAT_EVAL
-	    ch_log(NULL, "Removing xterm- prefix from terminal name %s", term);
-#endif
-	    if (p_verbose > 0)
-	    {
-		verbose_enter();
-		smsg(_("Removing xterm- prefix from terminal name %s"), term);
-		verbose_leave();
-	    }
-	    term = vim_strsave(term + 6);
-	    tofree = term;
-	}
-    }
 #endif
     if (term == NULL || *term == NUL)
 	term = DEFAULT_TERM;
@@ -2644,10 +2635,6 @@
 
     // Avoid using "term" here, because the next mch_getenv() may overwrite it.
     set_termname(T_NAME != NULL ? T_NAME : term);
-
-#ifndef MSWIN
-    vim_free(tofree);
-#endif
 }
 
 /*