| Index: chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
|
| diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
|
| index cacab46219f9aa2b960632eea8f5d4e513415161..aaea1451b3ba4e9379a670d6c34b9c3320831961 100644
|
| --- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
|
| +++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
|
| @@ -162,6 +162,11 @@ std::vector<gfx::Rect> CalculateNonDraggableRegions(
|
| appWindow_->WindowDidEnterFullscreen();
|
| }
|
|
|
| +- (void)windowWillExitFullScreen:(NSNotification*)notification {
|
| + if (appWindow_)
|
| + appWindow_->WindowWillExitFullscreen();
|
| +}
|
| +
|
| - (void)windowDidExitFullScreen:(NSNotification*)notification {
|
| if (appWindow_)
|
| appWindow_->WindowDidExitFullscreen();
|
| @@ -236,6 +241,10 @@ std::vector<gfx::Rect> CalculateNonDraggableRegions(
|
|
|
| @end
|
|
|
| +@interface NSViewController ()
|
| +@property NSInteger layoutAttribute;
|
| +@end
|
| +
|
| // TODO(jamescook): Should these be AppNSWindow to match AppWindow?
|
| // http://crbug.com/344082
|
| @interface ShellNSWindow : ChromeEventProcessingWindow
|
| @@ -295,6 +304,31 @@ std::vector<gfx::Rect> CalculateNonDraggableRegions(
|
| - (void)setMouseDownCanMoveWindow:(BOOL)can_move;
|
| @end
|
|
|
| +@interface WindowControlView : NSView
|
| +- (void)setupTrackingArea;
|
| +@end
|
| +
|
| +@implementation WindowControlView
|
| +
|
| +- (void)setupTrackingArea {
|
| + base::scoped_nsobject<NSTrackingArea> trackingArea([[NSTrackingArea alloc]
|
| + initWithRect:[self bounds]
|
| + options:(NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways)
|
| + owner:self
|
| + userInfo:nil]);
|
| + [self addTrackingArea:trackingArea];
|
| +}
|
| +
|
| +- (void)mouseEntered:(NSEvent *)theEvent {
|
| + // Show window control button icons.
|
| +}
|
| +
|
| +- (void)mouseExited:(NSEvent *)theEvent {
|
| + // Hide window control button icons.
|
| +}
|
| +
|
| +@end
|
| +
|
| NativeAppWindowCocoa::NativeAppWindowCocoa(
|
| AppWindow* app_window,
|
| const AppWindow::CreateParams& params)
|
| @@ -341,12 +375,57 @@ NativeAppWindowCocoa::NativeAppWindowCocoa(
|
| kTitlebarBackgroundViewPaintHeight)]);
|
| [titlebar_background_view_
|
| setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin];
|
| - [window_view addSubview:titlebar_background_view_
|
| - positioned:NSWindowBelow
|
| - relativeTo:nil];
|
| [titlebar_background_view_
|
| setColor:gfx::SkColorToSRGBNSColor(active_frame_color_)
|
| inactiveColor:gfx::SkColorToSRGBNSColor(inactive_frame_color_)];
|
| +
|
| + Class titlebar_class = NSClassFromString(@"NSTitlebarAccessoryViewController");
|
| + if (titlebar_class) {
|
| + CGFloat height = 30;
|
| + base::scoped_nsobject<NSView> container_view(
|
| + [[NSView alloc] initWithFrame:NSMakeRect(0, NSMaxY([window_view bounds]) - height, NSWidth([window_view bounds]), height)]);
|
| + [titlebar_background_view_ setFrameOrigin:NSMakePoint(0, 0)];
|
| + [container_view addSubview: titlebar_background_view_];
|
| + titlebar_accessory_view_controller_.reset([[titlebar_class alloc] init]);
|
| + [titlebar_accessory_view_controller_ setView:container_view];
|
| + [titlebar_accessory_view_controller_ setLayoutAttribute:2];
|
| +
|
| + CGFloat window_control_view_y = floor(height - 20) / 2;
|
| + base::scoped_nsobject<WindowControlView> window_control_view(
|
| + [[WindowControlView alloc] initWithFrame:NSMakeRect(1, window_control_view_y, 60, 20)]);
|
| + [container_view addSubview:window_control_view];
|
| + [window_control_view setupTrackingArea];
|
| +
|
| + CGFloat closeButtonX = 5;
|
| + CGFloat miniButtonX = 25;
|
| + CGFloat zoomButtonX = 45;
|
| +
|
| + NSUInteger styleMask = GetWindowStyleMask();
|
| + NSButton* closeButton = [NSWindow standardWindowButton:NSWindowCloseButton
|
| + forStyleMask:styleMask];
|
| + // Vertically center the buttons in the tab strip.
|
| + CGFloat buttonY = floor((20 - NSHeight([closeButton bounds])) / 2);
|
| + [closeButton setFrameOrigin:NSMakePoint(closeButtonX, buttonY)];
|
| + [window_control_view addSubview:closeButton];
|
| +
|
| + NSButton* miniaturizeButton =
|
| + [NSWindow standardWindowButton:NSWindowMiniaturizeButton
|
| + forStyleMask:styleMask];
|
| + [miniaturizeButton setFrameOrigin:NSMakePoint(miniButtonX, buttonY)];
|
| + [window_control_view addSubview:miniaturizeButton];
|
| +
|
| + NSButton* zoomButton =
|
| + [NSWindow standardWindowButton:NSWindowZoomButton
|
| + forStyleMask:styleMask];
|
| + [window_control_view addSubview:zoomButton];
|
| + [zoomButton setFrameOrigin:NSMakePoint(zoomButtonX, buttonY)];
|
| +
|
| + [window addTitlebarAccessoryViewController:titlebar_accessory_view_controller_];
|
| + } else {
|
| + [window_view addSubview:titlebar_background_view_
|
| + positioned:NSWindowBelow
|
| + relativeTo:nil];
|
| + }
|
| }
|
|
|
| if (base::mac::IsOSSnowLeopard() &&
|
| @@ -851,11 +930,18 @@ void NativeAppWindowCocoa::WindowDidDeminiaturize() {
|
| }
|
|
|
| void NativeAppWindowCocoa::WindowDidEnterFullscreen() {
|
| + if (titlebar_accessory_view_controller_)
|
| + [window() removeTitlebarAccessoryViewControllerAtIndex:0];
|
| is_fullscreen_ = true;
|
| app_window_->OSFullscreen();
|
| app_window_->OnNativeWindowChanged();
|
| }
|
|
|
| +void NativeAppWindowCocoa::WindowWillExitFullscreen() {
|
| + if (titlebar_accessory_view_controller_)
|
| + [window() addTitlebarAccessoryViewController:titlebar_accessory_view_controller_];
|
| +}
|
| +
|
| void NativeAppWindowCocoa::WindowDidExitFullscreen() {
|
| is_fullscreen_ = false;
|
| if (!shows_fullscreen_controls_)
|
|
|