From: "Drew Adams" <drew.adams@oracle.com>
To: "'martin rudalics'" <rudalics@gmx.at>
Cc: 11566@debbugs.gnu.org
Subject: bug#11566: 24.0.97; `read-from-minibuffer': focus to standalone minibuffer frame?
Date: Sun, 27 May 2012 08:01:58 -0700 [thread overview]
Message-ID: <8D43F91B0096402A9BCA59FE13513358@us.oracle.com> (raw)
In-Reply-To: <4FC22A8D.6040801@gmx.at>
> > On MS Windows at least, when a new frame is created it
> > grabs the input focus. The problem where the minibuffer
> > frame does not get the focus it needs seems to arise in a
> > situation where a new frame is popped up and then
> > `read-from-minibuffer' is called immediately afterward.
> > Maybe there is some kind of contention or delay/race problem
> > here (?) - I have no idea.
>
> You should be able to check this by inserting a (sit-for 1)
> somewhere in between popping up the frame and calling
> `read-from-minibuffer'.
Not too sure what you mean, but the test you proposed at the end of your post
seems to replace this - and it was telling.
> IIUC `read-from-minibuffer' uses `redirect-frame-focus' to send the
> keystrokes to the minibuffer window. If that function works
> for you in general, we likely have a race condition in this special case.
If so, what could a solution/fix be for it?
> > Shouldn't [`read-from-minibuffer'] have the responsibility
> > here to give the minibuffer frame the focus?
>
> Yes. But the window manager must not intercept it.
But that's what seems to be happening (intercept or interrupt or some such).
> > Here is a workaround I've come up with when trying to
> > "fix" `r-f-m' itself:...
> >
> > But that defadvice does not always make `r-f-m' DTRT, in
> > any case. For example, if the originally selected frame
> > is deleted during `ad-do-it', then it punts and leaves the
> > input focus in the minibuffer frame.
>
> I'm afraid that in this special case the current code will
> fail as well.
So - at least wrt that particular failing - it shouldn't hurt to add code
similar in effect to my defadvice to the C code for `read-from-minibuffer'?
It's just a question, as I'm not confident that the cure would be benign in all
cases.
In any case, it is not a real fix for the problem. I hope you might have some
ideas for that.
> Try the sit-for approach. Try to make a standalone example like
> (let ((old-frame ... some existing frame))
> (make-frame)
> (redirect-frame-focus old-frame))
> and see whether it fails giving focus to `old-frame'.
Still not sure what you mean by using `sit-for' (how/where?). But I tried that
simple example, and yes, it systematically fails to give focus to `old-frame'.
The newly created frame keeps the focus - every time.
That it does this systematically makes me think it is not a race condition but
some other problem. Placing a (sit-for 20) between the `make-frame' and the
`redirect...' made no difference. Likewise, with `sleep-for'. The new frame is
created, but no text is visibly displayed in it for the `sleep-for' period, then
the text appears (and the focus is still in the new frame). The new frame is
selected as soon as it is created (as told by its title bar being highlighted),
and it apparently remains so throughout.
So it would appear that that is the bug/problem. How to fix it so that
`redirect-frame-focus' can actually redirect the focus in this case?
I also tried some other things, like calling `force-mode-line-update' at the
end, thinking it might be an Emacs display problem. And I tried calling
`redirect...' more than once. But no luck. I even tried explicitly redirecting
to the new frame and then back to the old frame (and vice versa):
(let ((old-frame (selected-frame))
(new-frame (make-frame)))
;; (sleep-for 20)
(redirect-frame-focus new-frame)
(redirect-frame-focus old-frame))
So far, no luck getting Windows's attention and actually changing the frame
focus.
Hope you can see some light at the end of the tunnel. It would really be good
(for me at least) to get this fixed. I have a hunch that this might be at the
origin of other frame-related problems that I have dealt with more or less
successfully using various workarounds (e.g. calls to
`select-frame-set-input-focus').
next prev parent reply other threads:[~2012-05-27 15:01 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-27 0:07 bug#11566: 24.0.97; `read-from-minibuffer': focus to standalone minibuffer frame? Drew Adams
2012-05-27 13:22 ` martin rudalics
2012-05-27 15:01 ` Drew Adams [this message]
2012-05-29 9:43 ` martin rudalics
2012-05-29 14:12 ` Drew Adams
2012-05-29 15:44 ` Eli Zaretskii
2012-05-29 16:10 ` Drew Adams
2012-05-29 16:44 ` Eli Zaretskii
2012-05-29 19:15 ` Drew Adams
2012-05-29 19:47 ` Eli Zaretskii
2012-05-29 20:28 ` Drew Adams
2012-05-29 15:40 ` Eli Zaretskii
2012-05-29 16:10 ` Drew Adams
2012-05-29 16:46 ` Eli Zaretskii
2012-05-29 19:15 ` Drew Adams
2012-05-29 20:20 ` Eli Zaretskii
2012-05-29 21:31 ` Drew Adams
2012-05-30 18:43 ` Eli Zaretskii
2012-05-30 20:10 ` Drew Adams
2012-05-28 18:02 ` Drew Adams
2012-10-03 9:13 ` martin rudalics
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8D43F91B0096402A9BCA59FE13513358@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=11566@debbugs.gnu.org \
--cc=rudalics@gmx.at \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.