From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#55983: 29.0.50; If xref-goto-xref pops up a frame, it doesn't set its input focus Date: Sun, 19 Jun 2022 15:37:45 +0200 Message-ID: <8735g0u63a.fsf@miha-pc> References: <86o7yv9ez6.fsf@miha-pc> Reply-To: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19377"; mail-complaints-to="usenet@ciao.gmane.io" To: Dmitry Gutov , 55983@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 19 15:27:20 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o2uxS-0004tp-IQ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Jun 2022 15:27:19 +0200 Original-Received: from localhost ([::1]:37610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2uxR-0003Ca-5R for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Jun 2022 09:27:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2uxC-0003CS-K2 for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2022 09:27:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56986) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2uxC-00072i-Bh for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2022 09:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o2uxC-0005bZ-5a for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2022 09:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Jun 2022 13:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55983 X-GNU-PR-Package: emacs Original-Received: via spool by 55983-submit@debbugs.gnu.org id=B55983.165564521521532 (code B ref 55983); Sun, 19 Jun 2022 13:27:02 +0000 Original-Received: (at 55983) by debbugs.gnu.org; 19 Jun 2022 13:26:55 +0000 Original-Received: from localhost ([127.0.0.1]:50883 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2ux4-0005bE-Ga for submit@debbugs.gnu.org; Sun, 19 Jun 2022 09:26:55 -0400 Original-Received: from kamnitnik.top ([209.250.245.214]:48276) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2ux2-0005b4-PU for 55983@debbugs.gnu.org; Sun, 19 Jun 2022 09:26:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1655645210; bh=Z+VjZrJ5mWSQ2vPIRcOgdFZuDH7h3BpM2Zgsf2Jb74g=; h=From:To:Subject:In-Reply-To:References:Date:From; b=melVguDzV0Iyg8wDuaa7D9KQGV3zKLQEoqXz0Ex+kYNoiOGr5eUGk7Sa4scY6YY/v hEHua9bKVBSAMrvx/d/GxvNPSZ9z01ojK5ZsT9BS1wfU3TLcooA+LxjNm2TXa00mlF Wgbv9NiSz1iZeYZp/VdoEEtSV07Iu5kzXxiusaxG0IPVh/79dxFqmgRz7s7FspzCA0 iC1UOqIOKILKZru5afqV1rYlbEOXTZo61Kz65nzqGrt4vDcUA00vBPVU9zaWZel2GV a/Efby8s7klsdh92Kczj59GgOYJRZUx6eVUfcwp0flHD/n5VaKiL56zjnwmZ3t7hI+ jCNjIKNBh3YSQ== In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:234786 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Dmitry Gutov writes: > Hi! > > Thanks for the report. > > On 14.06.2022 23:17, miha--- via Bug reports for GNU Emacs, the Swiss=20 > army knife of text editors wrote: >> To reproduce, customize pop-up-frames to non-nil and set up your window >> manager such that it doesn't automatically set input focus on newly >> created frames. > > TBH I'm not sure how to setup GNOME Shell to do this. > >> Now in an xref-mode buffer, press RET on a search result >> (xref-goto-xref) and notice that the newly created frame doesn't receive >> input focus. That is because xref-goto-xref uses `display-buffer', >> followed by a `select-window'. >>=20 >> To contrast this behaviour with grep-mode, pressing RET in a grep-mode >> buffer (compile-goto-error) does set input focus to the newly created >> frame. That is because compile-goto-error uses `pop-to-buffer`, which >> also calls `select-frame-set-input-focus'. > > Window management in Emacs is a tricky business, and the current=20 > implementation is a result of https://debbugs.gnu.org/28814 which=20 > implemented a particular kind of behavior and=20 > https://debbugs.gnu.org/33870 which did try to make it more customizable= =20 > through display-buffer-alist. See both discussions for more detail. > > I don't have the time at the moment to try to rework it myself. > > Patches welcome, though. But please mind the original implementation > intent. Please see the attached patch. The only thing it adds is setting frame input focus if necessary before calling `select-window'. Other behaviour should remain the same as before. (The code and the comment is lifted from the function `pop-to-buffer'.) Best regards. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-xref-goto-xref-Set-input-focus-in-addition-to-select.patch Content-Transfer-Encoding: quoted-printable From=206fbdecf5e6a1726498287679bc276dfc0af0633f Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D Date: Sun, 19 Jun 2022 15:29:59 +0200 Subject: [PATCH] xref-goto-xref: Set input focus in addition to selecting window * lisp/progmodes/xref.el (xref--show-location): Set input focus in addition to selecting displayed window (Bug#55983). =2D-- lisp/progmodes/xref.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 683589d71c..0213ab3cc5 100644 =2D-- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -645,9 +645,15 @@ xref--show-location (xref-buffer (current-buffer))) (cond (select (if (eq select 'quit) (quit-window nil nil)) =2D (select-window =2D (with-current-buffer xref-buffer =2D (xref--show-pos-in-buf marker buf)))) + (let* ((old-frame (selected-frame)) + (window (with-current-buffer xref-buffer + (xref--show-pos-in-buf marker buf))) + (frame (window-frame window))) + ;; If we chose another frame, make sure it gets input + ;; focus. + (unless (eq frame old-frame) + (select-frame-set-input-focus frame)) + (select-window window))) (t (save-selected-window (xref--with-dedicated-window =2D-=20 2.36.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmKvJqkTHG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZPxnkD/9rOi0DV/JCzWvMI/d0uZa3FJpZGt2U ZpKw7wafC8+Aqx2tejzhYpEpTiFZQMhkAapyvw0bBFPYXkRy6j+oGKH2r/PDhj2v EtBFw+y7vQQ734RCNzlfexFAR3z3j3Cnc63Sea3XGEsmvUuVMNjd49cHoL3pZors V/yJeI72ttnIuBLj12bzHzwK+hNJi5F54LMQgtV9anUS3RrdbekIwFFZ4h2Qz2G4 2VFkFuzXXvlSaxBQyOY/F3JypPmrGbQ/nHj1SN7JVXK5/9oXx0ev5BK92zZq5xFo iuBINwoqImN3wjAVXAh5Kg1l2G5JqofuMS0736+mlnENDvISPdfbp4sO1QT8Hhl0 igE6UtJNL156TmFXy3mMIcqLeK3pIhQS9DOYIB0oKJu8jVFl+0dk108icQXDvC5S 90zxA2IDiuDCZ4R2IyYFKyFtL9lORrbJLM9sDlnfw8G2Ixhzs4q55SiuuK4ECXcq 7D8a4WdUXF26AtIuZ7VCszcz+tc4OfrAiYOyuZKF6GUZhw//hhLdHo1yxpGNA/SJ 60Miq2Kavydg57bQOpd+y3AbAtduPHeJdHZKy4HbU0IUKT1YiX/BcXoaoxoC3cai M8PhDeY1USWDIaQswVnM3g2LceDEFwwUZYX+qQi4ubVS6T3FDs1b9caBpbsEhZIl ipnTz0D5dWB49w== =rBpU -----END PGP SIGNATURE----- --==-=-=--