| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/widget/native_widget_mac.h" | 5 #include "ui/views/widget/native_widget_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 - (BOOL)canBecomeMainWindow { | 36 - (BOOL)canBecomeMainWindow { |
| 37 return YES; | 37 return YES; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Override orderWindow to intercept visibility changes, since there is no way | 40 // Override orderWindow to intercept visibility changes, since there is no way |
| 41 // to observe these changes via NSWindowDelegate. | 41 // to observe these changes via NSWindowDelegate. |
| 42 - (void)orderWindow:(NSWindowOrderingMode)orderingMode | 42 - (void)orderWindow:(NSWindowOrderingMode)orderingMode |
| 43 relativeTo:(NSInteger)otherWindowNumber { | 43 relativeTo:(NSInteger)otherWindowNumber { |
| 44 [[self viewsNSWindowDelegate] onWindowOrderWillChange:orderingMode]; | 44 [[self viewsNSWindowDelegate] onWindowOrderWillChange:orderingMode]; |
| 45 [super orderWindow:orderingMode relativeTo:otherWindowNumber]; | 45 [super orderWindow:orderingMode relativeTo:otherWindowNumber]; |
| 46 [[self viewsNSWindowDelegate] onWindowOrderChanged]; | 46 [[self viewsNSWindowDelegate] onWindowOrderChanged:nil]; |
| 47 } | 47 } |
| 48 | 48 |
| 49 @end | 49 @end |
| 50 | 50 |
| 51 namespace views { | 51 namespace views { |
| 52 namespace { | 52 namespace { |
| 53 | 53 |
| 54 NSInteger StyleMaskForParams(const Widget::InitParams& params) { | 54 NSInteger StyleMaskForParams(const Widget::InitParams& params) { |
| 55 // TODO(tapted): Determine better masks when there are use cases for it. | 55 // TODO(tapted): Determine better masks when there are use cases for it. |
| 56 if (params.remove_standard_frame) | 56 if (params.remove_standard_frame) |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 void NativeWidgetMac::CloseNow() { | 333 void NativeWidgetMac::CloseNow() { |
| 334 // Reset |bridge_| to NULL before destroying it. | 334 // Reset |bridge_| to NULL before destroying it. |
| 335 scoped_ptr<BridgedNativeWidget> bridge(bridge_.Pass()); | 335 scoped_ptr<BridgedNativeWidget> bridge(bridge_.Pass()); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void NativeWidgetMac::Show() { | 338 void NativeWidgetMac::Show() { |
| 339 ShowWithWindowState(ui::SHOW_STATE_NORMAL); | 339 ShowWithWindowState(ui::SHOW_STATE_NORMAL); |
| 340 } | 340 } |
| 341 | 341 |
| 342 void NativeWidgetMac::Hide() { | 342 void NativeWidgetMac::Hide() { |
| 343 NOTIMPLEMENTED(); | 343 [GetNativeWindow() orderOut:nil]; |
| 344 } | 344 } |
| 345 | 345 |
| 346 void NativeWidgetMac::ShowMaximizedWithBounds( | 346 void NativeWidgetMac::ShowMaximizedWithBounds( |
| 347 const gfx::Rect& restored_bounds) { | 347 const gfx::Rect& restored_bounds) { |
| 348 NOTIMPLEMENTED(); | 348 NOTIMPLEMENTED(); |
| 349 } | 349 } |
| 350 | 350 |
| 351 void NativeWidgetMac::ShowWithWindowState(ui::WindowShowState state) { | 351 void NativeWidgetMac::ShowWithWindowState(ui::WindowShowState state) { |
| 352 switch (state) { | 352 switch (state) { |
| 353 case ui::SHOW_STATE_DEFAULT: | 353 case ui::SHOW_STATE_DEFAULT: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 void NativeWidgetMac::SetVisibleOnAllWorkspaces(bool always_visible) { | 422 void NativeWidgetMac::SetVisibleOnAllWorkspaces(bool always_visible) { |
| 423 NOTIMPLEMENTED(); | 423 NOTIMPLEMENTED(); |
| 424 } | 424 } |
| 425 | 425 |
| 426 void NativeWidgetMac::Maximize() { | 426 void NativeWidgetMac::Maximize() { |
| 427 NOTIMPLEMENTED(); // See IsMaximized(). | 427 NOTIMPLEMENTED(); // See IsMaximized(). |
| 428 } | 428 } |
| 429 | 429 |
| 430 void NativeWidgetMac::Minimize() { | 430 void NativeWidgetMac::Minimize() { |
| 431 NOTIMPLEMENTED(); | 431 NSWindow* window = GetNativeWindow(); |
| 432 // Calling performMiniaturize: will momentarily highlight the button, but |
| 433 // AppKit will reject it if there is no miniaturize button. |
| 434 if ([window styleMask] & NSMiniaturizableWindowMask) |
| 435 [window performMiniaturize:nil]; |
| 436 else |
| 437 [window miniaturize:nil]; |
| 432 } | 438 } |
| 433 | 439 |
| 434 bool NativeWidgetMac::IsMaximized() const { | 440 bool NativeWidgetMac::IsMaximized() const { |
| 435 // The window frame isn't altered on Mac unless going fullscreen. The green | 441 // The window frame isn't altered on Mac unless going fullscreen. The green |
| 436 // "+" button just makes the window bigger. So, always false. | 442 // "+" button just makes the window bigger. So, always false. |
| 437 return false; | 443 return false; |
| 438 } | 444 } |
| 439 | 445 |
| 440 bool NativeWidgetMac::IsMinimized() const { | 446 bool NativeWidgetMac::IsMinimized() const { |
| 441 NOTIMPLEMENTED(); | 447 return [GetNativeWindow() isMiniaturized]; |
| 442 return false; | |
| 443 } | 448 } |
| 444 | 449 |
| 445 void NativeWidgetMac::Restore() { | 450 void NativeWidgetMac::Restore() { |
| 446 NOTIMPLEMENTED(); | 451 [GetNativeWindow() deminiaturize:nil]; |
| 447 } | 452 } |
| 448 | 453 |
| 449 void NativeWidgetMac::SetFullscreen(bool fullscreen) { | 454 void NativeWidgetMac::SetFullscreen(bool fullscreen) { |
| 450 if (!bridge_ || fullscreen == IsFullscreen()) | 455 if (!bridge_ || fullscreen == IsFullscreen()) |
| 451 return; | 456 return; |
| 452 | 457 |
| 453 bridge_->ToggleDesiredFullscreenState(); | 458 bridge_->ToggleDesiredFullscreenState(); |
| 454 } | 459 } |
| 455 | 460 |
| 456 bool NativeWidgetMac::IsFullscreen() const { | 461 bool NativeWidgetMac::IsFullscreen() const { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 } | 630 } |
| 626 | 631 |
| 627 // static | 632 // static |
| 628 gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { | 633 gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { |
| 629 NOTIMPLEMENTED(); | 634 NOTIMPLEMENTED(); |
| 630 return gfx::FontList(); | 635 return gfx::FontList(); |
| 631 } | 636 } |
| 632 | 637 |
| 633 } // namespace internal | 638 } // namespace internal |
| 634 } // namespace views | 639 } // namespace views |
| OLD | NEW |