diff options
| author | Jim Blandy | 1993-07-02 23:05:25 +0000 |
|---|---|---|
| committer | Jim Blandy | 1993-07-02 23:05:25 +0000 |
| commit | b846d0394aac294fe89900e5203313bdb9be47df (patch) | |
| tree | d9a035a983b56a8070dbd23383a5cb432f14ba1b | |
| parent | d7b4e137caa5ee452021e8d49ea88489e1b7f5dd (diff) | |
| download | emacs-b846d0394aac294fe89900e5203313bdb9be47df.tar.gz emacs-b846d0394aac294fe89900e5203313bdb9be47df.zip | |
* mouse.el (mouse-drag-region): Correctly handle drags which enter
other frames.
| -rw-r--r-- | lisp/mouse.el | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el index 100860f9fbe..592d2b79458 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -161,6 +161,7 @@ This must be bound to a button-down mouse event." | |||
| 161 | (let* ((start-posn (event-start start-event)) | 161 | (let* ((start-posn (event-start start-event)) |
| 162 | (start-point (posn-point start-posn)) | 162 | (start-point (posn-point start-posn)) |
| 163 | (start-window (posn-window start-posn)) | 163 | (start-window (posn-window start-posn)) |
| 164 | (start-frame (window-frame start-window)) | ||
| 164 | (bounds (window-edges start-window)) | 165 | (bounds (window-edges start-window)) |
| 165 | (top (nth 1 bounds)) | 166 | (top (nth 1 bounds)) |
| 166 | (bottom (if (window-minibuffer-p start-window) | 167 | (bottom (if (window-minibuffer-p start-window) |
| @@ -176,30 +177,45 @@ This must be bound to a button-down mouse event." | |||
| 176 | (let (event end end-point) | 177 | (let (event end end-point) |
| 177 | (track-mouse | 178 | (track-mouse |
| 178 | (while (progn | 179 | (while (progn |
| 179 | (setq event (read-event) | 180 | (setq event (read-event)) |
| 180 | end (event-end event) | 181 | (or (mouse-movement-p event) |
| 181 | end-point (posn-point end)) | 182 | (eq (car-safe event) 'switch-frame))) |
| 182 | (mouse-movement-p event)) | 183 | |
| 183 | ;; Is the mouse anywhere reasonable on the frame? | 184 | (if (eq (car-safe event) 'switch-frame) |
| 184 | (if (windowp (posn-window end)) | 185 | nil |
| 185 | ;; If the mouse is outside the current window, scroll it. | 186 | (setq end (event-end event) |
| 186 | (if (or (not (eq (posn-window end) start-window)) | 187 | end-point (posn-point end)) |
| 187 | (not (integer-or-marker-p end-point))) | 188 | |
| 188 | ;; Which direction should we scroll the window? | 189 | (cond |
| 189 | (let ((mouse-row | 190 | |
| 190 | (+ (nth 1 (window-edges (posn-window end))) | 191 | ;; Ignore switch-frame events. |
| 191 | (cdr (posn-col-row end))))) | 192 | ((eq (car-safe event) 'switch-frame)) |
| 192 | (cond | 193 | |
| 193 | ((< mouse-row top) | 194 | ;; Are we moving within the original window? |
| 194 | (mouse-scroll-subr | 195 | ((and (eq (posn-window end) start-window) |
| 195 | (- mouse-row top) mouse-drag-overlay start-point)) | 196 | (integer-or-marker-p end-point)) |
| 196 | ((and (not (eobp)) | 197 | (goto-char end-point) |
| 197 | (>= mouse-row bottom)) | 198 | (move-overlay mouse-drag-overlay |
| 198 | (mouse-scroll-subr (1+ (- mouse-row bottom)) | 199 | start-point (point))) |
| 199 | mouse-drag-overlay start-point)))) | 200 | |
| 200 | (goto-char end-point) | 201 | ;; Are we moving on a different window on the same frame? |
| 201 | (move-overlay mouse-drag-overlay | 202 | ((and (windowp (posn-window end)) |
| 202 | start-point (point)))))) | 203 | (eq (window-frame (posn-window end)) start-frame)) |
| 204 | (let ((mouse-row | ||
| 205 | (+ (nth 1 (window-edges (posn-window end))) | ||
| 206 | (cdr (posn-col-row end))))) | ||
| 207 | (cond | ||
| 208 | ((< mouse-row top) | ||
| 209 | (mouse-scroll-subr | ||
| 210 | (- mouse-row top) mouse-drag-overlay start-point)) | ||
| 211 | ((and (not (eobp)) | ||
| 212 | (>= mouse-row bottom)) | ||
| 213 | (mouse-scroll-subr (1+ (- mouse-row bottom)) | ||
| 214 | mouse-drag-overlay start-point))))) | ||
| 215 | |||
| 216 | ;; Otherwise, we have no idea where the mouse is. | ||
| 217 | (t))))) | ||
| 218 | |||
| 203 | (if (and (eq (get (event-basic-type event) 'event-kind) 'mouse-click) | 219 | (if (and (eq (get (event-basic-type event) 'event-kind) 'mouse-click) |
| 204 | (eq (posn-window (event-end event)) start-window) | 220 | (eq (posn-window (event-end event)) start-window) |
| 205 | (numberp (posn-point (event-end event)))) | 221 | (numberp (posn-point (event-end event)))) |