emacs-devel
[Top][All Lists]
Advanced

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

pop-to-buffer does not change input focus


From: David Reitter
Subject: pop-to-buffer does not change input focus
Date: Fri, 21 Apr 2006 17:59:48 +0100

With `pop-up-frames' set to t, `pop-to-buffer' will show a new frame with the buffer given. But if a frame showing that buffer already exists, this buffer is selected, the frame is raised, but it does not get input focus. This leads to situations where the frame is opened on top of the old one, but any input events go to the old one.

Either way, it is inconsistent with respect to the behavior you get when `pop-up-frames' is nil, `pop-up-windows' is t, and the buffer is shown in a new window. In that case, the window is always selected and the frame has input focus anyways, hence any input will go there.

The code below demonstrates the problem. A new frame with a new buffer is created, then we switch back to the old one. The final call to `pop-to-buffer' then doesn't set input focus.

This may not so evident in configurations where X is used and "focus follows mouse", because the user doesn't expect the system to select another frame without the mouse being moved (actively). It is less problem when new frames don't appear on top of the old ones. However, it is still inconsistent, and setting pop-up-frames to t will break the workflow in a lot of cases, where we expect the input to continue in the target buffer. Consider M-x compose-mail.


I suggest that `pop-to-buffer' should contain a call to something like `select-frame-set-input-focus'.


====
Code:


(let ((orig-window (selected-window))
      (orig-frame (selected-frame))
      (new-buf (generate-new-buffer "*test*"))
      (focus-follows-mouse nil) ;; to demonstrate the effect on X
      ;; move mouse out of the way on X
      )

  ;; the following command should set the input focus, but it doesn't
  ;; the result is a raised second frame, with the input focus back
  ;; in the old buffer.
  (let ((pop-up-windows nil)
        (pop-up-frames t))
    (pop-to-buffer new-buf)
(select-frame-set-input-focus orig-frame) ;; switch back to old frame
    (pop-to-buffer new-buf))
  (current-buffer))






reply via email to

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