+2007-09-21 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * termhooks.h (term_gpm): Delete. Use gpm_tty's NULLness instead.
+ (gpm_tty): Change its type.
+ * term.c (term_gpm): Delete. Use gpm_tty's NULLness instead.
+ (gpm_tty): Change its type and initialize it.
+ (Fterm_open_connection): Check the frame is indeed a tty.
+ Use the new gpm_tty.
+ (Fterm_close_connection): Use the new gpm_tty.
+ * keyboard.c (tty_read_avail_input): Use the new gpm_tty.
+ * sysdep.c (init_sys_modes): term_gpm -> gpm_tty.
+
2007-09-21 Juanma Barranquero <lekktu@gmail.com>
* w32term.c (x_draw_glyph_string): Use strike_through_color, not
fcntl (fileno (tty_out->input), F_SETOWN, getpid ());
init_sigio (fileno (tty_out->input));
#ifdef HAVE_GPM
- if (term_gpm)
+ if (gpm_tty)
{
fcntl (gpm_fd, F_SETOWN, getpid ());
fcntl (gpm_fd, F_SETFL, fcntl (gpm_fd, F_GETFL, 0) | O_NONBLOCK);
#include <sys/fcntl.h>
#include "buffer.h"
-/* Nonzero means mouse is enabled on Linux console. */
-int term_gpm = 0;
-
-/* The id of the terminal device for which we have gpm support. */
-int gpm_tty;
+/* The device for which we have enabled gpm support (or NULL). */
+struct tty_display_info *gpm_tty = NULL;
/* These variables describe the range of text currently shown in its
mouse-face, together with the window they apply to. As long as
DEFUN ("term-open-connection", Fterm_open_connection, Sterm_open_connection,
0, 0, 0,
- doc: /* Open a connection to Gpm. */)
+ doc: /* Open a connection to Gpm.
+We only support Gpm on one tty at a time. */)
()
{
- struct tty_display_info *tty = FRAME_TTY (SELECTED_FRAME ());
+ struct frame *f = SELECTED_FRAME ();
+ struct tty_display_info *tty
+ = ((f)->output_method == output_termcap
+ ? (f)->terminal->display_info.tty : NULL);
Gpm_Connect connection;
+ if (gpm_tty || !tty) /* Already running, or not applicable. */
+ return Qnil;
+
connection.eventMask = ~0;
connection.defaultMask = ~GPM_HARD;
connection.maxMod = ~0;
connection.minMod = 0;
gpm_zerobased = 1;
- /* We only support GPM on the controlling tty. */
- if (term_gpm || tty->terminal->id > 1
- || Gpm_Open (&connection, 0) < 0)
+ if (Gpm_Open (&connection, 0) < 0)
return Qnil;
else
{
- term_gpm = 1;
- gpm_tty = tty->terminal->id;
+ gpm_tty = tty;
reset_sys_modes (tty);
init_sys_modes (tty);
add_gpm_wait_descriptor (gpm_fd);
{
delete_gpm_wait_descriptor (gpm_fd);
while (Gpm_Close()); /* close all the stack */
- term_gpm = 0;
+ gpm_tty = NULL;
return Qnil;
}
#endif /* HAVE_GPM */
extern int handle_one_term_event (struct tty_display_info *, Gpm_Event *, struct input_event *);
extern void term_mouse_moveto (int, int);
-/* Nonzero means mouse is enabled on Linux console */
-extern int term_gpm;
-
-/* The id of the terminal device for which we have gpm support. */
-extern int gpm_tty;
+/* The device for which we have enabled gpm support. */
+extern struct tty_display_info *gpm_tty;
#endif
#endif /* CONSP */