Merge pull request #3256 from omrilitov/master

Use WPARAM as uint64_t and LPARAM as int64_t
This commit is contained in:
Cheng Zhao 2015-10-29 10:41:11 +08:00
commit bf9e6ba11e
5 changed files with 24 additions and 6 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
.DS_Store
/.idea/
/build/
/dist/
/external_binaries/

View file

@ -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<v8::Value> Window::ToBuffer(void* val, int size) {
auto buffer = node::Buffer::New(isolate(), static_cast<char*>(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<void*>(&w_param), sizeof(WPARAM)),
ToBuffer(static_cast<void*>(&l_param), sizeof(LPARAM)));
}
}
#endif

View file

@ -77,7 +77,8 @@ class Window : public mate::TrackableObject<Window>,
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<Window>,
void SetAspectRatio(double aspect_ratio, mate::Arguments* args);
#if defined(OS_WIN)
typedef base::Callback<void(WPARAM, uint64_t)> MessageCallback;
v8::Local<v8::Value> ToBuffer(void* val, int size);
typedef base::Callback<void(v8::Local<v8::Value>,
v8::Local<v8::Value>)> MessageCallback;
typedef std::map<UINT, MessageCallback> MessageCallbackMap;
MessageCallbackMap messages_callback_map_;

View file

@ -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<uint64_t>(l_param)));
OnWindowMessage(message, w_param,
l_param));
}
#endif

View file

@ -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.