From 5ae1a7d1b716211373d9e0b2fd2fff9ef4aa9c04 Mon Sep 17 00:00:00 2001 From: McLaren Labs Date: Fri, 12 Jan 2024 10:20:19 -0800 Subject: [PATCH] In a multi-display setup, the main menu does not move from one display to another when the Emacs window is moved between displays. This improvement adds a notification listener that notifies the mainMenu that the NSWindowDidChangeScreenNotification has occured. In other Apps this callback is registered automatically. In NSMenu, the applicationDidFinishLaunch method registers this for the mainMenu. However, the way emacs construcgts GNUstep menus in nsmenu.m, constructs menus in a different manner. Note: this proposed modification handles one emacs window moving between different displays, but does not handle the case where there are multiple emacs windows. In that case, the menu should appear on the display on which the emacs frame is shown. --- src/nsterm.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/nsterm.m b/src/nsterm.m index f094b145fe30..bd1b46db2d0c 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5802,6 +5802,10 @@ - (id)init selector: @selector(updateMonitors:) name: NSApplicationDidChangeScreenParametersNotification object: nil]; + [notification_center addObserver: self + selector: @selector(windowDidChangeScreen:) + name: NSWindowDidChangeScreenNotification + object: nil]; #endif return self; @@ -6033,6 +6037,11 @@ - (void) updateMonitors: (NSNotification *) notification kbd_buffer_store_event (&ie); } + +- (void) windowDidChangeScreen: (NSNotification *) notification +{ + [[NSApp mainMenu] windowDidChangeScreen:notification]; +} #endif /* **************************************************************************