fix: fallback to FullSizeContentView for frameless window on mac (#13599)
fix: draggable regions not working on macOS
This commit is contained in:
parent
28d4f7f25a
commit
0ec4ad288d
5 changed files with 123 additions and 55 deletions
|
@ -85,6 +85,11 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
|
|||
|
||||
InitWith(isolate, wrapper);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
if (!window()->has_frame())
|
||||
OverrideNSWindowContentView();
|
||||
#endif
|
||||
|
||||
// Init window after everything has been setup.
|
||||
window()->InitFromOptions(options);
|
||||
}
|
||||
|
|
|
@ -80,6 +80,10 @@ class BrowserWindow : public TopLevelWindow,
|
|||
v8::Local<v8::Value> GetWebContents(v8::Isolate* isolate);
|
||||
|
||||
private:
|
||||
#if defined(OS_MACOSX)
|
||||
void OverrideNSWindowContentView();
|
||||
#endif
|
||||
|
||||
// Helpers.
|
||||
|
||||
// Called when the window needs to update its draggable region.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "atom/browser/native_browser_view.h"
|
||||
#include "atom/browser/native_window_mac.h"
|
||||
#include "atom/common/draggable_region.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
|
||||
|
@ -53,6 +54,17 @@ std::vector<gfx::Rect> CalculateNonDraggableRegions(
|
|||
|
||||
} // namespace
|
||||
|
||||
void BrowserWindow::OverrideNSWindowContentView() {
|
||||
// Make NativeWindow use a NSView as content view.
|
||||
static_cast<NativeWindowMac*>(window())->OverrideNSWindowContentView();
|
||||
// Add webview to contentView.
|
||||
NSView* webView = web_contents()->GetNativeView();
|
||||
NSView* contentView = [window()->GetNativeWindow() contentView];
|
||||
[webView setFrame:[contentView bounds]];
|
||||
[contentView addSubview:webView];
|
||||
[contentView viewDidMoveToWindow];
|
||||
}
|
||||
|
||||
void BrowserWindow::UpdateDraggableRegions(
|
||||
content::RenderFrameHost* rfh,
|
||||
const std::vector<DraggableRegion>& regions) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue