aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-10-18 19:06:44 +0000
committerStefan Monnier2007-10-18 19:06:44 +0000
commitaf020a0464b03976a56041e25087f132e7d38160 (patch)
tree30a723de42bc99bb8dd9f77e93d5b6bbbddec550
parent8782c744ef0c1732c513e29f260b0e73263deffd (diff)
downloademacs-af020a0464b03976a56041e25087f132e7d38160.tar.gz
emacs-af020a0464b03976a56041e25087f132e7d38160.zip
Don't change the global function-key-map anny more.
(xterm-mouse-mode): Use terminal-init-xterm-hook. Don't use after-make-frame-functions now that term/xterm.el calls us directly. (turn-on-xterm-mouse-tracking, turn-off-xterm-mouse-tracking): Use turn-*-xterm-mouse-tracking-on-terminal. Only once per terminal. (turn-on-xterm-mouse-tracking-on-terminal): Make param optional. Setup input-decode-map and remember that xterm-mouse-mode was enabled in this terminal. (turn-off-xterm-mouse-tracking-on-terminal): Only disable on those terminals where it has been enabled.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/xt-mouse.el45
2 files changed, 36 insertions, 21 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9063215b99f..1714b9e850d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,17 @@
12007-10-18 Stefan Monnier <monnier@iro.umontreal.ca> 12007-10-18 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * xt-mouse.el: Don't change the global function-key-map anny more.
4 (xterm-mouse-mode): Use terminal-init-xterm-hook.
5 Don't use after-make-frame-functions now that term/xterm.el calls
6 us directly.
7 (turn-on-xterm-mouse-tracking, turn-off-xterm-mouse-tracking):
8 Use turn-*-xterm-mouse-tracking-on-terminal. Only once per terminal.
9 (turn-on-xterm-mouse-tracking-on-terminal): Make param optional.
10 Setup input-decode-map and remember that xterm-mouse-mode was
11 enabled in this terminal.
12 (turn-off-xterm-mouse-tracking-on-terminal): Only disable on those
13 terminals where it has been enabled.
14
3 * faces.el (tty-create-frame-with-faces): Make sure not only 15 * faces.el (tty-create-frame-with-faces): Make sure not only
4 tty-run-terminal-initialization but also set-locale-environment 16 tty-run-terminal-initialization but also set-locale-environment
5 are run only once per terminal. 17 are run only once per terminal.
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 15aebb08ab2..adb6f08943c 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -45,9 +45,6 @@
45 45
46(defvar xterm-mouse-debug-buffer nil) 46(defvar xterm-mouse-debug-buffer nil)
47 47
48;; XXX Perhaps this should be terminal-local instead. --lorentey
49(define-key function-key-map "\e[M" 'xterm-mouse-translate)
50
51(defvar xterm-mouse-last) 48(defvar xterm-mouse-last)
52 49
53;; Mouse events symbols must have an 'event-kind property with 50;; Mouse events symbols must have an 'event-kind property with
@@ -78,7 +75,7 @@
78 (error "Unexpected escape sequence from XTerm"))) 75 (error "Unexpected escape sequence from XTerm")))
79 76
80 (let* ((click (if is-click down (xterm-mouse-event))) 77 (let* ((click (if is-click down (xterm-mouse-event)))
81 (click-command (nth 0 click)) 78 ;; (click-command (nth 0 click))
82 (click-data (nth 1 click)) 79 (click-data (nth 1 click))
83 (click-where (nth 1 click-data))) 80 (click-where (nth 1 click-data)))
84 (if (memq down-binding '(nil ignore)) 81 (if (memq down-binding '(nil ignore))
@@ -209,14 +206,15 @@ down the SHIFT key while pressing the mouse button."
209 ;; Turn it on 206 ;; Turn it on
210 (progn 207 (progn
211 ;; Frame creation and deletion. 208 ;; Frame creation and deletion.
212 (add-hook 'after-make-frame-functions 209 (add-hook 'terminal-init-xterm-hook
213 'turn-on-xterm-mouse-tracking-on-terminal) 210 'turn-on-xterm-mouse-tracking-on-terminal)
211
214 (add-hook 'delete-frame-functions 'xterm-mouse-handle-delete-frame) 212 (add-hook 'delete-frame-functions 'xterm-mouse-handle-delete-frame)
215 213
216 ;; Restore normal mouse behaviour outside Emacs. 214 ;; Restore normal mouse behaviour outside Emacs.
217 (add-hook 'suspend-tty-functions 215 (add-hook 'suspend-tty-functions
218 'turn-off-xterm-mouse-tracking-on-terminal) 216 'turn-off-xterm-mouse-tracking-on-terminal)
219 (add-hook 'resume-tty-functions 217 (add-hook 'resume-tty-functions
220 'turn-on-xterm-mouse-tracking-on-terminal) 218 'turn-on-xterm-mouse-tracking-on-terminal)
221 (add-hook 'suspend-hook 'turn-off-xterm-mouse-tracking) 219 (add-hook 'suspend-hook 'turn-off-xterm-mouse-tracking)
222 (add-hook 'suspend-resume-hook 'turn-on-xterm-mouse-tracking) 220 (add-hook 'suspend-resume-hook 'turn-on-xterm-mouse-tracking)
@@ -224,8 +222,6 @@ down the SHIFT key while pressing the mouse button."
224 (setq mouse-position-function #'xterm-mouse-position-function) 222 (setq mouse-position-function #'xterm-mouse-position-function)
225 (turn-on-xterm-mouse-tracking)) 223 (turn-on-xterm-mouse-tracking))
226 ;; Turn it off 224 ;; Turn it off
227 (remove-hook 'after-make-frame-functions
228 'turn-on-xterm-mouse-tracking-on-terminal)
229 (remove-hook 'delete-frame-functions 'xterm-mouse-handle-delete-frame) 225 (remove-hook 'delete-frame-functions 'xterm-mouse-handle-delete-frame)
230 (remove-hook 'suspend-tty-functions 226 (remove-hook 'suspend-tty-functions
231 'turn-off-xterm-mouse-tracking-on-terminal) 227 'turn-off-xterm-mouse-tracking-on-terminal)
@@ -239,28 +235,35 @@ down the SHIFT key while pressing the mouse button."
239 235
240(defun turn-on-xterm-mouse-tracking () 236(defun turn-on-xterm-mouse-tracking ()
241 "Enable Emacs mouse tracking in xterm." 237 "Enable Emacs mouse tracking in xterm."
242 (dolist (f (frame-list)) 238 (dolist (terminal (delete-dups (mapcar 'frame-terminal (frame-list))))
243 (when (eq t (frame-live-p f)) 239 (turn-on-xterm-mouse-tracking-on-terminal terminal)))
244 (with-selected-frame f
245 (when xterm-mouse-mode
246 (send-string-to-terminal "\e[?1000h"))))))
247 240
248(defun turn-off-xterm-mouse-tracking (&optional force) 241(defun turn-off-xterm-mouse-tracking (&optional force)
249 "Disable Emacs mouse tracking in xterm." 242 "Disable Emacs mouse tracking in xterm."
250 (dolist (f (frame-list)) 243 (dolist (terminal (delete-dups (mapcar 'frame-terminal (frame-list))))
251 (when (eq t (frame-live-p f)) 244 (turn-off-xterm-mouse-tracking-on-terminal terminal)))
252 (with-selected-frame f
253 (when (or force xterm-mouse-mode)
254 (send-string-to-terminal "\e[?1000l"))))))
255 245
256(defun turn-on-xterm-mouse-tracking-on-terminal (terminal) 246(defun turn-on-xterm-mouse-tracking-on-terminal (&optional terminal)
257 "Enable xterm mouse tracking on TERMINAL." 247 "Enable xterm mouse tracking on TERMINAL."
258 (when (and xterm-mouse-mode (eq t (terminal-live-p terminal))) 248 (when (and xterm-mouse-mode (eq t (terminal-live-p terminal)))
249 (unless (terminal-parameter terminal 'xterm-mouse-mode)
250 ;; Simulate selecting a terminal by selecting one of its frames ;-(
251 (with-selected-frame (car (frames-on-display-list terminal))
252 (define-key input-decode-map "\e[M" 'xterm-mouse-translate))
253 (set-terminal-parameter terminal 'xterm-mouse-mode t))
259 (send-string-to-terminal "\e[?1000h" terminal))) 254 (send-string-to-terminal "\e[?1000h" terminal)))
260 255
261(defun turn-off-xterm-mouse-tracking-on-terminal (terminal) 256(defun turn-off-xterm-mouse-tracking-on-terminal (terminal)
262 "Disable xterm mouse tracking on TERMINAL." 257 "Disable xterm mouse tracking on TERMINAL."
263 (when (and xterm-mouse-mode (eq t (terminal-live-p terminal))) 258 ;; Only send the disable command to those terminals to which we've already
259 ;; sent the enable command.
260 (when (and (terminal-parameter terminal 'xterm-mouse-mode)
261 (eq t (terminal-live-p terminal)))
262 ;; We could remove the key-binding and unset the `xterm-mouse-mode'
263 ;; terminal parameter, but it seems less harmful to send this escape
264 ;; command too many times (or to catch an unintended key sequence), than
265 ;; to send it too few times (or to fail to let xterm-mouse events
266 ;; pass by untranslated).
264 (send-string-to-terminal "\e[?1000l" terminal))) 267 (send-string-to-terminal "\e[?1000l" terminal)))
265 268
266(defun xterm-mouse-handle-delete-frame (frame) 269(defun xterm-mouse-handle-delete-frame (frame)