]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_mouse.c
ncurses 5.7 - patch 20081206
[ncurses.git] / ncurses / base / lib_mouse.c
index 83f63a009143bfeff467a25b19c219058955db0e..d19189f7d6e97eac6555569ae780126949d05a36 100644 (file)
@@ -79,7 +79,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_mouse.c,v 1.103 2008/11/23 00:11:46 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.104 2008/11/30 01:37:27 tom Exp $")
 
 #include <term.h>
 #include <tic.h>
@@ -694,11 +694,16 @@ _nc_mouse_event(SCREEN *sp GCC_UNUSED)
 
 #if USE_GPM_SUPPORT
     case M_GPM:
-       {
+       if (sp->_mouse_fd >= 0) {
            /* query server for event, return TRUE if we find one */
            Gpm_Event ev;
 
-           if (my_Gpm_GetEvent(&ev) == 1) {
+           switch (my_Gpm_GetEvent(&ev)) {
+           case 0:
+               /* Connection closed, drop the mouse. */
+               sp->_mouse_fd = -1;
+               break;
+           case 1:
                /* there's only one mouse... */
                eventp->id = NORMAL_EVENT;
 
@@ -731,6 +736,7 @@ _nc_mouse_event(SCREEN *sp GCC_UNUSED)
                /* bump the next-free pointer into the circular list */
                sp->_mouse_eventp = eventp = NEXT(eventp);
                result = TRUE;
+               break;
            }
        }
        break;