From 5ff58ce636b360e185866377f6ef461dbae2f613 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sun, 19 Jul 2026 19:40:25 +0000 Subject: [PATCH 39/71] feat(macos): standard Window menu (open-windows list, Minimize/Zoom) Add a Window menu and register it via -[NSApplication setWindowsMenu:], so AppKit maintains the open-windows list, checkmarks and ordering itself. We supply the conventional Minimize (performMiniaturize:), Zoom (performZoom:) and Bring All to Front (arrangeInFront:) items; window entries below the separator are managed by AppKit. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01AeG2jwYMX5gdvvtUnx3PJa --- src/contour_macos/main.mm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/contour_macos/main.mm b/src/contour_macos/main.mm index 0b3aca9b..e1fa6586 100644 --- a/src/contour_macos/main.mm +++ b/src/contour_macos/main.mm @@ -100,6 +100,23 @@ static void installMainMenu(NSApplication* app, ContourAppDelegate* delegate) [editMenu release]; [editItem release]; + // Window menu. setWindowsMenu: hands AppKit ownership: it appends an item per open window, + // keeps the list and its checkmark in sync as windows open/close/gain focus, and orders them — + // we only provide the standard Minimize/Zoom actions (first-responder/window selectors). + NSMenuItem* windowItem = [[NSMenuItem alloc] init]; + [menubar addItem:windowItem]; + NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; + [windowItem setSubmenu:windowMenu]; + [windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; + [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; + [windowMenu addItem:[NSMenuItem separatorItem]]; + [windowMenu addItemWithTitle:@"Bring All to Front" + action:@selector(arrangeInFront:) + keyEquivalent:@""]; + [app setWindowsMenu:windowMenu]; + [windowMenu release]; + [windowItem release]; + [menubar release]; }