Skip to content

Commit

Permalink
handle rtl locale for layout controls on macos (microsoft#174107)
Browse files Browse the repository at this point in the history
* handling rtl case on macos layout controls

* remove console log

* unused import
  • Loading branch information
sbatten authored Feb 11, 2023
1 parent 7c54acb commit f718f1a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/envir
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ThemeIcon } from 'vs/base/common/themables';
import { TITLE_BAR_ACTIVE_BACKGROUND, TITLE_BAR_ACTIVE_FOREGROUND, TITLE_BAR_INACTIVE_FOREGROUND, TITLE_BAR_INACTIVE_BACKGROUND, TITLE_BAR_BORDER, WORKBENCH_BACKGROUND } from 'vs/workbench/common/theme';
import { isMacintosh, isWindows, isLinux, isWeb, isNative } from 'vs/base/common/platform';
import { isMacintosh, isWindows, isLinux, isWeb, isNative, locale } from 'vs/base/common/platform';
import { Color } from 'vs/base/common/color';
import { EventType, EventHelper, Dimension, isAncestor, append, $, addDisposableListener, prepend, reset } from 'vs/base/browser/dom';
import { CustomMenubarControl } from 'vs/workbench/browser/parts/titlebar/menubarControl';
Expand Down Expand Up @@ -286,8 +286,18 @@ export class TitlebarPart extends Part implements ITitleService {
});
}

this.primaryWindowControls = append(isMacintosh ? this.leftContent : this.rightContent, $('div.window-controls-container.primary'));
append(isMacintosh ? this.rightContent : this.leftContent, $('div.window-controls-container.secondary'));
let primaryControlLocation = isMacintosh ? 'left' : 'right';
if (isMacintosh && isNative && locale) {
// Check if the locale is RTL, macOS will move traffic lights in RTL locales
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/textInfo
const localeInfo = new Intl.Locale(locale) as any;
if (localeInfo?.textInfo?.direction === 'rtl') {
primaryControlLocation = 'right';
}
}

this.primaryWindowControls = append(primaryControlLocation === 'left' ? this.leftContent : this.rightContent, $('div.window-controls-container.primary'));
append(primaryControlLocation === 'left' ? this.rightContent : this.leftContent, $('div.window-controls-container.secondary'));

// Context menu on title
[EventType.CONTEXT_MENU, EventType.MOUSE_DOWN].forEach(event => {
Expand Down

0 comments on commit f718f1a

Please sign in to comment.