]> git.eshelyaron.com Git - emacs.git/commitdiff
(xterm-mouse-mode): Use delete-terminal-functions.
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 29 Mar 2008 02:15:56 +0000 (02:15 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 29 Mar 2008 02:15:56 +0000 (02:15 +0000)
(xterm-mouse-handle-delete-frame): Delete.

lisp/ChangeLog
lisp/xt-mouse.el

index 972aa057d18a640c7561e0582c476a4d76ece8b4..c7dc80a6d65a19a29e5629c1ffec74d29ad42ad1 100644 (file)
@@ -1,5 +1,8 @@
 2008-03-29  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * xt-mouse.el (xterm-mouse-mode): Use delete-terminal-functions.
+       (xterm-mouse-handle-delete-frame): Delete.
+
        * term/xterm.el (terminal-init-xterm): Use delete-terminal-functions.
        (xterm-turn-on-modify-other-keys, xterm-turn-off-modify-other-keys)
        (xterm-remove-modify-other-keys): Lookup terminal rather than frame
index 5f8d8ca61db626389cdbbc119d380ab909b0ec5d..ea0adc3c8a5328b4812f6f77b1206b19dde7265c 100644 (file)
@@ -205,34 +205,24 @@ single clicks are supported.  When turned on, the normal xterm
 mouse functionality for such clicks is still available by holding
 down the SHIFT key while pressing the mouse button."
   :global t :group 'mouse
+  (let ((do-hook (if xterm-mouse-mode 'add-hook 'remove-hook)))
+    (funcall do-hook 'terminal-init-xterm-hook
+             'turn-on-xterm-mouse-tracking-on-terminal)
+    (funcall do-hook 'delete-terminal-functions
+             'turn-off-xterm-mouse-tracking-on-terminal)
+    (funcall do-hook 'suspend-tty-functions
+             'turn-off-xterm-mouse-tracking-on-terminal)
+    (funcall do-hook 'resume-tty-functions
+             'turn-on-xterm-mouse-tracking-on-terminal)
+    (funcall do-hook 'suspend-hook 'turn-off-xterm-mouse-tracking)
+    (funcall do-hook 'suspend-resume-hook 'turn-on-xterm-mouse-tracking)
+    (funcall do-hook 'kill-emacs-hook 'turn-off-xterm-mouse-tracking))
   (if xterm-mouse-mode
       ;; Turn it on
       (progn
-       ;; Frame creation and deletion.
-        (add-hook 'terminal-init-xterm-hook
-                  'turn-on-xterm-mouse-tracking-on-terminal)
-
-       (add-hook 'delete-frame-functions 'xterm-mouse-handle-delete-frame)
-       
-       ;; Restore normal mouse behaviour outside Emacs.
-        (add-hook 'suspend-tty-functions
-                 'turn-off-xterm-mouse-tracking-on-terminal)
-       (add-hook 'resume-tty-functions
-                 'turn-on-xterm-mouse-tracking-on-terminal)
-       (add-hook 'suspend-hook 'turn-off-xterm-mouse-tracking)
-       (add-hook 'suspend-resume-hook 'turn-on-xterm-mouse-tracking)
-       (add-hook 'kill-emacs-hook 'turn-off-xterm-mouse-tracking)
        (setq mouse-position-function #'xterm-mouse-position-function)
        (turn-on-xterm-mouse-tracking))
     ;; Turn it off
-    (remove-hook 'delete-frame-functions 'xterm-mouse-handle-delete-frame)
-    (remove-hook 'suspend-tty-functions 
-                'turn-off-xterm-mouse-tracking-on-terminal)
-    (remove-hook 'resume-tty-functions 
-                'turn-on-xterm-mouse-tracking-on-terminal)
-    (remove-hook 'suspend-hook 'turn-off-xterm-mouse-tracking)
-    (remove-hook 'suspend-resume-hook 'turn-on-xterm-mouse-tracking)
-    (remove-hook 'kill-emacs-hook 'turn-off-xterm-mouse-tracking)
     (turn-off-xterm-mouse-tracking 'force)
     (setq mouse-position-function nil)))
 
@@ -269,12 +259,6 @@ down the SHIFT key while pressing the mouse button."
     ;; pass by untranslated).
     (send-string-to-terminal "\e[?1000l" terminal)))
 
-(defun xterm-mouse-handle-delete-frame (frame)
-  "Turn off xterm mouse tracking if FRAME is the last frame on its device."
-  (when (and (eq t (frame-live-p frame))
-            (<= 1 (length (frames-on-display-list (frame-terminal frame)))))
-    (turn-off-xterm-mouse-tracking-on-terminal frame)))
-
 (provide 'xt-mouse)
 
 ;; arch-tag: 84962d4e-fae9-4c13-a9d7-ef4925a4ac03