]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.6 - patch 20080925
authorThomas E. Dickey <dickey@invisible-island.net>
Thu, 25 Sep 2008 23:54:34 +0000 (23:54 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Thu, 25 Sep 2008 23:54:34 +0000 (23:54 +0000)
+ fix bug in mouse code for GPM from 20080920 changes (reported in
  Debian #500103, also Miroslav Lichvar).

NEWS
dist.mk
ncurses/base/lib_mouse.c

diff --git a/NEWS b/NEWS
index c8b86fad23e98cf926ddb44d53f17376c9f02e20..c9b0e427afcfc8e16638203f1997b7bb345416d8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.1296 2008/09/20 21:45:57 tom Exp $
+-- $Id: NEWS,v 1.1297 2008/09/25 23:30:56 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -45,6 +45,10 @@ See the AUTHORS file for the corresponding full names.
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
+20080925
+       + fix bug in mouse code for GPM from 20080920 changes (reported in
+         Debian #500103, also Miroslav Lichvar).
+
 20080920
        + fix shared-library rules for cygwin with tic- and tinfo-libraries.
        + fix a memory leak when failure to connect to GPM.
 20080920
        + fix shared-library rules for cygwin with tic- and tinfo-libraries.
        + fix a memory leak when failure to connect to GPM.
diff --git a/dist.mk b/dist.mk
index 4bd872a40adfffd4c1889bca3ac0a89cf768fd1e..9d30d2b4e7b874976554621a976c6f47230311bf 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -25,7 +25,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.661 2008/09/20 16:52:23 tom Exp $
+# $Id: dist.mk,v 1.662 2008/09/25 20:12:43 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
@@ -37,7 +37,7 @@ SHELL = /bin/sh
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 6
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 6
-NCURSES_PATCH = 20080920
+NCURSES_PATCH = 20080925
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index e92be5b92fe0f8a716bf8876070aa6b4f1845284..731025e30d3a12666ea06cc6888202c4b32bb18e 100644 (file)
@@ -79,7 +79,7 @@
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_mouse.c,v 1.98 2008/09/20 21:26:19 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.99 2008/09/25 21:47:51 tom Exp $")
 
 #include <term.h>
 #include <tic.h>
 
 #include <term.h>
 #include <tic.h>
@@ -381,29 +381,69 @@ allow_gpm_mouse(void)
     return FALSE;
 }
 
     return FALSE;
 }
 
+#ifdef HAVE_LIBDL
+static void
+unload_gpm_library(SCREEN *sp)
+{
+    if (SP->_dlopen_gpm != 0) {
+       T(("unload GPM library"));
+       sp->_mouse_gpm_loaded = FALSE;
+       dlclose(sp->_dlopen_gpm);
+       sp->_dlopen_gpm = 0;
+    }
+}
+
+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;
+       }
+    }
+}
+#endif
+
 static bool
 static bool
-enable_gpm_mouse(SCREEN *sp, int enable)
+enable_gpm_mouse(SCREEN *sp, bool enable)
 {
     bool result;
 
     T((T_CALLED("enable_gpm_mouse(%d)"), enable));
 
     if (enable && !sp->_mouse_active) {
 {
     bool result;
 
     T((T_CALLED("enable_gpm_mouse(%d)"), enable));
 
     if (enable && !sp->_mouse_active) {
-       /* 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);
+#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 {
        sp->_mouse_active = result;
        T(("GPM open %s", result ? "succeeded" : "failed"));
     } else {
@@ -413,15 +453,11 @@ enable_gpm_mouse(SCREEN *sp, int enable)
            sp->_mouse_active = FALSE;
            T(("GPM closed"));
        }
            sp->_mouse_active = FALSE;
            T(("GPM closed"));
        }
-       result = FALSE;
+       result = enable;
     }
 #ifdef HAVE_LIBDL
     }
 #ifdef HAVE_LIBDL
-    if (!result && (SP->_dlopen_gpm != 0)) {
-       T(("unload GPM library"));
-       SP->_mouse_gpm_found = FALSE;
-       SP->_mouse_gpm_loaded = FALSE;
-       dlclose(SP->_dlopen_gpm);
-       SP->_dlopen_gpm = 0;
+    if (!result) {
+       unload_gpm_library(sp);
     }
 #endif
     returnBool(result);
     }
 #endif
     returnBool(result);
@@ -440,21 +476,11 @@ initialize_mousetype(SCREEN *sp)
     if (allow_gpm_mouse()) {
        if (!sp->_mouse_gpm_loaded) {
 #ifdef HAVE_LIBDL
     if (allow_gpm_mouse()) {
        if (!sp->_mouse_gpm_loaded) {
 #ifdef HAVE_LIBDL
-           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()));
-                   dlclose(SP->_dlopen_gpm);
-               } else {
-                   sp->_mouse_gpm_found = TRUE;
-               }
-           }
+           load_gpm_library(sp);
 #else /* !HAVE_LIBDL */
            sp->_mouse_gpm_found = TRUE;
 #else /* !HAVE_LIBDL */
            sp->_mouse_gpm_found = TRUE;
-#endif
            sp->_mouse_gpm_loaded = TRUE;
            sp->_mouse_gpm_loaded = TRUE;
+#endif
        }
 
        /*
        }
 
        /*
@@ -904,7 +930,7 @@ mouse_activate(SCREEN *sp, bool on)
            break;
 #if USE_GPM_SUPPORT
        case M_GPM:
            break;
 #if USE_GPM_SUPPORT
        case M_GPM:
-           if (enable_gpm_mouse(sp, 1)) {
+           if (enable_gpm_mouse(sp, TRUE)) {
                sp->_mouse_fd = *(my_gpm_fd);
                T(("GPM mouse_fd %d", sp->_mouse_fd));
            }
                sp->_mouse_fd = *(my_gpm_fd);
                T(("GPM mouse_fd %d", sp->_mouse_fd));
            }
@@ -936,7 +962,7 @@ mouse_activate(SCREEN *sp, bool on)
            break;
 #if USE_GPM_SUPPORT
        case M_GPM:
            break;
 #if USE_GPM_SUPPORT
        case M_GPM:
-           enable_gpm_mouse(sp, 0);
+           enable_gpm_mouse(sp, FALSE);
            break;
 #endif
 #if USE_SYSMOUSE
            break;
 #endif
 #if USE_SYSMOUSE