From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: closing emacsclient always focuses another emacs window Date: Mon, 10 Mar 2014 22:29:54 +0200 Message-ID: <83ppltokzh.fsf@gnu.org> References: <83pplwq0s2.fsf@gnu.org> <83ob1gpw98.fsf@gnu.org> <9cc39d8d-e5ae-488b-9ba6-78dd71a2257f@googlegroups.com> <913ee34a-f81c-408f-afe4-6944a9c56430@googlegroups.com> <10020dec-82f2-41de-93d3-06d8984dcfba@googlegroups.com> <87pplv6omp.fsf@web.de> <831tyapvp6.fsf@gnu.org> <87wqg28ykt.fsf@web.de> <83y50inhn7.fsf@gnu.org> <87eh29zvtb.fsf@web.de> <83r469om72.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1394483446 4415 80.91.229.3 (10 Mar 2014 20:30:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 10 Mar 2014 20:30:46 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 10 21:30:54 2014 Return-path: Envelope-to: geh-help-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 1WN6qb-0008L1-6T for geh-help-gnu-emacs@m.gmane.org; Mon, 10 Mar 2014 21:30:53 +0100 Original-Received: from localhost ([::1]:51118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN6qa-0001aG-Ju for geh-help-gnu-emacs@m.gmane.org; Mon, 10 Mar 2014 16:30:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN6q0-0001NF-P4 for help-gnu-emacs@gnu.org; Mon, 10 Mar 2014 16:30:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WN6pu-0004Hn-C7 for help-gnu-emacs@gnu.org; Mon, 10 Mar 2014 16:30:16 -0400 Original-Received: from mtaout26.012.net.il ([80.179.55.182]:58585) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN6pt-0004HZ-Vu for help-gnu-emacs@gnu.org; Mon, 10 Mar 2014 16:30:10 -0400 Original-Received: from conversion-daemon.mtaout26.012.net.il by mtaout26.012.net.il (HyperSendmail v2007.08) id <0N2800200LMMRF00@mtaout26.012.net.il> for help-gnu-emacs@gnu.org; Mon, 10 Mar 2014 22:29:43 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout26.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N2800191M9IY930@mtaout26.012.net.il> for help-gnu-emacs@gnu.org; Mon, 10 Mar 2014 22:29:43 +0200 (IST) In-reply-to: <83r469om72.fsf@gnu.org> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.179.55.182 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96409 Archived-At: > Date: Mon, 10 Mar 2014 22:03:45 +0200 > From: Eli Zaretskii > Cc: help-gnu-emacs@gnu.org > > > From: Michael Heerdegen > > Date: Mon, 10 Mar 2014 20:40:32 +0100 > > > > > AFAIK, which frame becomes selected in this situation is determined by > > > the window manager. > > > > I don't think that's what's happening. > > > > This is what is evaluated: > > > > (apply 'server-switch-buffer (server-done)) > > > > After `server-done' is evaluated, the client (e.g. the xterm) always has > > input focus. The fact that > > > > (advice-add > > 'server-switch-buffer :around > > (lambda (f &rest args) > > (when (car args) (apply f args)))) > > > > fixes the problem for the OP shows that this is also the case for him. > > > > Note: while (server-done) is evaluated, `server-delete-client' calls > > `delete-frame', which implicitly selects another Emacs frame. > > > > Ok, after evaluating (server-done) now we have a different Emacs frame > > selected, the server frame was deleted, and xterm has focus. > > > > Now, `server-switch-buffer' is evaluated (without any Emacs frame having > > input focus), and, depending on the current selected frame, > > `select-frame-set-input-focus'es it as I explained. > > > > So, the issue is completely independent from any window manager. > > I'm sorry, but you lost me. > > All I know is that I don't see on my system any Emacs frame being > raised. Sorry, hit the wrong key. What I wanted to say is that Emacs doesn't have any capabilities to set input focus to a TTY (or xterm) frame. It can only do that for GUI frames, and even then not always. Also, selecting a frame doesn't mean that frame gets focus, even for GUI frames. There's always a selected frame in Emacs, but focus might well belong to another application, so we could have a situation where none of the Emacs frames has focus. So I'm not at all sure how all this description of what happens with selecting a different frame is relevant to the issue at hand, which (AFAIU) is about Emacs TTY frames or xterm windows that get or don't get focus after "C-x #".