mac: Call setMouseDownCanMoveWindow in BrowserWindow

This commit is contained in:
Cheng Zhao 2018-03-06 14:07:06 +09:00
Родитель 7d4ff3b061
Коммит bc34ca9e25
5 изменённых файлов: 52 добавлений и 17 удалений

Просмотреть файл

@ -1169,12 +1169,6 @@ void BrowserWindow::RemoveFromParentChildWindows() {
parent->child_windows_.Remove(ID());
}
void BrowserWindow::UpdateDraggableRegions(
content::RenderFrameHost* rfh,
const std::vector<DraggableRegion>& regions) {
window_->UpdateDraggableRegions(regions);
}
void BrowserWindow::ScheduleUnresponsiveEvent(int ms) {
if (!window_unresponsive_closure_.IsCancelled())
return;

Просмотреть файл

@ -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 <Cocoa/Cocoa.h>
@interface NSView (WebContentsView)
- (void)setMouseDownCanMoveWindow:(BOOL)can_move;
@end
namespace atom {
namespace api {
void BrowserWindow::UpdateDraggableRegions(
content::RenderFrameHost* rfh,
const std::vector<DraggableRegion>& 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

Просмотреть файл

@ -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<DraggableRegion>& regions) {
window_->UpdateDraggableRegions(regions);
}
} // namespace api
} // namespace atom

Просмотреть файл

@ -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<DraggableRegion>& 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

Просмотреть файл

@ -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',