summaryrefslogtreecommitdiff
path: root/lisp/frame.el
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2008-09-13 08:28:04 +0000
committerMartin Rudalics <rudalics@gmx.at>2008-09-13 08:28:04 +0000
commitb0c7121cabe1cc5f4df12c3acd4354d4a5c5f042 (patch)
tree52cbccf460bd3be9b1e75a771072a8f3293f8aea /lisp/frame.el
parentda643190850a27485d88dd59a19ca6eaf881ef7b (diff)
downloademacs-b0c7121cabe1cc5f4df12c3acd4354d4a5c5f042.tar.gz
(select-frame-set-input-focus): With focus follows
mouse move mouse cursor to right window.
Diffstat (limited to 'lisp/frame.el')
-rw-r--r--lisp/frame.el24
1 files changed, 17 insertions, 7 deletions
diff --git a/lisp/frame.el b/lisp/frame.el
index 5454ac8f58c..8acafa9c690 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -842,13 +842,23 @@ the user during startup."
(defun select-frame-set-input-focus (frame)
"Select FRAME, raise it, and set input focus, if possible."
- (select-frame frame)
- (raise-frame frame)
- ;; Ensure, if possible, that frame gets input focus.
- (when (memq (window-system frame) '(x w32 ns))
- (x-focus-frame frame))
- (when focus-follows-mouse
- (set-mouse-position (selected-frame) (1- (frame-width)) 0)))
+ (select-frame frame)
+ (raise-frame frame)
+ ;; Ensure, if possible, that frame gets input focus.
+ (when (memq (window-system frame) '(x w32 ns))
+ (x-focus-frame frame))
+ (when focus-follows-mouse
+ ;; When the mouse cursor is not in FRAME's selected window move it
+ ;; there to avoid that some other window gets selected when focus
+ ;; follows mouse.
+ (condition-case nil
+ (let ((window (frame-selected-window frame))
+ (coordinates (cdr-safe (mouse-position))))
+ (unless (and (car-safe coordinates)
+ (coordinates-in-window-p coordinates window))
+ (let ((edges (window-inside-edges (frame-selected-window frame))))
+ (set-mouse-position frame (nth 2 edges) (nth 1 edges)))))
+ (error nil))))
(defun other-frame (arg)
"Select the ARGth different visible frame on current display, and raise it.