Returns buffer instead of WPARAM and LPARAM
This commit is contained in:
parent
f22837523f
commit
ef038257d1
4 changed files with 23 additions and 8 deletions
|
@ -190,9 +190,21 @@ void Window::OnExecuteWindowsCommand(const std::string& command_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
void Window::OnWindowMessage(UINT message, uint64_t w_param, int64_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)) {
|
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
|
#endif
|
||||||
|
|
|
@ -77,8 +77,8 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
void OnExecuteWindowsCommand(const std::string& command_name) override;
|
void OnExecuteWindowsCommand(const std::string& command_name) override;
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
void OnWindowMessage(UINT message, uint64_t w_param,
|
void OnWindowMessage(UINT message, WPARAM w_param,
|
||||||
int64_t l_param) override;
|
LPARAM l_param) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// mate::Wrappable:
|
// mate::Wrappable:
|
||||||
|
@ -150,7 +150,10 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
void SetAspectRatio(double aspect_ratio, mate::Arguments* args);
|
void SetAspectRatio(double aspect_ratio, mate::Arguments* args);
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#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;
|
typedef std::map<UINT, MessageCallback> MessageCallbackMap;
|
||||||
MessageCallbackMap messages_callback_map_;
|
MessageCallbackMap messages_callback_map_;
|
||||||
|
|
||||||
|
|
|
@ -469,8 +469,8 @@ void NativeWindow::NotifyWindowMessage(UINT message, WPARAM w_param,
|
||||||
LPARAM l_param) {
|
LPARAM l_param) {
|
||||||
FOR_EACH_OBSERVER(
|
FOR_EACH_OBSERVER(
|
||||||
NativeWindowObserver, observers_,
|
NativeWindowObserver, observers_,
|
||||||
OnWindowMessage(message, static_cast<uint64_t>(w_param),
|
OnWindowMessage(message, w_param,
|
||||||
static_cast<int64_t>(l_param)));
|
l_param));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class NativeWindowObserver {
|
||||||
|
|
||||||
// Called when window message received
|
// Called when window message received
|
||||||
#if defined(OS_WIN)
|
#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
|
#endif
|
||||||
|
|
||||||
// Called when renderer is hung.
|
// Called when renderer is hung.
|
||||||
|
|
Loading…
Reference in a new issue