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: Wed, 27 Aug 2008 14:54:13 +0200 [thread overview]
Message-ID: <m23akqlitm.fsf@gmail.com> (raw)
In-Reply-To: <48B50C63.8010402@gmx.at> (martin rudalics's message of "Wed, 27 Aug 2008 10:12:19 +0200")
* martin rudalics [2008-08-27 10:12+0200] writes:
>> Currently Emacs does both. Requesting the focus from the X server
>> (XSetInputFocus) and telling the window manager to activate
>> (x_ewmh_activate_frame [which for most WMs is focus+raise]) the frame.
>
> I suppose we do both just because up to Emacs 22 we used XSetInputFocus
> exclusively and maybe some window managers won't handle EWMHs yet (or
> won't handle them in the sense of Emacs). Should we, in your opinion
> make this customizable? That is, an option `frame-activate-method'
> which if nil does both (as now), if 'explicit does XSetInputFocus only,
> and if 'implicit does x_ewmh_activate_frame only?.
A way to call one of XSetInputFocus or x_ewmh_activate_frame without
calling the other would be useful for experimentation. But I think that
few people will use/need that. So, no, it shouldn't be customizable.
It think it would be nice (but not worth to implement) if Emacs could be
customized with two "focus models":
1. Let the window manager do all the focus handling. This is similar
to what Emacs does currently. In this model Emacs should use
x_ewmh_activate_frame without XSetInputFocus [I think that this would
avoid some race conditions]. pop-to-buffer could
still "activate" the frame, but it would be merely a hint and no
guarantee. Creating frames which aren't focused initially is
probably hard(er) in this model.
2. Emacs does its own focus management. In this model, Emacs should
clear the input flag in WM_HINTS, handle WM_TAKE_FOCUS events, and
explicitly call XSetInputFocus. A reasonable window manager will
handle FocusIn events to decorate the focused frame appropriately.
Since the input flag is cleared, the WM shouldn't focus new frames.
[This model may be incompatible with toolkits, like GTK.]
>> I guess the usual sequence of events is this:
>>
>> 1. Emacs tries to map a frame and waits for notification
>> 2. WM intercepts map request
>> 3. WM maps the frame + gives focus to frame + raises frame
>> 4. Emacs receives MapNotify
>>
>> If we add a fifth step:
>>
>> 5. Emacs requests focus and informs WM to activate the frame
>
> .... without waiting for a FocusIn event?
Yes, without waiting. If we call
(select-frame-set-input-focus (window-frame (display-buffer ...)))
we don't wait for FocusIn.
>> we probably do something twice, but activating the same frame twice
>> shouldn't hurt. We have a problem if the WM decides to activate a
>> different frame, but that seems unlikely.
>
> IIRC window managers relying on EWMHs do not like explicit focus and
> raise frame requests. They might do something with such requests but
> this something could be quite unpredictable. I also STR that people
> reported some flickering with two subsequent raise or focus requests.
> Hence, once again: Should we try - with the help of an option - do this
> either the old-style way without calling window-manager hints or do it
> new-style with such hints and possibly waiting for a FocusIn event?
Since we don't have a window manager which causes trouble, we can't even
test whether the change makes any difference. Let's wait until somebody
reports actual problems :-)
>>> Does it do so even with `focus-follows-mouse' nil?
>>
>> select-frame-set-input-focus seems to work identical for
>> focus-follows-mouse and click-to-focus mode. The frame receives the
>> input focus, is raised, and the mouse pointer is moved to its upper
>> right corner.
>
> Ahhh no, this time I meant the Emacs option `focus-follows-mouse'.
> `select-frame-set-input-focus' moves the mouse iff that is non-nil.
I read to fast :-) No with focus-follows-mouse=nil the mouse pointer
doesn't move but the other frame receives the input focus.
>>> (defcustom pop-up-frame-activate nil
>>> "When non-nil try to explicitly activate popped up frames.
>>> If this is nil leave it to Emacs how to activate the frame. If
>>> this is t always try to activate a new frame. Anything else
>>> means activate a frame if and only if it existed before the most
>>> recent call to `display-buffer' ..."
>>> :type '(choice (const :tag "System Dependent" nil)
>>> (const :tag "Existing frames only" 'existing-only)
>>> (const :tag "Always" t))
>>> :group 'frames)
>>
>> I'm not sure that this issue must be customizable at all. As a user of
>> pop-to-buffer, I don't quite see the usefulness of the "System
>> Dependent" and "Existing frames only" choices. An Emacs implementor
>> could argue that "System Dependent" is simpler to implement, but if the
>> more complicated variants are implemented too it's no longer "simpler".
>
> The "System Dependent" choice is necessary to let the current (maybe
> faulty for some or many of us) behavior carry over for those who like it
> as it is. The question is whether we want to distinguish the other two.
I think that, if "System Dependent" stays the default, then few people
will profit from the other choices, simply because few people take the
time to customize it. Despite that, I think that very few people prefer
the current behavior.
>> I propose this change instead:
> [...]
>> (let ((old-frame (selected-frame)))
>> (select-window (display-buffer buffer other-window) norecord)
>> (unless (eq old-frame (selected-frame))
>> ;; select-window doesn't set the input focus. Set it explicitly.
>> ;; FIXME: select-window should request focus (perhaps lazily).
>> (select-frame-set-input-focus (select-frame))))
>> buffer))
>
> I suppose you mean
>
> (select-frame-set-input-focus (selected-frame))))
>
> here.
Yes, you are right.
> This has the drawback that we unconditionally do
> `select-frame-set-input-focus' for new frames. If we decide that this
> won't harm ...
Most of the time it will work flawlessly on new frames. What's the
worst that could happen? Some flickering. I think that we can live
with that imperfection.
Helmut.
next prev parent reply other threads:[~2008-08-27 12:54 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
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 [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m23akqlitm.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 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).