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" |
11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
12 #import "ui/base/cocoa/window_size_constants.h" | 12 #import "ui/base/cocoa/window_size_constants.h" |
13 #include "ui/gfx/font_list.h" | 13 #include "ui/gfx/font_list.h" |
14 #import "ui/gfx/mac/coordinate_conversion.h" | 14 #import "ui/gfx/mac/coordinate_conversion.h" |
| 15 #import "ui/gfx/mac/nswindow_frame_controls.h" |
15 #include "ui/native_theme/native_theme.h" | 16 #include "ui/native_theme/native_theme.h" |
16 #import "ui/views/cocoa/bridged_content_view.h" | 17 #import "ui/views/cocoa/bridged_content_view.h" |
17 #import "ui/views/cocoa/bridged_native_widget.h" | 18 #import "ui/views/cocoa/bridged_native_widget.h" |
18 #import "ui/views/cocoa/native_widget_mac_nswindow.h" | 19 #import "ui/views/cocoa/native_widget_mac_nswindow.h" |
19 #import "ui/views/cocoa/views_nswindow_delegate.h" | 20 #import "ui/views/cocoa/views_nswindow_delegate.h" |
20 #include "ui/views/window/native_frame_view.h" | 21 #include "ui/views/window/native_frame_view.h" |
21 | 22 |
22 namespace views { | 23 namespace views { |
23 namespace { | 24 namespace { |
24 | 25 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 77 |
77 //////////////////////////////////////////////////////////////////////////////// | 78 //////////////////////////////////////////////////////////////////////////////// |
78 // NativeWidgetMac, internal::NativeWidgetPrivate implementation: | 79 // NativeWidgetMac, internal::NativeWidgetPrivate implementation: |
79 | 80 |
80 void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) { | 81 void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) { |
81 ownership_ = params.ownership; | 82 ownership_ = params.ownership; |
82 base::scoped_nsobject<NSWindow> window([CreateNSWindow(params) retain]); | 83 base::scoped_nsobject<NSWindow> window([CreateNSWindow(params) retain]); |
83 [window setReleasedWhenClosed:NO]; // Owned by scoped_nsobject. | 84 [window setReleasedWhenClosed:NO]; // Owned by scoped_nsobject. |
84 bridge_->Init(window, params); | 85 bridge_->Init(window, params); |
85 | 86 |
| 87 // Only set always-on-top here if it is true since setting it may affect how |
| 88 // the window is treated by Expose. |
| 89 if (params.keep_on_top) |
| 90 SetAlwaysOnTop(true); |
| 91 |
86 delegate_->OnNativeWidgetCreated(true); | 92 delegate_->OnNativeWidgetCreated(true); |
87 | 93 |
88 bridge_->SetFocusManager(GetWidget()->GetFocusManager()); | 94 bridge_->SetFocusManager(GetWidget()->GetFocusManager()); |
89 | 95 |
90 DCHECK(GetWidget()->GetRootView()); | 96 DCHECK(GetWidget()->GetRootView()); |
91 bridge_->SetRootView(GetWidget()->GetRootView()); | 97 bridge_->SetRootView(GetWidget()->GetRootView()); |
92 | 98 |
93 // "Infer" must be handled by ViewsDelegate::OnBeforeWidgetInit(). | 99 // "Infer" must be handled by ViewsDelegate::OnBeforeWidgetInit(). |
94 DCHECK_NE(Widget::InitParams::INFER_OPACITY, params.opacity); | 100 DCHECK_NE(Widget::InitParams::INFER_OPACITY, params.opacity); |
95 bool translucent = params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW; | 101 bool translucent = params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 376 |
371 void NativeWidgetMac::Deactivate() { | 377 void NativeWidgetMac::Deactivate() { |
372 NOTIMPLEMENTED(); | 378 NOTIMPLEMENTED(); |
373 } | 379 } |
374 | 380 |
375 bool NativeWidgetMac::IsActive() const { | 381 bool NativeWidgetMac::IsActive() const { |
376 return [GetNativeWindow() isKeyWindow]; | 382 return [GetNativeWindow() isKeyWindow]; |
377 } | 383 } |
378 | 384 |
379 void NativeWidgetMac::SetAlwaysOnTop(bool always_on_top) { | 385 void NativeWidgetMac::SetAlwaysOnTop(bool always_on_top) { |
380 NOTIMPLEMENTED(); | 386 gfx::SetNSWindowAlwaysOnTop(GetNativeWindow(), always_on_top); |
381 } | 387 } |
382 | 388 |
383 bool NativeWidgetMac::IsAlwaysOnTop() const { | 389 bool NativeWidgetMac::IsAlwaysOnTop() const { |
384 NOTIMPLEMENTED(); | 390 return gfx::IsNSWindowAlwaysOnTop(GetNativeWindow()); |
385 return false; | |
386 } | 391 } |
387 | 392 |
388 void NativeWidgetMac::SetVisibleOnAllWorkspaces(bool always_visible) { | 393 void NativeWidgetMac::SetVisibleOnAllWorkspaces(bool always_visible) { |
389 NOTIMPLEMENTED(); | 394 gfx::SetNSWindowVisibleOnAllWorkspaces(GetNativeWindow(), always_visible); |
390 } | 395 } |
391 | 396 |
392 void NativeWidgetMac::Maximize() { | 397 void NativeWidgetMac::Maximize() { |
393 NOTIMPLEMENTED(); // See IsMaximized(). | 398 NOTIMPLEMENTED(); // See IsMaximized(). |
394 } | 399 } |
395 | 400 |
396 void NativeWidgetMac::Minimize() { | 401 void NativeWidgetMac::Minimize() { |
397 NSWindow* window = GetNativeWindow(); | 402 NSWindow* window = GetNativeWindow(); |
398 // Calling performMiniaturize: will momentarily highlight the button, but | 403 // Calling performMiniaturize: will momentarily highlight the button, but |
399 // AppKit will reject it if there is no miniaturize button. | 404 // AppKit will reject it if there is no miniaturize button. |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 } | 638 } |
634 | 639 |
635 // static | 640 // static |
636 gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { | 641 gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { |
637 NOTIMPLEMENTED(); | 642 NOTIMPLEMENTED(); |
638 return gfx::FontList(); | 643 return gfx::FontList(); |
639 } | 644 } |
640 | 645 |
641 } // namespace internal | 646 } // namespace internal |
642 } // namespace views | 647 } // namespace views |
OLD | NEW |