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

Unified Diff: chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm

Issue 10823195: Draggable region support for frameless app window on Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedback Created 8 years, 4 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
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm b/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm
index b76391fa12801da1d4cf4989258b1813e6878007..b9b00f1140e93da8c5b1934dc75969961da95105 100644
--- a/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm
@@ -139,18 +139,6 @@ ShellWindowCocoa::ShellWindowCocoa(Profile* profile,
NSView* view = web_contents()->GetView()->GetNativeView();
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
- if (!has_frame_) {
- // TODO(jeremya): this is a temporary hack to allow moving the window while
- // we still don't have proper draggable region support.
- NSView* controlRegion = [[ControlRegionView alloc] init];
- [controlRegion setFrame:NSMakeRect(0, 0, NSWidth([view bounds]),
- NSHeight([view bounds]) - 20)];
- [controlRegion setAutoresizingMask:
- NSViewWidthSizable | NSViewHeightSizable];
- [view addSubview:controlRegion];
- [controlRegion release];
- }
-
InstallView();
[[window_controller_ window] setDelegate:window_controller_];
@@ -176,6 +164,8 @@ void ShellWindowCocoa::InstallView() {
[[window() standardWindowButton:NSWindowZoomButton] setHidden:YES];
[[window() standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
[[window() standardWindowButton:NSWindowCloseButton] setHidden:YES];
+
+ InstallDraggableRegionViews();
}
}
@@ -339,6 +329,53 @@ void ShellWindowCocoa::SetBounds(const gfx::Rect& bounds) {
[window() setFrame:cocoa_bounds display:YES];
}
+void ShellWindowCocoa::UpdateDraggableRegions(
+ const std::vector<extensions::DraggableRegion>& regions) {
+ // Draggable region is not supported for non-frameless window.
+ if (has_frame_)
+ return;
+
+ draggable_regions_ = regions;
+ InstallDraggableRegionViews();
+}
+
+void ShellWindowCocoa::InstallDraggableRegionViews() {
+ DCHECK(!has_frame_);
+
+ // All ControlRegionViews should be added as children of the WebContentsView,
+ // because WebContentsView will be removed and re-added when entering and
+ // leaving fullscreen mode.
+ NSView* contentView = web_contents()->GetView()->GetNativeView();
jeremya 2012/08/09 00:16:44 nit: perhaps call this webView to avoid confusion
jianli 2012/08/09 00:29:27 Done.
+ int contentHeight = NSHeight([contentView bounds]);
+
+ // Remove all ControlRegionViews that are added last time.
+ // Note that we need to copy subviews because [contentView subviews] returns
+ // the view's mutable internal array and we do not want to mutate the array
+ // while enumerating it.
+ NSArray* subviews = [[contentView subviews] copy];
+ for (NSView* subview in subviews) {
+ if ([subview isKindOfClass:[ControlRegionView class]]) {
+ [subview setHidden:YES];
jeremya 2012/08/09 00:16:44 curious: why do we need to setHidden here?
jianli 2012/08/09 00:29:27 Some sample code uses it before removing the view.
+ [subview removeFromSuperview];
+ }
+ }
+ [subviews release];
+
+ // Create and add ControlRegionView for each region that needs to be excluded
+ // from the dragging.
+ for (std::vector<extensions::DraggableRegion>::const_iterator iter =
+ draggable_regions_.begin();
+ iter != draggable_regions_.end(); ++iter) {
+ const extensions::DraggableRegion& region = *iter;
+ scoped_nsobject<NSView> controlRegion([[ControlRegionView alloc] init]);
+ [controlRegion setFrame:NSMakeRect(region.bounds.x(),
+ contentHeight - region.bounds.bottom(),
+ region.bounds.width(),
+ region.bounds.height())];
+ [contentView addSubview:controlRegion];
+ }
+}
+
void ShellWindowCocoa::FlashFrame(bool flash) {
if (flash) {
attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest];
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698