unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Third <alan@idiocy.org>
To: rswgnu@gmail.com
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: select-frame-set-input-focus fails to raise the frame
Date: Wed, 13 Dec 2017 22:26:34 +0000	[thread overview]
Message-ID: <20171213222634.GA2144@breton.holly.idiocy.org> (raw)
In-Reply-To: <CA+OMD9gFoiNrqau9dV8cWa1ZCVPUciJRVZbucKW6d9H9k9Ev2g@mail.gmail.com>

On Wed, Dec 13, 2017 at 05:00:18PM -0500, Robert Weiner wrote:
> On Wed, Dec 13, 2017 at 3:47 PM, Alan Third <alan@idiocy.org> wrote:
> 
> > On Tue, Dec 12, 2017 at 06:26:50PM -0500, Robert Weiner wrote:
> > > Here is a seemingly related problem with raise and lower frame.
> > >
> > > ;; This whole sexp works
> > > (let ((f (selected-frame)))
> > >   (lower-frame f)
> > >   (sit-for 1)
> > >   (raise-frame f))
> > >
> > > ;; Only the first raise-frame call works
> > > (let ((f (next-frame)))
> > >   ;; f is raised
> > >   (raise-frame f)
> > >   (sit-for 1)
> > >   ;; f is NEVER LOWERED
> > >   (lower-frame f))
> >
> > I can’t reproduce this, these both work as expected for me here on
> > macOS using the master branch and the -Q flag.
> >
> ​​
> ​You are correct.  This works fine today; strange it did not yesterday.
> The example I gave with the function named 'test' still fails as before.

I tried it again and it didn’t work! Changing the sit-for to sleep-for
fixed it. I know that sometimes sit-for doesn’t actually wait for the
given time, and I think that’s what’s happening here as I’m seeing the
frame being lowered, but not raised.

Presumably there’s some sort of timing thing where raise-frame then
lower-frame in rapid succession fails randomly.

FWIW, changing sit-for to sleep-for in ‘test’ results in 4 seconds of
a blank frame, but otherwise behaves as expected. This seems to work,
though:

    (defun test ()
      (let ((depress-frame (selected-frame))
            (release-frame (make-frame)))
        (select-frame-set-input-focus depress-frame)
        (sit-for 0)
        (sit-for 4)
        (select-frame-set-input-focus release-frame)))
    
    (test)

Presumably the first sit-for clears any pending input which then means
the second sit-for can actually do its thing.

(I think this is a side‐effect of the way input works on the NS port
where various things that you might not think of as ‘input’ are
essentially indistinguishable from keyboard input.)
-- 
Alan Third



  reply	other threads:[~2017-12-13 22:26 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-12 23:02 select-frame-set-input-focus fails to raise the frame Bob Weiner
2017-12-12 23:26 ` Robert Weiner
2017-12-13 20:47   ` Alan Third
2017-12-13 22:00     ` Robert Weiner
2017-12-13 22:26       ` Alan Third [this message]
2017-12-14  0:33         ` Robert Weiner
2017-12-14 21:03           ` Robert Weiner
2017-12-15 15:53             ` Robert Weiner
2017-12-15 16:10               ` Eli Zaretskii
2017-12-15 17:38                 ` Robert Weiner
2017-12-15 20:44                   ` Eli Zaretskii
2017-12-16 13:41                     ` Robert Weiner
2017-12-16 14:39                       ` Eli Zaretskii
2017-12-16 15:06                         ` Robert Weiner
2017-12-16 16:15                           ` Eli Zaretskii
2017-12-16 18:57                             ` Robert Weiner
2017-12-16 19:45                               ` Eli Zaretskii
2017-12-16 20:07                                 ` Robert Weiner
2017-12-16 19:06                             ` martin rudalics
2017-12-16 19:24                               ` Robert Weiner
2017-12-13  8:50 ` martin rudalics
2017-12-13 15:00   ` Robert Weiner
2017-12-13 16:07     ` Stefan Monnier
2017-12-13 16:33       ` Robert Weiner
2017-12-13 19:39         ` Eli Zaretskii
2017-12-13 19:30     ` martin rudalics
2017-12-13 22:14       ` Robert Weiner
2017-12-13 20:49 ` Alan Third
2017-12-13 21:53   ` Robert Weiner

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=20171213222634.GA2144@breton.holly.idiocy.org \
    --to=alan@idiocy.org \
    --cc=emacs-devel@gnu.org \
    --cc=rswgnu@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 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).