]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_mouse.c
ncurses 5.9 - patch 20121026
[ncurses.git] / ncurses / base / lib_mouse.c
index 840d341b395bba702b80cf25f105300c93bf1d17..6f62120904a0824f80e959bc18ba905631f03f28 100644 (file)
@@ -84,7 +84,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_mouse.c,v 1.136 2012/02/22 22:40:24 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.139 2012/07/21 23:30:50 tom Exp $")
 
 #include <tic.h>
 
@@ -225,7 +225,7 @@ write_event(SCREEN *sp, int down, int button, int x, int y)
     char buf[6];
     unsigned long ignore;
 
-    strncpy(buf, key_mouse, 3);        /* should be "\033[M" */
+    strcpy(buf, "\033[M");     /* should be the same as key_mouse */
     buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
     buf[4] = ' ' + x - LEFT_COL + 1;
     buf[5] = ' ' + y - TOP_ROW + 1;
@@ -397,11 +397,19 @@ enable_xterm_mouse(SCREEN *sp, int enable)
 
 #if USE_GPM_SUPPORT
 static bool
-allow_gpm_mouse(void)
+allow_gpm_mouse(SCREEN *sp)
 {
     bool result = FALSE;
 
-    /* GPM does printf's without checking if stdout is a terminal */
+#if USE_WEAK_SYMBOLS
+    /* Danger Robinson: do not use dlopen for libgpm if already loaded */
+    if ((Gpm_Wgetch)) {
+       if (!sp->_mouse_gpm_loaded) {
+           T(("GPM library was already dlopen'd, not by us"));
+       }
+    } else
+#endif
+       /* GPM does printf's without checking if stdout is a terminal */
     if (isatty(fileno(stdout))) {
        char *list = getenv("NCURSES_GPM_TERMS");
        char *env = getenv("TERM");
@@ -527,7 +535,7 @@ initialize_mousetype(SCREEN *sp)
 
     /* Try gpm first, because gpm may be configured to run in xterm */
 #if USE_GPM_SUPPORT
-    if (allow_gpm_mouse()) {
+    if (allow_gpm_mouse(sp)) {
        if (!sp->_mouse_gpm_loaded) {
 #ifdef HAVE_LIBDL
            load_gpm_library(sp);