|
@@ -28,6 +28,7 @@
|
|
|
#include "shell/browser/ui/inspectable_web_contents_view.h"
|
|
|
#include "shell/browser/window_list.h"
|
|
|
#include "shell/common/deprecate_util.h"
|
|
|
+#include "shell/common/gin_converters/gfx_converter.h"
|
|
|
#include "shell/common/gin_helper/dictionary.h"
|
|
|
#include "shell/common/options_switches.h"
|
|
|
#include "skia/ext/skia_utils_mac.h"
|
|
@@ -335,6 +336,7 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
|
|
|
options.Get(options::kZoomToPageWidth, &zoom_to_page_width_);
|
|
|
options.Get(options::kFullscreenWindowTitle, &fullscreen_window_title_);
|
|
|
options.Get(options::kSimpleFullScreen, &always_simple_fullscreen_);
|
|
|
+ options.Get(options::kTrafficLightPosition, &traffic_light_position_);
|
|
|
|
|
|
bool minimizable = true;
|
|
|
options.Get(options::kMinimizable, &minimizable);
|
|
@@ -509,6 +511,45 @@ NativeWindowMac::~NativeWindowMac() {
|
|
|
[NSEvent removeMonitor:wheel_event_monitor_];
|
|
|
}
|
|
|
|
|
|
+void NativeWindowMac::RepositionTrafficLights() {
|
|
|
+ if (!traffic_light_position_.x() && !traffic_light_position_.y()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSWindow* window = window_;
|
|
|
+ NSButton* close = [window standardWindowButton:NSWindowCloseButton];
|
|
|
+ NSButton* miniaturize =
|
|
|
+ [window standardWindowButton:NSWindowMiniaturizeButton];
|
|
|
+ NSButton* zoom = [window standardWindowButton:NSWindowZoomButton];
|
|
|
+ NSView* titleBarContainerView = close.superview.superview;
|
|
|
+
|
|
|
+ // Hide the container when exiting fullscreen, otherwise traffic light buttons
|
|
|
+ // jump
|
|
|
+ if (exiting_fullscreen_) {
|
|
|
+ [titleBarContainerView setHidden:YES];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ [titleBarContainerView setHidden:NO];
|
|
|
+ CGFloat buttonHeight = [close frame].size.height;
|
|
|
+ CGFloat titleBarFrameHeight = buttonHeight + traffic_light_position_.y();
|
|
|
+ CGRect titleBarRect = titleBarContainerView.frame;
|
|
|
+ titleBarRect.size.height = titleBarFrameHeight;
|
|
|
+ titleBarRect.origin.y = window.frame.size.height - titleBarFrameHeight;
|
|
|
+ [titleBarContainerView setFrame:titleBarRect];
|
|
|
+
|
|
|
+ NSArray* windowButtons = @[ close, miniaturize, zoom ];
|
|
|
+ const CGFloat space_between =
|
|
|
+ [miniaturize frame].origin.x - [close frame].origin.x;
|
|
|
+ for (NSUInteger i = 0; i < windowButtons.count; i++) {
|
|
|
+ NSView* view = [windowButtons objectAtIndex:i];
|
|
|
+ CGRect rect = [view frame];
|
|
|
+ rect.origin.x = traffic_light_position_.x() + (i * space_between);
|
|
|
+ rect.origin.y = (titleBarFrameHeight - rect.size.height) / 2;
|
|
|
+ [view setFrameOrigin:rect.origin];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void NativeWindowMac::SetContentView(views::View* view) {
|
|
|
views::View* root_view = GetContentsView();
|
|
|
if (content_view())
|
|
@@ -628,6 +669,10 @@ bool NativeWindowMac::IsVisible() {
|
|
|
return [window_ isVisible] && !occluded && !IsMinimized();
|
|
|
}
|
|
|
|
|
|
+void NativeWindowMac::SetExitingFullScreen(bool flag) {
|
|
|
+ exiting_fullscreen_ = flag;
|
|
|
+}
|
|
|
+
|
|
|
bool NativeWindowMac::IsEnabled() {
|
|
|
return [window_ attachedSheet] == nil;
|
|
|
}
|
|
@@ -949,6 +994,9 @@ void NativeWindowMac::Invalidate() {
|
|
|
|
|
|
void NativeWindowMac::SetTitle(const std::string& title) {
|
|
|
[window_ setTitle:base::SysUTF8ToNSString(title)];
|
|
|
+ if (title_bar_style_ == TitleBarStyle::HIDDEN) {
|
|
|
+ RepositionTrafficLights();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
std::string NativeWindowMac::GetTitle() {
|