X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_mouse.c;h=d19189f7d6e97eac6555569ae780126949d05a36;hp=83f63a009143bfeff467a25b19c219058955db0e;hb=879fd5bd9d5139bcf96c9188cbc3858014fceb4d;hpb=86b23c4fe3179cfe3308ef5952cabc613d168c96 diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c index 83f63a00..d19189f7 100644 --- a/ncurses/base/lib_mouse.c +++ b/ncurses/base/lib_mouse.c @@ -79,7 +79,7 @@ #include -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 #include @@ -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;