Added browser-window event 'message'
authorOmri Litov <omrilitov@gmail.com>
Tue, 27 Oct 2015 01:12:01 +0000 (03:12 +0200)
committerOmri Litov <omrilitov@gmail.com>
Tue, 27 Oct 2015 01:12:01 +0000 (03:12 +0200)
atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h
atom/browser/native_window.cc
atom/browser/native_window.h
atom/browser/native_window_observer.h
atom/browser/native_window_views_win.cc
docs/api/browser-window.md

index 62994c9c93d417c04c4a1f6b15d4aebef26615e9..7daab4d1a08525ae93516be882475723d443f087 100644 (file)
@@ -189,6 +189,12 @@ void Window::OnExecuteWindowsCommand(const std::string& command_name) {
   Emit("app-command", command_name);
 }
 
+#if defined(OS_WIN)
+void Window::OnWindowMessage(UINT message, LPARAM l_param, WPARAM w_param) {
+  Emit("message", message, l_param, w_param);
+}
+#endif
+
 // static
 mate::Wrappable* Window::New(v8::Isolate* isolate,
                              const mate::Dictionary& options) {
index 8a8ff266a883306bc3f5cd5df934a9bd205e4ce3..419564146149ebb4da7e2307b40a12dfb3506a4e 100644 (file)
@@ -75,6 +75,11 @@ class Window : public mate::TrackableObject<Window>,
   void OnRendererResponsive() override;
   void OnExecuteWindowsCommand(const std::string& command_name) override;
 
+  #if defined(OS_WIN)
+  void OnWindowMessage(unsigned int message, LPARAM l_param,
+                       WPARAM w_param) override;
+  #endif
+
   // mate::Wrappable:
   bool IsDestroyed() const override;
 
index c19bcdf467f3948e04f0d905a6499a55069c1a46..e3abed473e7d5b27f52a7f1ad47b29f1a9d33f2f 100644 (file)
@@ -464,6 +464,14 @@ void NativeWindow::NotifyWindowExecuteWindowsCommand(
                     OnExecuteWindowsCommand(command));
 }
 
+#if defined(OS_WIN)
+void NativeWindow::NotifyWindowMessage(UINT message, WPARAM w_param,
+                                       LPARAM l_param) {
+  FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
+                    OnWindowMessage(message, w_param, l_param));
+}
+#endif
+
 scoped_ptr<SkRegion> NativeWindow::DraggableRegionsToSkRegion(
     const std::vector<DraggableRegion>& regions) {
   scoped_ptr<SkRegion> sk_region(new SkRegion);
index 37a59ff8a9e4361ed4a0e709c8174dae1af1550f..e32b9481182388fe141212a6ab96da49b8788704 100644 (file)
@@ -210,6 +210,10 @@ class NativeWindow : public base::SupportsUserData,
   void NotifyWindowLeaveHtmlFullScreen();
   void NotifyWindowExecuteWindowsCommand(const std::string& command);
 
+  #if defined(OS_WIN)
+  void NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param);
+  #endif
+
   void AddObserver(NativeWindowObserver* obs) {
     observers_.AddObserver(obs);
   }
index 33ab1ecb6b3d102ba102e3e29ccbd183ca249009..db693b47d53d24575cb7da7f25e15651d96bd42b 100644 (file)
 #include "ui/base/window_open_disposition.h"
 #include "url/gurl.h"
 
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
+
 namespace atom {
 
 class NativeWindowObserver {
@@ -55,6 +59,11 @@ class NativeWindowObserver {
   virtual void OnWindowEnterHtmlFullScreen() {}
   virtual void OnWindowLeaveHtmlFullScreen() {}
 
+  // Called when window message received
+  #if defined(OS_WIN)
+  virtual void OnWindowMessage(UINT message, LPARAM l_param, WPARAM w_param) {}
+  #endif
+
   // Called when renderer is hung.
   virtual void OnRendererUnresponsive() {}
 
index 6092a2242ac0cd2fdea9d556dc8124199901bd29..d49683acb3cf80ce859d044b93c48a781e0d6f71 100644 (file)
@@ -80,6 +80,8 @@ bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
 
 bool NativeWindowViews::PreHandleMSG(
     UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) {
+  NotifyWindowMessage(message, w_param, l_param);
+
   switch (message) {
     case WM_COMMAND:
       // Handle thumbar button click message.
index aa46590c746ba7307a163c5ab295537a53fa7400..99578c902ef046f869a7c87604e75241964cd743 100644 (file)
@@ -232,6 +232,10 @@ Emitted when the window enters full screen state triggered by html api.
 
 Emitted when the window leaves full screen state triggered by html api.
 
+### Event: 'message' _WINDOWS_
+
+Emitted when the window receives a message from the operating system.
+
 ### Event: 'app-command':
 
 Emitted when an [App Command](https://msdn.microsoft.com/en-us/library/windows/desktop/ms646275(v=vs.85).aspx)