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 #import "ui/views/cocoa/bridged_native_widget.h" | 5 #import "ui/views/cocoa/bridged_native_widget.h" |
6 | 6 |
7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 // of relying on AppKit to do it, and not worry that OnVisibilityChanged() | 423 // of relying on AppKit to do it, and not worry that OnVisibilityChanged() |
424 // won't be called for externally triggered fullscreen requests. | 424 // won't be called for externally triggered fullscreen requests. |
425 if (!window_visible_) | 425 if (!window_visible_) |
426 SetVisibilityState(SHOW_INACTIVE); | 426 SetVisibilityState(SHOW_INACTIVE); |
427 | 427 |
428 if (base::mac::IsOSSnowLeopard()) { | 428 if (base::mac::IsOSSnowLeopard()) { |
429 NOTIMPLEMENTED(); | 429 NOTIMPLEMENTED(); |
430 return; // TODO(tapted): Implement this for Snow Leopard. | 430 return; // TODO(tapted): Implement this for Snow Leopard. |
431 } | 431 } |
432 | 432 |
433 // Since fullscreen requests are ignored if the collection behavior does not | 433 // Enable fullscreen collection behavior because: |
434 // allow it, save the collection behavior and restore it after. | 434 // 1: -[NSWindow toggleFullscreen:] would otherwise be ignored, |
435 NSWindowCollectionBehavior behavior = [window_ collectionBehavior]; | 435 // 2: the fullscreen button must be enabled so the user can leave fullscreen. |
436 [window_ setCollectionBehavior:behavior | | 436 gfx::SetNSWindowCanFullscreen(window_, true); |
tapted
2015/05/06 06:20:41
Why always `true`? (this function is a toggle).
i
jackhou1
2015/05/13 04:27:53
Changed to only set the collection behavior if not
| |
437 NSWindowCollectionBehaviorFullScreenPrimary]; | |
438 [window_ toggleFullScreen:nil]; | 437 [window_ toggleFullScreen:nil]; |
439 [window_ setCollectionBehavior:behavior]; | |
440 } | 438 } |
441 | 439 |
442 void BridgedNativeWidget::OnSizeChanged() { | 440 void BridgedNativeWidget::OnSizeChanged() { |
443 gfx::Size new_size = GetClientAreaSize(); | 441 gfx::Size new_size = GetClientAreaSize(); |
444 native_widget_mac_->GetWidget()->OnNativeWidgetSizeChanged(new_size); | 442 native_widget_mac_->GetWidget()->OnNativeWidgetSizeChanged(new_size); |
445 if (layer()) | 443 if (layer()) |
446 UpdateLayerProperties(); | 444 UpdateLayerProperties(); |
447 } | 445 } |
448 | 446 |
449 void BridgedNativeWidget::OnVisibilityChanged() { | 447 void BridgedNativeWidget::OnVisibilityChanged() { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 } | 519 } |
522 | 520 |
523 void BridgedNativeWidget::OnSizeConstraintsChanged() { | 521 void BridgedNativeWidget::OnSizeConstraintsChanged() { |
524 NSWindow* window = ns_window(); | 522 NSWindow* window = ns_window(); |
525 Widget* widget = native_widget_mac()->GetWidget(); | 523 Widget* widget = native_widget_mac()->GetWidget(); |
526 gfx::Size min_size = widget->GetMinimumSize(); | 524 gfx::Size min_size = widget->GetMinimumSize(); |
527 gfx::Size max_size = widget->GetMaximumSize(); | 525 gfx::Size max_size = widget->GetMaximumSize(); |
528 bool is_resizable = widget->widget_delegate()->CanResize(); | 526 bool is_resizable = widget->widget_delegate()->CanResize(); |
529 bool shows_resize_controls = | 527 bool shows_resize_controls = |
530 is_resizable && (min_size.IsEmpty() || min_size != max_size); | 528 is_resizable && (min_size.IsEmpty() || min_size != max_size); |
531 bool shows_fullscreen_controls = | 529 // Fullscreen controls should be enabled when in fullscreen so the user can |
532 is_resizable && widget->widget_delegate()->CanMaximize(); | 530 // leave. |
531 bool shows_fullscreen_controls = target_fullscreen_state_ || | |
tapted
2015/05/06 06:20:41
What will call OnSizeConstraintsChanged() when tar
jackhou1
2015/05/13 04:27:53
There's a RootView::Layout after leaving fullscree
| |
532 (is_resizable && widget->widget_delegate()->CanMaximize()); | |
533 | 533 |
534 gfx::ApplyNSWindowSizeConstraints(window, min_size, max_size, | 534 gfx::ApplyNSWindowSizeConstraints(window, min_size, max_size, |
535 shows_resize_controls, | 535 shows_resize_controls, |
536 shows_fullscreen_controls); | 536 shows_fullscreen_controls); |
537 } | 537 } |
538 | 538 |
539 InputMethod* BridgedNativeWidget::CreateInputMethod() { | 539 InputMethod* BridgedNativeWidget::CreateInputMethod() { |
540 if (switches::IsTextInputFocusManagerEnabled()) | 540 if (switches::IsTextInputFocusManagerEnabled()) |
541 return new NullInputMethod(); | 541 return new NullInputMethod(); |
542 | 542 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
832 window_, &kWindowPropertiesKey); | 832 window_, &kWindowPropertiesKey); |
833 if (!properties) { | 833 if (!properties) { |
834 properties = [NSMutableDictionary dictionary]; | 834 properties = [NSMutableDictionary dictionary]; |
835 objc_setAssociatedObject(window_, &kWindowPropertiesKey, | 835 objc_setAssociatedObject(window_, &kWindowPropertiesKey, |
836 properties, OBJC_ASSOCIATION_RETAIN); | 836 properties, OBJC_ASSOCIATION_RETAIN); |
837 } | 837 } |
838 return properties; | 838 return properties; |
839 } | 839 } |
840 | 840 |
841 } // namespace views | 841 } // namespace views |
OLD | NEW |