static bool enable_gpm_mouse(SCREEN *sp, bool enable) { bool result; T((T_CALLED("enable_gpm_mouse(%d)"), enable)); if (enable && !sp->_mouse_active) { #ifdef HAVE_LIBDL if (sp->_mouse_gpm_found && !sp->_mouse_gpm_loaded) { load_gpm_library(sp); } #endif if (sp->_mouse_gpm_loaded) { /* GPM: initialize connection to gpm server */ sp->_mouse_gpm_connect.eventMask = GPM_DOWN | GPM_UP; sp->_mouse_gpm_connect.defaultMask = (unsigned short) (~(sp->_mouse_gpm_connect.eventMask | GPM_HARD)); sp->_mouse_gpm_connect.minMod = 0; sp->_mouse_gpm_connect.maxMod = (unsigned short) (~((1 << KG_SHIFT) | (1 << KG_SHIFTL) | (1 << KG_SHIFTR))); /* * Note: GPM hardcodes \E[?1001s and \E[?1000h during its open. * The former is recognized by wscons (SunOS), and the latter by * xterm. Those will not show up in ncurses' traces. */ result = (my_Gpm_Open(&sp->_mouse_gpm_connect, 0) >= 0); } else { result = FALSE; } sp->_mouse_active = result; T(("GPM open %s", result ? "succeeded" : "failed")); } else { if (!enable && sp->_mouse_active) { /* GPM: close connection to gpm server */ my_Gpm_Close(); sp->_mouse_active = FALSE; T(("GPM closed")); } result = enable; } #ifdef HAVE_LIBDL if (!result) { unload_gpm_library(sp); } #endif returnBool(result); }
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; } } }