@@ -542,17 +542,27 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
542542 CGFloat buttonHeight = [close frame ].size .height ;
543543 CGFloat titleBarFrameHeight = buttonHeight + traffic_light_position_.y ();
544544 CGRect titleBarRect = titleBarContainerView.frame ;
545+ CGFloat titleBarWidth = NSWidth (titleBarRect);
545546 titleBarRect.size .height = titleBarFrameHeight;
546547 titleBarRect.origin .y = window.frame .size .height - titleBarFrameHeight;
547548 [titleBarContainerView setFrame: titleBarRect];
548549
550+ BOOL isRTL = [titleBarContainerView userInterfaceLayoutDirection ] ==
551+ NSUserInterfaceLayoutDirectionRightToLeft;
549552 NSArray * windowButtons = @[ close, miniaturize, zoom ];
550553 const CGFloat space_between =
551554 [miniaturize frame ].origin .x - [close frame ].origin .x ;
552555 for (NSUInteger i = 0 ; i < windowButtons.count ; i++) {
553556 NSView * view = [windowButtons objectAtIndex: i];
554557 CGRect rect = [view frame ];
555- rect.origin .x = traffic_light_position_.x () + (i * space_between);
558+ if (isRTL) {
559+ CGFloat buttonWidth = NSWidth (rect);
560+ // origin is always top-left, even in RTL
561+ rect.origin .x = titleBarWidth - traffic_light_position_.x () +
562+ (i * space_between) - buttonWidth;
563+ } else {
564+ rect.origin .x = traffic_light_position_.x () + (i * space_between);
565+ }
556566 rect.origin .y = (titleBarFrameHeight - rect.size .height ) / 2 ;
557567 [view setFrameOrigin: rect.origin];
558568 }
0 commit comments