# HG changeset patch # User Stefan Monnier # Date 1221192659 0 # Node ID 314662df7c17cd443799d32bbedb564a882eba8f # Parent b67146e746c0d1eacb25cf06c96c13061209a4f9 * term.c (close_gpm): New fun extracted from Fgpm_mouse_stop. (Fgpm_mouse_stop): Use it. * termhooks.h (close_gpm): Declare. * keyboard.c (tty_read_avail_input): Forcefully close the gpm connection if Gpm_GetEvent fails. diff -r b67146e746c0 -r 314662df7c17 src/ChangeLog --- a/src/ChangeLog Fri Sep 12 03:41:11 2008 +0000 +++ b/src/ChangeLog Fri Sep 12 04:10:59 2008 +0000 @@ -1,5 +1,11 @@ 2008-09-12 Stefan Monnier + * term.c (close_gpm): New fun extracted from Fgpm_mouse_stop. + (Fgpm_mouse_stop): Use it. + * termhooks.h (close_gpm): Declare. + * keyboard.c (tty_read_avail_input): Forcefully close the gpm + connection if Gpm_GetEvent fails. + * window.c (set_window_buffer): Always preserve current-buffer. 2008-09-12 Glenn Morris diff -r b67146e746c0 -r 314662df7c17 src/keyboard.c --- a/src/keyboard.c Fri Sep 12 03:41:11 2008 +0000 +++ b/src/keyboard.c Fri Sep 12 04:10:59 2008 +0000 @@ -7110,6 +7110,9 @@ while (gpm = Gpm_GetEvent (&event), gpm == 1) { nread += handle_one_term_event (tty, &event, &hold_quit); } + if (gpm < 0) + /* Presumably the GPM daemon has closed the connection. */ + close_gpm (); if (hold_quit.kind != NO_EVENT) kbd_buffer_store_event (&hold_quit); if (nread) diff -r b67146e746c0 -r 314662df7c17 src/term.c --- a/src/term.c Fri Sep 12 03:41:11 2008 +0000 +++ b/src/term.c Fri Sep 12 04:10:59 2008 +0000 @@ -3128,6 +3128,15 @@ } } +void +close_gpm () +{ + if (gpm_fd >= 0) + delete_gpm_wait_descriptor (gpm_fd); + while (Gpm_Close()); /* close all the stack */ + gpm_tty = NULL; +} + DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop, 0, 0, 0, doc: /* Close a connection to Gpm. */) @@ -3141,10 +3150,7 @@ if (!tty || gpm_tty != tty) return Qnil; /* Not activated on this terminal, nothing to do. */ - if (gpm_fd >= 0) - delete_gpm_wait_descriptor (gpm_fd); - while (Gpm_Close()); /* close all the stack */ - gpm_tty = NULL; + close_gpm (); return Qnil; } #endif /* HAVE_GPM */ diff -r b67146e746c0 -r 314662df7c17 src/termhooks.h --- a/src/termhooks.h Fri Sep 12 03:41:11 2008 +0000 +++ b/src/termhooks.h Fri Sep 12 04:10:59 2008 +0000 @@ -643,5 +643,9 @@ /* The initial terminal device, created by initial_term_init. */ extern struct terminal *initial_terminal; +#ifdef HAVE_GPM +extern void close_gpm (void); +#endif + /* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d (do not change this comment) */