unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Po Lu <luangruo@yahoo.com>
To: Daniel Colascione <dancol@dancol.org>
Cc: emacs-devel@gnu.org
Subject: Re: master 4b98a79a50: Improve X event timestamp tracking
Date: Sun, 07 Aug 2022 14:07:08 +0800	[thread overview]
Message-ID: <87iln4wprn.fsf@yahoo.com> (raw)
In-Reply-To: <0b58658c390b8c62cc1c5dfadd9e1f0621f64d82.camel@dancol.org> (Daniel Colascione's message of "Sun, 07 Aug 2022 01:43:43 -0400")

Daniel Colascione <dancol@dancol.org> writes:

> Yes, it does. That's the whole point of being the window manager. Are
> you suggesting that application developers, not users, ought to get
> the final word on what windows go where?

_Emacs_ users and developers get the final word, not window manager
developers.

> Yes, they are sloppy, just like all other users and developers, you
> and me included, are sloppy. What's the old quip? Ah, right: "If men
> were angels, no laws would be necessary". If developers were perfect,
> we wouldn't need ASLR, or memory protection, or file permissions, or
> fuzzing, or memory-safe languages --- yet here we are.

So you are saying that ASLR or memory protection is the same as focus
stealing "prevention"? Seriously?

> Developers of Emacs are no more angelic than developers using any
> other toolkit, and focus stealing prevention mitigates their mistakes
> as much as it does any others. If a user doesn't want focus stealing
> preventation, he can disable it or use a window manager that doesn't
> provide it. It's not the place of Emacs to override the user's
> preference.

Why can't the user also customize `x-allow-focus-stealing' (see the
patch I sent) to nil?  Or better, report a bug to the Emacs developers
while at it?

Focus stealing prevention is not a user choice, and can't even be turned
off in the popular window managers.

> If a process filter tries to asynchronously raise a window when the
> user is the middle of browsing cat pictures, and that user has
> configured his WM to block attempts by applications in the background
> to raise windows, the WM is right to block that raise attempt. The WM
> is where policy belongs.

I don't see 

> It does exist elsewhere. From MSDN's page on SetForegroundWindow
> (https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setforegroundwindow)
> :
>
>   The system restricts which processes can set the foreground window.
>   A process can set the foreground window only if one of the
> following
>   conditions is true:
>
>   * The process is the foreground process.
>
>   * The process was started by the foreground process.
>
>   * The process received the last input event.
>
>   * There is no foreground process.
>
>   * The process is being debugged.
>
>   * The foreground process is not a Modern Application or the
>     Start Screen.
>
>   * The foreground is not locked (see LockSetForegroundWindow).
>
>   * The foreground lock time-out has expired (see *
>     SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
>
>   * No menus are active.

I don't see an analogue here, because there's no way for us to manually
specify that Emacs received the last input event.

> Also from that page:
>
>   A process that can set the foreground window can enable another
>   process to set the foreground window by calling the
>   AllowSetForegroundWindow function. The process specified by
>   dwProcessId loses the ability to set the foreground window the next
>   time the user generates input, unless the input is directed at that
>   process, or the next time a process calls AllowSetForegroundWindow,
>   unless that process is specified.

That's different, because another program is explictly prohibiting a
program from setting the input focus.  Whether or not input was received
is also accounted for by the window system, not the program itself.

Also, is Emacs a "Modern Application" on MS-Windows? I thought it still
runs on Windows 9X.

> Guess what API emacsclient calls.

Yet x-focus-frame works.

> It's a generic hint that only one or two backends care about right
> now. That's not the same as a leaky abstraction.

It's not a hint at all.

> Platform-implementation code shouldn't have to know about platform
> specifics. That's why frame operations should be generic and
> polymorphic, not ad-hoc and gated behind type tests.

So it doesn't have to apply such a hint.  It only has to run
x-focus-frame, and as a result the frame is activated.

> I'll say it again: server.el hinting to Emacs that the user has
> interacted with a frame is not an implementation detail of a window
> system.

> Startup notification isn't suitable here because we're not starting
> anything.

It's the only protocol that transfers the X server timestamp at which a
user launched a program (by dropping a file onto an Emacsclient desktop
icon) to the program being launched.

> Emacsclient could include *its* server time in the message.

How will emacsclient be able to send the server time reliably, ensuring
"correct ordering"?

Consider the following sequence of events:

emacsclient                        X server                     emacs
ChangeProperty ------------------->
                                   <other event> -------------->
               <------------------ PropertyNotify
                                   <other event> -------------->
ClientMessage  ------------------>
                                   <other event> -------------->
                                   ClientMessage -------------->

By the time the client message arrives, the timestamp will already be
out of date.

> Well, a related protocol would be nice. Feel free to propose one.

It would be useless since nobody else will support it at this point.
All active development is happening around Wayland (no matter how much
your or I despise that fact.)



  reply	other threads:[~2022-08-07  6:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <165984385935.14715.8191942019361575877@vcs2.savannah.gnu.org>
     [not found] ` <20220807034419.B5F2FC09BFD@vcs2.savannah.gnu.org>
2022-08-07  3:46   ` master 4b98a79a50: Improve X event timestamp tracking Po Lu
2022-08-07  3:48     ` Daniel Colascione
2022-08-07  3:51       ` Po Lu
2022-08-07  4:03         ` Daniel Colascione
2022-08-07  4:23           ` Po Lu
2022-08-07  4:39             ` Daniel Colascione
2022-08-07  5:26               ` Po Lu
2022-08-07  5:43                 ` Daniel Colascione
2022-08-07  6:07                   ` Po Lu [this message]
2022-08-07  6:25                     ` Daniel Colascione
2022-08-07  6:41                       ` Po Lu
2022-08-07  6:55                         ` Daniel Colascione
2022-08-07  7:06                           ` Po Lu
2022-08-07  5:41               ` Eli Zaretskii
2022-08-07  5:51                 ` Daniel Colascione
2022-08-07  5:53                 ` Po Lu
2022-08-07  6:04                   ` Daniel Colascione
2022-08-07  6:15                     ` Po Lu
2022-08-07  6:43                       ` Daniel Colascione
2022-08-07  7:02                         ` Po Lu

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=87iln4wprn.fsf@yahoo.com \
    --to=luangruo@yahoo.com \
    --cc=dancol@dancol.org \
    --cc=emacs-devel@gnu.org \
    /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).