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

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: Address comments. 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/base/ui_base.gyp ('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 24275787c04e43ac1ab87b032e13ff5f4665461c..ad0c44a7501cd0cdccb05ab4b152e62b3cde1a6a 100644
--- a/ui/views/cocoa/bridged_native_widget.mm
+++ b/ui/views/cocoa/bridged_native_widget.mm
@@ -374,7 +374,6 @@ void BridgedNativeWidget::OnFullscreenTransitionStart(
// shouldn't be able to do that if the window is invisible to begin with.
DCHECK(window_visible_);
- DCHECK_NE(target_fullscreen_state, target_fullscreen_state_);
tapted 2015/05/13 06:12:42 I think we can keep this.... see below
jackhou1 2015/05/13 06:53:10 Done.
target_fullscreen_state_ = target_fullscreen_state;
in_fullscreen_transition_ = true;
@@ -386,6 +385,12 @@ void BridgedNativeWidget::OnFullscreenTransitionStart(
void BridgedNativeWidget::OnFullscreenTransitionComplete(
bool actual_fullscreen_state) {
in_fullscreen_transition_ = false;
+
+ // If window did leave fullscreen, reset the size constraints and collection
+ // behavior.
+ if (!actual_fullscreen_state)
+ OnSizeConstraintsChanged();
tapted 2015/05/13 06:12:42 This should only happen if we're staying in this s
jackhou1 2015/05/13 06:53:10 Done.
+
if (target_fullscreen_state_ == actual_fullscreen_state)
return;
@@ -430,13 +435,18 @@ 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];
+ // Before entering fullscreen, and during fullscreen:
+ // 1: Size constraints must be removed so that the window takes up the entire
+ // screen.
+ // 2: Fullscreen collection behavior must be enabled because:
+ // a: -[NSWindow toggleFullscreen:] would otherwise be ignored,
+ // b: it enables the fullscreen button so the user can leave fullscreen.
+ // These will be reset after leaving fullscreen.
+ if (!([ns_window() styleMask] & NSFullScreenWindowMask)) {
+ target_fullscreen_state_ = true;
tapted 2015/05/13 06:12:42 it feels fragile to update target_fullscreen_state
jackhou1 2015/05/13 06:53:10 By bringing back the willUseFullScreenContentSize,
+ OnSizeConstraintsChanged();
+ }
[window_ toggleFullScreen:nil];
- [window_ setCollectionBehavior:behavior];
}
void BridgedNativeWidget::OnSizeChanged() {
@@ -522,6 +532,15 @@ void BridgedNativeWidget::OnWindowKeyStatusChangedTo(bool is_key) {
void BridgedNativeWidget::OnSizeConstraintsChanged() {
NSWindow* window = ns_window();
+
+ // If entering or in fullscreen, remove size constraints so that the window
+ // fills the screen, and show fullscreen controls so the user can leave.
+ if (target_fullscreen_state_) {
tapted 2015/05/13 06:12:42 I think just (at the start, with an appropriate co
jackhou1 2015/05/13 06:53:10 Done.
+ gfx::ApplyNSWindowSizeConstraints(window, gfx::Size(), gfx::Size(), true,
+ true);
+ return;
+ }
+
Widget* widget = native_widget_mac()->GetWidget();
gfx::Size min_size = widget->GetMinimumSize();
gfx::Size max_size = widget->GetMaximumSize();
« no previous file with comments | « ui/base/ui_base.gyp ('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