X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_mouse.c;h=6caef327a3c02b404e420da90fc42494d9706e5a;hp=6422b52e0c1a869e7b0d9281a3f73eef46619885;hb=3934889cc6b0f45cf218c88df7f35634d250c9e5;hpb=790a85dbd4a81d5f5d8dd02a44d84f01512ef443 diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c index 6422b52e..6caef327 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.190 2020/05/27 23:55:32 tom Exp $") +MODULE_ID("$Id: lib_mouse.c,v 1.192 2021/02/14 00:17:09 tom Exp $") #include @@ -487,8 +487,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 +494,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 +515,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 +978,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 {