diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index bf0d0fad721c..352b9284cf45 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -190,9 +190,21 @@ void Window::OnExecuteWindowsCommand(const std::string& command_name) { } #if defined(OS_WIN) -void Window::OnWindowMessage(UINT message, uint64_t w_param, int64_t l_param) { +v8::Local Window::ToBuffer(void* val, int size) { + auto buffer = node::Buffer::New(isolate(), static_cast(val), size); + + if (buffer.IsEmpty()) { + return v8::Null(isolate()); + } else { + return buffer.ToLocalChecked(); + } +} + +void Window::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) { if (IsWindowMessageHooked(message)) { - messages_callback_map_[message].Run(w_param, l_param); + messages_callback_map_[message].Run( + ToBuffer(static_cast(&w_param), sizeof(WPARAM)), + ToBuffer(static_cast(&l_param), sizeof(LPARAM))); } } #endif diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index ea86150ae1e3..ffbd9b63b40a 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -77,8 +77,8 @@ class Window : public mate::TrackableObject, void OnExecuteWindowsCommand(const std::string& command_name) override; #if defined(OS_WIN) - void OnWindowMessage(UINT message, uint64_t w_param, - int64_t l_param) override; + void OnWindowMessage(UINT message, WPARAM w_param, + LPARAM l_param) override; #endif // mate::Wrappable: @@ -150,7 +150,10 @@ class Window : public mate::TrackableObject, void SetAspectRatio(double aspect_ratio, mate::Arguments* args); #if defined(OS_WIN) - typedef base::Callback MessageCallback; + v8::Local ToBuffer(void* val, int size); + + typedef base::Callback, + v8::Local)> MessageCallback; typedef std::map MessageCallbackMap; MessageCallbackMap messages_callback_map_; diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index a1b6f95c3ac9..bf400dc8c74e 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -469,8 +469,8 @@ void NativeWindow::NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) { FOR_EACH_OBSERVER( NativeWindowObserver, observers_, - OnWindowMessage(message, static_cast(w_param), - static_cast(l_param))); + OnWindowMessage(message, w_param, + l_param)); } #endif diff --git a/atom/browser/native_window_observer.h b/atom/browser/native_window_observer.h index 559d5f72a804..a76f314129f6 100644 --- a/atom/browser/native_window_observer.h +++ b/atom/browser/native_window_observer.h @@ -61,7 +61,7 @@ class NativeWindowObserver { // Called when window message received #if defined(OS_WIN) - virtual void OnWindowMessage(UINT message, uint64_t wparam, int64_t lparam) {} + virtual void OnWindowMessage(UINT message, WPARAM wparam, LPARAM lparam) {} #endif // Called when renderer is hung.