From: Eli Zaretskii Date: Tue, 30 Jun 2015 15:59:21 +0000 (+0300) Subject: Don't block changes in mouse pointer inside 'track-mouse' X-Git-Tag: emacs-25.0.90~1603 X-Git-Url: https://code.delx.au/gnu-emacs/commitdiff_plain/edd09381c618125d8aa23c9414034fbeee176305 Don't block changes in mouse pointer inside 'track-mouse' * etc/NEWS: * doc/lispref/frames.texi (Mouse Tracking): Document the special effect of setting 'track-mouse' to 'dragging'. * lisp/textmodes/artist.el (artist-mouse-draw-continously): * lisp/ruler-mode.el (ruler-mode-mouse-drag-any-column-iteration): * lisp/mouse-drag.el (mouse-drag-throw): * lisp/mouse.el (mouse-drag-line): Set 'track-mouse' to 'dragging' to avoid changes in the shape of the mouse pointer. * src/xdisp.c (define_frame_cursor1): Don't change the mouse pointer shape when do_mouse_tracking has the value of 'dragging', not just any non-nil value. (Bug#20934) (syms_of_xdisp): DEFSYM 'dragging'. --- diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index ddf81f3e80..79b5172ae0 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -2018,6 +2018,19 @@ The value of @code{track-mouse} is that of the last form in @var{body}. You should design @var{body} to return when it sees the up-event that indicates the release of the button, or whatever kind of event means it is time to stop tracking. + +The @code{track-mouse} form causes Emacs to generate mouse motion +events by binding the variable @code{mouse-tracking} to a +non-@code{nil} value. If that variable has the special value +@code{dragging}, it additionally instructs the display engine to +refrain from changing the shape of the mouse pointer. This is +desirable in Lisp programs that require mouse dragging across large +portions of Emacs display, which might otherwise cause the mouse +pointer to change its shape according to the display portion it hovers +on (@pxref{Pointer Shape}). Therefore, Lisp programs that need the +mouse pointer to retain its original shape during dragging should bind +@code{track-mouse} to the value @code{dragging} at the beginning of +their @var{body}. @end defspec The usual purpose of tracking mouse motion is to indicate on the screen diff --git a/etc/NEWS b/etc/NEWS index 1f8cbbc1b9..389de167fc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -815,6 +815,15 @@ This means that you can't use `make-local-variable' and expect them to ** `inhibit-point-motion-hooks' now defaults to t and is obsolete. ++++ +** `track-mouse' no longer freezes the shape of the mouse pointer. +The `track-mouse' form no longer refrains from changing the shape of +the mouse pointer for the entire time the body of that form is +executed. Lisp programs that use `track-mouse' for dragging across +large portions of the Emacs display, and want to avoid changes in the +pointer shape during dragging, should bind the variable `track-mouse' +to the special value `dragging' in the body of the form. + ** The optional `predicate' argument of `lisp-complete-symbol' no longer has any effect. (This change was made in Emacs 24.4 but was not advertised at the time.) diff --git a/lisp/mouse-drag.el b/lisp/mouse-drag.el index 88838edaae..945c305db7 100644 --- a/lisp/mouse-drag.el +++ b/lisp/mouse-drag.el @@ -222,6 +222,8 @@ To test this function, evaluate: (col-scrolling-p (mouse-drag-should-do-col-scrolling))) (select-window start-window) (track-mouse + ;; Don't change the mouse pointer shape while we drag. + (setq track-mouse 'dragging) (while (progn (setq event (read-event) end (event-end event) diff --git a/lisp/mouse.el b/lisp/mouse.el index 7854d32eb2..9bb00cb105 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -468,8 +468,10 @@ must be one of the symbols `header', `mode', or `vertical'." (setq dragged t) (adjust-window-trailing-edge window growth nil t)) (setq last-position position)))))) - ;; Start tracking. - (setq track-mouse t) + ;; Start tracking. The special value 'dragging' signals the + ;; display engine to freeze the mouse pointer shape for as long + ;; as we drag. + (setq track-mouse 'dragging) ;; Loop reading events and sampling the position of the mouse. (setq exitfun (set-transient-map diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el index f0b012ed2f..4f68909ed4 100644 --- a/lisp/ruler-mode.el +++ b/lisp/ruler-mode.el @@ -437,6 +437,8 @@ the mouse has been clicked." (let ((drags 0) event) (track-mouse + ;; Signal the display engine to freeze the mouse pointer shape. + (setq track-mouse 'dragging) (while (mouse-movement-p (setq event (read-event))) (setq drags (1+ drags)) (when (eq window (posn-window (event-end event))) diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el index 14cf402a97..a29418e6f8 100644 --- a/lisp/textmodes/artist.el +++ b/lisp/textmodes/artist.el @@ -4965,6 +4965,9 @@ The event, EV, is the mouse event." (artist-no-rb-set-point1 x1 y1)) (unwind-protect (track-mouse + ;; We don't want flickering of mouse pointer shape while we + ;; drag the mouse. + (setq track-mouse 'dragging) (while (or (mouse-movement-p ev) (member 'down (event-modifiers ev))) (setq ev-start-pos (artist-coord-win-to-buf diff --git a/src/xdisp.c b/src/xdisp.c index 25eed01ecf..5bef44c6e5 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -29105,7 +29105,7 @@ static void define_frame_cursor1 (struct frame *f, Cursor cursor, Lisp_Object pointer) { /* Do not change cursor shape while dragging mouse. */ - if (!NILP (do_mouse_tracking)) + if (EQ (do_mouse_tracking, Qdragging)) return; if (!NILP (pointer)) @@ -30727,6 +30727,8 @@ They are still logged to the *Messages* buffer. */); DEFSYM (Qarrow, "arrow"); /* also Qtext */ + DEFSYM (Qdragging, "dragging"); + DEFSYM (Qinhibit_free_realized_faces, "inhibit-free-realized-faces"); list_of_error = list1 (list2 (Qerror, Qvoid_variable));