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

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: Add comments Created 5 years, 8 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
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,

Powered by Google App Engine
This is Rietveld 408576698