diff --git a/internal/platform/darwin/native.m b/internal/platform/darwin/native.m index 5eb7c1678..4e62135b3 100644 --- a/internal/platform/darwin/native.m +++ b/internal/platform/darwin/native.m @@ -6250,6 +6250,12 @@ - (void)setWindowTitle:(NSString *)title { _title = [title copy]; if (_window != nil) { _window.title = _title; + /* A new title lays the titlebar out again, and AppKit sets the zoom + * button back at the system's height without reporting the move as a + * frame change, so keepTrafficLightsCentered never hears of it. */ + if (_windowMode == VIVA_WINDOW_CUSTOM_TITLEBAR) { + viva_place_traffic_lights(_window, _titlebarHeight); + } } } diff --git a/internal/platform/darwin/testdata/traffic_lights.m b/internal/platform/darwin/testdata/traffic_lights.m index bdcae84fd..e6c7e15c5 100644 --- a/internal/platform/darwin/testdata/traffic_lights.m +++ b/internal/platform/darwin/testdata/traffic_lights.m @@ -121,6 +121,13 @@ int main(void) { window.titlebarAppearsTransparent = NO; window.titlebarAppearsTransparent = YES; assertCenter(window, 18, "after the titlebar was restyled"); + // A new title lays the titlebar out too, and AppKit moves the zoom + // button back without reporting it as a frame change. + [delegate setWindowTitle:@"project"]; + assertCenter(window, 18, "after the title changed"); + assertAligned(window, "after the title changed"); + [delegate setWindowTitle:@"project - file"]; + assertAligned(window, "after the title changed again"); [delegate setAlwaysOnTop:YES]; assert(window.level == NSFloatingWindowLevel); [delegate setAlwaysOnTop:NO];