unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: dancol@dancol.org
To: "T.V Raman" <raman@google.com>
Cc: dancol@dancol.org, Emacs developers <emacs-devel@gnu.org>
Subject: Re: We should decouple focus and frame switching
Date: Sun, 10 Jun 2018 17:20:34 -0700	[thread overview]
Message-ID: <c058fc3e665f3e4407750ea75433937d.squirrel@dancol.org> (raw)
In-Reply-To: <p91lgbm5gtw.fsf@google.com>

> dancol@dancol.org writes:
>
> focus-in-hook and focus-out-hook are demonstrably broken --- I remember
> sending a message here that showed those hooks firing multiple times
> under stumpwm for a single window-switch event. I believe someone else
> also reproed the buggy behavior under a different WM

Yeah. That said, I'm not sure that asking for strictly ordered
exactly-once delivery is reasonable where we have a bunch of asynchronous
window systems and now focus events also being delivered to TTY terminals
via escape codes. Suppose you're switching from a TTY gui frame to a GUI
frame: you might see the focus-in on the GUI frame before the focus-out on
the TTY, and there's nothing we can do about it. Or it could happen the
other way around, unpredictably.

I don't even think we should have separate focus-in and focus-out hooks.
We should just have one extension point, some kind focus-change-function.
Modes would add-function a handler to focus-change-function, and each time
the handler is called, it'd re-scan all the frames and windows it's
interested in and do whatever it wants to do based on that snapshot of the
current focus state. That's why it's important to provide some kind of API
that lets a package ask Emacs, "To the best of your current knowledge,
does FRAME have input focus?" and not just rely on state change
notifications.

Now, we already have focus-in-hook and focus-out-hook. Do we just apply
the new semantics to these hooks? Having two separate hooks encourages
people to use the fragile edge-triggered model instead of the
level-triggered one I described above.

Maybe the right approach is to just declare focus-in-hook and
focus-out-hook obsolete and not call them anymore at all, then direct
people to this new focus-change-function extension point that has the
improved semantics I described. I normally don't like that sort of change,
but the existing hooks are hopelessly broken.




  reply	other threads:[~2018-06-11  0:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-10 18:07 We should decouple focus and frame switching Daniel Colascione
2018-06-10 23:16 ` John Wiegley
2018-06-10 23:28   ` dancol
2018-06-11  0:04     ` T.V Raman
2018-06-11  0:20       ` dancol [this message]
2018-06-11  1:07         ` T.V Raman
2018-06-11 13:00           ` Clément Pit-Claudel
2018-06-11 15:17         ` Stefan Monnier
2018-06-11 15:56         ` Eli Zaretskii
2018-06-13  3:34     ` Michael Heerdegen
2018-06-13  3:50       ` dancol
2018-06-11  2:35 ` Eli Zaretskii
2018-06-11  3:24   ` dancol

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=c058fc3e665f3e4407750ea75433937d.squirrel@dancol.org \
    --to=dancol@dancol.org \
    --cc=emacs-devel@gnu.org \
    --cc=raman@google.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 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).