changeset 84768:53194ec05789

* 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.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 21 Sep 2007 17:10:48 +0000
parents 3fb70c6369b7
children cbcb89640ef2
files src/ChangeLog src/keyboard.c src/sysdep.c src/term.c src/termhooks.h
diffstat 5 files changed, 30 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Sep 21 11:08:00 2007 +0000
+++ b/src/ChangeLog	Fri Sep 21 17:10:48 2007 +0000
@@ -1,3 +1,15 @@
+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
--- a/src/keyboard.c	Fri Sep 21 11:08:00 2007 +0000
+++ b/src/keyboard.c	Fri Sep 21 17:10:48 2007 +0000
@@ -7121,7 +7121,7 @@
     return 0;                   /* The terminal is suspended. */
 
 #ifdef HAVE_GPM
-  if (term_gpm && gpm_tty == tty->terminal->id)
+  if (gpm_tty == tty)
   {
       Gpm_Event event;
       struct input_event hold_quit;
--- a/src/sysdep.c	Fri Sep 21 11:08:00 2007 +0000
+++ b/src/sysdep.c	Fri Sep 21 17:10:48 2007 +0000
@@ -1752,7 +1752,7 @@
       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);
--- a/src/term.c	Fri Sep 21 11:08:00 2007 +0000
+++ b/src/term.c	Fri Sep 21 17:10:48 2007 +0000
@@ -195,11 +195,8 @@
 #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
@@ -2961,26 +2958,30 @@
 
 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);
@@ -2995,7 +2996,7 @@
 {
    delete_gpm_wait_descriptor (gpm_fd);
    while (Gpm_Close()); /* close all the stack */
-   term_gpm = 0;
+   gpm_tty = NULL;
    return Qnil;
 }
 #endif /* HAVE_GPM */
--- a/src/termhooks.h	Fri Sep 21 11:08:00 2007 +0000
+++ b/src/termhooks.h	Fri Sep 21 17:10:48 2007 +0000
@@ -302,11 +302,8 @@
 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 */