emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: select-frame-set-input-focus fails to raise the frame


From: Alan Third
Subject: Re: select-frame-set-input-focus fails to raise the frame
Date: Wed, 13 Dec 2017 22:26:34 +0000
User-agent: Mutt/1.9.1 (2017-09-22)

On Wed, Dec 13, 2017 at 05:00:18PM -0500, Robert Weiner wrote:
> On Wed, Dec 13, 2017 at 3:47 PM, Alan Third <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]