gfx::NativeView is no longer NSView on mac
https://chromium-review.googlesource.com/c/1270343
This commit is contained in:
parent
70887ae21a
commit
d228bdfb9e
12 changed files with 78 additions and 53 deletions
|
@ -59,8 +59,9 @@ void BrowserWindow::OverrideNSWindowContentView(InspectableWebContents* iwc) {
|
||||||
// Make NativeWindow use a NSView as content view.
|
// Make NativeWindow use a NSView as content view.
|
||||||
static_cast<NativeWindowMac*>(window())->OverrideNSWindowContentView();
|
static_cast<NativeWindowMac*>(window())->OverrideNSWindowContentView();
|
||||||
// Add webview to contentView.
|
// Add webview to contentView.
|
||||||
NSView* webView = iwc->GetView()->GetNativeView();
|
NSView* webView = iwc->GetView()->GetNativeView().GetNativeNSView();
|
||||||
NSView* contentView = [window()->GetNativeWindow() contentView];
|
NSView* contentView =
|
||||||
|
[window()->GetNativeWindow().GetNativeNSWindow() contentView];
|
||||||
[webView setFrame:[contentView bounds]];
|
[webView setFrame:[contentView bounds]];
|
||||||
|
|
||||||
// ensure that buttons view is floated to top of view hierarchy
|
// ensure that buttons view is floated to top of view hierarchy
|
||||||
|
@ -80,7 +81,7 @@ void BrowserWindow::UpdateDraggableRegions(
|
||||||
// All ControlRegionViews should be added as children of the WebContentsView,
|
// All ControlRegionViews should be added as children of the WebContentsView,
|
||||||
// because WebContentsView will be removed and re-added when entering and
|
// because WebContentsView will be removed and re-added when entering and
|
||||||
// leaving fullscreen mode.
|
// leaving fullscreen mode.
|
||||||
NSView* webView = web_contents()->GetNativeView();
|
NSView* webView = web_contents()->GetNativeView().GetNativeNSView();
|
||||||
NSInteger webViewWidth = NSWidth([webView bounds]);
|
NSInteger webViewWidth = NSWidth([webView bounds]);
|
||||||
NSInteger webViewHeight = NSHeight([webView bounds]);
|
NSInteger webViewHeight = NSHeight([webView bounds]);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||||
base::Closure callback) {
|
base::Closure callback) {
|
||||||
if (!native_window)
|
if (!native_window)
|
||||||
return;
|
return;
|
||||||
NSWindow* nswindow = native_window->GetNativeWindow();
|
NSWindow* nswindow = native_window->GetNativeWindow().GetNativeNSWindow();
|
||||||
|
|
||||||
auto close_callback = base::Bind(
|
auto close_callback = base::Bind(
|
||||||
&MenuMac::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
|
&MenuMac::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
|
||||||
|
|
|
@ -17,7 +17,7 @@ bool WebContents::IsFocused() const {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (GetType() != BACKGROUND_PAGE) {
|
if (GetType() != BACKGROUND_PAGE) {
|
||||||
auto window = [web_contents()->GetNativeView() window];
|
auto window = [web_contents()->GetNativeView().GetNativeNSView() window];
|
||||||
// On Mac the render widget host view does not lose focus when the window
|
// On Mac the render widget host view does not lose focus when the window
|
||||||
// loses focus so check if the top level window is the key window.
|
// loses focus so check if the top level window is the key window.
|
||||||
if (window && ![window isKeyWindow])
|
if (window && ![window isKeyWindow])
|
||||||
|
|
|
@ -325,7 +325,7 @@ std::string Browser::DockGetBadgeText() {
|
||||||
|
|
||||||
void Browser::DockHide() {
|
void Browser::DockHide() {
|
||||||
for (auto* const& window : WindowList::GetWindows())
|
for (auto* const& window : WindowList::GetWindows())
|
||||||
[window->GetNativeWindow() setCanHide:NO];
|
[window->GetNativeWindow().GetNativeNSWindow() setCanHide:NO];
|
||||||
|
|
||||||
ProcessSerialNumber psn = {0, kCurrentProcess};
|
ProcessSerialNumber psn = {0, kCurrentProcess};
|
||||||
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
|
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
|
||||||
|
|
|
@ -160,7 +160,8 @@ namespace atom {
|
||||||
NativeBrowserViewMac::NativeBrowserViewMac(
|
NativeBrowserViewMac::NativeBrowserViewMac(
|
||||||
InspectableWebContents* inspectable_web_contents)
|
InspectableWebContents* inspectable_web_contents)
|
||||||
: NativeBrowserView(inspectable_web_contents) {
|
: NativeBrowserView(inspectable_web_contents) {
|
||||||
auto* view = GetInspectableWebContentsView()->GetNativeView();
|
auto* view =
|
||||||
|
GetInspectableWebContentsView()->GetNativeView().GetNativeNSView();
|
||||||
view.autoresizingMask = kDefaultAutoResizingMask;
|
view.autoresizingMask = kDefaultAutoResizingMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,12 +176,14 @@ void NativeBrowserViewMac::SetAutoResizeFlags(uint8_t flags) {
|
||||||
autoresizing_mask |= NSViewHeightSizable;
|
autoresizing_mask |= NSViewHeightSizable;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* view = GetInspectableWebContentsView()->GetNativeView();
|
auto* view =
|
||||||
|
GetInspectableWebContentsView()->GetNativeView().GetNativeNSView();
|
||||||
view.autoresizingMask = autoresizing_mask;
|
view.autoresizingMask = autoresizing_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeBrowserViewMac::SetBounds(const gfx::Rect& bounds) {
|
void NativeBrowserViewMac::SetBounds(const gfx::Rect& bounds) {
|
||||||
auto* view = GetInspectableWebContentsView()->GetNativeView();
|
auto* view =
|
||||||
|
GetInspectableWebContentsView()->GetNativeView().GetNativeNSView();
|
||||||
auto* superview = view.superview;
|
auto* superview = view.superview;
|
||||||
const auto superview_height = superview ? superview.frame.size.height : 0;
|
const auto superview_height = superview ? superview.frame.size.height : 0;
|
||||||
view.frame =
|
view.frame =
|
||||||
|
@ -189,15 +192,17 @@ void NativeBrowserViewMac::SetBounds(const gfx::Rect& bounds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeBrowserViewMac::SetBackgroundColor(SkColor color) {
|
void NativeBrowserViewMac::SetBackgroundColor(SkColor color) {
|
||||||
auto* view = GetInspectableWebContentsView()->GetNativeView();
|
auto* view =
|
||||||
|
GetInspectableWebContentsView()->GetNativeView().GetNativeNSView();
|
||||||
view.wantsLayer = YES;
|
view.wantsLayer = YES;
|
||||||
view.layer.backgroundColor = skia::CGColorCreateFromSkColor(color);
|
view.layer.backgroundColor = skia::CGColorCreateFromSkColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeBrowserViewMac::UpdateDraggableRegions(
|
void NativeBrowserViewMac::UpdateDraggableRegions(
|
||||||
const std::vector<gfx::Rect>& drag_exclude_rects) {
|
const std::vector<gfx::Rect>& drag_exclude_rects) {
|
||||||
NSView* web_view = GetWebContents()->GetNativeView();
|
NSView* web_view = GetWebContents()->GetNativeView().GetNativeNSView();
|
||||||
NSView* inspectable_view = GetInspectableWebContentsView()->GetNativeView();
|
NSView* inspectable_view =
|
||||||
|
GetInspectableWebContentsView()->GetNativeView().GetNativeNSView();
|
||||||
NSView* window_content_view = inspectable_view.superview;
|
NSView* window_content_view = inspectable_view.superview;
|
||||||
const auto window_content_view_height = NSHeight(window_content_view.bounds);
|
const auto window_content_view_height = NSHeight(window_content_view.bounds);
|
||||||
|
|
||||||
|
|
|
@ -347,7 +347,8 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
||||||
params.type = views::Widget::InitParams::TYPE_WINDOW;
|
params.type = views::Widget::InitParams::TYPE_WINDOW;
|
||||||
params.native_widget = new AtomNativeWidgetMac(this, styleMask, widget());
|
params.native_widget = new AtomNativeWidgetMac(this, styleMask, widget());
|
||||||
widget()->Init(params);
|
widget()->Init(params);
|
||||||
window_ = static_cast<AtomNSWindow*>(widget()->GetNativeWindow());
|
window_ = static_cast<AtomNSWindow*>(
|
||||||
|
widget()->GetNativeWindow().GetNativeNSWindow());
|
||||||
|
|
||||||
[window_ setEnableLargerThanScreen:enable_larger_than_screen()];
|
[window_ setEnableLargerThanScreen:enable_larger_than_screen()];
|
||||||
|
|
||||||
|
@ -497,7 +498,7 @@ void NativeWindowMac::SetContentView(views::View* view) {
|
||||||
void NativeWindowMac::Close() {
|
void NativeWindowMac::Close() {
|
||||||
// When this is a sheet showing, performClose won't work.
|
// When this is a sheet showing, performClose won't work.
|
||||||
if (is_modal() && parent() && IsVisible()) {
|
if (is_modal() && parent() && IsVisible()) {
|
||||||
[parent()->GetNativeWindow() endSheet:window_];
|
[parent()->GetNativeWindow().GetNativeNSWindow() endSheet:window_];
|
||||||
CloseImmediately();
|
CloseImmediately();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -545,9 +546,10 @@ bool NativeWindowMac::IsFocused() {
|
||||||
void NativeWindowMac::Show() {
|
void NativeWindowMac::Show() {
|
||||||
if (is_modal() && parent()) {
|
if (is_modal() && parent()) {
|
||||||
if ([window_ sheetParent] == nil)
|
if ([window_ sheetParent] == nil)
|
||||||
[parent()->GetNativeWindow() beginSheet:window_
|
[parent()->GetNativeWindow().GetNativeNSWindow()
|
||||||
completionHandler:^(NSModalResponse){
|
beginSheet:window_
|
||||||
}];
|
completionHandler:^(NSModalResponse){
|
||||||
|
}];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +575,7 @@ void NativeWindowMac::ShowInactive() {
|
||||||
void NativeWindowMac::Hide() {
|
void NativeWindowMac::Hide() {
|
||||||
if (is_modal() && parent()) {
|
if (is_modal() && parent()) {
|
||||||
[window_ orderOut:nil];
|
[window_ orderOut:nil];
|
||||||
[parent()->GetNativeWindow() endSheet:window_];
|
[parent()->GetNativeWindow().GetNativeNSWindow() endSheet:window_];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,7 +899,7 @@ void NativeWindowMac::FlashFrame(bool flash) {
|
||||||
void NativeWindowMac::SetSkipTaskbar(bool skip) {}
|
void NativeWindowMac::SetSkipTaskbar(bool skip) {}
|
||||||
|
|
||||||
void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
|
void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
|
||||||
NSWindow* window = GetNativeWindow();
|
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
|
||||||
|
|
||||||
if (simple_fullscreen && !is_simple_fullscreen_) {
|
if (simple_fullscreen && !is_simple_fullscreen_) {
|
||||||
is_simple_fullscreen_ = true;
|
is_simple_fullscreen_ = true;
|
||||||
|
@ -1079,7 +1081,8 @@ void NativeWindowMac::AddBrowserView(NativeBrowserView* view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_browser_view(view);
|
add_browser_view(view);
|
||||||
auto* native_view = view->GetInspectableWebContentsView()->GetNativeView();
|
auto* native_view =
|
||||||
|
view->GetInspectableWebContentsView()->GetNativeView().GetNativeNSView();
|
||||||
[[window_ contentView] addSubview:native_view
|
[[window_ contentView] addSubview:native_view
|
||||||
positioned:NSWindowAbove
|
positioned:NSWindowAbove
|
||||||
relativeTo:nil];
|
relativeTo:nil];
|
||||||
|
@ -1097,7 +1100,8 @@ void NativeWindowMac::RemoveBrowserView(NativeBrowserView* view) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[view->GetInspectableWebContentsView()->GetNativeView() removeFromSuperview];
|
[view->GetInspectableWebContentsView()->GetNativeView().GetNativeNSView()
|
||||||
|
removeFromSuperview];
|
||||||
remove_browser_view(view);
|
remove_browser_view(view);
|
||||||
|
|
||||||
[CATransaction commit];
|
[CATransaction commit];
|
||||||
|
@ -1212,11 +1216,12 @@ void NativeWindowMac::ToggleTabBar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
|
bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
|
||||||
if (window_ == window->GetNativeWindow()) {
|
if (window_ == window->GetNativeWindow().GetNativeNSWindow()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (@available(macOS 10.12, *))
|
if (@available(macOS 10.12, *))
|
||||||
[window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove];
|
[window_ addTabbedWindow:window->GetNativeWindow().GetNativeNSWindow()
|
||||||
|
ordered:NSWindowAbove];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1441,7 +1446,8 @@ void NativeWindowMac::InternalSetParentWindow(NativeWindow* parent,
|
||||||
NativeWindow::SetParentWindow(parent);
|
NativeWindow::SetParentWindow(parent);
|
||||||
|
|
||||||
// Do not remove/add if we are already properly attached.
|
// Do not remove/add if we are already properly attached.
|
||||||
if (attach && parent && [window_ parentWindow] == parent->GetNativeWindow())
|
if (attach && parent &&
|
||||||
|
[window_ parentWindow] == parent->GetNativeWindow().GetNativeNSWindow())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Remove current parent window.
|
// Remove current parent window.
|
||||||
|
@ -1451,7 +1457,9 @@ void NativeWindowMac::InternalSetParentWindow(NativeWindow* parent,
|
||||||
// Set new parent window.
|
// Set new parent window.
|
||||||
// Note that this method will force the window to become visible.
|
// Note that this method will force the window to become visible.
|
||||||
if (parent && attach)
|
if (parent && attach)
|
||||||
[parent->GetNativeWindow() addChildWindow:window_ ordered:NSWindowAbove];
|
[parent->GetNativeWindow().GetNativeNSWindow()
|
||||||
|
addChildWindow:window_
|
||||||
|
ordered:NSWindowAbove];
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::ShowWindowButton(NSWindowButton button) {
|
void NativeWindowMac::ShowWindowButton(NSWindowButton button) {
|
||||||
|
|
|
@ -92,7 +92,9 @@ void ShowCertificateTrust(atom::NativeWindow* parent_window,
|
||||||
SecTrustRef trust = nullptr;
|
SecTrustRef trust = nullptr;
|
||||||
SecTrustCreateWithCertificates(cert_chain, sec_policy, &trust);
|
SecTrustCreateWithCertificates(cert_chain, sec_policy, &trust);
|
||||||
|
|
||||||
NSWindow* window = parent_window ? parent_window->GetNativeWindow() : nil;
|
NSWindow* window = parent_window
|
||||||
|
? parent_window->GetNativeWindow().GetNativeNSWindow()
|
||||||
|
: nil;
|
||||||
auto msg = base::SysUTF8ToNSString(message);
|
auto msg = base::SysUTF8ToNSString(message);
|
||||||
|
|
||||||
auto panel = [[SFCertificateTrustPanel alloc] init];
|
auto panel = [[SFCertificateTrustPanel alloc] init];
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
} else {
|
} else {
|
||||||
auto* contents = inspectableWebContentsView_->inspectable_web_contents()
|
auto* contents = inspectableWebContentsView_->inspectable_web_contents()
|
||||||
->GetWebContents();
|
->GetWebContents();
|
||||||
auto contentsView = contents->GetNativeView();
|
auto* contentsView = contents->GetNativeView().GetNativeNSView();
|
||||||
[contentsView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
[contentsView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
[self addSubview:contentsView];
|
[self addSubview:contentsView];
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
inspectableWebContentsView_->inspectable_web_contents();
|
inspectableWebContentsView_->inspectable_web_contents();
|
||||||
auto* devToolsWebContents =
|
auto* devToolsWebContents =
|
||||||
inspectable_web_contents->GetDevToolsWebContents();
|
inspectable_web_contents->GetDevToolsWebContents();
|
||||||
auto devToolsView = devToolsWebContents->GetNativeView();
|
auto* devToolsView = devToolsWebContents->GetNativeView().GetNativeNSView();
|
||||||
|
|
||||||
devtools_visible_ = visible;
|
devtools_visible_ = visible;
|
||||||
if (devtools_docked_) {
|
if (devtools_docked_) {
|
||||||
|
@ -134,7 +134,7 @@
|
||||||
inspectableWebContentsView_->inspectable_web_contents();
|
inspectableWebContentsView_->inspectable_web_contents();
|
||||||
auto* devToolsWebContents =
|
auto* devToolsWebContents =
|
||||||
inspectable_web_contents->GetDevToolsWebContents();
|
inspectable_web_contents->GetDevToolsWebContents();
|
||||||
auto devToolsView = devToolsWebContents->GetNativeView();
|
auto devToolsView = devToolsWebContents->GetNativeView().GetNativeNSView();
|
||||||
|
|
||||||
auto styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
auto styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
||||||
NSMiniaturizableWindowMask | NSWindowStyleMaskResizable |
|
NSMiniaturizableWindowMask | NSWindowStyleMaskResizable |
|
||||||
|
@ -203,7 +203,7 @@
|
||||||
if (!inspectable_web_contents || inspectable_web_contents->IsGuest())
|
if (!inspectable_web_contents || inspectable_web_contents->IsGuest())
|
||||||
return;
|
return;
|
||||||
auto* webContents = inspectable_web_contents->GetWebContents();
|
auto* webContents = inspectable_web_contents->GetWebContents();
|
||||||
auto webContentsView = webContents->GetNativeView();
|
auto* webContentsView = webContents->GetNativeView().GetNativeNSView();
|
||||||
|
|
||||||
NSView* view = [notification object];
|
NSView* view = [notification object];
|
||||||
if ([[webContentsView subviews] containsObject:view]) {
|
if ([[webContentsView subviews] containsObject:view]) {
|
||||||
|
@ -215,7 +215,7 @@
|
||||||
inspectable_web_contents->GetDevToolsWebContents();
|
inspectable_web_contents->GetDevToolsWebContents();
|
||||||
if (!devToolsWebContents)
|
if (!devToolsWebContents)
|
||||||
return;
|
return;
|
||||||
auto devToolsView = devToolsWebContents->GetNativeView();
|
auto devToolsView = devToolsWebContents->GetNativeView().GetNativeNSView();
|
||||||
|
|
||||||
if ([[devToolsView subviews] containsObject:view]) {
|
if ([[devToolsView subviews] containsObject:view]) {
|
||||||
devtools_is_first_responder_ = YES;
|
devtools_is_first_responder_ = YES;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "atom/browser/ui/cocoa/atom_preview_item.h"
|
#include "atom/browser/ui/cocoa/atom_preview_item.h"
|
||||||
#include "atom/browser/ui/cocoa/atom_touch_bar.h"
|
#include "atom/browser/ui/cocoa/atom_touch_bar.h"
|
||||||
#include "base/mac/mac_util.h"
|
#include "base/mac/mac_util.h"
|
||||||
|
#include "ui/views/cocoa/bridged_native_widget_host_impl.h"
|
||||||
#include "ui/views/widget/native_widget_mac.h"
|
#include "ui/views/widget/native_widget_mac.h"
|
||||||
#include "ui/views_bridge_mac/bridged_native_widget_impl.h"
|
#include "ui/views_bridge_mac/bridged_native_widget_impl.h"
|
||||||
|
|
||||||
|
@ -21,12 +22,13 @@
|
||||||
// on the fly.
|
// on the fly.
|
||||||
// TODO(zcbenz): Add interface in NativeWidgetMac to allow overriding creating
|
// TODO(zcbenz): Add interface in NativeWidgetMac to allow overriding creating
|
||||||
// window delegate.
|
// window delegate.
|
||||||
auto* bridged_view = views::BridgedNativeWidgetImpl::GetFromNativeWindow(
|
auto* bridge_host = views::BridgedNativeWidgetHostImpl::GetFromNativeWindow(
|
||||||
shell->GetNativeWindow());
|
shell->GetNativeWindow());
|
||||||
|
auto* bridged_view = bridge_host->bridge_impl();
|
||||||
if ((self = [super initWithBridgedNativeWidget:bridged_view])) {
|
if ((self = [super initWithBridgedNativeWidget:bridged_view])) {
|
||||||
shell_ = shell;
|
shell_ = shell;
|
||||||
is_zooming_ = false;
|
is_zooming_ = false;
|
||||||
level_ = [shell_->GetNativeWindow() level];
|
level_ = [shell_->GetNativeWindow().GetNativeNSWindow() level];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +140,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowWillMiniaturize:(NSNotification*)notification {
|
- (void)windowWillMiniaturize:(NSNotification*)notification {
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
|
||||||
// store the current status window level to be restored in
|
// store the current status window level to be restored in
|
||||||
// windowDidDeminiaturize
|
// windowDidDeminiaturize
|
||||||
level_ = [window level];
|
level_ = [window level];
|
||||||
|
@ -152,7 +154,7 @@
|
||||||
|
|
||||||
- (void)windowDidDeminiaturize:(NSNotification*)notification {
|
- (void)windowDidDeminiaturize:(NSNotification*)notification {
|
||||||
[super windowDidDeminiaturize:notification];
|
[super windowDidDeminiaturize:notification];
|
||||||
[shell_->GetNativeWindow() setLevel:level_];
|
[shell_->GetNativeWindow().GetNativeNSWindow() setLevel:level_];
|
||||||
shell_->NotifyWindowRestore();
|
shell_->NotifyWindowRestore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +181,7 @@
|
||||||
// artifacts.
|
// artifacts.
|
||||||
if (@available(macOS 10.10, *)) {
|
if (@available(macOS 10.10, *)) {
|
||||||
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
|
||||||
[window setToolbar:nil];
|
[window setToolbar:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +194,7 @@
|
||||||
// For frameless window we don't show set title for normal mode since the
|
// For frameless window we don't show set title for normal mode since the
|
||||||
// titlebar is expected to be empty, but after entering fullscreen mode we
|
// titlebar is expected to be empty, but after entering fullscreen mode we
|
||||||
// have to set one, because title bar is visible here.
|
// have to set one, because title bar is visible here.
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
|
||||||
if ((shell_->transparent() || !shell_->has_frame()) &&
|
if ((shell_->transparent() || !shell_->has_frame()) &&
|
||||||
// FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under
|
// FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under
|
||||||
// fullscreen mode.
|
// fullscreen mode.
|
||||||
|
@ -221,7 +223,7 @@
|
||||||
- (void)windowWillExitFullScreen:(NSNotification*)notification {
|
- (void)windowWillExitFullScreen:(NSNotification*)notification {
|
||||||
if (@available(macOS 10.10, *)) {
|
if (@available(macOS 10.10, *)) {
|
||||||
// Restore the titlebar visibility.
|
// Restore the titlebar visibility.
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
|
||||||
if ((shell_->transparent() || !shell_->has_frame()) &&
|
if ((shell_->transparent() || !shell_->has_frame()) &&
|
||||||
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET ||
|
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET ||
|
||||||
shell_->fullscreen_window_title())) {
|
shell_->fullscreen_window_title())) {
|
||||||
|
@ -247,8 +249,9 @@
|
||||||
// Clears the delegate when window is going to be closed, since EL Capitan it
|
// Clears the delegate when window is going to be closed, since EL Capitan it
|
||||||
// is possible that the methods of delegate would get called after the window
|
// is possible that the methods of delegate would get called after the window
|
||||||
// has been closed.
|
// has been closed.
|
||||||
auto* bridged_view = views::BridgedNativeWidgetImpl::GetFromNativeWindow(
|
auto* bridge_host = views::BridgedNativeWidgetHostImpl::GetFromNativeWindow(
|
||||||
shell_->GetNativeWindow());
|
shell_->GetNativeWindow());
|
||||||
|
auto* bridged_view = bridge_host->bridge_impl();
|
||||||
bridged_view->OnWindowWillClose();
|
bridged_view->OnWindowWillClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,26 +33,27 @@ void DragFileItems(const std::vector<base::FilePath>& files,
|
||||||
|
|
||||||
// Synthesize a drag event, since we don't have access to the actual event
|
// Synthesize a drag event, since we don't have access to the actual event
|
||||||
// that initiated a drag (possibly consumed by the Web UI, for example).
|
// that initiated a drag (possibly consumed by the Web UI, for example).
|
||||||
NSPoint position = [[view window] mouseLocationOutsideOfEventStream];
|
NSWindow* window = [view.GetNativeNSView() window];
|
||||||
|
NSPoint position = [window mouseLocationOutsideOfEventStream];
|
||||||
NSTimeInterval eventTime = [[NSApp currentEvent] timestamp];
|
NSTimeInterval eventTime = [[NSApp currentEvent] timestamp];
|
||||||
NSEvent* dragEvent = [NSEvent mouseEventWithType:NSLeftMouseDragged
|
NSEvent* dragEvent = [NSEvent mouseEventWithType:NSLeftMouseDragged
|
||||||
location:position
|
location:position
|
||||||
modifierFlags:NSLeftMouseDraggedMask
|
modifierFlags:NSLeftMouseDraggedMask
|
||||||
timestamp:eventTime
|
timestamp:eventTime
|
||||||
windowNumber:[[view window] windowNumber]
|
windowNumber:[window windowNumber]
|
||||||
context:nil
|
context:nil
|
||||||
eventNumber:0
|
eventNumber:0
|
||||||
clickCount:1
|
clickCount:1
|
||||||
pressure:1.0];
|
pressure:1.0];
|
||||||
|
|
||||||
// Run the drag operation.
|
// Run the drag operation.
|
||||||
[[view window] dragImage:icon.ToNSImage()
|
[window dragImage:icon.ToNSImage()
|
||||||
at:position
|
at:position
|
||||||
offset:NSZeroSize
|
offset:NSZeroSize
|
||||||
event:dragEvent
|
event:dragEvent
|
||||||
pasteboard:pasteboard
|
pasteboard:pasteboard
|
||||||
source:view
|
source:view.GetNativeNSView()
|
||||||
slideBack:YES];
|
slideBack:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -210,7 +210,8 @@ int RunModalDialog(NSSavePanel* dialog, const DialogSettings& settings) {
|
||||||
settings.force_detached) {
|
settings.force_detached) {
|
||||||
chosen = [dialog runModal];
|
chosen = [dialog runModal];
|
||||||
} else {
|
} else {
|
||||||
NSWindow* window = settings.parent_window->GetNativeWindow();
|
NSWindow* window =
|
||||||
|
settings.parent_window->GetNativeWindow().GetNativeNSWindow();
|
||||||
|
|
||||||
[dialog beginSheetModalForWindow:window
|
[dialog beginSheetModalForWindow:window
|
||||||
completionHandler:^(NSInteger c) {
|
completionHandler:^(NSInteger c) {
|
||||||
|
@ -328,7 +329,8 @@ void ShowOpenDialog(const DialogSettings& settings,
|
||||||
OpenDialogCompletion(chosen, dialog, settings, callback);
|
OpenDialogCompletion(chosen, dialog, settings, callback);
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
NSWindow* window = settings.parent_window->GetNativeWindow();
|
NSWindow* window =
|
||||||
|
settings.parent_window->GetNativeWindow().GetNativeNSWindow();
|
||||||
[dialog beginSheetModalForWindow:window
|
[dialog beginSheetModalForWindow:window
|
||||||
completionHandler:^(NSInteger chosen) {
|
completionHandler:^(NSInteger chosen) {
|
||||||
OpenDialogCompletion(chosen, dialog, settings, callback);
|
OpenDialogCompletion(chosen, dialog, settings, callback);
|
||||||
|
@ -389,7 +391,8 @@ void ShowSaveDialog(const DialogSettings& settings,
|
||||||
SaveDialogCompletion(chosen, dialog, settings, callback);
|
SaveDialogCompletion(chosen, dialog, settings, callback);
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
NSWindow* window = settings.parent_window->GetNativeWindow();
|
NSWindow* window =
|
||||||
|
settings.parent_window->GetNativeWindow().GetNativeNSWindow();
|
||||||
[dialog beginSheetModalForWindow:window
|
[dialog beginSheetModalForWindow:window
|
||||||
completionHandler:^(NSInteger chosen) {
|
completionHandler:^(NSInteger chosen) {
|
||||||
SaveDialogCompletion(chosen, dialog, settings, callback);
|
SaveDialogCompletion(chosen, dialog, settings, callback);
|
||||||
|
|
|
@ -156,7 +156,7 @@ int ShowMessageBox(NativeWindow* parent_window,
|
||||||
andAlert:alert
|
andAlert:alert
|
||||||
callEndModal:true];
|
callEndModal:true];
|
||||||
|
|
||||||
NSWindow* window = parent_window->GetNativeWindow();
|
NSWindow* window = parent_window->GetNativeWindow().GetNativeNSWindow();
|
||||||
[alert beginSheetModalForWindow:window
|
[alert beginSheetModalForWindow:window
|
||||||
modalDelegate:delegate
|
modalDelegate:delegate
|
||||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||||
|
@ -193,7 +193,9 @@ void ShowMessageBox(NativeWindow* parent_window,
|
||||||
andAlert:alert
|
andAlert:alert
|
||||||
callEndModal:false];
|
callEndModal:false];
|
||||||
|
|
||||||
NSWindow* window = parent_window ? parent_window->GetNativeWindow() : nil;
|
NSWindow* window =
|
||||||
|
parent_window ? parent_window->GetNativeWindow().GetNativeNSWindow()
|
||||||
|
: nil;
|
||||||
[alert
|
[alert
|
||||||
beginSheetModalForWindow:window
|
beginSheetModalForWindow:window
|
||||||
modalDelegate:delegate
|
modalDelegate:delegate
|
||||||
|
|
Loading…
Reference in a new issue