From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.bugs Subject: bug#745: pop-to-buffer, frames, and input focus Date: Thu, 21 Aug 2008 15:20:18 +0200 Message-ID: References: <48AC2F4A.1000507@gmx.at> <48AC851A.3020906@gmx.at> <48AD2FB5.3000204@gmx.at> Reply-To: Helmut Eller , 745@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1219325407 24372 80.91.229.12 (21 Aug 2008 13:30:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Aug 2008 13:30:07 +0000 (UTC) Cc: 745@emacsbugs.donarmstrong.com To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 21 15:30:59 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 1KWAFJ-0006RF-Rx for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Aug 2008 15:30:38 +0200 Original-Received: from localhost ([127.0.0.1]:54606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWAEL-0006Tu-58 for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Aug 2008 09:29:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KWACN-0005QR-5C for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 09:27:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KWACJ-0005Ok-Jx for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 09:27:34 -0400 Original-Received: from [199.232.76.173] (port=60744 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWACJ-0005OU-8P for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 09:27:31 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:36054) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KWACI-00064e-Rf for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 09:27:31 -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 m7LDRR9G032685; Thu, 21 Aug 2008 06:27:27 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m7LDP5tc031346; Thu, 21 Aug 2008 06:25:05 -0700 X-Loop: don@donarmstrong.com Resent-From: Helmut Eller Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 21 Aug 2008 13:25:04 +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.121932474629576 (code B ref 745); Thu, 21 Aug 2008 13:25:04 +0000 Original-Received: (at 745) by emacsbugs.donarmstrong.com; 21 Aug 2008 13:19:06 +0000 Original-Received: from rolmail.net (cgp1.rolmail.net [195.254.252.190]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m7LDIwBK029570 for <745@emacsbugs.donarmstrong.com>; Thu, 21 Aug 2008 06:19:00 -0700 Original-Received: from dummy.name; Thu, 21 Aug 2008 15:18:56 +0200 Original-Received: from dummy.name; Thu, 21 Aug 2008 15:20:19 +0200 In-Reply-To: <48AD2FB5.3000204@gmx.at> (martin rudalics's message of "Thu, 21 Aug 2008 11:04:53 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Thu, 21 Aug 2008 09:27:34 -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:19599 Archived-At: * martin rudalics [2008-08-21 11:04+0200] writes: >> 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 have tried a few window managers now. pop-to-buffer doesn't switch input focus with: Sawfish, kwin, metacity, fluxbox, twm. It does with icewm. display-buffer seems to switch focus with: Sawfish, kwin, fluxbox, icewm, twm. Metacity seems to make the decision based on the mouse pointer, but it's not clear how. The new buffer receives the input focus sometimes but not always. > >> 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. I still think that display-buffer should neither select the other frame nor give it the input focus. (Whether the other frame should be raised or not should probably be customizable, but that's a minor issue.) If the problem only occurs for new frames it's not so serious, tough. Once created, frames will probably stay there for a while and not be continuously closed/created. It's probably also harder to stop window managers from doing stupid things with new frames. >>> 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? Yes, I think so. > >> 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? For now, yes :-) > I suppose it won't be > of any help when you use `display-buffer' with `pop-up-frames' t :-( Well, yeah this wouldn't fix display-buffer. >> ... 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'). Hmm, I see. Yet, select-window calls Fselect_frame. The distinction between select-frame and select-frame-set-input-focus is certainly confusing. > Shifting input focus to another frame and possibly back to the initial > frame might confuse the window manager. That would be a stupid window manager :-) Helmut.