changeset 98155:314662df7c17

* 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.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 12 Sep 2008 04:10:59 +0000
parents b67146e746c0
children 464ec62a612c
files src/ChangeLog src/keyboard.c src/term.c src/termhooks.h
diffstat 4 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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  <monnier@iro.umontreal.ca>
 
+	* 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  <rgm@gnu.org>
--- 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)
--- 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 */
--- 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) */