X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_mouse.c;h=6f62120904a0824f80e959bc18ba905631f03f28;hp=840d341b395bba702b80cf25f105300c93bf1d17;hb=91fa4688e82518794fcf0c32a36f3fcca5e4c2d5;hpb=8b06e371ed1bce3dd6f37138e6becb5e1a562fe0 diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c index 840d341b..6f621209 100644 --- a/ncurses/base/lib_mouse.c +++ b/ncurses/base/lib_mouse.c @@ -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 @@ -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);