all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Helmut Eller <eller.helmut@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: 745@emacsbugs.donarmstrong.com
Subject: bug#745: pop-to-buffer, frames, and input focus
Date: Thu, 21 Aug 2008 15:20:18 +0200	[thread overview]
Message-ID: <m28wuqa4j1.fsf@gmail.com> (raw)
In-Reply-To: <48AD2FB5.3000204@gmx.at> (martin rudalics's message of "Thu, 21 Aug 2008 11:04:53 +0200")

* martin rudalics [2008-08-21 11:04+0200] writes:

>> Consider my original example:
>>
>> (progn
>>   (let ((frame (selected-frame))
>>         (pop-up-frames t))
>>     (display-buffer (get-buffer-create "foo"))
>>     (select-frame-set-input-focus frame))
>>
>>   (let ((display-buffer-reuse-frames t))
>>     (pop-to-buffer "foo")))
>>
>> First, display-buffer is just used to create two frames.  This switches
>> (surprisingly) focus to the "foo" buffer.  select-frame-set-input-focus
>> is used to force the focus back to the "*scratch*" buffer.  Then we use
>> pop-to-buffer, but the input focus remains (surprisingly) in the
>> "*scratch*" buffer.
>
> Ahhh, I can't reproduce that.  Evaluating your `progn' moves focus to
> the `foo' buffer here (with emacs -Q).  So it seems we have a platform
> (maybe window manager) specific problem.

I have tried a few window managers now.  

pop-to-buffer doesn't switch input focus with: Sawfish, kwin,
metacity, fluxbox, twm.  
It does with icewm.

display-buffer seems to switch focus with: Sawfish, kwin, fluxbox,
icewm, twm.

Metacity seems to make the decision based on the mouse pointer, but it's
not clear how.  The new buffer receives the input focus sometimes but
not always.

>
>> I expect this:
>>
>>   pop-to-buffer     should switch the input focus
>>   display-buffer    should not change the input focus
>
> `pop-to-buffer' has the sole additional twist WRT `display-buffer':
>
>     (select-window (display-buffer buffer other-window) norecord)
>
> That is, the window used by `display-buffer' should get definitively
> selected.  So, if `display-buffer' has decided to use "another" frame,
> raising that frame, giving it input focus, and implicitly selecting that
> frame and the window used for displaying the buffer_must_ have been
> already handled by `display-buffer'.  In this case, the `select-window'
> done by `pop-to-buffer' looks like a NOOP though I didn't verify that.

I still think that display-buffer should neither select the other frame
nor give it the input focus.  (Whether the other frame should be raised
or not should probably be customizable, but that's a minor issue.)

If the problem only occurs for new frames it's not so serious, tough.
Once created, frames will probably stay there for a while and not be
continuously closed/created.  It's probably also harder to stop window
managers from doing stupid things with new frames.

>>> All I wanted to say that raising a
>>> frame, giving it input focus, and _not_ selecting it might be difficult.
>>
>> I see.  But this is also not what I expect.
>
> So `pop-to-buffer' raising a frame + giving it input focus + selecting
> it is always OK with you?

Yes, I think so.

>
>> pop-to-buffer is more or less (select-window (display-buffer ...)).
>> This looks very reasonable, but it doesn't transfer the input focus.
>> (under X; in a tty everything works well.)
>>
>> On the other hand, display-buffer switches sometimes (when a new frame
>> is created) the input focus, even when that was not asked for.
>>
>> Maybe pop-to-buffer could do something like
>>
>>   (let ((window (display-buffer ...)))
>>     (select-window window)
>>     (select-frame-set-input-focus (window-frame window)))
>>
>> That would solve my immediate problem, ...
>
> Does it solve all your problems in this context?  

For now, yes :-)    

> I suppose it won't be
> of any help when you use `display-buffer' with `pop-up-frames' t :-(

Well, yeah this wouldn't fix display-buffer.  

>> ... but I suspect that select-window
>> should be smarter.  My naive interpretation of select-window's C source
>> is that select-window tries to select the frame.  But apparently forgets
>> about the input focus.  This may also be the reason why
>> save-window-excursion doesn't restore the input focus.
>>
>> Selecting a window, without giving it the input focus is probably rarely
>> needed.  Perhaps select-window should transfer the input focus by
>> default.
>
> I suppose we can't do that.  `select-window' is frequently used to
> temporarily switch to another window (compare `save-selected-window').

Hmm, I see.  Yet, select-window calls Fselect_frame.
The distinction between select-frame and select-frame-set-input-focus
is certainly confusing.

> Shifting input focus to another frame and possibly back to the initial
> frame might confuse the window manager.

That would be a stupid window manager :-) 

Helmut.






  reply	other threads:[~2008-08-21 13:20 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <48C8C046.50203@gmx.at>
2008-08-20  7:35 ` bug#745: pop-to-buffer, frames, and input focus Helmut Eller
2008-08-20 14:50   ` martin rudalics
2008-08-20 18:42     ` Helmut Eller
2008-08-20 20:42       ` David Reitter
2008-08-20 20:56       ` martin rudalics
2008-08-21  8:07         ` Helmut Eller
2008-08-21  9:04           ` martin rudalics
2008-08-21 13:20             ` Helmut Eller [this message]
2008-08-21 20:31               ` martin rudalics
2008-08-22 14:27                 ` Helmut Eller
2008-08-22 16:39                   ` martin rudalics
2008-08-23  8:55                     ` Helmut Eller
2008-08-23 12:05                       ` martin rudalics
2008-08-24 13:14                         ` Helmut Eller
2008-08-25 13:45                           ` martin rudalics
2008-08-26 21:45                             ` Helmut Eller
2008-08-27  8:12                               ` martin rudalics
2008-08-27 12:54                                 ` Helmut Eller
2008-08-28 11:46                                   ` martin rudalics
2008-08-28 16:47                                     ` Helmut Eller
2008-08-28 21:26                                       ` martin rudalics
2008-08-29  7:39                                         ` Helmut Eller
2008-08-29  9:26                                           ` martin rudalics
2008-08-29 15:02                                             ` Helmut Eller
2008-08-30  8:15                                               ` martin rudalics
2008-08-30 11:06                                                 ` Helmut Eller
2008-08-30 13:42                                                   ` martin rudalics
2008-08-31  8:55                                                     ` Helmut Eller
2008-09-06 11:56                                                       ` martin rudalics
2008-09-09  6:24                                                         ` Helmut Eller
2008-09-11  7:05   ` bug#745: marked as done (pop-to-buffer, frames, and input focus) Emacs bug Tracking System

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m28wuqa4j1.fsf@gmail.com \
    --to=eller.helmut@gmail.com \
    --cc=745@emacsbugs.donarmstrong.com \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.