summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2007-10-06 10:19:45 +0000
committerMartin Rudalics <rudalics@gmx.at>2007-10-06 10:19:45 +0000
commit1398509c21ea8ab4ec8be1a445355c0b281dd04e (patch)
tree2b208764363a1703b3d9fe0f0bae6f53ac7d75c2 /lisp
parent9bcf0f44a1bf2f691f338e5fc2d7c3ac3349e379 (diff)
downloademacs-1398509c21ea8ab4ec8be1a445355c0b281dd04e.tar.gz
(mouse-autoselect-window-cancel): Don't cancel for
select-window or select-frame events. (handle-select-window): When autoselecting window set input focus. Restructure.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/window.el67
2 files changed, 48 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 976caa10356..80d5f3f7e43 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
+2007-10-06 Martin Rudalics <rudalics@gmx.at>
+
+ * window.el (mouse-autoselect-window-cancel): Don't cancel for
+ select-window or select-frame events.
+ (handle-select-window): When autoselecting window set input
+ focus. Restructure.
+
+ * frame.el (focus-follows-mouse): Moved to frame.c.
+ * cus-start.el (all): Add focus-follows-mouse.
+
2007-10-05 Chris Moore <dooglus@gmail.com>
* server.el (server-kill-new-buffers): Doc fix.
diff --git a/lisp/window.el b/lisp/window.el
index 7a64588c076..dd402750de4 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -805,10 +805,13 @@ scrollbar interaction\) and `select' \(the next invocation of
"Cancel delayed window autoselection.
Optional argument FORCE means cancel unconditionally."
(unless (and (not force)
- ;; Don't cancel while the user drags a scroll bar.
- (eq this-command 'scroll-bar-toolkit-scroll)
- (memq (nth 4 (event-end last-input-event))
- '(handle end-scroll)))
+ ;; Don't cancel for select-window or select-frame events
+ ;; or when the user drags a scroll bar.
+ (or (memq this-command
+ '(handle-select-window handle-switch-frame))
+ (and (eq this-command 'scroll-bar-toolkit-scroll)
+ (memq (nth 4 (event-end last-input-event))
+ '(handle end-scroll)))))
(setq mouse-autoselect-window-state nil)
(when (timerp mouse-autoselect-window-timer)
(cancel-timer mouse-autoselect-window-timer))
@@ -896,33 +899,39 @@ active. This function is run by `mouse-autoselect-window-timer'."
"Handle select-window events."
(interactive "e")
(let ((window (posn-window (event-start event))))
- (when (and (window-live-p window)
- ;; Don't switch if we're currently in the minibuffer.
- ;; This tries to work around problems where the minibuffer gets
- ;; unselected unexpectedly, and where you then have to move
- ;; your mouse all the way down to the minibuffer to select it.
- (not (window-minibuffer-p (selected-window)))
- ;; Don't switch to a minibuffer window unless it's active.
- (or (not (window-minibuffer-p window))
- (minibuffer-window-active-p window)))
- (unless (and (numberp mouse-autoselect-window)
- (not (zerop mouse-autoselect-window))
- (not (eq mouse-autoselect-window-state 'select))
- (progn
- ;; Cancel any delayed autoselection.
- (mouse-autoselect-window-cancel t)
- ;; Start delayed autoselection from current mouse position
- ;; and window.
- (mouse-autoselect-window-start (mouse-position) window)
- ;; Executing a command cancels delayed autoselection.
- (add-hook
- 'pre-command-hook 'mouse-autoselect-window-cancel)))
+ (unless (or (not (window-live-p window))
+ ;; Don't switch if we're currently in the minibuffer.
+ ;; This tries to work around problems where the
+ ;; minibuffer gets unselected unexpectedly, and where
+ ;; you then have to move your mouse all the way down to
+ ;; the minibuffer to select it.
+ (window-minibuffer-p (selected-window))
+ ;; Don't switch to minibuffer window unless it's active.
+ (and (window-minibuffer-p window)
+ (not (minibuffer-window-active-p window)))
+ ;; Don't switch when autoselection shall be delayed.
+ (and (numberp mouse-autoselect-window)
+ (not (zerop mouse-autoselect-window))
+ (not (eq mouse-autoselect-window-state 'select))
+ (progn
+ ;; Cancel any delayed autoselection.
+ (mouse-autoselect-window-cancel t)
+ ;; Start delayed autoselection from current mouse position
+ ;; and window.
+ (mouse-autoselect-window-start (mouse-position) window)
+ ;; Executing a command cancels delayed autoselection.
+ (add-hook
+ 'pre-command-hook 'mouse-autoselect-window-cancel))))
+ (when mouse-autoselect-window
;; Reset state of delayed autoselection.
(setq mouse-autoselect-window-state nil)
- (when mouse-autoselect-window
- ;; Run `mouse-leave-buffer-hook' when autoselecting window.
- (run-hooks 'mouse-leave-buffer-hook))
- (select-window window)))))
+ ;; Set input focus to handle cross-frame movement. Bind
+ ;; `focus-follows-mouse' to avoid moving the mouse cursor.
+ (let (focus-follows-mouse)
+ (select-frame-set-input-focus (window-frame window)))
+ ;; Run `mouse-leave-buffer-hook' when autoselecting window.
+ (run-hooks 'mouse-leave-buffer-hook))
+ (select-window window))))
(define-key ctl-x-map "2" 'split-window-vertically)
(define-key ctl-x-map "3" 'split-window-horizontally)