diff options
| author | Gerd Moellmann | 2000-10-06 11:43:39 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-10-06 11:43:39 +0000 |
| commit | ee0e2bddb8e9d5daaef824a93123a6ea29747e46 (patch) | |
| tree | 8695e9904f479d34861566e94245fe751de35c45 | |
| parent | 65d425aca59cacf22b7fd11fc7c911892cedeff3 (diff) | |
| download | emacs-ee0e2bddb8e9d5daaef824a93123a6ea29747e46.tar.gz emacs-ee0e2bddb8e9d5daaef824a93123a6ea29747e46.zip | |
(mouse-drag-header-line): Don't allow window resizing
by dragging a header-line at the top of the frame because that
looks odd.
(mouse-drag-mode-line-1): Use event-* and posn-* functions
instead of treating the event as a list. Some cleanup.
| -rw-r--r-- | lisp/mouse.el | 72 |
1 files changed, 45 insertions, 27 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el index 90b9a572aeb..f4f35d90673 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -308,22 +308,22 @@ START-EVENT is the starting mouse-event of the drag action. | |||
| 308 | MODE-LINE-P non-nil means a mode line is dragged." | 308 | MODE-LINE-P non-nil means a mode line is dragged." |
| 309 | ;; Give temporary modes such as isearch a chance to turn off. | 309 | ;; Give temporary modes such as isearch a chance to turn off. |
| 310 | (run-hooks 'mouse-leave-buffer-hook) | 310 | (run-hooks 'mouse-leave-buffer-hook) |
| 311 | (let ((done nil) | 311 | (let* ((done nil) |
| 312 | (echo-keystrokes 0) | 312 | (echo-keystrokes 0) |
| 313 | (start-event-frame (window-frame (car (car (cdr start-event))))) | 313 | (start (event-start start-event)) |
| 314 | (start-event-window (car (car (cdr start-event)))) | 314 | (start-event-window (posn-window start)) |
| 315 | (start-nwindows (count-windows t)) | 315 | (start-event-frame (window-frame start-event-window)) |
| 316 | (old-selected-window (selected-window)) | 316 | (start-nwindows (count-windows t)) |
| 317 | should-enlarge-minibuffer | 317 | (old-selected-window (selected-window)) |
| 318 | event mouse minibuffer y top bot edges wconfig params growth) | 318 | (minibuffer (frame-parameter nil 'minibuffer)) |
| 319 | (setq params (frame-parameters)) | 319 | should-enlarge-minibuffer event mouse y top bot edges wconfig growth) |
| 320 | (setq minibuffer (cdr (assq 'minibuffer params))) | ||
| 321 | (track-mouse | 320 | (track-mouse |
| 322 | (progn | 321 | (progn |
| 323 | ;; enlarge-window only works on the selected window, so | 322 | ;; enlarge-window only works on the selected window, so |
| 324 | ;; we must select the window where the start event originated. | 323 | ;; we must select the window where the start event originated. |
| 325 | ;; unwind-protect will restore the old selected window later. | 324 | ;; unwind-protect will restore the old selected window later. |
| 326 | (select-window start-event-window) | 325 | (select-window start-event-window) |
| 326 | |||
| 327 | ;; if this is the bottommost ordinary window, then to | 327 | ;; if this is the bottommost ordinary window, then to |
| 328 | ;; move its modeline the minibuffer must be enlarged. | 328 | ;; move its modeline the minibuffer must be enlarged. |
| 329 | (setq should-enlarge-minibuffer | 329 | (setq should-enlarge-minibuffer |
| @@ -332,11 +332,13 @@ MODE-LINE-P non-nil means a mode line is dragged." | |||
| 332 | (not (one-window-p t)) | 332 | (not (one-window-p t)) |
| 333 | (= (nth 1 (window-edges minibuffer)) | 333 | (= (nth 1 (window-edges minibuffer)) |
| 334 | (nth 3 (window-edges))))) | 334 | (nth 3 (window-edges))))) |
| 335 | |||
| 335 | ;; loop reading events and sampling the position of | 336 | ;; loop reading events and sampling the position of |
| 336 | ;; the mouse. | 337 | ;; the mouse. |
| 337 | (while (not done) | 338 | (while (not done) |
| 338 | (setq event (read-event) | 339 | (setq event (read-event) |
| 339 | mouse (mouse-position)) | 340 | mouse (mouse-position)) |
| 341 | |||
| 340 | ;; do nothing if | 342 | ;; do nothing if |
| 341 | ;; - there is a switch-frame event. | 343 | ;; - there is a switch-frame event. |
| 342 | ;; - the mouse isn't in the frame that we started in | 344 | ;; - the mouse isn't in the frame that we started in |
| @@ -350,18 +352,21 @@ MODE-LINE-P non-nil means a mode line is dragged." | |||
| 350 | ;; unknown event. | 352 | ;; unknown event. |
| 351 | (cond ((integerp event) | 353 | (cond ((integerp event) |
| 352 | (setq done t)) | 354 | (setq done t)) |
| 355 | |||
| 353 | ((eq (car event) 'switch-frame) | 356 | ((eq (car event) 'switch-frame) |
| 354 | nil) | 357 | nil) |
| 355 | ((not (memq (car event) | 358 | |
| 356 | '(mouse-movement scroll-bar-movement))) | 359 | ((not (memq (car event) '(mouse-movement scroll-bar-movement))) |
| 357 | (if (consp event) | 360 | (when (consp event) |
| 358 | (setq unread-command-events | 361 | (push event unread-command-events)) |
| 359 | (cons event unread-command-events))) | ||
| 360 | (setq done t)) | 362 | (setq done t)) |
| 363 | |||
| 361 | ((not (eq (car mouse) start-event-frame)) | 364 | ((not (eq (car mouse) start-event-frame)) |
| 362 | nil) | 365 | nil) |
| 366 | |||
| 363 | ((null (car (cdr mouse))) | 367 | ((null (car (cdr mouse))) |
| 364 | nil) | 368 | nil) |
| 369 | |||
| 365 | (t | 370 | (t |
| 366 | (setq y (cdr (cdr mouse)) | 371 | (setq y (cdr (cdr mouse)) |
| 367 | edges (window-edges) | 372 | edges (window-edges) |
| @@ -382,10 +387,10 @@ MODE-LINE-P non-nil means a mode line is dragged." | |||
| 382 | (setq wconfig (current-window-configuration)) | 387 | (setq wconfig (current-window-configuration)) |
| 383 | 388 | ||
| 384 | ;; Check for an error case. | 389 | ;; Check for an error case. |
| 385 | (if (and (/= growth 0) | 390 | (when (and (/= growth 0) |
| 386 | (not minibuffer) | 391 | (not minibuffer) |
| 387 | (one-window-p t)) | 392 | (one-window-p t)) |
| 388 | (error "Attempt to resize sole window")) | 393 | (error "Attempt to resize sole window")) |
| 389 | 394 | ||
| 390 | ;; grow/shrink minibuffer? | 395 | ;; grow/shrink minibuffer? |
| 391 | (if should-enlarge-minibuffer | 396 | (if should-enlarge-minibuffer |
| @@ -405,7 +410,7 @@ MODE-LINE-P non-nil means a mode line is dragged." | |||
| 405 | (enlarge-window (- growth)) | 410 | (enlarge-window (- growth)) |
| 406 | (select-window start-event-window)) | 411 | (select-window start-event-window)) |
| 407 | ;; no. grow/shrink the selected window | 412 | ;; no. grow/shrink the selected window |
| 408 | ;; (message "growth = %d" growth) | 413 | ;(message "growth = %d" growth) |
| 409 | (enlarge-window growth)) | 414 | (enlarge-window growth)) |
| 410 | 415 | ||
| 411 | ;; if this window's growth caused another | 416 | ;; if this window's growth caused another |
| @@ -418,11 +423,11 @@ MODE-LINE-P non-nil means a mode line is dragged." | |||
| 418 | ;; the minibuffer. minibuffer size changes | 423 | ;; the minibuffer. minibuffer size changes |
| 419 | ;; can cause all windows to shrink... no way | 424 | ;; can cause all windows to shrink... no way |
| 420 | ;; around it. | 425 | ;; around it. |
| 421 | (if (or (/= start-nwindows (count-windows t)) | 426 | (when (or (/= start-nwindows (count-windows t)) |
| 422 | (and (not should-enlarge-minibuffer) | 427 | (and (not should-enlarge-minibuffer) |
| 423 | mode-line-p | 428 | mode-line-p |
| 424 | (/= top (nth 1 (window-edges))))) | 429 | (/= top (nth 1 (window-edges))))) |
| 425 | (set-window-configuration wconfig))))))))) | 430 | (set-window-configuration wconfig))))))))) |
| 426 | 431 | ||
| 427 | (defun mouse-drag-mode-line (start-event) | 432 | (defun mouse-drag-mode-line (start-event) |
| 428 | "Change the height of a window by dragging on the mode line." | 433 | "Change the height of a window by dragging on the mode line." |
| @@ -430,9 +435,22 @@ MODE-LINE-P non-nil means a mode line is dragged." | |||
| 430 | (mouse-drag-mode-line-1 start-event t)) | 435 | (mouse-drag-mode-line-1 start-event t)) |
| 431 | 436 | ||
| 432 | (defun mouse-drag-header-line (start-event) | 437 | (defun mouse-drag-header-line (start-event) |
| 433 | "Change the height of a window by dragging on the header line." | 438 | "Change the height of a window by dragging on the header line. |
| 439 | Windows whose header-lines are at the top of the frame cannot be | ||
| 440 | resized by dragging their header-line." | ||
| 434 | (interactive "e") | 441 | (interactive "e") |
| 435 | (mouse-drag-mode-line-1 start-event nil)) | 442 | ;; Changing the window's size by dragging its header-line when the |
| 443 | ;; header-line is at the top of the frame is somewhat strange, | ||
| 444 | ;; because the header-line doesn't move, so don't do it. | ||
| 445 | (let* ((start (event-start start-event)) | ||
| 446 | (window (posn-window start)) | ||
| 447 | (frame (window-frame window)) | ||
| 448 | (first-window (frame-first-window frame))) | ||
| 449 | (when (or (eq window first-window) | ||
| 450 | (= (nth 1 (window-edges window)) | ||
| 451 | (nth 1 (window-edges first-window)))) | ||
| 452 | (error "Cannot move header-line at the top of the frame")) | ||
| 453 | (mouse-drag-mode-line-1 start-event nil))) | ||
| 436 | 454 | ||
| 437 | 455 | ||
| 438 | (defun mouse-drag-vertical-line (start-event) | 456 | (defun mouse-drag-vertical-line (start-event) |