| Index: ui/views/cocoa/bridged_native_widget.mm
|
| diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm
|
| index 2a959daf9e139a6b5ccccc869ba79aa40d727c1c..29bf9b7c1e562b9d991247ad1a846c6e82320ff3 100644
|
| --- a/ui/views/cocoa/bridged_native_widget.mm
|
| +++ b/ui/views/cocoa/bridged_native_widget.mm
|
| @@ -5,9 +5,12 @@
|
| #import "ui/views/cocoa/bridged_native_widget.h"
|
|
|
| #include "base/logging.h"
|
| +#include "base/mac/mac_util.h"
|
| +#import "base/mac/sdk_forward_declarations.h"
|
| #include "ui/base/ime/input_method.h"
|
| #include "ui/base/ime/input_method_factory.h"
|
| #include "ui/base/ui_base_switches_util.h"
|
| +#import "ui/gfx/mac/coordinate_conversion.h"
|
| #import "ui/views/cocoa/bridged_content_view.h"
|
| #import "ui/views/cocoa/views_nswindow_delegate.h"
|
| #include "ui/views/widget/native_widget_mac.h"
|
| @@ -19,7 +22,10 @@
|
| namespace views {
|
|
|
| BridgedNativeWidget::BridgedNativeWidget(NativeWidgetMac* parent)
|
| - : native_widget_mac_(parent), focus_manager_(NULL) {
|
| + : native_widget_mac_(parent),
|
| + focus_manager_(NULL),
|
| + target_fullscreen_state_(false),
|
| + in_fullscreen_transition_(false) {
|
| DCHECK(parent);
|
| window_delegate_.reset(
|
| [[ViewsNSWindowDelegate alloc] initWithBridgedNativeWidget:this]);
|
| @@ -44,6 +50,11 @@ void BridgedNativeWidget::Init(base::scoped_nsobject<NSWindow> window,
|
| window_.swap(window);
|
| [window_ setDelegate:window_delegate_];
|
|
|
| + // Validate the window's initial state, otherwise the bridge's initial
|
| + // tracking state will be incorrect.
|
| + DCHECK(![window_ isVisible]);
|
| + DCHECK_EQ(0u, [window_ styleMask] & NSFullScreenWindowMask);
|
| +
|
| if (params.parent) {
|
| // Use NSWindow to manage child windows. This won't automatically close them
|
| // but it will maintain relative positioning of the window layer and origin.
|
| @@ -89,6 +100,55 @@ void BridgedNativeWidget::OnWindowWillClose() {
|
| native_widget_mac_->OnWindowWillClose();
|
| }
|
|
|
| +void BridgedNativeWidget::OnFullscreenTransitionStart(
|
| + bool target_fullscreen_state) {
|
| + DCHECK_NE(target_fullscreen_state, target_fullscreen_state_);
|
| + target_fullscreen_state_ = target_fullscreen_state;
|
| + in_fullscreen_transition_ = true;
|
| +
|
| + // If going into fullscreen, store an answer for GetRestoredBounds().
|
| + if (target_fullscreen_state)
|
| + bounds_before_fullscreen_ = gfx::ScreenRectFromNSRect([window_ frame]);
|
| +}
|
| +
|
| +void BridgedNativeWidget::OnFullscreenTransitionComplete(
|
| + bool actual_fullscreen_state) {
|
| + in_fullscreen_transition_ = false;
|
| + if (target_fullscreen_state_ == actual_fullscreen_state)
|
| + return;
|
| +
|
| + // First update to reflect reality so that OnTargetFullscreenStateChanged()
|
| + // expects the change.
|
| + target_fullscreen_state_ = actual_fullscreen_state;
|
| + ToggleDesiredFullscreenState();
|
| + DCHECK_NE(target_fullscreen_state_, actual_fullscreen_state);
|
| +}
|
| +
|
| +void BridgedNativeWidget::ToggleDesiredFullscreenState() {
|
| + if (base::mac::IsOSSnowLeopard()) {
|
| + NOTIMPLEMENTED();
|
| + return; // TODO(tapted): Implement this for Snow Leopard.
|
| + }
|
| +
|
| + // If there is currently an animation into or out of fullscreen, then AppKit
|
| + // emits the string "not in fullscreen state" to stdio and does nothing. For
|
| + // this case, schedule a transition back into the desired state when the
|
| + // animation completes.
|
| + if (in_fullscreen_transition_) {
|
| + target_fullscreen_state_ = !target_fullscreen_state_;
|
| + return;
|
| + }
|
| +
|
| + // Since fullscreen requests are ignored if the collection behavior does not
|
| + // allow it, save the collection behavior and restore it after.
|
| + NSWindowCollectionBehavior behavior = [window_ collectionBehavior];
|
| + [window_ setCollectionBehavior:behavior |
|
| + NSWindowCollectionBehaviorFullScreenPrimary];
|
| + [window_ toggleFullScreen:nil];
|
| + [window_ setCollectionBehavior:behavior];
|
| + DCHECK(in_fullscreen_transition_);
|
| +}
|
| +
|
| InputMethod* BridgedNativeWidget::CreateInputMethod() {
|
| if (switches::IsTextInputFocusManagerEnabled())
|
| return new NullInputMethod();
|
| @@ -105,6 +165,13 @@ ui::InputMethod* BridgedNativeWidget::GetHostInputMethod() {
|
| return input_method_.get();
|
| }
|
|
|
| +gfx::Rect BridgedNativeWidget::GetRestoredBounds() const {
|
| + if (target_fullscreen_state_ || in_fullscreen_transition_)
|
| + return bounds_before_fullscreen_;
|
| +
|
| + return gfx::ScreenRectFromNSRect([window_ frame]);
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // BridgedNativeWidget, internal::InputMethodDelegate:
|
|
|
|
|