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

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

Issue 1105613002: [MacViews] Implement AlwaysOnTop and VisibleOnAllWorkspaces. (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 | « no previous file | ui/gfx/mac/nswindow_frame_controls.h » ('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 e823f1903b4ef27fc5c72236a2a54173c97dc7aa..acf1de75fa284ceffef6be8c336c91dbfd587fef 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
@@ -51,32 +51,6 @@ using extensions::AppWindow;
namespace {
-void SetWorkspacesCollectionBehavior(NSWindow* window, bool always_visible) {
- NSWindowCollectionBehavior behavior = [window collectionBehavior];
- if (always_visible)
- behavior |= NSWindowCollectionBehaviorCanJoinAllSpaces;
- else
- behavior &= ~NSWindowCollectionBehaviorCanJoinAllSpaces;
- [window setCollectionBehavior:behavior];
-}
-
-void InitCollectionBehavior(NSWindow* window) {
- // Since always-on-top windows have a higher window level
- // than NSNormalWindowLevel, they will default to
- // NSWindowCollectionBehaviorTransient. Set the value
- // explicitly here to match normal windows.
- NSWindowCollectionBehavior behavior = [window collectionBehavior];
- behavior |= NSWindowCollectionBehaviorManaged;
- [window setCollectionBehavior:behavior];
-}
-
-// Returns the level for windows that are configured to be always on top.
-// This is not a constant because NSFloatingWindowLevel is a macro defined
-// as a function call.
-NSInteger AlwaysOnTopWindowLevel() {
- return NSFloatingWindowLevel;
-}
-
NSRect GfxToCocoaBounds(gfx::Rect bounds) {
typedef AppWindow::BoundsSpecification BoundsSpecification;
@@ -358,10 +332,10 @@ NativeAppWindowCocoa::NativeAppWindowCocoa(
[window setBottomCornerRounded:NO];
if (params.always_on_top)
- [window setLevel:AlwaysOnTopWindowLevel()];
- InitCollectionBehavior(window);
+ gfx::SetNSWindowAlwaysOnTop(window, true);
- SetWorkspacesCollectionBehavior(window, params.visible_on_all_workspaces);
+ gfx::SetNSWindowVisibleOnAllWorkspaces(window,
+ params.visible_on_all_workspaces);
window_controller_.reset(
[[NativeAppWindowController alloc] initWithWindow:window.release()]);
@@ -709,7 +683,7 @@ void NativeAppWindowCocoa::FlashFrame(bool flash) {
}
bool NativeAppWindowCocoa::IsAlwaysOnTop() const {
- return [window() level] == AlwaysOnTopWindowLevel();
+ return gfx::IsNSWindowAlwaysOnTop(window());
}
void NativeAppWindowCocoa::RenderViewCreated(content::RenderViewHost* rvh) {
@@ -923,12 +897,11 @@ void NativeAppWindowCocoa::SetContentSizeConstraints(
}
void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) {
- [window() setLevel:(always_on_top ? AlwaysOnTopWindowLevel() :
- NSNormalWindowLevel)];
+ gfx::SetNSWindowAlwaysOnTop(window(), always_on_top);
}
void NativeAppWindowCocoa::SetVisibleOnAllWorkspaces(bool always_visible) {
- SetWorkspacesCollectionBehavior(window(), always_visible);
+ gfx::SetNSWindowVisibleOnAllWorkspaces(window(), always_visible);
}
void NativeAppWindowCocoa::SetInterceptAllKeys(bool want_all_key) {
« no previous file with comments | « no previous file | ui/gfx/mac/nswindow_frame_controls.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698