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

Side by Side Diff: chrome/browser/ui/panels/panel_window_controller_cocoa.mm

Issue 9546001: Support detaching/attaching panels via inter-strip drags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch to land Created 8 years, 9 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
« no previous file with comments | « chrome/browser/ui/panels/panel_window_controller_cocoa.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/panels/panel_window_controller_cocoa.h" 5 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/bundle_locations.h" 10 #include "base/mac/bundle_locations.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 @implementation PanelWindowControllerCocoa 75 @implementation PanelWindowControllerCocoa
76 76
77 - (id)initWithBrowserWindow:(PanelBrowserWindowCocoa*)window { 77 - (id)initWithBrowserWindow:(PanelBrowserWindowCocoa*)window {
78 NSString* nibpath = 78 NSString* nibpath =
79 [base::mac::FrameworkBundle() pathForResource:@"Panel" ofType:@"nib"]; 79 [base::mac::FrameworkBundle() pathForResource:@"Panel" ofType:@"nib"];
80 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { 80 if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
81 windowShim_.reset(window); 81 windowShim_.reset(window);
82 animateOnBoundsChange_ = YES; 82 animateOnBoundsChange_ = YES;
83 canBecomeKeyWindow_ = YES; 83 canBecomeKeyWindow_ = YES;
84 alwaysOnTop_ = YES;
84 } 85 }
85 contentsController_.reset( 86 contentsController_.reset(
86 [[TabContentsController alloc] initWithContents:nil]); 87 [[TabContentsController alloc] initWithContents:nil]);
87 return self; 88 return self;
88 } 89 }
89 90
90 - (void)dealloc { 91 - (void)dealloc {
91 if (windowTrackingArea_.get()) { 92 if (windowTrackingArea_.get()) {
92 [[[[self window] contentView] superview] 93 [[[[self window] contentView] superview]
93 removeTrackingArea:windowTrackingArea_.get()]; 94 removeTrackingArea:windowTrackingArea_.get()];
(...skipping 17 matching lines...) Expand all
111 return [BrowserWindowUtils themePatternPhaseFor:windowView withTabStrip:nil]; 112 return [BrowserWindowUtils themePatternPhaseFor:windowView withTabStrip:nil];
112 } 113 }
113 114
114 - (void)awakeFromNib { 115 - (void)awakeFromNib {
115 NSWindow* window = [self window]; 116 NSWindow* window = [self window];
116 117
117 DCHECK(window); 118 DCHECK(window);
118 DCHECK(titlebar_view_); 119 DCHECK(titlebar_view_);
119 DCHECK_EQ(self, [window delegate]); 120 DCHECK_EQ(self, [window delegate]);
120 121
121 if (!windowShim_->panel()->manager()->is_full_screen()) 122 [self updateWindowLevel];
122 [window setLevel:NSStatusWindowLevel];
123 123
124 if (base::mac::IsOSSnowLeopardOrLater()) { 124 if (base::mac::IsOSSnowLeopardOrLater()) {
125 [window setCollectionBehavior: 125 [window setCollectionBehavior:
126 NSWindowCollectionBehaviorParticipatesInCycle]; 126 NSWindowCollectionBehaviorParticipatesInCycle];
127 } 127 }
128 128
129 [titlebar_view_ attach]; 129 [titlebar_view_ attach];
130 130
131 // Set initial size of the window to match the size of the panel to give 131 // Set initial size of the window to match the size of the panel to give
132 // the renderer the proper size to work with earlier, avoiding a resize 132 // the renderer the proper size to work with earlier, avoiding a resize
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 browser_window->Activate(); 630 browser_window->Activate();
631 else 631 else
632 [NSApp deactivate]; 632 [NSApp deactivate];
633 } 633 }
634 634
635 - (void)preventBecomingKeyWindow:(BOOL)prevent { 635 - (void)preventBecomingKeyWindow:(BOOL)prevent {
636 canBecomeKeyWindow_ = !prevent; 636 canBecomeKeyWindow_ = !prevent;
637 } 637 }
638 638
639 - (void)fullScreenModeChanged:(bool)isFullScreen { 639 - (void)fullScreenModeChanged:(bool)isFullScreen {
640 NSWindow* window = [self window]; 640 [self updateWindowLevel];
641 [window setLevel:(isFullScreen ? NSNormalWindowLevel : NSStatusWindowLevel)];
642 } 641 }
643 642
644 - (BOOL)canBecomeKeyWindow { 643 - (BOOL)canBecomeKeyWindow {
645 // Panel can only gain focus if it is expanded. Minimized panels do not 644 // Panel can only gain focus if it is expanded. Minimized panels do not
646 // participate in Cmd-~ rotation. 645 // participate in Cmd-~ rotation.
647 // TODO(dimich): If it will be ever desired to expand/focus the Panel on 646 // TODO(dimich): If it will be ever desired to expand/focus the Panel on
648 // keyboard navigation or via main menu, the care should be taken to avoid 647 // keyboard navigation or via main menu, the care should be taken to avoid
649 // cases when minimized Panel is getting keyboard input, invisibly. 648 // cases when minimized Panel is getting keyboard input, invisibly.
650 return canBecomeKeyWindow_; 649 return canBecomeKeyWindow_;
651 } 650 }
652 651
652 - (void)setAlwaysOnTop:(bool)onTop {
653 if (alwaysOnTop_ == onTop)
654 return;
655 alwaysOnTop_ = onTop;
656 [self updateWindowLevel];
657 }
658
659 - (void)updateWindowLevel {
660 if (![self isWindowLoaded])
661 return;
662 BOOL onTop = alwaysOnTop_ &&
663 !windowShim_->panel()->manager()->is_full_screen();
664 [[self window] setLevel:(onTop ? NSStatusWindowLevel : NSNormalWindowLevel)];
665 }
653 @end 666 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_window_controller_cocoa.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698