From 3f8d0ee00ab9392d27831d64ef154c92b2b60608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Fri, 18 Aug 2023 15:03:21 +0200 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 | 15 +++++++++------ src/frame.h | 4 ++++ src/nsfns.m | 6 ++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/frame.c b/src/frame.c index da00cbf4bce..addeb013b4a 100644 --- a/src/frame.c +++ b/src/frame.c @@ -2212,12 +2212,15 @@ delete_frame (Lisp_Object frame, Lisp_Object force) } #ifdef NS_IMPL_COCOA else - /* 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); + { + /* 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 make the frame we switch to the key window. */ + struct frame *f1 = XFRAME (frame1); + if (FRAME_NS_P (f1)) + ns_make_frame_key_window (f1); + } #endif do_switch_frame (frame1, 0, 1, Qnil); diff --git a/src/frame.h b/src/frame.h index c85df378da6..f4726f1c0e5 100644 --- a/src/frame.h +++ b/src/frame.h @@ -1521,6 +1521,10 @@ 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 b846b490ff7..a79892f73b6 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.40.1