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

Unified Diff: chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm

Issue 1023083002: [MacViews] Implement size constraints for app windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update ui/gfx/BUILD.gn Created 5 years, 9 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 | « no previous file | chrome/browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
index 95b1c8ac900bae6ce19b795c0208eccda0e1638c..6744a8c5f72f47755778e020293f83aaa21bcf0c 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
@@ -22,6 +22,7 @@
#include "extensions/common/extension.h"
#include "skia/ext/skia_utils_mac.h"
#include "third_party/skia/include/core/SkRegion.h"
+#import "ui/gfx/mac/nswindow_frame_controls.h"
#include "ui/gfx/skia_util.h"
// NOTE: State Before Update.
@@ -50,15 +51,6 @@ using extensions::AppWindow;
namespace {
-void SetFullScreenCollectionBehavior(NSWindow* window, bool allow_fullscreen) {
- NSWindowCollectionBehavior behavior = [window collectionBehavior];
- if (allow_fullscreen)
- behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
- else
- behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
- [window setCollectionBehavior:behavior];
-}
-
void SetWorkspacesCollectionBehavior(NSWindow* window, bool always_visible) {
NSWindowCollectionBehavior behavior = [window collectionBehavior];
if (always_visible)
@@ -472,7 +464,7 @@ void NativeAppWindowCocoa::SetFullscreen(int fullscreen_types) {
// is disabled), temporarily enable it. It will be disabled again on leaving
// fullscreen.
if (fullscreen && !shows_fullscreen_controls_)
- SetFullScreenCollectionBehavior(window(), true);
+ gfx::SetNSWindowCanFullscreen(window(), true);
[window() toggleFullScreen:nil];
return;
}
@@ -871,7 +863,7 @@ void NativeAppWindowCocoa::WindowDidEnterFullscreen() {
void NativeAppWindowCocoa::WindowDidExitFullscreen() {
is_fullscreen_ = false;
if (!shows_fullscreen_controls_)
- SetFullScreenCollectionBehavior(window(), false);
+ gfx::SetNSWindowCanFullscreen(window(), false);
app_window_->Restore();
app_window_->OnNativeWindowChanged();
@@ -922,39 +914,15 @@ void NativeAppWindowCocoa::SetContentSizeConstraints(
size_constraints_.set_minimum_size(min_size);
size_constraints_.set_maximum_size(max_size);
- gfx::Size minimum_size = size_constraints_.GetMinimumSize();
- [window() setContentMinSize:NSMakeSize(minimum_size.width(),
- minimum_size.height())];
-
- gfx::Size maximum_size = size_constraints_.GetMaximumSize();
- const int kUnboundedSize = extensions::SizeConstraints::kUnboundedSize;
- CGFloat max_width = maximum_size.width() == kUnboundedSize ?
- CGFLOAT_MAX : maximum_size.width();
- CGFloat max_height = maximum_size.height() == kUnboundedSize ?
- CGFLOAT_MAX : maximum_size.height();
- [window() setContentMaxSize:NSMakeSize(max_width, max_height)];
-
// Update the window controls.
shows_resize_controls_ =
is_resizable_ && !size_constraints_.HasFixedSize();
shows_fullscreen_controls_ =
is_resizable_ && !size_constraints_.HasMaximumSize() && has_frame_;
- if (!is_fullscreen_) {
- [window() setStyleMask:GetWindowStyleMask()];
-
- // Set the window to participate in Lion Fullscreen mode. Setting this flag
- // has no effect on Snow Leopard or earlier. UI controls for fullscreen are
- // only shown for apps that have unbounded size.
- if (base::mac::IsOSLionOrLater())
- SetFullScreenCollectionBehavior(window(), shows_fullscreen_controls_);
- }
-
- if (has_frame_) {
- [window() setShowsResizeIndicator:shows_resize_controls_];
- [[window() standardWindowButton:NSWindowZoomButton]
- setEnabled:shows_fullscreen_controls_];
- }
+ gfx::ApplyNSWindowSizeConstraints(window(), min_size, max_size,
+ shows_resize_controls_,
+ shows_fullscreen_controls_);
}
void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) {
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698