diff --git a/atom/browser/api/atom_api_top_level_window.cc b/atom/browser/api/atom_api_top_level_window.cc index 334f7950cfd1..a334dd9a143d 100644 --- a/atom/browser/api/atom_api_top_level_window.cc +++ b/atom/browser/api/atom_api_top_level_window.cc @@ -664,8 +664,11 @@ void TopLevelWindow::SetBrowserView(v8::Local value) { } v8::Local TopLevelWindow::GetNativeWindowHandle() { - gfx::AcceleratedWidget handle = window_->GetAcceleratedWidget(); - return ToBuffer(isolate(), static_cast(&handle), sizeof(handle)); + // TODO(MarshallOfSound): Replace once + // https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has + // landed + auto handle = window_->GetNativeWindowHandlePointer(); + return ToBuffer(isolate(), std::get<0>(handle), std::get<1>(handle)); } void TopLevelWindow::SetProgressBar(double progress, mate::Arguments* args) { diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 759d7cb20210..23ec5e0c4281 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "atom/browser/native_window_observer.h" @@ -150,6 +151,7 @@ class NativeWindow : public base::SupportsUserData, virtual gfx::NativeView GetNativeView() const = 0; virtual gfx::NativeWindow GetNativeWindow() const = 0; virtual gfx::AcceleratedWidget GetAcceleratedWidget() const = 0; + virtual std::tuple GetNativeWindowHandlePointer() const = 0; // Taskbar/Dock APIs. enum ProgressState { diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index e6e75cd43825..716c1c881e72 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -8,6 +8,7 @@ #import #include +#include #include #include "atom/browser/native_window.h" @@ -103,6 +104,7 @@ class NativeWindowMac : public NativeWindow { gfx::NativeView GetNativeView() const override; gfx::NativeWindow GetNativeWindow() const override; gfx::AcceleratedWidget GetAcceleratedWidget() const override; + std::tuple GetNativeWindowHandlePointer() const override; void SetProgressBar(double progress, const ProgressState state) override; void SetOverlayIcon(const gfx::Image& overlay, const std::string& description) override; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index b3515b9e547e..b59831aac145 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -1079,6 +1079,11 @@ gfx::AcceleratedWidget NativeWindowMac::GetAcceleratedWidget() const { return gfx::kNullAcceleratedWidget; } +std::tuple NativeWindowMac::GetNativeWindowHandlePointer() const { + NSView* view = [window_ contentView]; + return std::make_tuple(static_cast(view), sizeof(view)); +} + void NativeWindowMac::SetProgressBar(double progress, const NativeWindow::ProgressState state) { NSDockTile* dock_tile = [NSApp dockTile]; diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 5f6b1f0ab09c..03c2c7543cc0 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -9,6 +9,7 @@ #include #endif +#include #include #include "atom/browser/api/atom_api_web_contents.h" @@ -1046,6 +1047,11 @@ gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() const { return GetNativeWindow()->GetHost()->GetAcceleratedWidget(); } +std::tuple NativeWindowViews::GetNativeWindowHandlePointer() const { + gfx::AcceleratedWidget handle = GetAcceleratedWidget(); + return std::make_tuple(static_cast(&handle), sizeof(handle)); +} + gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds( const gfx::Rect& bounds) const { if (!has_frame()) diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 881d6ca37128..05954cfde4af 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -9,6 +9,7 @@ #include #include +#include #include "ui/views/widget/widget_observer.h" @@ -123,6 +124,7 @@ class NativeWindowViews : public NativeWindow, bool IsVisibleOnAllWorkspaces() override; gfx::AcceleratedWidget GetAcceleratedWidget() const override; + std::tuple GetNativeWindowHandlePointer() const override; gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override; gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const override;