From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#745: pop-to-buffer, frames, and input focus Date: Thu, 21 Aug 2008 11:04:53 +0200 Message-ID: <48AD2FB5.3000204@gmx.at> References: <48AC2F4A.1000507@gmx.at> <48AC851A.3020906@gmx.at> Reply-To: martin rudalics , 745@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1219310895 3229 80.91.229.12 (21 Aug 2008 09:28:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Aug 2008 09:28:15 +0000 (UTC) Cc: 745@emacsbugs.donarmstrong.com To: Helmut Eller Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 21 11:29:08 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KW6Tb-00082d-5n for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Aug 2008 11:29:07 +0200 Original-Received: from localhost ([127.0.0.1]:46861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KW6Sd-0008Vi-MJ for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Aug 2008 05:28:07 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KW6S6-0008BM-ST for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 05:27:34 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KW6S2-0008AB-Qe for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 05:27:33 -0400 Original-Received: from [199.232.76.173] (port=41272 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KW6S2-0008A0-Gf for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 05:27:30 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:45422) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KW6S1-0002UA-Te for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 05:27:30 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m7L9RRl5020728; Thu, 21 Aug 2008 02:27:27 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m7L9F3qq016352; Thu, 21 Aug 2008 02:15:03 -0700 X-Loop: don@donarmstrong.com Resent-From: martin rudalics Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 21 Aug 2008 09:15:03 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 745 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 745-submit@emacsbugs.donarmstrong.com id=B745.121930969314599 (code B ref 745); Thu, 21 Aug 2008 09:15:03 +0000 Original-Received: (at 745) by emacsbugs.donarmstrong.com; 21 Aug 2008 09:08:13 +0000 Original-Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with SMTP id m7L989ZH014593 for <745@emacsbugs.donarmstrong.com>; Thu, 21 Aug 2008 02:08:10 -0700 Original-Received: (qmail invoked by alias); 21 Aug 2008 09:08:03 -0000 Original-Received: from 62-47-34-123.adsl.highway.telekom.at (EHLO [62.47.34.123]) [62.47.34.123] by mail.gmx.net (mp038) with SMTP; 21 Aug 2008 11:08:03 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX18yQSMnLt0yYWtUvLgc6NjKMpRMSqQenZALQ8Muz4 lcOrY7vleX3oDh User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) In-Reply-To: X-Y-GMX-Trusted: 0 X-FuHaFi: 0.64 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Thu, 21 Aug 2008 05:27:33 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:19594 Archived-At: > Consider my original example: > > (progn > (let ((frame (selected-frame)) > (pop-up-frames t)) > (display-buffer (get-buffer-create "foo")) > (select-frame-set-input-focus frame)) > > (let ((display-buffer-reuse-frames t)) > (pop-to-buffer "foo"))) > > First, display-buffer is just used to create two frames. This switches > (surprisingly) focus to the "foo" buffer. select-frame-set-input-focus > is used to force the focus back to the "*scratch*" buffer. Then we use > pop-to-buffer, but the input focus remains (surprisingly) in the > "*scratch*" buffer. Ahhh, I can't reproduce that. Evaluating your `progn' moves focus to the `foo' buffer here (with emacs -Q). So it seems we have a platform (maybe window manager) specific problem. > I expect this: > > pop-to-buffer should switch the input focus > display-buffer should not change the input focus `pop-to-buffer' has the sole additional twist WRT `display-buffer': (select-window (display-buffer buffer other-window) norecord) That is, the window used by `display-buffer' should get definitively selected. So, if `display-buffer' has decided to use "another" frame, raising that frame, giving it input focus, and implicitly selecting that frame and the window used for displaying the buffer_must_ have been already handled by `display-buffer'. In this case, the `select-window' done by `pop-to-buffer' looks like a NOOP though I didn't verify that. >> All I wanted to say that raising a >> frame, giving it input focus, and _not_ selecting it might be difficult. > > I see. But this is also not what I expect. So `pop-to-buffer' raising a frame + giving it input focus + selecting it is always OK with you? > pop-to-buffer is more or less (select-window (display-buffer ...)). > This looks very reasonable, but it doesn't transfer the input focus. > (under X; in a tty everything works well.) > > On the other hand, display-buffer switches sometimes (when a new frame > is created) the input focus, even when that was not asked for. > > Maybe pop-to-buffer could do something like > > (let ((window (display-buffer ...))) > (select-window window) > (select-frame-set-input-focus (window-frame window))) > > That would solve my immediate problem, ... Does it solve all your problems in this context? I suppose it won't be of any help when you use `display-buffer' with `pop-up-frames' t :-( > ... but I suspect that select-window > should be smarter. My naive interpretation of select-window's C source > is that select-window tries to select the frame. But apparently forgets > about the input focus. This may also be the reason why > save-window-excursion doesn't restore the input focus. > > Selecting a window, without giving it the input focus is probably rarely > needed. Perhaps select-window should transfer the input focus by > default. I suppose we can't do that. `select-window' is frequently used to temporarily switch to another window (compare `save-selected-window'). Shifting input focus to another frame and possibly back to the initial frame might confuse the window manager. martin