OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/widget/native_widget_mac.h" | 5 #include "ui/views/widget/native_widget_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 [window setTitle:new_title]; | 244 [window setTitle:new_title]; |
245 return true; | 245 return true; |
246 } | 246 } |
247 | 247 |
248 void NativeWidgetMac::SetWindowIcons(const gfx::ImageSkia& window_icon, | 248 void NativeWidgetMac::SetWindowIcons(const gfx::ImageSkia& window_icon, |
249 const gfx::ImageSkia& app_icon) { | 249 const gfx::ImageSkia& app_icon) { |
250 NOTIMPLEMENTED(); | 250 NOTIMPLEMENTED(); |
251 } | 251 } |
252 | 252 |
253 void NativeWidgetMac::InitModalType(ui::ModalType modal_type) { | 253 void NativeWidgetMac::InitModalType(ui::ModalType modal_type) { |
254 NOTIMPLEMENTED(); | 254 if (modal_type == ui::MODAL_TYPE_NONE) |
| 255 return; |
| 256 |
| 257 // System modal windows not implemented (or used) on Mac. |
| 258 DCHECK_NE(ui::MODAL_TYPE_SYSTEM, modal_type); |
| 259 DCHECK(bridge_->parent()); |
| 260 // Everyhing happens upon show. |
255 } | 261 } |
256 | 262 |
257 gfx::Rect NativeWidgetMac::GetWindowBoundsInScreen() const { | 263 gfx::Rect NativeWidgetMac::GetWindowBoundsInScreen() const { |
258 return gfx::ScreenRectFromNSRect([GetNativeWindow() frame]); | 264 return gfx::ScreenRectFromNSRect([GetNativeWindow() frame]); |
259 } | 265 } |
260 | 266 |
261 gfx::Rect NativeWidgetMac::GetClientAreaBoundsInScreen() const { | 267 gfx::Rect NativeWidgetMac::GetClientAreaBoundsInScreen() const { |
262 NSWindow* window = GetNativeWindow(); | 268 NSWindow* window = GetNativeWindow(); |
263 return gfx::ScreenRectFromNSRect( | 269 return gfx::ScreenRectFromNSRect( |
264 [window contentRectForFrameRect:[window frame]]); | 270 [window contentRectForFrameRect:[window frame]]); |
(...skipping 27 matching lines...) Expand all Loading... |
292 } | 298 } |
293 | 299 |
294 void NativeWidgetMac::SetShape(gfx::NativeRegion shape) { | 300 void NativeWidgetMac::SetShape(gfx::NativeRegion shape) { |
295 NOTIMPLEMENTED(); | 301 NOTIMPLEMENTED(); |
296 } | 302 } |
297 | 303 |
298 void NativeWidgetMac::Close() { | 304 void NativeWidgetMac::Close() { |
299 if (!bridge_) | 305 if (!bridge_) |
300 return; | 306 return; |
301 | 307 |
| 308 if (delegate_->IsModal()) { |
| 309 // Sheets can't be closed normally. This starts the sheet closing. Once the |
| 310 // sheet has finished animating, it will call sheetDidEnd: on the parent |
| 311 // window's delegate. Note it still needs to be asynchronous, since code |
| 312 // calling Widget::Close() doesn't expect things to be deleted upon return. |
| 313 [NSApp performSelector:@selector(endSheet:) |
| 314 withObject:GetNativeWindow() |
| 315 afterDelay:0]; |
| 316 return; |
| 317 } |
| 318 |
302 // Clear the view early to suppress repaints. | 319 // Clear the view early to suppress repaints. |
303 bridge_->SetRootView(NULL); | 320 bridge_->SetRootView(NULL); |
304 | 321 |
305 NSWindow* window = GetNativeWindow(); | 322 NSWindow* window = GetNativeWindow(); |
306 // Calling performClose: will momentarily highlight the close button, but | 323 // Calling performClose: will momentarily highlight the close button, but |
307 // AppKit will reject it if there is no close button. | 324 // AppKit will reject it if there is no close button. |
308 SEL close_selector = ([window styleMask] & NSClosableWindowMask) | 325 SEL close_selector = ([window styleMask] & NSClosableWindowMask) |
309 ? @selector(performClose:) | 326 ? @selector(performClose:) |
310 : @selector(close); | 327 : @selector(close); |
311 [window performSelector:close_selector withObject:nil afterDelay:0]; | 328 [window performSelector:close_selector withObject:nil afterDelay:0]; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 } | 635 } |
619 | 636 |
620 // static | 637 // static |
621 gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { | 638 gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { |
622 NOTIMPLEMENTED(); | 639 NOTIMPLEMENTED(); |
623 return gfx::FontList(); | 640 return gfx::FontList(); |
624 } | 641 } |
625 | 642 |
626 } // namespace internal | 643 } // namespace internal |
627 } // namespace views | 644 } // namespace views |
OLD | NEW |