|
@@ -47,13 +47,13 @@
|
|
|
// This view would inform Chromium to resize the hosted views::View.
|
|
|
//
|
|
|
// The overrided methods should behave the same with BridgedContentView.
|
|
|
-@interface ElectronAdapatedContentView : NSView {
|
|
|
+@interface ElectronAdaptedContentView : NSView {
|
|
|
@private
|
|
|
views::NativeWidgetMacNSWindowHost* bridge_host_;
|
|
|
}
|
|
|
@end
|
|
|
|
|
|
-@implementation ElectronAdapatedContentView
|
|
|
+@implementation ElectronAdaptedContentView
|
|
|
|
|
|
- (id)initWithShell:(electron::NativeWindowMac*)shell {
|
|
|
if ((self = [self init])) {
|
|
@@ -519,7 +519,10 @@ NativeWindowMac::~NativeWindowMac() {
|
|
|
[NSEvent removeMonitor:wheel_event_monitor_];
|
|
|
}
|
|
|
|
|
|
-void NativeWindowMac::RepositionTrafficLights() {
|
|
|
+void NativeWindowMac::RedrawTrafficLights() {
|
|
|
+ // Ensure maximizable options retain pre-existing state.
|
|
|
+ SetMaximizable(maximizable_);
|
|
|
+
|
|
|
if (!traffic_light_position_.x() && !traffic_light_position_.y()) {
|
|
|
return;
|
|
|
}
|
|
@@ -708,7 +711,7 @@ void NativeWindowMac::SetExitingFullScreen(bool flag) {
|
|
|
|
|
|
void NativeWindowMac::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
|
|
|
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
|
|
|
- base::BindOnce(&NativeWindowMac::RepositionTrafficLights,
|
|
|
+ base::BindOnce(&NativeWindowMac::RedrawTrafficLights,
|
|
|
base::Unretained(this)));
|
|
|
}
|
|
|
|
|
@@ -930,6 +933,7 @@ bool NativeWindowMac::IsMinimizable() {
|
|
|
}
|
|
|
|
|
|
void NativeWindowMac::SetMaximizable(bool maximizable) {
|
|
|
+ maximizable_ = maximizable;
|
|
|
[[window_ standardWindowButton:NSWindowZoomButton] setEnabled:maximizable];
|
|
|
}
|
|
|
|
|
@@ -1009,8 +1013,7 @@ void NativeWindowMac::SetWindowLevel(int unbounded_level) {
|
|
|
|
|
|
// Set level will make the zoom button revert to default, probably
|
|
|
// a bug of Cocoa or macOS.
|
|
|
- [[window_ standardWindowButton:NSWindowZoomButton]
|
|
|
- setEnabled:was_maximizable_];
|
|
|
+ SetMaximizable(was_maximizable_);
|
|
|
|
|
|
// This must be notified at the very end or IsAlwaysOnTop
|
|
|
// will not yet have been updated to reflect the new status
|
|
@@ -1034,7 +1037,7 @@ void NativeWindowMac::Invalidate() {
|
|
|
void NativeWindowMac::SetTitle(const std::string& title) {
|
|
|
[window_ setTitle:base::SysUTF8ToNSString(title)];
|
|
|
if (title_bar_style_ == TitleBarStyle::HIDDEN) {
|
|
|
- RepositionTrafficLights();
|
|
|
+ RedrawTrafficLights();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1554,7 +1557,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
|
|
|
|
|
void NativeWindowMac::SetTrafficLightPosition(const gfx::Point& position) {
|
|
|
traffic_light_position_ = position;
|
|
|
- RepositionTrafficLights();
|
|
|
+ RedrawTrafficLights();
|
|
|
}
|
|
|
|
|
|
gfx::Point NativeWindowMac::GetTrafficLightPosition() const {
|
|
@@ -1683,7 +1686,7 @@ void NativeWindowMac::AddContentViewLayers(bool minimizable, bool closable) {
|
|
|
// Some third-party macOS utilities check the zoom button's enabled state to
|
|
|
// determine whether to show custom UI on hover, so we disable it here to
|
|
|
// prevent them from doing so in a frameless app window.
|
|
|
- [[window_ standardWindowButton:NSWindowZoomButton] setEnabled:NO];
|
|
|
+ SetMaximizable(false);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1722,7 +1725,7 @@ void NativeWindowMac::OverrideNSWindowContentView() {
|
|
|
// content view with a simple NSView.
|
|
|
if (has_frame()) {
|
|
|
container_view_.reset(
|
|
|
- [[ElectronAdapatedContentView alloc] initWithShell:this]);
|
|
|
+ [[ElectronAdaptedContentView alloc] initWithShell:this]);
|
|
|
} else {
|
|
|
container_view_.reset([[FullSizeContentView alloc] init]);
|
|
|
[container_view_ setFrame:[[[window_ contentView] superview] bounds]];
|