comparison lisp/xt-mouse.el @ 83561:dc002877ce12

Merged from emacs@sv.gnu.org Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-674 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-675 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-676 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-677 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-678 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-679 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-680 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-681 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-682 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-683 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-684 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-685 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-686 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-687 Release ERC 5.2. * emacs@sv.gnu.org/emacs--devo--0--patch-688 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-689 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-690 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-691 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-692 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-693 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-694 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-695 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-696 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-697 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-698 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-699 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-700 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-701 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-209 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-210 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-211 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-212 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-213 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-214 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-215 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-601
author Karoly Lorentey <karoly@lorentey.hu>
date Sun, 22 Apr 2007 12:42:47 +0000
parents b8d9a391daf3 44b6d7a1ef55
children 0a3247aa24a4
comparison
equal deleted inserted replaced
83560:738ce3540ffb 83561:dc002877ce12
48 48
49 (defvar xterm-mouse-last) 49 (defvar xterm-mouse-last)
50 50
51 ;; Mouse events symbols must have an 'event-kind property with 51 ;; Mouse events symbols must have an 'event-kind property with
52 ;; the value 'mouse-click. 52 ;; the value 'mouse-click.
53 (dolist (event-type '(mouse-1 mouse-2 mouse-3)) 53 (dolist (event-type '(mouse-1 mouse-2 mouse-3
54 M-down-mouse-1 M-down-mouse-2 M-down-mouse-3))
54 (put event-type 'event-kind 'mouse-click)) 55 (put event-type 'event-kind 'mouse-click))
55 56
56 (defun xterm-mouse-translate (event) 57 (defun xterm-mouse-translate (event)
57 "Read a click and release event from XTerm." 58 "Read a click and release event from XTerm."
58 (save-excursion 59 (save-excursion
106 ;; "Position of last xterm mouse event relative to the frame.") 107 ;; "Position of last xterm mouse event relative to the frame.")
107 ;; 108 ;;
108 ;;(defvar xterm-mouse-y 0 109 ;;(defvar xterm-mouse-y 0
109 ;; "Position of last xterm mouse event relative to the frame.") 110 ;; "Position of last xterm mouse event relative to the frame.")
110 111
112 (defvar xt-mouse-epoch nil)
113
111 ;; Indicator for the xterm-mouse mode. 114 ;; Indicator for the xterm-mouse mode.
112 115
113 (defun xterm-mouse-position-function (pos) 116 (defun xterm-mouse-position-function (pos)
114 "Bound to `mouse-position-function' in XTerm mouse mode." 117 "Bound to `mouse-position-function' in XTerm mouse mode."
115 (when (terminal-parameter nil 'xterm-mouse-x) 118 (when (terminal-parameter nil 'xterm-mouse-x)
127 (defun xterm-mouse-event () 130 (defun xterm-mouse-event ()
128 "Convert XTerm mouse event to Emacs mouse event." 131 "Convert XTerm mouse event to Emacs mouse event."
129 (let* ((type (- (xterm-mouse-event-read) #o40)) 132 (let* ((type (- (xterm-mouse-event-read) #o40))
130 (x (- (xterm-mouse-event-read) #o40 1)) 133 (x (- (xterm-mouse-event-read) #o40 1))
131 (y (- (xterm-mouse-event-read) #o40 1)) 134 (y (- (xterm-mouse-event-read) #o40 1))
135 ;; Emulate timestamp information. This is accurate enough
136 ;; for default value of mouse-1-click-follows-link (450msec).
137 (timestamp (truncate
138 (* 1000
139 (- (float-time)
140 (or xt-mouse-epoch
141 (setq xt-mouse-epoch (float-time)))))))
132 (mouse (intern 142 (mouse (intern
133 ;; For buttons > 3, the release-event looks 143 ;; For buttons > 3, the release-event looks
134 ;; differently (see xc/programs/xterm/button.c, 144 ;; differently (see xc/programs/xterm/button.c,
135 ;; function EditorButton), and there seems to come in 145 ;; function EditorButton), and there seems to come in
136 ;; a release-event only, no down-event. 146 ;; a release-event only, no down-event.
137 (cond ((>= type 64) 147 (cond ((>= type 64)
138 (format "mouse-%d" (- type 60))) 148 (format "mouse-%d" (- type 60)))
149 ((memq type '(8 9 10))
150 (setq xterm-mouse-last type)
151 (format "M-down-mouse-%d" (- type 7)))
152 ((= type 11)
153 (format "mouse-%d" (- xterm-mouse-last 7)))
139 ((= type 3) 154 ((= type 3)
140 (format "mouse-%d" (+ 1 xterm-mouse-last))) 155 (format "mouse-%d" (+ 1 xterm-mouse-last)))
141 (t 156 (t
142 (setq xterm-mouse-last type) 157 (setq xterm-mouse-last type)
143 (format "down-mouse-%d" (+ 1 type)))))) 158 (format "down-mouse-%d" (+ 1 type))))))
148 163
149 (set-terminal-parameter nil 'xterm-mouse-x x) 164 (set-terminal-parameter nil 'xterm-mouse-x x)
150 (set-terminal-parameter nil 'xterm-mouse-y y) 165 (set-terminal-parameter nil 'xterm-mouse-y y)
151 (setq 166 (setq
152 last-input-event 167 last-input-event
153 (if w 168 (list mouse
154 (list mouse (posn-at-x-y (- x left) (- y top) w t)) 169 (let ((event (if w
155 (list mouse 170 (posn-at-x-y (- x left) (- y top) w t)
156 (append (list nil 'menu-bar) (nthcdr 2 (posn-at-x-y x y w t)))))))) 171 (append (list nil 'menu-bar)
172 (nthcdr 2 (posn-at-x-y x y))))))
173 (setcar (nthcdr 3 event) timestamp)
174 event)))))
157 175
158 ;;;###autoload 176 ;;;###autoload
159 (define-minor-mode xterm-mouse-mode 177 (define-minor-mode xterm-mouse-mode
160 "Toggle XTerm mouse mode. 178 "Toggle XTerm mouse mode.
161 With prefix arg, turn XTerm mouse mode on iff arg is positive. 179 With prefix arg, turn XTerm mouse mode on iff arg is positive.