emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

select-frame-set-input-focus and select-frame-by-name


From: Drew Adams
Subject: select-frame-set-input-focus and select-frame-by-name
Date: Tue, 10 May 2005 08:28:18 -0700

A minor detail -

I see this new function in frame.el (in 21.3.50 of 2005-01-30):

(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.
    (cond ((eq window-system 'x)
           (x-focus-frame frame))
          ((eq window-system 'w32)
           (w32-focus-frame frame)))
    (cond (focus-follows-mouse
           (set-mouse-position (selected-frame) (1- (frame-width)) 0))))

It looks like the same code is used in `select-frame-by-name':

(defun select-frame-by-name (name)
  "Select the frame on the current terminal whose name is NAME and raise it.
If there is no frame by that name, signal an error."
  (interactive
   (let* ((frame-names-alist (make-frame-names-alist))
           (default (car (car frame-names-alist)))
           (input (completing-read
                   (format "Select Frame (default %s): " default)
                   frame-names-alist nil t nil 'frame-name-history)))
     (if (= (length input) 0)
         (list default)
       (list input))))
  (let* ((frame-names-alist (make-frame-names-alist))
         (frame (cdr (assoc name frame-names-alist))))
    (or frame
        (error "There is no frame named `%s'" name))
    (make-frame-visible frame)
    (raise-frame frame)
    (select-frame frame)
    ;; Ensure, if possible, that frame gets input focus.
    (cond ((eq window-system 'x)
           (x-focus-frame frame))
          ((eq window-system 'w32)
           (w32-focus-frame frame)))
    (when focus-follows-mouse
      (set-mouse-position frame (1- (frame-width frame)) 0))))

Is there a reason not to use the new function here? Also, is the call to
`make-frame-visible' necessary? The doc for `raise-frame' says that it makes
an invisible frame visible.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]