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

Side by Side Diff: chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm

Issue 469993003: Add AppWindow.setVisibleOnAllWorkspaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize AppWindow::CreateParams::visible_on_all_workspaces. Created 6 years, 3 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 | Annotate | Revision Log
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/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 void SetFullScreenCollectionBehavior(NSWindow* window, bool allow_fullscreen) { 54 void SetFullScreenCollectionBehavior(NSWindow* window, bool allow_fullscreen) {
55 NSWindowCollectionBehavior behavior = [window collectionBehavior]; 55 NSWindowCollectionBehavior behavior = [window collectionBehavior];
56 if (allow_fullscreen) 56 if (allow_fullscreen)
57 behavior |= NSWindowCollectionBehaviorFullScreenPrimary; 57 behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
58 else 58 else
59 behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary; 59 behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
60 [window setCollectionBehavior:behavior]; 60 [window setCollectionBehavior:behavior];
61 } 61 }
62 62
63 void SetWorkspacesCollectionBehavior(NSWindow* window, bool always_visible) {
64 NSWindowCollectionBehavior behavior = [window collectionBehavior];
65 if (always_visible)
66 behavior |= NSWindowCollectionBehaviorCanJoinAllSpaces;
67 else
68 behavior &= ~NSWindowCollectionBehaviorCanJoinAllSpaces;
69 [window setCollectionBehavior:behavior];
70 }
71
63 void InitCollectionBehavior(NSWindow* window) { 72 void InitCollectionBehavior(NSWindow* window) {
64 // Since always-on-top windows have a higher window level 73 // Since always-on-top windows have a higher window level
65 // than NSNormalWindowLevel, they will default to 74 // than NSNormalWindowLevel, they will default to
66 // NSWindowCollectionBehaviorTransient. Set the value 75 // NSWindowCollectionBehaviorTransient. Set the value
67 // explicitly here to match normal windows. 76 // explicitly here to match normal windows.
68 NSWindowCollectionBehavior behavior = [window collectionBehavior]; 77 NSWindowCollectionBehavior behavior = [window collectionBehavior];
69 behavior |= NSWindowCollectionBehaviorManaged; 78 behavior |= NSWindowCollectionBehaviorManaged;
70 [window setCollectionBehavior:behavior]; 79 [window setCollectionBehavior:behavior];
71 } 80 }
72 81
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 381 }
373 382
374 if (base::mac::IsOSSnowLeopard() && 383 if (base::mac::IsOSSnowLeopard() &&
375 [window respondsToSelector:@selector(setBottomCornerRounded:)]) 384 [window respondsToSelector:@selector(setBottomCornerRounded:)])
376 [window setBottomCornerRounded:NO]; 385 [window setBottomCornerRounded:NO];
377 386
378 if (params.always_on_top) 387 if (params.always_on_top)
379 [window setLevel:AlwaysOnTopWindowLevel()]; 388 [window setLevel:AlwaysOnTopWindowLevel()];
380 InitCollectionBehavior(window); 389 InitCollectionBehavior(window);
381 390
391 SetWorkspacesCollectionBehavior(window, params.visible_on_all_workspaces);
392
382 window_controller_.reset( 393 window_controller_.reset(
383 [[NativeAppWindowController alloc] initWithWindow:window.release()]); 394 [[NativeAppWindowController alloc] initWithWindow:window.release()]);
384 395
385 NSView* view = WebContents()->GetNativeView(); 396 NSView* view = WebContents()->GetNativeView();
386 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; 397 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
387 398
388 InstallView(); 399 InstallView();
389 400
390 [[window_controller_ window] setDelegate:window_controller_]; 401 [[window_controller_ window] setDelegate:window_controller_];
391 [window_controller_ setAppWindow:this]; 402 [window_controller_ setAppWindow:this];
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 [[window() standardWindowButton:NSWindowZoomButton] 971 [[window() standardWindowButton:NSWindowZoomButton]
961 setEnabled:shows_fullscreen_controls_]; 972 setEnabled:shows_fullscreen_controls_];
962 } 973 }
963 } 974 }
964 975
965 void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) { 976 void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) {
966 [window() setLevel:(always_on_top ? AlwaysOnTopWindowLevel() : 977 [window() setLevel:(always_on_top ? AlwaysOnTopWindowLevel() :
967 NSNormalWindowLevel)]; 978 NSNormalWindowLevel)];
968 } 979 }
969 980
981 void NativeAppWindowCocoa::SetVisibleOnAllWorkspaces(bool always_visible) {
982 SetWorkspacesCollectionBehavior(window(), always_visible);
983 }
984
970 NativeAppWindowCocoa::~NativeAppWindowCocoa() { 985 NativeAppWindowCocoa::~NativeAppWindowCocoa() {
971 } 986 }
972 987
973 ShellNSWindow* NativeAppWindowCocoa::window() const { 988 ShellNSWindow* NativeAppWindowCocoa::window() const {
974 NSWindow* window = [window_controller_ window]; 989 NSWindow* window = [window_controller_ window];
975 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); 990 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]);
976 return static_cast<ShellNSWindow*>(window); 991 return static_cast<ShellNSWindow*>(window);
977 } 992 }
978 993
979 content::WebContents* NativeAppWindowCocoa::WebContents() const { 994 content::WebContents* NativeAppWindowCocoa::WebContents() const {
980 return app_window_->web_contents(); 995 return app_window_->web_contents();
981 } 996 }
982 997
983 void NativeAppWindowCocoa::UpdateRestoredBounds() { 998 void NativeAppWindowCocoa::UpdateRestoredBounds() {
984 if (IsRestored(*this)) 999 if (IsRestored(*this))
985 restored_bounds_ = [window() frame]; 1000 restored_bounds_ = [window() frame];
986 } 1001 }
987 1002
988 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { 1003 void NativeAppWindowCocoa::HideWithoutMarkingHidden() {
989 [window() orderOut:window_controller_]; 1004 [window() orderOut:window_controller_];
990 } 1005 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h ('k') | chrome/browser/ui/views/apps/chrome_native_app_window_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698