aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/mouse.el71
2 files changed, 53 insertions, 24 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e249b4ab759..c23079e1839 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12012-07-26 Martin Rudalics <rudalics@gmx.at>
2
3 * mouse.el (popup-menu): Fix doc-string and re-indent code.
4 (mouse-drag-line): Don't exit tracking when a switch-frame or
5 switch-window event occurs (Bug#12006).
6
12012-07-26 Stefan Monnier <monnier@iro.umontreal.ca> 72012-07-26 Stefan Monnier <monnier@iro.umontreal.ca>
2 8
3 * mouse.el (popup-menu): Fix last change. 9 * mouse.el (popup-menu): Fix last change.
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 07277a409ae..71336c08ee3 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -101,9 +101,11 @@ point at the click position."
101 "Popup the given menu and call the selected option. 101 "Popup the given menu and call the selected option.
102MENU can be a keymap, an easymenu-style menu or a list of keymaps as for 102MENU can be a keymap, an easymenu-style menu or a list of keymaps as for
103`x-popup-menu'. 103`x-popup-menu'.
104POSITION can be a click event or ((XOFFSET YOFFSET) WINDOW) and defaults to 104
105 the current mouse position. If POSITION is a symbol, `point' the current point 105POSITION can be a click event or ((XOFFSET YOFFSET) WINDOW) and
106position is used. 106defaults to the current mouse position. If POSITION is the
107symbol `point', the current point position is used.
108
107PREFIX is the prefix argument (if any) to pass to the command." 109PREFIX is the prefix argument (if any) to pass to the command."
108 (let* ((map (cond 110 (let* ((map (cond
109 ((keymapp menu) menu) 111 ((keymapp menu) menu)
@@ -113,17 +115,17 @@ PREFIX is the prefix argument (if any) to pass to the command."
113 (plist-get (get map 'menu-prop) :filter)))) 115 (plist-get (get map 'menu-prop) :filter))))
114 (if filter (funcall filter (symbol-function map)) map))))) 116 (if filter (funcall filter (symbol-function map)) map)))))
115 event cmd) 117 event cmd)
116 (setq position 118 (setq position
117 (cond 119 (cond
118 ((eq position 'point) 120 ((eq position 'point)
119 (let* ((pp (posn-at-point)) 121 (let* ((pp (posn-at-point))
120 (xy (posn-x-y pp))) 122 (xy (posn-x-y pp)))
121 (list (list (car xy) (cdr xy)) (posn-window pp)))) 123 (list (list (car xy) (cdr xy)) (posn-window pp))))
122 ((not position) 124 ((not position)
123 (let ((mp (mouse-pixel-position))) 125 (let ((mp (mouse-pixel-position)))
124 (list (list (cadr mp) (cddr mp)) (car mp)))) 126 (list (list (cadr mp) (cddr mp)) (car mp))))
125 (t 127 (t
126 position))) 128 position)))
127 ;; The looping behavior was taken from lmenu's popup-menu-popup 129 ;; The looping behavior was taken from lmenu's popup-menu-popup
128 (while (and map (setq event 130 (while (and map (setq event
129 ;; map could be a prefix key, in which case 131 ;; map could be a prefix key, in which case
@@ -141,7 +143,7 @@ PREFIX is the prefix argument (if any) to pass to the command."
141 binding) 143 binding)
142 (while (and map (null binding)) 144 (while (and map (null binding))
143 (setq binding (lookup-key (car map) mouse-click)) 145 (setq binding (lookup-key (car map) mouse-click))
144 (if (numberp binding) ; `too long' 146 (if (numberp binding) ; `too long'
145 (setq binding nil)) 147 (setq binding nil))
146 (setq map (cdr map))) 148 (setq map (cdr map)))
147 binding) 149 binding)
@@ -447,17 +449,39 @@ must be one of the symbols `header', `mode', or `vertical'."
447 449
448 ;; Start tracking. 450 ;; Start tracking.
449 (track-mouse 451 (track-mouse
450 ;; Loop reading events and sampling the position of the mouse, 452 ;; Loop reading events and sampling the position of the mouse.
451 ;; until there is a non-mouse-movement event. Also, 453 (while draggable
452 ;; scroll-bar-movement events are the same as mouse movement for 454 (setq event (read-event))
453 ;; our purposes. (Why? -- cyd)
454 (while (progn
455 (setq event (read-event))
456 (memq (car-safe event) '(mouse-movement scroll-bar-movement)))
457 (setq position (mouse-position)) 455 (setq position (mouse-position))
456 ;; Do nothing if
457 ;; - there is a switch-frame event.
458 ;; - the mouse isn't in the frame that we started in
459 ;; - the mouse isn't in any Emacs frame
460 ;; Drag if
461 ;; - there is a mouse-movement event
462 ;; - there is a scroll-bar-movement event (Why? -- cyd)
463 ;; (same as mouse movement for our purposes)
464 ;; Quit if
465 ;; - there is a keyboard event or some other unknown event.
458 (cond 466 (cond
467 ((not (consp event))
468 (setq draggable nil))
469 ((memq (car event) '(switch-frame select-window))
470 nil)
471 ((not (memq (car event) '(mouse-movement scroll-bar-movement)))
472 (when (consp event)
473 ;; Do not unread a drag-mouse-1 event to avoid selecting
474 ;; some other window. For vertical line dragging do not
475 ;; unread mouse-1 events either (but only if we dragged at
476 ;; least once to allow mouse-1 clicks get through.
477 (unless (and dragged
478 (if (eq line 'vertical)
479 (memq (car event) '(drag-mouse-1 mouse-1))
480 (eq (car event) 'drag-mouse-1)))
481 (push event unread-command-events)))
482 (setq draggable nil))
459 ((or (not (eq (car position) frame)) 483 ((or (not (eq (car position) frame))
460 (null (cadr position))) 484 (null (car (cdr position))))
461 nil) 485 nil)
462 ((eq line 'vertical) 486 ((eq line 'vertical)
463 ;; Drag vertical divider. 487 ;; Drag vertical divider.
@@ -489,7 +513,6 @@ must be one of the symbols `header', `mode', or `vertical'."
489 (setcar event 'mouse-2)) 513 (setcar event 'mouse-2))
490 (push event unread-command-events))) 514 (push event unread-command-events)))
491 515
492
493(defun mouse-drag-mode-line (start-event) 516(defun mouse-drag-mode-line (start-event)
494 "Change the height of a window by dragging on the mode line." 517 "Change the height of a window by dragging on the mode line."
495 (interactive "e") 518 (interactive "e")