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

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

Issue 26427002: Add always-on-top property to app windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cache state of isAlwaysOnTop in widget. Fixed clobber in x11 window init. Created 7 years, 2 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: 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 e5181a84e0cffab5171f59fdce8eb28275beccce..523db1984df5f3bbedc7ee97c64b1118d54a63ab 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
@@ -265,6 +265,12 @@ void SetFullScreenCollectionBehavior(NSWindow* window, bool allow_fullscreen) {
- (void)setMouseDownCanMoveWindow:(BOOL)can_move;
@end
+namespace {
+
+const NSInteger kAlwaysOnTopWindowLevel = NSFloatingWindowLevel;
+
+} // namespace
+
NativeAppWindowCocoa::NativeAppWindowCocoa(
ShellWindow* shell_window,
const ShellWindow::CreateParams& params)
@@ -334,6 +340,9 @@ NativeAppWindowCocoa::NativeAppWindowCocoa(
[window respondsToSelector:@selector(setBottomCornerRounded:)])
[window setBottomCornerRounded:NO];
+ if (params.always_on_top)
+ [window setLevel:kAlwaysOnTopWindowLevel];
+
// 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.
@@ -807,7 +816,7 @@ void NativeAppWindowCocoa::FlashFrame(bool flash) {
}
bool NativeAppWindowCocoa::IsAlwaysOnTop() const {
- return false;
+ return [window() level] == kAlwaysOnTopWindowLevel;
}
void NativeAppWindowCocoa::RenderViewHostChanged(
@@ -977,6 +986,12 @@ void NativeAppWindowCocoa::ShowWithApp() {
ShowInactive();
}
+void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) {
+ [window() setLevel:(always_on_top ? kAlwaysOnTopWindowLevel :
+ NSNormalWindowLevel)];
+ shell_window_->OnNativeWindowChanged();
+}
+
void NativeAppWindowCocoa::HideWithoutMarkingHidden() {
[window() orderOut:window_controller_];
}

Powered by Google App Engine
This is Rietveld 408576698