X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=ncurses%2Fbase%2Flib_mouse.c;h=2fb261df0734696948dcc7887921b75e73319422;hb=a5fe3726f7d4374e9b1551b535c8617b423996f2;hp=887f1ab5cf8f146324fb772daf80261f6a7423e0;hpb=3e37c7d3fa122563a9d88168926f61286ef30cd3;p=ncurses.git diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c index 887f1ab5..2fb261df 100644 --- a/ncurses/base/lib_mouse.c +++ b/ncurses/base/lib_mouse.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -85,7 +85,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_mouse.c,v 1.188 2020/05/23 23:35:35 tom Exp $") +MODULE_ID("$Id: lib_mouse.c,v 1.193 2021/03/20 12:56:32 tom Exp $") #include @@ -419,13 +419,22 @@ init_xterm_mouse(SCREEN *sp) } else { int code = tigetnum("XM"); switch (code) { +#ifdef EXP_XTERM_1005 + case 1005: + /* see "xterm+sm+1005" */ + sp->_mouse_xtermcap = "\033[?1005;1000%?%p1%{1}%=%th%el%;"; + sp->_mouse_format = MF_XTERM_1005; + break; +#endif case 1006: + /* see "xterm+sm+1006" */ + sp->_mouse_xtermcap = "\033[?1006;1000%?%p1%{1}%=%th%el%;"; + sp->_mouse_format = MF_SGR1006; break; default: - code = 1000; + sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;"; break; } - sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;"; } } #endif @@ -436,7 +445,7 @@ enable_xterm_mouse(SCREEN *sp, int enable) #if USE_EMX_MOUSE sp->_emxmouse_activated = enable; #else - NCURSES_PUTP2("xterm-mouse", TPARM_1(sp->_mouse_xtermcap, enable)); + NCURSES_PUTP2("xterm-mouse", TIPARM_1(sp->_mouse_xtermcap, enable)); #endif sp->_mouse_active = enable; } @@ -487,8 +496,6 @@ unload_gpm_library(SCREEN *sp) T(("unload GPM library")); sp->_mouse_gpm_loaded = FALSE; sp->_mouse_fd = -1; - dlclose(sp->_dlopen_gpm); - sp->_dlopen_gpm = 0; } } @@ -496,7 +503,14 @@ static void load_gpm_library(SCREEN *sp) { sp->_mouse_gpm_found = FALSE; - if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) { + + /* + * If we already had a successful dlopen, reuse it. + */ + if (sp->_dlopen_gpm != 0) { + sp->_mouse_gpm_found = TRUE; + sp->_mouse_gpm_loaded = TRUE; + } else if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) { #if (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" @@ -510,13 +524,15 @@ load_gpm_library(SCREEN *sp) #endif T(("GPM initialization failed: %s", dlerror())); unload_gpm_library(sp); + dlclose(sp->_dlopen_gpm); + sp->_dlopen_gpm = 0; } else { sp->_mouse_gpm_found = TRUE; sp->_mouse_gpm_loaded = TRUE; } } } -#endif +#endif /* HAVE_LIBDL */ static bool enable_gpm_mouse(SCREEN *sp, bool enable) @@ -971,7 +987,7 @@ decode_X10_bstate(SCREEN *sp, MEVENT * eventp, unsigned intro) if (intro >= 96) { if (intro >= 160) { button = (int) (intro - 152); /* buttons 8-11 */ - } else if (intro >= 96) { + } else { button = (int) (intro - 92); /* buttons 4-7 */ } } else {