From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.bugs Subject: bug#11566: 24.0.97; `read-from-minibuffer': focus to standalone minibuffer frame? Date: Sun, 27 May 2012 08:01:58 -0700 Message-ID: <8D43F91B0096402A9BCA59FE13513358@us.oracle.com> References: <6A40227DCFBF427491B710A473E45744@us.oracle.com> <4FC22A8D.6040801@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1338130978 782 80.91.229.3 (27 May 2012 15:02:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 27 May 2012 15:02:58 +0000 (UTC) Cc: 11566@debbugs.gnu.org To: "'martin rudalics'" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun May 27 17:02:57 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SYezg-0008Bm-VG for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 May 2012 17:02:57 +0200 Original-Received: from localhost ([::1]:33952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYezg-0001Q6-JD for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 May 2012 11:02:56 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:39754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYezc-0001Pd-PO for bug-gnu-emacs@gnu.org; Sun, 27 May 2012 11:02:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SYeza-00038D-47 for bug-gnu-emacs@gnu.org; Sun, 27 May 2012 11:02:52 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36072) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYeza-000389-0y for bug-gnu-emacs@gnu.org; Sun, 27 May 2012 11:02:50 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SYf0j-0007tD-Po for bug-gnu-emacs@gnu.org; Sun, 27 May 2012 11:04:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Drew Adams" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 May 2012 15:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11566 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11566-submit@debbugs.gnu.org id=B11566.133813101130290 (code B ref 11566); Sun, 27 May 2012 15:04:01 +0000 Original-Received: (at 11566) by debbugs.gnu.org; 27 May 2012 15:03:31 +0000 Original-Received: from localhost ([127.0.0.1]:45618 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SYf0E-0007sV-T1 for submit@debbugs.gnu.org; Sun, 27 May 2012 11:03:31 -0400 Original-Received: from rcsinet15.oracle.com ([148.87.113.117]:43015) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SYf0C-0007sJ-IC for 11566@debbugs.gnu.org; Sun, 27 May 2012 11:03:29 -0400 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q4RF29LA024529 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 27 May 2012 15:02:10 GMT Original-Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q4RF29eJ011669 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 27 May 2012 15:02:09 GMT Original-Received: from abhmt111.oracle.com (abhmt111.oracle.com [141.146.116.63]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q4RF28aP001656; Sun, 27 May 2012 10:02:08 -0500 Original-Received: from dradamslap1 (/10.159.190.91) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 27 May 2012 08:02:08 -0700 X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Thread-Index: Ac08C7v/FACUIl/XTjaNFKSLJNjfbQACrN1g In-Reply-To: <4FC22A8D.6040801@gmx.at> X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:60401 Archived-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').