Function: mouse-copy-work-around-drag-bug
mouse-copy-work-around-drag-bug is a byte-compiled function defined in
mouse-copy.el.gz.
Signature
(mouse-copy-work-around-drag-bug START-EVENT END-EVENT)
Documentation
Code to work around a bug in post-19.29 Emacs: it drops mouse-drag events.
The problem occurs under XFree86-3.1.1 (X11R6pl11) but not under X11R5, and under post-19.29 but not early versions of Emacs.
19.29 and 19.30 seems to drop mouse drag events
sometimes. (Reproducible under XFree86-3.1.1 (X11R6pl11) and
XFree86-3.1.2 under Linux 1.2.x. Doesn't occur under X11R5 and SunOS
4.1.1.)
To see if you have the problem: Disable this routine (with (setq mouse-copy-have-drag-bug nil)). Click and drag for a while. If highlighting stops tracking, you have the bug. If you have the bug (or the real fix :-), please let me know.
Source Code
;; Defined in /usr/src/emacs/lisp/mouse-copy.el.gz
(defun mouse-copy-work-around-drag-bug (start-event end-event)
"Code to work around a bug in post-19.29 Emacs: it drops mouse-drag events.
The problem occurs under XFree86-3.1.1 (X11R6pl11) but not under X11R5,
and under post-19.29 but not early versions of Emacs.
19.29 and 19.30 seems to drop mouse drag events
sometimes. (Reproducible under XFree86-3.1.1 (X11R6pl11) and
XFree86-3.1.2 under Linux 1.2.x. Doesn't occur under X11R5 and SunOS
4.1.1.)
To see if you have the problem:
Disable this routine (with (setq mouse-copy-have-drag-bug nil)).
Click and drag for a while.
If highlighting stops tracking, you have the bug.
If you have the bug (or the real fix :-), please let me know."
;; To work-around, call mouse-set-secondary with a fake
;; drag event to set the overlay,
;; the load the x-selection.
(save-excursion
(let*
((start-posn (event-start start-event))
(end-posn (event-end end-event))
(end-buffer (window-buffer (posn-window end-posn)))
;; First, figure out the region (left as point/mark).
(range (progn
(set-buffer end-buffer)
(mouse-start-end (posn-point start-posn)
(posn-point end-posn)
(1- (event-click-count start-event)))))
(beg (car range))
(end (car (cdr range))))
;; Second, set the overlay.
(if mouse-secondary-overlay
(move-overlay mouse-secondary-overlay beg end)
(setq mouse-secondary-overlay (make-overlay beg (posn-point end))))
(overlay-put mouse-secondary-overlay 'face 'secondary-selection)
;; Third, set the selection.
;; (setq me-beg beg me-end end me-range range) ; for debugging
(set-buffer end-buffer)
(gui-set-selection 'SECONDARY (buffer-substring beg end)))))