changeset 84570:d1fd48a6a8ed

* xt-mouse.el (xterm-mouse-mode): Add hooks here not at the top level. Remove the hooks when turning off the mode. * term/xterm.el: Require xt-mouse at compile time. (terminal-init-xterm): Turn on xterm mouse tracking for this terminal if xterm-mouse-mode is enabled.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sat, 15 Sep 2007 00:27:38 +0000
parents cad259e522a5
children 44b45775d250
files lisp/ChangeLog lisp/term/xterm.el lisp/xt-mouse.el
diffstat 3 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Sep 14 22:58:55 2007 +0000
+++ b/lisp/ChangeLog	Sat Sep 15 00:27:38 2007 +0000
@@ -1,3 +1,12 @@
+2007-09-15  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* xt-mouse.el (xterm-mouse-mode): Add hooks here not at the top
+	level.  Remove the hooks when turning off the mode.
+
+	* term/xterm.el: Require xt-mouse at compile time.
+	(terminal-init-xterm): Turn on xterm mouse tracking for this
+	terminal if xterm-mouse-mode is enabled.
+
 2007-09-14  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* term/xterm.el (xterm-function-map): Replace bindings that were
--- a/lisp/term/xterm.el	Fri Sep 14 22:58:55 2007 +0000
+++ b/lisp/term/xterm.el	Sat Sep 15 00:27:38 2007 +0000
@@ -27,6 +27,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'xt-mouse))
+
 (defvar xterm-function-map
   (let ((map (make-sparse-keymap)))
 
@@ -455,7 +457,11 @@
     (xterm-register-default-colors)
     ;; This recomputes all the default faces given the colors we've just set up.
     (tty-set-up-initial-frame-faces)
-
+    
+    (when xterm-mouse-mode
+      (turn-on-xterm-mouse-tracking-on-terminal 
+       (frame-terminal (selected-frame))))
+    
     ;; Try to turn on the modifyOtherKeys feature on modern xterms.
     ;; When it is turned on much more key bindings work: things like
     ;; C-. C-, etc.
--- a/lisp/xt-mouse.el	Fri Sep 14 22:58:55 2007 +0000
+++ b/lisp/xt-mouse.el	Sat Sep 15 00:27:38 2007 +0000
@@ -208,9 +208,32 @@
   (if xterm-mouse-mode
       ;; Turn it on
       (progn
+	;; Frame creation and deletion.
+	(add-hook 'after-make-frame-functions 
+		  '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 'after-make-frame-functions 
+		 'turn-on-xterm-mouse-tracking-on-terminal)
+    (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)))