(defun mouse--down-1-maybe-follows-link (&optional _prompt)
"Turn `mouse-1' events into `mouse-2' events if follows-link.
Expects to be bound to `down-mouse-1' in `key-translation-map'."
- (if (or (null mouse-1-click-follows-link)
- (not (eq (if (eq mouse-1-click-follows-link 'double)
- 'double-down-mouse-1 'down-mouse-1)
- (car-safe last-input-event)))
- (not (mouse-on-link-p (event-start last-input-event)))
- (and (not mouse-1-click-in-non-selected-windows)
- (not (eq (selected-window)
- (posn-window (event-start last-input-event))))))
- nil
+ (when (and mouse-1-click-follows-link
+ (eq (if (eq mouse-1-click-follows-link 'double)
+ 'double-down-mouse-1 'down-mouse-1)
+ (car-safe last-input-event))
+ (mouse-on-link-p (event-start last-input-event))
+ (or mouse-1-click-in-non-selected-windows
+ (eq (selected-window)
+ (posn-window (event-start last-input-event)))))
(let ((this-event last-input-event)
(timedout
(sit-for (if (numberp mouse-1-click-follows-link)
'double-mouse-1 'mouse-1))
;; Turn the mouse-1 into a mouse-2 to follow links.
(let ((newup (if (eq mouse-1-click-follows-link 'double)
- 'double-mouse-2 'mouse-2))
- (newdown (if (eq mouse-1-click-follows-link 'double)
- 'double-down-mouse-2 'down-mouse-2)))
+ 'double-mouse-2 'mouse-2)))
;; If mouse-2 has never been done by the user, it doesn't have
;; the necessary property to be interpreted correctly.
- (put newup 'event-kind (get (car event) 'event-kind))
- (put newdown 'event-kind (get (car this-event) 'event-kind))
+ (unless (get newup 'event-kind)
+ (put newup 'event-kind (get (car event) 'event-kind)))
(push (cons newup (cdr event)) unread-command-events)
- ;; Modify the event in place, so read-key-sequence doesn't
- ;; generate a second fake prefix key (see fake_prefixed_keys in
- ;; src/keyboard.c).
- (setcar this-event newdown)
- (vector this-event))
+ ;; Don't change the down event, only the up-event (bug#18212).
+ nil)
(push event unread-command-events)
nil))))))
(or (eq frame oframe)
(set-mouse-position (selected-frame) (1- (frame-width)) 0))))
-(defun mouse-tear-off-window (click)
- "Delete the window clicked on, and create a new frame displaying its buffer."
+(define-obsolete-function-alias 'mouse-tear-off-window 'tear-off-window "24.4")
+(defun tear-off-window (click)
+ "Delete the selected window, and create a new frame displaying its buffer."
(interactive "e")
(mouse-minibuffer-check click)
(let* ((window (posn-window (event-start click)))
(buf (window-buffer window))
- (frame (make-frame)))
+ (frame (make-frame))) ;FIXME: Use pop-to-buffer.
(select-frame frame)
(switch-to-buffer buf)
(delete-window window)))
;; Check whether header-line can be dragged at all.
(if (window-at-side-p window 'top)
(setq draggable nil)
- (setq height (/ (window-header-line-height window) 2))
+ ;; window-pixel-edges includes the header and mode lines, so
+ ;; we need to account for that when calculating window growth.
+ ;; On GUI frames, assume the mouse is approximately in the
+ ;; middle of the header/mode line, so we need only half the
+ ;; height in pixels.
+ (setq height
+ (cond
+ ((display-graphic-p frame)
+ (/ (window-header-line-height window) 2))
+ (t (window-header-line-height window))))
(setq window (window-in-direction 'above window t))))
((eq line 'mode)
;; Check whether mode-line can be dragged at all.
(eq minibuffer-window
(active-minibuffer-window))))))
(setq draggable nil)
- (setq height (/ (window-mode-line-height window) 2))))
+ (setq height
+ (cond
+ ((display-graphic-p frame)
+ (/ (window-mode-line-height window) 2))
+ (t (window-mode-line-height window))))))
((eq line 'vertical)
;; Get the window to adjust for the vertical case. If the scroll
;; bar is on the window's right or we drag a vertical divider,
(let (select-active-regions)
(deactivate-mark)))
(or mouse-yank-at-point (mouse-set-point click))
- (let ((primary
- (if (fboundp 'x-get-selection-value)
- (if (eq (framep (selected-frame)) 'w32)
- ;; MS-Windows emulates PRIMARY in x-get-selection, but not
- ;; in x-get-selection-value (the latter only accesses the
- ;; clipboard). So try PRIMARY first, in case they selected
- ;; something with the mouse in the current Emacs session.
- (or (x-get-selection 'PRIMARY)
- (x-get-selection-value))
- ;; Else MS-DOS or X.
- ;; On X, x-get-selection-value supports more formats and
- ;; encodings, so use it in preference to x-get-selection.
- (or (x-get-selection-value)
- (x-get-selection 'PRIMARY)))
- ;; FIXME: What about xterm-mouse-mode etc.?
- (x-get-selection 'PRIMARY))))
- (unless primary
- (error "No selection is available"))
+ (let ((primary (gui-get-primary-selection)))
(push-mark (point))
(insert-for-yank primary)))
(if (numberp (posn-point posn))
(setq beg (posn-point posn)))
(move-overlay mouse-secondary-overlay beg (posn-point end))
- (x-set-selection
+ (gui-set-selection
'SECONDARY
(buffer-substring (overlay-start mouse-secondary-overlay)
(overlay-end mouse-secondary-overlay))))))
(if (marker-position mouse-secondary-start)
(save-window-excursion
(delete-overlay mouse-secondary-overlay)
- (x-set-selection 'SECONDARY nil)
+ (gui-set-selection 'SECONDARY nil)
(select-window start-window)
(save-excursion
(goto-char mouse-secondary-start)
(sit-for 1)
nil))
- (x-set-selection
+ (gui-set-selection
'SECONDARY
(buffer-substring (overlay-start mouse-secondary-overlay)
(overlay-end mouse-secondary-overlay)))))))))
(setq str (buffer-substring (overlay-start mouse-secondary-overlay)
(overlay-end mouse-secondary-overlay)))
(> (length str) 0)
- (x-set-selection 'SECONDARY str))))
+ (gui-set-selection 'SECONDARY str))))
\f
(defcustom mouse-buffer-menu-maxlen 20