all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Helmut Eller <eller.helmut@gmail.com>
Cc: 745@emacsbugs.donarmstrong.com
Subject: bug#745: pop-to-buffer, frames, and input focus
Date: Wed, 27 Aug 2008 10:12:19 +0200	[thread overview]
Message-ID: <48B50C63.8010402@gmx.at> (raw)
In-Reply-To: <m2tzd75u2w.fsf@gmail.com>

 >> So when `display-buffer' has called `pop-up-frame-function' we always
 >> anticipate that the new frame is mapped (visible), has got input focus,
 >> and is raised.
[...]
 > In other words, we don't even know that the frame is mapped!]
 >
 > However, even documenting that the input focus is unspecified would be
 > of some use.

Yes.  Nevertheless, the idea that we "anticipate" the window manager to
do all these things is valid I presume - even it we don't "know" whether
the frame is visible in the first place.

 >>  IIUC we currently rely on the window-manager to
 >> raise and focus the frame.
 >
 > 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?.

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

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

 >> Note that `x-focus-frame' uses XSetInputFocus together with
 >> x_ewmh_activate_frame.  This mixture seems slightly frightening.
 >
 > Yes, this looks like "programming by accident".

... rather "better safe than sorry".

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

 >> (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 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.  This has the drawback that we unconditionally do
`select-frame-set-input-focus' for new frames.  If we decide that this
won't harm ...

My experience is that once in a while some window manager won't get
along with whatever we decide here.  Hence I'd like to put in one or two
options so users can try an alternative without immediately affecting
the behavior of this on other systems.

martin







  reply	other threads:[~2008-08-27  8:12 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 [this message]
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=48B50C63.8010402@gmx.at \
    --to=rudalics@gmx.at \
    --cc=745@emacsbugs.donarmstrong.com \
    --cc=eller.helmut@gmail.com \
    /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.