From c8273e375ce0f40a9fea17ae3235e43a8aafae54 Mon Sep 17 00:00:00 2001 From: Sesh Sadasivam Date: Thu, 6 Feb 2020 13:14:18 -0800 Subject: [PATCH] fix: add Chromium patch to fix RTL window buttons (#22016) Classes that inherit from `NSThemeFrame` seem to show window buttons in the incorrect position when the primary MacOS language is set to an RTL (right-to-left) language like Arabic or Hebrew. The fix in this commit mirrors that of `tabbed_browser_window.mm` (https://chromium-review.googlesource.com/c/chromium/src/+/562603/10/chrome/browser/ui/cocoa/tabbed_browser_window.mm#88). This change should be upstreamed, and then this patch can be removed. --- patches/chromium/.patches | 1 + ...n_positions_when_macos_locale_is_rtl.patch | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 patches/chromium/fix_use_native_window_button_positions_when_macos_locale_is_rtl.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 3c0542e32610..3b636e2e6fde 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -81,3 +81,4 @@ feat_allow_disabling_blink_scheduler_throttling_per_renderview.patch accessible_pane_view.patch fixme_grit_conflicts.patch fix_use_the_new_mediaplaypause_key_listener_for_internal_chrome.patch +fix_use_native_window_button_positions_when_macos_locale_is_rtl.patch diff --git a/patches/chromium/fix_use_native_window_button_positions_when_macos_locale_is_rtl.patch b/patches/chromium/fix_use_native_window_button_positions_when_macos_locale_is_rtl.patch new file mode 100644 index 000000000000..9f5bf1c18e4b --- /dev/null +++ b/patches/chromium/fix_use_native_window_button_positions_when_macos_locale_is_rtl.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Sesh Sadasivam +Date: Fri, 31 Jan 2020 19:02:27 -0800 +Subject: fix: use native window button positions when MacOS locale is RTL + +Classes that inherit from `NSThemeFrame` seem to show window buttons in the +incorrect position when the primary MacOS language is set to an RTL +(right-to-left) language like Arabic or Hebrew. The fix in this commit mirrors +that of `tabbed_browser_window.mm` +(https://chromium-review.googlesource.com/c/chromium/src/+/562603/10/chrome/browser/ui/cocoa/tabbed_browser_window.mm#88). + +This change should be upstreamed, and then this patch can be removed. + +diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm +index 9905e1c8914f852e250480797f43d17bf9d7f794..0016cc129805726d6518036fb181a2a9715af8c5 100644 +--- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm ++++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm +@@ -69,6 +69,13 @@ - (void)mouseDown:(NSEvent*)event { + - (BOOL)usesCustomDrawing { + return NO; + } ++// AppKit's implementation only returns YES if [self class] == [NSThemeFrame ++// class]. See: ++// https://chromium-review.googlesource.com/c/chromium/src/+/562603/10/chrome/browser/ui/cocoa/tabbed_browser_window.mm#88 ++- (BOOL)_shouldFlipTrafficLightsForRTL API_AVAILABLE(macosx(10.13)) { ++ return self.window.windowTitlebarLayoutDirection == ++ NSUserInterfaceLayoutDirectionRightToLeft; ++} + @end + + @implementation NativeWidgetMacNSWindowBorderlessFrame