- /* GPM checks the beginning of the $TERM variable to decide if
- * it should pass xterm events through. There is no real advantage
- * in allowing GPM to do this.
- */
- if (env == 0 || strncmp(env, "xterm", 5))
- return TRUE;
+ if (list != 0) {
+ if (env != 0) {
+ result = _nc_name_match(list, env, "|:");
+ }
+ } else {
+ /* GPM checks the beginning of the $TERM variable to decide if it
+ * should pass xterm events through. There is no real advantage in
+ * allowing GPM to do this. Recent versions relax that check, and
+ * pretend that GPM can work with any terminal having the kmous
+ * capability. Perhaps that works for someone. If so, they can
+ * set the environment variable (above).
+ */
+ if (env != 0 && strstr(env, "linux") != 0) {
+ result = TRUE;
+ }
+ }
+ }
+ return result;
+}
+
+#ifdef HAVE_LIBDL
+static void
+unload_gpm_library(SCREEN *sp)
+{
+ if (sp->_dlopen_gpm != 0) {
+ T(("unload GPM library"));
+ sp->_mouse_gpm_loaded = FALSE;
+ sp->_mouse_fd = -1;
+ dlclose(sp->_dlopen_gpm);
+ sp->_dlopen_gpm = 0;
+ }
+}
+
+static void
+load_gpm_library(SCREEN *sp)
+{
+ sp->_mouse_gpm_found = FALSE;
+ if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
+ if (GET_DLSYM(gpm_fd) == 0 ||
+ GET_DLSYM(Gpm_Open) == 0 ||
+ GET_DLSYM(Gpm_Close) == 0 ||
+ GET_DLSYM(Gpm_GetEvent) == 0) {
+ T(("GPM initialization failed: %s", dlerror()));
+ unload_gpm_library(sp);
+ } else {
+ sp->_mouse_gpm_found = TRUE;
+ sp->_mouse_gpm_loaded = TRUE;
+ }