Mercurial > emacs
comparison lisp/frame.el @ 98194:6cf707f7e962
(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.
author | Martin Rudalics <rudalics@gmx.at> |
---|---|
date | Tue, 16 Sep 2008 08:20:21 +0000 |
parents | 2f659932a2fb |
children | a923103ca68c |
comparison
equal
deleted
inserted
replaced
98193:85915b708993 | 98194:6cf707f7e962 |
---|---|
839 (cdr param-list)) | 839 (cdr param-list)) |
840 | 840 |
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. |
865 All frames are arranged in a cyclic order. | 867 All frames are arranged in a cyclic order. |
866 This command selects the frame ARG steps away in that order. | 868 This command selects the frame ARG steps away in that order. |
932 (if (= (length input) 0) | 934 (if (= (length input) 0) |
933 (list default) | 935 (list default) |
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 |
950 (defun current-frame-configuration () | 945 (defun current-frame-configuration () |
951 "Return a list describing the positions and states of all frames. | 946 "Return a list describing the positions and states of all frames. |