diff --git a/.gitignore b/.gitignore index 0c6f4cb79dd..b8a221c9e52 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +/.idea/ /build/ /dist/ /external_binaries/ diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 077dffe0bc5..352b9284cf4 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, WPARAM w_param, uint64_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 f4bc4cdba01..ffbd9b63b40 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -77,7 +77,8 @@ class Window : public mate::TrackableObject, void OnExecuteWindowsCommand(const std::string& command_name) override; #if defined(OS_WIN) - void OnWindowMessage(UINT message, WPARAM w_param, uint64_t l_param) override; + void OnWindowMessage(UINT message, WPARAM w_param, + LPARAM l_param) override; #endif // mate::Wrappable: @@ -149,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 6e38f402874..bf400dc8c74 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -469,7 +469,8 @@ void NativeWindow::NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) { FOR_EACH_OBSERVER( NativeWindowObserver, observers_, - OnWindowMessage(message, 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 240a7277fa0..a76f314129f 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, WPARAM wparam, uint64_t lparam) {} + virtual void OnWindowMessage(UINT message, WPARAM wparam, LPARAM lparam) {} #endif // Called when renderer is hung.