diff options
| author | Martin Rudalics | 2008-09-16 08:20:21 +0000 |
|---|---|---|
| committer | Martin Rudalics | 2008-09-16 08:20:21 +0000 |
| commit | bbca16d8d14cd70b45dffeea59a17033ed4df8b4 (patch) | |
| tree | 185ef830c2996ebd6f5dddc6c7f85248c017319d | |
| parent | 0cf1893f3416bd0ef448ac6529a9bec2073e9035 (diff) | |
| download | emacs-bbca16d8d14cd70b45dffeea59a17033ed4df8b4.tar.gz emacs-bbca16d8d14cd70b45dffeea59a17033ed4df8b4.zip | |
(select-frame-set-input-focus): With non-nil
mouse-autoselect-window always move mouse cursor to frame's
selected window. Otherwise restore pre 2008-09-13 behavior.
(select-frame-by-name): Use select-frame-set-input-focus.
| -rw-r--r-- | lisp/frame.el | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/lisp/frame.el b/lisp/frame.el index 8acafa9c690..cbf4c9f1372 100644 --- a/lisp/frame.el +++ b/lisp/frame.el | |||
| @@ -841,24 +841,26 @@ the user during startup." | |||
| 841 | (declare-function x-focus-frame "xfns.c" (frame)) | 841 | (declare-function x-focus-frame "xfns.c" (frame)) |
| 842 | 842 | ||
| 843 | (defun select-frame-set-input-focus (frame) | 843 | (defun select-frame-set-input-focus (frame) |
| 844 | "Select FRAME, raise it, and set input focus, if possible." | 844 | "Select FRAME, raise it, and set input focus, if possible. |
| 845 | If `mouse-autoselect-window' is non-nil, also move mouse cursor | ||
| 846 | to FRAME's selected window. Otherwise, if `focus-follows-mouse' | ||
| 847 | is non-nil, move mouse cursor to FRAME." | ||
| 845 | (select-frame frame) | 848 | (select-frame frame) |
| 846 | (raise-frame frame) | 849 | (raise-frame frame) |
| 847 | ;; Ensure, if possible, that frame gets input focus. | 850 | ;; Ensure, if possible, that FRAME gets input focus. |
| 848 | (when (memq (window-system frame) '(x w32 ns)) | 851 | (when (memq (window-system frame) '(x w32 ns)) |
| 849 | (x-focus-frame frame)) | 852 | (x-focus-frame frame)) |
| 850 | (when focus-follows-mouse | 853 | ;; Move mouse cursor if necessary. |
| 851 | ;; When the mouse cursor is not in FRAME's selected window move it | 854 | (cond |
| 852 | ;; there to avoid that some other window gets selected when focus | 855 | (mouse-autoselect-window |
| 853 | ;; follows mouse. | 856 | (let ((edges (window-inside-edges (frame-selected-window frame)))) |
| 854 | (condition-case nil | 857 | ;; Move mouse cursor into FRAME's selected window to avoid that |
| 855 | (let ((window (frame-selected-window frame)) | 858 | ;; Emacs mouse-autoselects another window. |
| 856 | (coordinates (cdr-safe (mouse-position)))) | 859 | (set-mouse-position frame (nth 2 edges) (nth 1 edges)))) |
| 857 | (unless (and (car-safe coordinates) | 860 | (focus-follows-mouse |
| 858 | (coordinates-in-window-p coordinates window)) | 861 | ;; Move mouse cursor into FRAME to avoid that another frame gets |
| 859 | (let ((edges (window-inside-edges (frame-selected-window frame)))) | 862 | ;; selected by the window manager. |
| 860 | (set-mouse-position frame (nth 2 edges) (nth 1 edges))))) | 863 | (set-mouse-position frame (1- (frame-width frame)) 0)))) |
| 861 | (error nil)))) | ||
| 862 | 864 | ||
| 863 | (defun other-frame (arg) | 865 | (defun other-frame (arg) |
| 864 | "Select the ARGth different visible frame on current display, and raise it. | 866 | "Select the ARGth different visible frame on current display, and raise it. |
| @@ -934,16 +936,9 @@ If there is no frame by that name, signal an error." | |||
| 934 | (list input)))) | 936 | (list input)))) |
| 935 | (let* ((frame-names-alist (make-frame-names-alist)) | 937 | (let* ((frame-names-alist (make-frame-names-alist)) |
| 936 | (frame (cdr (assoc name frame-names-alist)))) | 938 | (frame (cdr (assoc name frame-names-alist)))) |
| 937 | (or frame | 939 | (if frame |
| 938 | (error "There is no frame named `%s'" name)) | 940 | (select-frame-set-input-focus frame) |
| 939 | (make-frame-visible frame) | 941 | (error "There is no frame named `%s'" name)))) |
| 940 | (raise-frame frame) | ||
| 941 | (select-frame frame) | ||
| 942 | ;; Ensure, if possible, that frame gets input focus. | ||
| 943 | (cond ((memq (window-system frame) '(x w32 ns)) | ||
| 944 | (x-focus-frame frame))) | ||
| 945 | (when focus-follows-mouse | ||
| 946 | (set-mouse-position frame (1- (frame-width frame)) 0)))) | ||
| 947 | 942 | ||
| 948 | ;;;; Frame configurations | 943 | ;;;; Frame configurations |
| 949 | 944 | ||