2020-01-13 14:04:38 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Cheng Zhao <zcbenz@gmail.com>
|
|
|
|
Date: Thu, 20 Sep 2018 17:48:49 -0700
|
|
|
|
Subject: mas_disable_custom_window_frame.patch
|
|
|
|
|
|
|
|
Disable private window frame APIs (NSNextStepFrame and NSThemeFrame) for MAS
|
|
|
|
build.
|
|
|
|
|
|
|
|
diff --git a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
|
2020-07-22 05:34:34 +00:00
|
|
|
index 69580888047c4ac6abb68873315bcafb78dda706..aa347913a75084f669bf7d89fbcc919b5222c2d5 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
|
|
|
|
+++ b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
|
|
|
|
@@ -9,6 +9,7 @@
|
|
|
|
#include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
|
|
|
|
#include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
@interface NSWindow (PrivateBrowserNativeWidgetAPI)
|
|
|
|
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
|
|
|
|
@end
|
2020-06-22 17:35:10 +00:00
|
|
|
@@ -63,6 +64,8 @@
|
2020-01-13 14:04:38 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
+#endif // MAS_BUILD
|
|
|
|
+
|
|
|
|
@implementation BrowserNativeWidgetWindow
|
|
|
|
|
2020-06-22 17:35:10 +00:00
|
|
|
// Prevent detached tabs from glitching when the window is partially offscreen.
|
2020-07-22 05:34:34 +00:00
|
|
|
@@ -84,6 +87,7 @@
|
2020-06-22 17:35:10 +00:00
|
|
|
|
2020-01-13 14:04:38 +00:00
|
|
|
// NSWindow (PrivateAPI) overrides.
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
|
|
|
|
// - NSThemeFrame and its subclasses will be nil if it's missing at runtime.
|
|
|
|
if ([BrowserWindowFrame class])
|
2020-07-22 05:34:34 +00:00
|
|
|
@@ -98,6 +102,8 @@
|
2020-01-13 14:04:38 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
+#endif // MAS_BUILD
|
|
|
|
+
|
|
|
|
// Handle "Move focus to the window toolbar" configured in System Preferences ->
|
|
|
|
// Keyboard -> Shortcuts -> Keyboard. Usually Ctrl+F5. The argument (|unknown|)
|
|
|
|
// tends to just be nil.
|
|
|
|
diff --git a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
|
2020-01-17 18:41:52 +00:00
|
|
|
index 8416c7c6e052dafb2aad61c0bd3224c36e945d23..cd356beda023ab2409b16d58ca38c70ba3674913 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
|
|
|
|
+++ b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
|
|
|
|
@@ -4,6 +4,8 @@
|
|
|
|
|
|
|
|
#import "components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.h"
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
+
|
|
|
|
@interface NSWindow (PrivateAPI)
|
|
|
|
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
|
|
|
|
@end
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -18,8 +20,12 @@
|
2020-01-13 14:04:38 +00:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
+#endif // MAS_BUILD
|
|
|
|
+
|
|
|
|
@implementation NativeWidgetMacFramelessNSWindow
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
+
|
|
|
|
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
|
|
|
|
if ([NativeWidgetMacFramelessNSWindowFrame class]) {
|
|
|
|
return [NativeWidgetMacFramelessNSWindowFrame class];
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -27,4 +33,6 @@
|
2020-01-13 14:04:38 +00:00
|
|
|
return [super frameViewClassForStyleMask:windowStyle];
|
|
|
|
}
|
|
|
|
|
|
|
|
+#endif // MAS_BUILD
|
|
|
|
+
|
|
|
|
@end
|
|
|
|
diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
|
2020-01-17 18:41:52 +00:00
|
|
|
index e03bbc724cfd01967e71998394361556df1c4915..783745b11365c04c1e1052197d20d494bc901d45 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
|
|
|
|
+++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
|
|
|
|
@@ -17,6 +17,7 @@ class NativeWidgetNSWindowBridge;
|
|
|
|
|
|
|
|
@protocol WindowTouchBarDelegate;
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
// Weak lets Chrome launch even if a future macOS doesn't have the below classes
|
|
|
|
WEAK_IMPORT_ATTRIBUTE
|
|
|
|
@interface NSNextStepFrame : NSView
|
|
|
|
@@ -33,6 +34,7 @@ REMOTE_COCOA_APP_SHIM_EXPORT
|
|
|
|
REMOTE_COCOA_APP_SHIM_EXPORT
|
|
|
|
@interface NativeWidgetMacNSWindowTitledFrame : NSThemeFrame
|
|
|
|
@end
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
// The NSWindow used by BridgedNativeWidget. Provides hooks into AppKit that
|
|
|
|
// can only be accomplished by overriding methods.
|
|
|
|
diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
|
2020-06-01 20:34:34 +00:00
|
|
|
index 757c72d98de11f611309f4f5af8d0d9aab639181..a6319a0760308df6bac6b39ad3500ad77c1b6525 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
|
|
|
|
+++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
|
2020-06-01 20:34:34 +00:00
|
|
|
@@ -16,7 +16,9 @@
|
2020-01-13 14:04:38 +00:00
|
|
|
#import "ui/base/cocoa/window_size_constants.h"
|
|
|
|
|
|
|
|
@interface NSWindow (Private)
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
+ (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle;
|
|
|
|
+#endif
|
|
|
|
- (BOOL)hasKeyAppearance;
|
|
|
|
- (long long)_resizeDirectionForMouseLocation:(CGPoint)location;
|
|
|
|
- (BOOL)_isConsideredOpenForPersistentState;
|
2020-06-01 20:34:34 +00:00
|
|
|
@@ -58,6 +60,8 @@
|
2020-01-13 14:04:38 +00:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
+
|
|
|
|
@implementation NativeWidgetMacNSWindowTitledFrame
|
|
|
|
- (void)mouseDown:(NSEvent*)event {
|
2020-06-01 20:34:34 +00:00
|
|
|
if (base::mac::IsAtMostOS10_11() && self.window.isMovable)
|
|
|
|
@@ -84,6 +88,8 @@
|
2020-01-13 14:04:38 +00:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
+#endif // MAS_BUILD
|
|
|
|
+
|
|
|
|
@implementation NativeWidgetMacNSWindow {
|
|
|
|
@private
|
|
|
|
base::scoped_nsobject<CommandDispatcher> _commandDispatcher;
|
2020-06-01 20:34:34 +00:00
|
|
|
@@ -165,6 +171,8 @@
|
2020-01-13 14:04:38 +00:00
|
|
|
|
|
|
|
// NSWindow overrides.
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
+
|
|
|
|
+ (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
|
|
|
|
if (windowStyle & NSWindowStyleMaskTitled) {
|
|
|
|
if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class])
|
2020-06-01 20:34:34 +00:00
|
|
|
@@ -176,6 +184,8 @@
|
2020-01-13 14:04:38 +00:00
|
|
|
return [super frameViewClassForStyleMask:windowStyle];
|
|
|
|
}
|
|
|
|
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
- (BOOL)_isTitleHidden {
|
|
|
|
bool shouldShowWindowTitle = YES;
|
|
|
|
if (_bridge)
|