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

Unified Diff: ui/gfx/mac/nswindow_frame_controls.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 | « ui/gfx/mac/nswindow_frame_controls.h ('k') | ui/views/widget/native_widget_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e1983daa2d25a9c0b7d6def9bcdf6a00b7d32cc3 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,32 @@ 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) {
+ [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.
+ 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,
« no previous file with comments | « ui/gfx/mac/nswindow_frame_controls.h ('k') | ui/views/widget/native_widget_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698