Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1331)

Unified Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 1109493002: [MacViews] Fix behavior of non-resizable windows in fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert to Patch Set 7 Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/BUILD.gn ('k') | ui/views/cocoa/bridged_native_widget_interactive_uitest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 107896f931f200368571f936db5dd58cc4eebeb7..7947a2e8b6cf215196d87dad8e8e80ca9e3bb723 100644
--- a/ui/views/cocoa/bridged_native_widget.mm
+++ b/ui/views/cocoa/bridged_native_widget.mm
@@ -388,8 +388,12 @@ void BridgedNativeWidget::OnFullscreenTransitionStart(
void BridgedNativeWidget::OnFullscreenTransitionComplete(
bool actual_fullscreen_state) {
in_fullscreen_transition_ = false;
- if (target_fullscreen_state_ == actual_fullscreen_state)
+
+ if (target_fullscreen_state_ == actual_fullscreen_state) {
+ // Ensure constraints are re-applied when completing a transition.
+ OnSizeConstraintsChanged();
return;
+ }
// First update to reflect reality so that OnTargetFullscreenStateChanged()
// expects the change.
@@ -432,13 +436,13 @@ void BridgedNativeWidget::ToggleDesiredFullscreenState() {
return; // TODO(tapted): Implement this for Snow Leopard.
}
- // 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];
+ // Enable fullscreen collection behavior because:
+ // 1: -[NSWindow toggleFullscreen:] would otherwise be ignored,
+ // 2: the fullscreen button must be enabled so the user can leave fullscreen.
+ // This will be reset when a transition out of fullscreen completes.
+ gfx::SetNSWindowCanFullscreen(window_, true);
+
[window_ toggleFullScreen:nil];
- [window_ setCollectionBehavior:behavior];
}
void BridgedNativeWidget::OnSizeChanged() {
@@ -523,7 +527,12 @@ void BridgedNativeWidget::OnWindowKeyStatusChangedTo(bool is_key) {
}
void BridgedNativeWidget::OnSizeConstraintsChanged() {
- NSWindow* window = ns_window();
+ // Don't modify the size constraints or fullscreen collection behavior while
+ // in fullscreen or during a transition. OnFullscreenTransitionComplete will
+ // reset these after leaving fullscreen.
+ if (target_fullscreen_state_ || in_fullscreen_transition_)
+ return;
+
Widget* widget = native_widget_mac()->GetWidget();
gfx::Size min_size = widget->GetMinimumSize();
gfx::Size max_size = widget->GetMaximumSize();
@@ -533,7 +542,7 @@ void BridgedNativeWidget::OnSizeConstraintsChanged() {
bool shows_fullscreen_controls =
is_resizable && widget->widget_delegate()->CanMaximize();
- gfx::ApplyNSWindowSizeConstraints(window, min_size, max_size,
+ gfx::ApplyNSWindowSizeConstraints(window_, min_size, max_size,
shows_resize_controls,
shows_fullscreen_controls);
}
« no previous file with comments | « ui/views/BUILD.gn ('k') | ui/views/cocoa/bridged_native_widget_interactive_uitest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698