unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* pop-to-buffer does not change input focus
@ 2006-04-21 16:59 David Reitter
  2006-04-21 17:44 ` Stefan Monnier
  2006-04-21 20:57 ` Lars Hansen
  0 siblings, 2 replies; 10+ messages in thread
From: David Reitter @ 2006-04-21 16:59 UTC (permalink / raw)


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))

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-04-24 21:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-21 16:59 pop-to-buffer does not change input focus David Reitter
2006-04-21 17:44 ` Stefan Monnier
2006-04-21 20:01   ` Lennart Borgman
2006-04-21 20:23     ` David Reitter
2006-04-21 20:57 ` Lars Hansen
2006-04-21 21:06   ` Stefan Monnier
2006-04-21 22:51     ` Lars Hansen
2006-04-23 19:31     ` Lars Hansen
2006-04-24 17:52       ` Richard Stallman
2006-04-24 21:27         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).