From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel =?UTF-8?Q?Mart=C3=ADn?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#61525: 29.0.60; delete-frame will raise frames in another virtual desktop Date: Thu, 16 Feb 2023 00:48:59 +0100 Message-ID: References: <835yc2c0vw.fsf@gnu.org> Reply-To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30728"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin) Cc: 61525@debbugs.gnu.org, justksqsf@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 16 00:50:13 2023 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 1pSRXQ-0007m6-RS for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 16 Feb 2023 00:50:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSRXI-00054h-ID; Wed, 15 Feb 2023 18:50:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSRXG-00054F-Au for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2023 18:50:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSRXG-000529-0L for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2023 18:50:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pSRXF-0003vK-Mf for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2023 18:50:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Feb 2023 23:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61525 X-GNU-PR-Package: emacs Original-Received: via spool by 61525-submit@debbugs.gnu.org id=B61525.167650495515014 (code B ref 61525); Wed, 15 Feb 2023 23:50:01 +0000 Original-Received: (at 61525) by debbugs.gnu.org; 15 Feb 2023 23:49:15 +0000 Original-Received: from localhost ([127.0.0.1]:34454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSRWU-0003u5-W0 for submit@debbugs.gnu.org; Wed, 15 Feb 2023 18:49:15 -0500 Original-Received: from sonic314-20.consmr.mail.ir2.yahoo.com ([77.238.177.146]:36227) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSRWQ-0003tp-LZ for 61525@debbugs.gnu.org; Wed, 15 Feb 2023 18:49:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1676504944; bh=gZCIv9lqbuZ67TgGGoAK/4qENfjLUGYQZk6MtVK+2hs=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=XHbPc5esk4b59r/pM+mqlxYzYNCy77sCKzGgkRRKGza0qMyT0iCl2DEv63pljh1Yvou71IkTeks0d4xzi93ui7JIBq7VCBghWPbmAojMJvyKIJHmk3gwK1/oi2e8TpByuhkIPH4MiJ4+EyIn5chbnyS2H3D8ewTJzUMIsjsfd7UDA0CWNBddX5NovOJaSIWoTINZFJYe2CUSCHZVCNwcS/h2q4V+rMiRa3UqI7ooF+Ip6YgH6v0QE+RbbEA1FX+7QK6qkNZidALaLRR2/mn8UItq+XWq9i8QTqGZKzA7bOzVhUueABYvrDJEyag/bXDSvr+0Ei6ag2+8L70KlU3qMA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1676504944; bh=OO8FMl3iXp64rlqbC5DLnjgBjyuz6CLYfYxcDm7cZqk=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=n7tbkqTto1YpaEmsql/6j4mcQzjgH1j4SdwN7AVtWZB4UQQmLTI0uPs/rt+5NH5jl+ESrCce1eT1Tk8UPZ5PU5wHbYluCx7Iz18lc/cUtAmwUbrh/QgkUIMkZWP2R5X85FEGDnS/6exxODt1lWP6C6FAMHfpO57iJmxHmLhwRqUamkpKgHvrB3wpBqHIWphiZU7XEHSyXqiRkYpJGD+vGNW0A8QWQARt4rjIjjFFVrDey6zH2TQFMkq0iLZaO8FYUUT7h/GWEeG0ZC34rhQrCZdIUqrbKOY+c/ZS07gOQcvVtxx2svN41flsPklWuoE5ve/BmBAjxc8IPCHBfwYDYw== X-YMail-OSG: r6knUCMVM1lPHB_PW300xgtefuNE7xsO2w.Vu5T1Fuh4Egu35NwIq87Zo2a4XbX 22CWdiBYwFUgECux20mCyY.MClBNI6PlUoLj1qjLLHQpSPVg3k348htFr78IUvdvYKZwEW0a0Y4F m2XjfjckBd6a6I4GaTnE0QZgm9.c7tMWnVVwh1M1iMN9F7kbkUN7FUa121SUJl16.pJG1xetskr3 rNcpOplb51T5R3BR8EOXki4qhyb3CS2cEQ4pOLVHqD.a5fQV4ACePgTlupK4lJ00Nd2TcOgXHxkP U1YL_KOf_XNKnZ1fp00i2P9NZgfxxcdGuDyBbsAneo09.w8Q66CdUx2UuZnThLM0tEkXzUwwp_E2 Z8.fSY1h2L_YLENqn9wOj0qPJsuhN.38S3mb089H_KEsiH5ySYL4m3mC2zOKJkU2I8D6B63D9RE8 GO9AEMqpMnun0JX_QQLsaEfRzqu.Mc8Mj45wnypZOiwwWzpcEhkMmir0BXvCBOj2UzG1nEAy.xn_ wS1a8VDdmxEeSpU3eXT9GF10BbWhV6vLNxscg8AiD83s1mw8MROIg2SKp.wKRiRYgQ2CKXe8ASE_ icXvKeb.HPIu8ZKmdsiHHq0H47_6eQLpGeOKOzWe28ezwor9McU0mgDg1Q6F6DavwKsS5LXOa3wE 1cpHI5hQdJKd_EnKYHZuo.IOL_X4WUdABanTPjZZlPqc5GAi5P44MkkQO.b2mzutqR871CVeE.MB 680e2WP4NHDBzTVzH7Ol4qXSX1Sl7gbVAC05EsH5okbJjV7h.nOMB1VH2X5MCZlmQwvubE5b6FYs YkfKcJ4Ewt7a81U050J_HlwpcsWQ0.BiZkc2jyMIW8 X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Wed, 15 Feb 2023 23:49:04 +0000 Original-Received: by hermes--production-ir2-65c64dfd66-vsc2c (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 366fdfd4be3b624e76b5d97f6b008fe9; Wed, 15 Feb 2023 23:49:00 +0000 (UTC) In-Reply-To: <835yc2c0vw.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 15 Feb 2023 19:08:19 +0200") X-Mailer: WebService/1.1.21183 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:255778 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> +void ns_make_frame_key_window (struct frame *f) >> +{ >> + [[FRAME_NS_VIEW (f) window] makeKeyWindow]; >> +} > > Is this new call guaranteed to exist and work well on all the > supported OS versions where we have the NS build? I wouldn't want to > fix this on some systems and break it on others at the same time. makeKeyWindow is a very old API that should be available on every macOS and GNUstep we support, AFAIK. I see usages of that API in other parts of the NS build, in things as central as frame creation, and they are not protected by any version or system check. > > Alternatively, can we come up with a change that does both what the > old code did and this addition? That old code did work at some point, > I presume? This is not the case of the old code breaking at some point. It's a difference in behavior between the GNU/Linux version of Emacs and the NS version of Emacs. In GNU/Linux, if you place an Emacs frame in a separate desktop and press C-x 5 0, the window manager does not automatically switch to the desktop where the other Emacs frames reside. I don't know the reason why the NS build has been calling raise-frame for so long. I presume it was considered a good enough way to refocus to another frame after closing one, in a world where virtual desktops were not very common and the behavior reported by the OP was ignored. I've attached a revised version of the patch, to fix a couple of code style issues. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-NS-Do-not-raise-a-different-frame-when-closing-a-fra.patch >From 07035d7bfadff32d6ff954c221331f2060e0f5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Wed, 15 Feb 2023 16:33:14 +0100 Subject: [PATCH] [NS] Do not raise a different frame when closing a frame * src/frame.h: Declare an NS-only function to make a frame the key window. * src/nsfns.m (ns_make_frame_key_window): Implement it. * src/frame.c (delete_frame): Call ns_make_frame_key_window instead of Fraise_frame. (Bug#61525) --- src/frame.c | 5 ++--- src/frame.h | 5 +++++ src/nsfns.m | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/frame.c b/src/frame.c index 983424b0bee..b2319a35aed 100644 --- a/src/frame.c +++ b/src/frame.c @@ -2152,9 +2152,8 @@ delete_frame (Lisp_Object frame, Lisp_Object force) /* Under NS, there is no system mechanism for choosing a new window to get focus -- it is left to application code. So the portion of THIS application interfacing with NS - needs to know about it. We call Fraise_frame, but the - purpose is really to transfer focus. */ - Fraise_frame (frame1); + needs to make the frame we switch to the key window. */ + ns_make_frame_key_window (XFRAME (frame1)); #endif do_switch_frame (frame1, 1, Qnil); diff --git a/src/frame.h b/src/frame.h index b95b94c7685..30c1de20fde 100644 --- a/src/frame.h +++ b/src/frame.h @@ -1380,6 +1380,11 @@ window_system_available (struct frame *f) extern void frame_size_history_plain (struct frame *, Lisp_Object); extern void frame_size_history_extra (struct frame *, Lisp_Object, int, int, int, int, int, int); +#ifdef NS_IMPL_COCOA +/* Implemented in nsfns.m. */ +extern void ns_make_frame_key_window (struct frame *); +#endif + extern Lisp_Object Vframe_list; /* Value is a pointer to the selected frame. If the selected frame diff --git a/src/nsfns.m b/src/nsfns.m index 8804a7df7cf..96434230cc6 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -685,6 +685,12 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. SET_FRAME_GARBAGED (f); } +void +ns_make_frame_key_window (struct frame *f) +{ + [[FRAME_NS_VIEW (f) window] makeKeyWindow]; +} + /* tabbar support */ static void ns_set_tab_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) -- 2.34.1 --=-=-=--