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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" 5 #include "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h"
6 6
7 #include "apps/app_shim/extension_app_shim_handler_mac.h" 7 #include "apps/app_shim/extension_app_shim_handler_mac.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 - (void)mouseDragged:(NSEvent*)event { 258 - (void)mouseDragged:(NSEvent*)event {
259 appWindow_->HandleMouseEvent(event); 259 appWindow_->HandleMouseEvent(event);
260 } 260 }
261 261
262 @end 262 @end
263 263
264 @interface NSView (WebContentsView) 264 @interface NSView (WebContentsView)
265 - (void)setMouseDownCanMoveWindow:(BOOL)can_move; 265 - (void)setMouseDownCanMoveWindow:(BOOL)can_move;
266 @end 266 @end
267 267
268 namespace {
269
270 const NSInteger kAlwaysOnTopWindowLevel = NSFloatingWindowLevel;
271
272 } // namespace
273
268 NativeAppWindowCocoa::NativeAppWindowCocoa( 274 NativeAppWindowCocoa::NativeAppWindowCocoa(
269 ShellWindow* shell_window, 275 ShellWindow* shell_window,
270 const ShellWindow::CreateParams& params) 276 const ShellWindow::CreateParams& params)
271 : shell_window_(shell_window), 277 : shell_window_(shell_window),
272 has_frame_(params.frame == ShellWindow::FRAME_CHROME), 278 has_frame_(params.frame == ShellWindow::FRAME_CHROME),
273 is_hidden_(false), 279 is_hidden_(false),
274 is_hidden_with_app_(false), 280 is_hidden_with_app_(false),
275 is_maximized_(false), 281 is_maximized_(false),
276 is_fullscreen_(false), 282 is_fullscreen_(false),
277 attention_request_id_(0), 283 attention_request_id_(0),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 if (IsBoundedSize(max_size_)) { 333 if (IsBoundedSize(max_size_)) {
328 CGFloat max_width = max_size_.width() ? max_size_.width() : CGFLOAT_MAX; 334 CGFloat max_width = max_size_.width() ? max_size_.width() : CGFLOAT_MAX;
329 CGFloat max_height = max_size_.height() ? max_size_.height() : CGFLOAT_MAX; 335 CGFloat max_height = max_size_.height() ? max_size_.height() : CGFLOAT_MAX;
330 [window setContentMaxSize:NSMakeSize(max_width, max_height)]; 336 [window setContentMaxSize:NSMakeSize(max_width, max_height)];
331 } 337 }
332 338
333 if (base::mac::IsOSSnowLeopard() && 339 if (base::mac::IsOSSnowLeopard() &&
334 [window respondsToSelector:@selector(setBottomCornerRounded:)]) 340 [window respondsToSelector:@selector(setBottomCornerRounded:)])
335 [window setBottomCornerRounded:NO]; 341 [window setBottomCornerRounded:NO];
336 342
343 if (params.always_on_top)
344 [window setLevel:kAlwaysOnTopWindowLevel];
345
337 // Set the window to participate in Lion Fullscreen mode. Setting this flag 346 // Set the window to participate in Lion Fullscreen mode. Setting this flag
338 // has no effect on Snow Leopard or earlier. UI controls for fullscreen are 347 // has no effect on Snow Leopard or earlier. UI controls for fullscreen are
339 // only shown for apps that have unbounded size. 348 // only shown for apps that have unbounded size.
340 if (shows_fullscreen_controls_) 349 if (shows_fullscreen_controls_)
341 SetFullScreenCollectionBehavior(window, true); 350 SetFullScreenCollectionBehavior(window, true);
342 351
343 window_controller_.reset( 352 window_controller_.reset(
344 [[NativeAppWindowController alloc] initWithWindow:window.release()]); 353 [[NativeAppWindowController alloc] initWithWindow:window.release()]);
345 354
346 NSView* view = web_contents()->GetView()->GetNativeView(); 355 NSView* view = web_contents()->GetView()->GetNativeView();
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 void NativeAppWindowCocoa::FlashFrame(bool flash) { 809 void NativeAppWindowCocoa::FlashFrame(bool flash) {
801 if (flash) { 810 if (flash) {
802 attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest]; 811 attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest];
803 } else { 812 } else {
804 [NSApp cancelUserAttentionRequest:attention_request_id_]; 813 [NSApp cancelUserAttentionRequest:attention_request_id_];
805 attention_request_id_ = 0; 814 attention_request_id_ = 0;
806 } 815 }
807 } 816 }
808 817
809 bool NativeAppWindowCocoa::IsAlwaysOnTop() const { 818 bool NativeAppWindowCocoa::IsAlwaysOnTop() const {
810 return false; 819 return [window() level] == kAlwaysOnTopWindowLevel;
811 } 820 }
812 821
813 void NativeAppWindowCocoa::RenderViewHostChanged( 822 void NativeAppWindowCocoa::RenderViewHostChanged(
814 content::RenderViewHost* old_host, 823 content::RenderViewHost* old_host,
815 content::RenderViewHost* new_host) { 824 content::RenderViewHost* new_host) {
816 web_contents()->GetView()->Focus(); 825 web_contents()->GetView()->Focus();
817 } 826 }
818 827
819 gfx::Insets NativeAppWindowCocoa::GetFrameInsets() const { 828 gfx::Insets NativeAppWindowCocoa::GetFrameInsets() const {
820 if (!has_frame_) 829 if (!has_frame_)
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 is_hidden_with_app_ = true; 979 is_hidden_with_app_ = true;
971 HideWithoutMarkingHidden(); 980 HideWithoutMarkingHidden();
972 } 981 }
973 982
974 void NativeAppWindowCocoa::ShowWithApp() { 983 void NativeAppWindowCocoa::ShowWithApp() {
975 is_hidden_with_app_ = false; 984 is_hidden_with_app_ = false;
976 if (!is_hidden_) 985 if (!is_hidden_)
977 ShowInactive(); 986 ShowInactive();
978 } 987 }
979 988
989 void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) {
990 [window() setLevel:(always_on_top ? kAlwaysOnTopWindowLevel :
991 NSNormalWindowLevel)];
992 shell_window_->OnNativeWindowChanged();
993 }
994
980 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { 995 void NativeAppWindowCocoa::HideWithoutMarkingHidden() {
981 [window() orderOut:window_controller_]; 996 [window() orderOut:window_controller_];
982 } 997 }
983 998
984 NativeAppWindowCocoa::~NativeAppWindowCocoa() { 999 NativeAppWindowCocoa::~NativeAppWindowCocoa() {
985 } 1000 }
986 1001
987 ShellNSWindow* NativeAppWindowCocoa::window() const { 1002 ShellNSWindow* NativeAppWindowCocoa::window() const {
988 NSWindow* window = [window_controller_ window]; 1003 NSWindow* window = [window_controller_ window];
989 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); 1004 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]);
990 return static_cast<ShellNSWindow*>(window); 1005 return static_cast<ShellNSWindow*>(window);
991 } 1006 }
992 1007
993 void NativeAppWindowCocoa::UpdateRestoredBounds() { 1008 void NativeAppWindowCocoa::UpdateRestoredBounds() {
994 if (IsRestored(*this)) 1009 if (IsRestored(*this))
995 restored_bounds_ = [window() frame]; 1010 restored_bounds_ = [window() frame];
996 } 1011 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698