diff --git a/atom/browser/api/atom_api_browser_window.cc b/atom/browser/api/atom_api_browser_window.cc index 8294dc1de..92647e808 100644 --- a/atom/browser/api/atom_api_browser_window.cc +++ b/atom/browser/api/atom_api_browser_window.cc @@ -1169,12 +1169,6 @@ void BrowserWindow::RemoveFromParentChildWindows() { parent->child_windows_.Remove(ID()); } -void BrowserWindow::UpdateDraggableRegions( - content::RenderFrameHost* rfh, - const std::vector& regions) { - window_->UpdateDraggableRegions(regions); -} - void BrowserWindow::ScheduleUnresponsiveEvent(int ms) { if (!window_unresponsive_closure_.IsCancelled()) return; diff --git a/atom/browser/api/atom_api_browser_window_mac.mm b/atom/browser/api/atom_api_browser_window_mac.mm new file mode 100644 index 000000000..00fa4436c --- /dev/null +++ b/atom/browser/api/atom_api_browser_window_mac.mm @@ -0,0 +1,31 @@ +// Copyright (c) 2018 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/browser/api/atom_api_browser_window.h" + +#import + +@interface NSView (WebContentsView) +- (void)setMouseDownCanMoveWindow:(BOOL)can_move; +@end + +namespace atom { + +namespace api { + +void BrowserWindow::UpdateDraggableRegions( + content::RenderFrameHost* rfh, + const std::vector& regions) { + if (window_->has_frame()) + return; + NSView* webView = web_contents()->GetNativeView(); + if ([webView respondsToSelector:@selector(setMouseDownCanMoveWindow:)]) { + [webView setMouseDownCanMoveWindow:YES]; + } + window_->UpdateDraggableRegions(regions); +} + +} // namespace api + +} // namespace atom diff --git a/atom/browser/api/atom_api_browser_window_views.cc b/atom/browser/api/atom_api_browser_window_views.cc new file mode 100644 index 000000000..23982281f --- /dev/null +++ b/atom/browser/api/atom_api_browser_window_views.cc @@ -0,0 +1,19 @@ +// Copyright (c) 2018 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/browser/api/atom_api_browser_window.h" + +namespace atom { + +namespace api { + +void BrowserWindow::UpdateDraggableRegions( + content::RenderFrameHost* rfh, + const std::vector& regions) { + window_->UpdateDraggableRegions(regions); +} + +} // namespace api + +} // namespace atom diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index de1303a26..d3b1db60a 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -736,10 +736,6 @@ enum { @end -@interface NSView (WebContentsView) -- (void)setMouseDownCanMoveWindow:(BOOL)can_move; -@end - @interface AtomProgressBar : NSProgressIndicator @end @@ -1765,9 +1761,6 @@ gfx::Rect NativeWindowMac::WindowBoundsToContentBounds( void NativeWindowMac::UpdateDraggableRegions( const std::vector& regions) { - if (has_frame()) - return; - // All ControlRegionViews should be added as children of the WebContentsView, // because WebContentsView will be removed and re-added when entering and // leaving fullscreen mode. @@ -1775,10 +1768,6 @@ void NativeWindowMac::UpdateDraggableRegions( NSInteger webViewWidth = NSWidth([webView bounds]); NSInteger webViewHeight = NSHeight([webView bounds]); - if ([webView respondsToSelector:@selector(setMouseDownCanMoveWindow:)]) { - [webView setMouseDownCanMoveWindow:YES]; - } - // Remove all ControlRegionViews that are added last time. // Note that [webView subviews] returns the view's mutable internal array and // it should be copied to avoid mutating the original array while enumerating diff --git a/filenames.gypi b/filenames.gypi index 38ba7b226..e051b4707 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -163,6 +163,8 @@ 'atom/browser/api/atom_api_web_view_manager.cc', 'atom/browser/api/atom_api_browser_window.cc', 'atom/browser/api/atom_api_browser_window.h', + 'atom/browser/api/atom_api_browser_window_mac.mm', + 'atom/browser/api/atom_api_browser_window_views.cc', 'atom/browser/api/event.cc', 'atom/browser/api/event.h', 'atom/browser/api/event_emitter.cc',