From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#24803: Redirection problem with separate minibuffer frame Date: Wed, 26 Oct 2016 14:09:00 -0400 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1477505438 23632 195.159.176.226 (26 Oct 2016 18:10:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 26 Oct 2016 18:10:38 +0000 (UTC) To: 24803@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 26 20:10:30 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bzSeW-0002qb-JZ for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Oct 2016 20:10:16 +0200 Original-Received: from localhost ([::1]:36637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzSeU-0002WW-2O for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Oct 2016 14:10:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzSeN-0002To-Eu for bug-gnu-emacs@gnu.org; Wed, 26 Oct 2016 14:10:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzSeI-0008FZ-EX for bug-gnu-emacs@gnu.org; Wed, 26 Oct 2016 14:10:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42445) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bzSeI-0008FV-By for bug-gnu-emacs@gnu.org; Wed, 26 Oct 2016 14:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bzSeI-0004Kz-5c for bug-gnu-emacs@gnu.org; Wed, 26 Oct 2016 14:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Oct 2016 18:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24803 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.147750535816619 (code B ref -1); Wed, 26 Oct 2016 18:10:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Oct 2016 18:09:18 +0000 Original-Received: from localhost ([127.0.0.1]:57844 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bzSda-0004Jx-Fo for submit@debbugs.gnu.org; Wed, 26 Oct 2016 14:09:18 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52095) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bzSdY-0004Jj-68 for submit@debbugs.gnu.org; Wed, 26 Oct 2016 14:09:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzSdR-0007o8-Rg for submit@debbugs.gnu.org; Wed, 26 Oct 2016 14:09:10 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:37462) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bzSdR-0007o4-OT for submit@debbugs.gnu.org; Wed, 26 Oct 2016 14:09:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzSdP-0002Pk-U9 for bug-gnu-emacs@gnu.org; Wed, 26 Oct 2016 14:09:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzSdK-0007kW-TU for bug-gnu-emacs@gnu.org; Wed, 26 Oct 2016 14:09:07 -0400 Original-Received: from alt44.smtp-out.videotron.ca ([23.233.128.31]:7268) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bzSdK-0007k0-Oc for bug-gnu-emacs@gnu.org; Wed, 26 Oct 2016 14:09:02 -0400 Original-Received: from ceviche.home ([24.202.159.173]) by Videotron with SMTP id zSdIbxrbZcMN9zSdJbIhSq; Wed, 26 Oct 2016 14:09:01 -0400 X-Authority-Analysis: v=2.1 cv=YqOvP9sX c=1 sm=1 tr=0 a=drQ1+/MlVPSpi4JwKQuNfg==:117 a=drQ1+/MlVPSpi4JwKQuNfg==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=CH0kA5CcgfcA:10 a=hcp_KWb3LyN37U6EM3cA:9 Original-Received: by ceviche.home (Postfix, from userid 20848) id 57ED066239; Wed, 26 Oct 2016 14:09:00 -0400 (EDT) X-CMAE-Envelope: MS4wfLFOLedcgw37bnFU14+HNiirkNppFGehI4HrTQ0ttcZQMImefX3ItZoHpGyLduDYVKu9Wprdr7MoqEAnYHkwAWUWEFnmJ2WmjPxEqdpz+GCk628b1JSG 799XHib7d0cD5mZ+RTBrhZWyAhNQ0F2tWM17TzEJqnnwYzQ8wCDZMlAYELCzVLgCqIo+ECmRJr9H8A== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:125042 Archived-At: Package: Emacs Version: 26.0.50 I'm seeing redirection problems in my Emacs setup (with separate minibuffer-only frame). I suspect it comes from commit 421c0512f76683e0b85ea5e1362291c2da4149ba Author: Martin Rudalics Date: Mon Oct 17 10:52:01 2016 +0200 Fix frame focus redirection with shared minibuffer windows (Bug#24500) * src/frame.c (do_switch_frame): Redirect frame focus also when the frame switched to has its minibuffer window on the selected frame. * src/window.c (candidate_window_p): To qualify as candidate it's not sufficient for the window's frame to just share the minibuffer window - it must be active as well. I just managed to reliably reproduce one of the symptoms of the problem: % emacs -Q --eval "(setq default-frame-alist '((minibuffer)))" ... place the minibuffer frame so that half of it covers the main frame ... ... now from the minibuffer frame, do C-h f car RET at this point, the stacking order has been changed: the main frame is above the minibuffer-only frame. Then I move the mouse into the part of the minibuffer frame still visible and I type ffff The first `f` should call `find-file` (according to minibuffer-inactive-mode-map), but instead the `ffff` text gets inserted into the *scratch* buffer because of some inappropriate focus redirection. [ This recipe depends on using a window-manager with focus-follows-mouse and it might also depend on other aspects of the window manager's behavior. ] A few years back, I had a problem with focus redirection which I tracked with the patch below. I never removed the patch after fixing the bug, so the first symptom of the new problem was that I started to see "Left over focus redirection!" messages all the time. At first I thought it was my patch at fault, so I disabled it, but since then I started to see various odd behaviors, which I think all get down to the left over redirection reproduced in the above recipe. This said, I also noticed something else: ever since this redirection problem appeared, I often see my cursor furiously blinking very rapidly for a very short amount of time, every time I select another frame (which happens all the time with my focus-follows-mouse WM). I used to see this also back when I was tracking that old redirection problem, so I suspect that we have a redisplay bug/inefficiency that's only triggered when some redirection is in place. Stefan diff --git a/src/minibuf.c b/src/minibuf.c index 57eea05..dcafc77 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -338,6 +338,18 @@ If the current buffer is not a minibuffer, return its entire contents. */) return make_buffer_string (prompt_end, PT, 1); } +static void +check_no_redirected_focus (void) +{ + Lisp_Object tail, frame; + FOR_EACH_FRAME (tail, frame) + { + if (!NILP (FRAME_FOCUS_FRAME (XFRAME (frame))) + && !EQ (FRAME_FOCUS_FRAME (XFRAME (frame)), frame)) + message ("Left over focus redirection!"); + } +} + /* Read from the minibuffer using keymap MAP and initial contents INITIAL, putting point minus BACKUP_N bytes from the end of INITIAL, @@ -380,6 +392,10 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, Lisp_Object empty_minibuf; Lisp_Object dummy, frame; + + if (minibuf_level == 0) + record_unwind_protect_void (check_no_redirected_focus); + specbind (Qminibuffer_default, defalt); specbind (Qinhibit_read_only, Qnil);