Chromium Code Reviews| Index: ui/gfx/mac/nswindow_frame_controls.mm |
| diff --git a/ui/gfx/mac/nswindow_frame_controls.mm b/ui/gfx/mac/nswindow_frame_controls.mm |
| index 34f7d266516c823bc53ea6f612eee9dc22446057..b98ef247687e418fcdfa6e3d7223ea8690aa7f8e 100644 |
| --- a/ui/gfx/mac/nswindow_frame_controls.mm |
| +++ b/ui/gfx/mac/nswindow_frame_controls.mm |
| @@ -22,6 +22,13 @@ void SetResizableStyleMask(NSWindow* window, bool resizable) { |
| [window setStyleMask:style_mask]; |
| } |
| +// 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; |
| +} |
| + |
| } // namespace |
| namespace gfx { |
| @@ -35,6 +42,35 @@ void SetNSWindowCanFullscreen(NSWindow* window, bool allow_fullscreen) { |
| [window setCollectionBehavior:behavior]; |
| } |
| +bool IsNSWindowAlwaysOnTop(NSWindow* window) { |
| + return [window level] == AlwaysOnTopWindowLevel(); |
| +} |
| + |
| +void SetNSWindowAlwaysOnTop(NSWindow* window, |
| + bool always_on_top, |
| + bool transient) { |
| + [window setLevel:(always_on_top ? AlwaysOnTopWindowLevel() |
| + : NSNormalWindowLevel)]; |
| + // 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. |
| + if (!transient) { |
|
jackhou1
2015/04/24 07:04:24
The call from NativeWidgetMac::AlwaysOnTop should
tapted
2015/05/06 02:00:19
I would assume transient is always false (i.e. dro
jackhou1
2015/05/12 01:42:12
Done.
|
| + NSWindowCollectionBehavior behavior = |
| + [window collectionBehavior] | NSWindowCollectionBehaviorManaged; |
| + [window setCollectionBehavior:behavior]; |
| + } |
| +} |
| + |
| +void SetNSWindowVisibleOnAllWorkspaces(NSWindow* window, bool always_visible) { |
| + NSWindowCollectionBehavior behavior = [window collectionBehavior]; |
| + if (always_visible) |
| + behavior |= NSWindowCollectionBehaviorCanJoinAllSpaces; |
| + else |
| + behavior &= ~NSWindowCollectionBehaviorCanJoinAllSpaces; |
| + [window setCollectionBehavior:behavior]; |
| +} |
| + |
| void ApplyNSWindowSizeConstraints(NSWindow* window, |
| const gfx::Size& min_size, |
| const gfx::Size& max_size, |