]> git.eshelyaron.com Git - emacs.git/commitdiff
(Fgpm_mouse_start): Don't signal an error if already activated on this tty.
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 28 Sep 2007 20:07:54 +0000 (20:07 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 28 Sep 2007 20:07:54 +0000 (20:07 +0000)
(Fgpm_mouse_stop): Only deactivate if it was activated on this tty.

src/ChangeLog
src/term.c

index f7698a2cfc30482ff1d0b7cb828b27ccc97f4962..7ed8e48a4ccde7c7da8e9cd3ab00b3bb9d6ee707 100644 (file)
@@ -1,5 +1,9 @@
 2007-09-28  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * term.c (Fgpm_mouse_start): Don't signal an error if already activated
+       on this tty.
+       (Fgpm_mouse_stop): Only deactivate if it was activated on this tty.
+
        * term.c (mouse_face_window): Rename from Qmouse_face_window.
        Update all users.
        (handle_one_term_event): Use Gpm_DrawPointer.
index 6dbfb5daee8edf7e31464f891589eea8e4ea6408..f00f7b2fb753a5ef3572dee8c0d31380472c8cb2 100644 (file)
@@ -2952,10 +2952,12 @@ Gpm-mouse can only be activated for one tty at a time.  */)
        ? (f)->terminal->display_info.tty : NULL);
   Gpm_Connect connection;
 
-  if (gpm_tty)
-    error ("Gpm-mouse can only be activated for one tty at a time");
   if (!tty)
     error ("Gpm-mouse only works in the GNU/Linux console");
+  if (gpm_tty == tty)
+    return Qnil;               /* Already activated, nothing to do.  */
+  if (gpm_tty)
+    error ("Gpm-mouse can only be activated for one tty at a time");
 
   connection.eventMask = ~0;
   connection.defaultMask = ~GPM_HARD;
@@ -2983,6 +2985,14 @@ DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop,
        doc: /* Close a connection to Gpm.  */)
      ()
 {
+  struct frame *f = SELECTED_FRAME ();
+  struct tty_display_info *tty
+    = ((f)->output_method == output_termcap
+       ? (f)->terminal->display_info.tty : NULL);
+
+  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 */