Subject: Re: bug#49997: 27.2; idle-time reset when switching desktop-page

From: Eli Zaretskii <[email-masked]>
Date: Sun, 15 Aug 2021 20:39:30 +0300

> From: Lars Ingebrigtsen <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sun, 15 Aug 2021 19:12:55 +0200
> 
> Well, it does definitely lose focus when we switch to a different
> desktop, so I think the events themselves are correct (more or less).

If we get a focus-out event for a frame that was already in
"focus-out" state, we could detect that and do nothing.  This would
correspond to the situation where the user already moved focus from
Emacs (i.e. was working in some other application's window), and
switched to a different page -- in such a situation I could indeed
understand why the user didn't expect the idleness to end.

But if the user had focus in an Emacs frame, and switched pages, then
the focus-out event indeed counts, and the user cannot expect the
idleness to continue.

> I guess the concept of "Emacs is idle" isn't well-defined.  I think a
> natural interpretation of the it is "I haven't done anything in Emacs".

No, it means no input events came in.  Emacs cannot know whether the
user does anything, it can only know what events come its way.

> And giving focus to Emacs isn't "in Emacs", in a way.  So we could bar
> FOCUS_IN/FOCUS_OUT from changing idleness in general.
> 
> On the other hand, getting/losing focus is a thing that happens to
> Emacs, so it's not really "idle".
> 
> I dunno.  Perhaps we should just leave it as is.

Can we please see if this also happens when the frame is already in a
focus-out state?  We could perhaps ignore such events.  Otherwise, I
tend to agree that there's not much we could do here.