(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.
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>
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)
}
}
+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. */)
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 */
/* 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) */