fix: explicitly call GetNativeNSView() on macOS (#46733)

* fix: explicitly call GetNativeNSView() on macOS

* chore: move macOS impl to a .mm file

This is needed in order to access gfx::NativeView::GetNativeNSView()
This commit is contained in:
Charles Kerr 2025-04-23 17:55:18 -05:00 committed by GitHub
parent 686ae47696
commit c7b0bdab7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 62 additions and 4 deletions

View file

@ -70,6 +70,7 @@ namespace electron::api {
namespace {
#if !BUILDFLAG(IS_MAC)
// Converts binary data to Buffer.
v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
@ -78,6 +79,7 @@ v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
else
return buffer.ToLocalChecked();
}
#endif
[[nodiscard]] constexpr std::array<int, 2U> ToArray(const gfx::Size size) {
return {size.width(), size.height()};
@ -778,6 +780,7 @@ std::string BaseWindow::GetMediaSourceId() const {
return window_->GetDesktopMediaID().ToString();
}
#if !BUILDFLAG(IS_MAC)
v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
// TODO(MarshallOfSound): Replace once
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
@ -785,6 +788,7 @@ v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
NativeWindowHandle handle = window_->GetNativeWindowHandle();
return ToBuffer(isolate(), &handle, sizeof(handle));
}
#endif
void BaseWindow::SetProgressBar(double progress, gin_helper::Arguments* args) {
gin_helper::Dictionary options;