(xterm-mouse-event): Compute a timestamp using
[bpt/emacs.git] / lisp / xt-mouse.el
index 4f7e196..39333f7 100644 (file)
@@ -1,6 +1,7 @@
 ;;; xt-mouse.el --- support the mouse when emacs run in an xterm
 
-;; Copyright (C) 1994, 2000, 2001, 2005 Free Software Foundation
+;; Copyright (C) 1994, 2000, 2001, 2002, 2003,
+;;   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Keywords: mouse, terminals
@@ -19,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -38,9 +39,6 @@
 
 ;;; Todo:
 
-;; The xterm mouse escape codes are supposedly also supported by the
-;; Linux console, but I have not been able to verify this.
-
 ;; Support multi-click -- somehow.
 
 ;;; Code:
   (let* ((type (- (xterm-mouse-event-read) #o40))
         (x (- (xterm-mouse-event-read) #o40 1))
         (y (- (xterm-mouse-event-read) #o40 1))
+        (time (current-time))
+        (timestamp (+ ( * (nth 1 time) 1000 ) (/ (nth 2 time) 1000)))
         (mouse (intern
                 ;; For buttons > 3, the release-event looks
                 ;; differently (see xc/programs/xterm/button.c,
 
     (setq xterm-mouse-x x
          xterm-mouse-y y)
-    (if w
-       (list mouse (posn-at-x-y (- x left) (- y top) w t))
-      (list mouse
-           (append (list nil 'menu-bar) (nthcdr 2 (posn-at-x-y x y w t)))))))
+    (setq
+     last-input-event
+     (list mouse 
+          (let ((event (if w
+                           (posn-at-x-y (- x left) (- y top) w t)
+                         (append (list nil 'menu-bar)
+                                 (nthcdr 2 (posn-at-x-y x y w t))))))
+            (setcar (nthcdr 3 event) timestamp)
+            event)))))
 
 ;;;###autoload
 (define-minor-mode xterm-mouse-mode
 With prefix arg, turn XTerm mouse mode on iff arg is positive.
 
 Turn it on to use Emacs mouse commands, and off to use xterm mouse commands.
-This works in terminal emulators compatible with xterm.  Only single clicks
-are supported.  When turned on, the normal xterm mouse functionality is still
-available by holding down the SHIFT key while pressing the mouse button."
-  nil " Mouse" nil :global t :group 'mouse
+This works in terminal emulators compatible with xterm.  It only
+works for simple uses of the mouse.  Basically, only non-modified
+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
   (if xterm-mouse-mode
       ;; Turn it on
       (unless window-system