From ed5ff21d09be6c15cefcc000fe266604a4c83544 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 12 Sep 2008 04:10:59 +0000 Subject: [PATCH] * 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. --- src/ChangeLog | 6 ++++++ src/keyboard.c | 3 +++ src/term.c | 14 ++++++++++---- src/termhooks.h | 4 ++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index adcc4851d22..1136e5e6057 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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 --git a/src/keyboard.c b/src/keyboard.c index 5015155d97f..cd18b91abf1 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -7110,6 +7110,9 @@ tty_read_avail_input (struct terminal *terminal, 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 --git a/src/term.c b/src/term.c index 367040288ef..19382f9667c 100644 --- a/src/term.c +++ b/src/term.c @@ -3128,6 +3128,15 @@ Gpm-mouse can only be activated for one tty at a time. */) } } +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 @@ DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop, 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 --git a/src/termhooks.h b/src/termhooks.h index 9edd4bf052e..71a935420d5 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -643,5 +643,9 @@ extern void delete_terminal P_ ((struct terminal *)); /* 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) */ -- 2.39.5