Added browser-window event 'message'
This commit is contained in:
		
					parent
					
						
							
								65ece4b1ca
							
						
					
				
			
			
				commit
				
					
						edbebf84b9
					
				
			
		
					 7 changed files with 38 additions and 0 deletions
				
			
		| 
						 | 
					@ -189,6 +189,12 @@ void Window::OnExecuteWindowsCommand(const std::string& command_name) {
 | 
				
			||||||
  Emit("app-command", 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
 | 
					// static
 | 
				
			||||||
mate::Wrappable* Window::New(v8::Isolate* isolate,
 | 
					mate::Wrappable* Window::New(v8::Isolate* isolate,
 | 
				
			||||||
                             const mate::Dictionary& options) {
 | 
					                             const mate::Dictionary& options) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,6 +75,11 @@ class Window : public mate::TrackableObject<Window>,
 | 
				
			||||||
  void OnRendererResponsive() override;
 | 
					  void OnRendererResponsive() override;
 | 
				
			||||||
  void OnExecuteWindowsCommand(const std::string& command_name) 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:
 | 
					  // mate::Wrappable:
 | 
				
			||||||
  bool IsDestroyed() const override;
 | 
					  bool IsDestroyed() const override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -464,6 +464,14 @@ void NativeWindow::NotifyWindowExecuteWindowsCommand(
 | 
				
			||||||
                    OnExecuteWindowsCommand(command));
 | 
					                    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(
 | 
					scoped_ptr<SkRegion> NativeWindow::DraggableRegionsToSkRegion(
 | 
				
			||||||
    const std::vector<DraggableRegion>& regions) {
 | 
					    const std::vector<DraggableRegion>& regions) {
 | 
				
			||||||
  scoped_ptr<SkRegion> sk_region(new SkRegion);
 | 
					  scoped_ptr<SkRegion> sk_region(new SkRegion);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -210,6 +210,10 @@ class NativeWindow : public base::SupportsUserData,
 | 
				
			||||||
  void NotifyWindowLeaveHtmlFullScreen();
 | 
					  void NotifyWindowLeaveHtmlFullScreen();
 | 
				
			||||||
  void NotifyWindowExecuteWindowsCommand(const std::string& command);
 | 
					  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) {
 | 
					  void AddObserver(NativeWindowObserver* obs) {
 | 
				
			||||||
    observers_.AddObserver(obs);
 | 
					    observers_.AddObserver(obs);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,10 @@
 | 
				
			||||||
#include "ui/base/window_open_disposition.h"
 | 
					#include "ui/base/window_open_disposition.h"
 | 
				
			||||||
#include "url/gurl.h"
 | 
					#include "url/gurl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(OS_WIN)
 | 
				
			||||||
 | 
					#include <windows.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace atom {
 | 
					namespace atom {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NativeWindowObserver {
 | 
					class NativeWindowObserver {
 | 
				
			||||||
| 
						 | 
					@ -55,6 +59,11 @@ class NativeWindowObserver {
 | 
				
			||||||
  virtual void OnWindowEnterHtmlFullScreen() {}
 | 
					  virtual void OnWindowEnterHtmlFullScreen() {}
 | 
				
			||||||
  virtual void OnWindowLeaveHtmlFullScreen() {}
 | 
					  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.
 | 
					  // Called when renderer is hung.
 | 
				
			||||||
  virtual void OnRendererUnresponsive() {}
 | 
					  virtual void OnRendererUnresponsive() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,6 +80,8 @@ bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool NativeWindowViews::PreHandleMSG(
 | 
					bool NativeWindowViews::PreHandleMSG(
 | 
				
			||||||
    UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) {
 | 
					    UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) {
 | 
				
			||||||
 | 
					  NotifyWindowMessage(message, w_param, l_param);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  switch (message) {
 | 
					  switch (message) {
 | 
				
			||||||
    case WM_COMMAND:
 | 
					    case WM_COMMAND:
 | 
				
			||||||
      // Handle thumbar button click message.
 | 
					      // Handle thumbar button click message.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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.
 | 
					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':
 | 
					### Event: 'app-command':
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Emitted when an [App Command](https://msdn.microsoft.com/en-us/library/windows/desktop/ms646275(v=vs.85).aspx)
 | 
					Emitted when an [App Command](https://msdn.microsoft.com/en-us/library/windows/desktop/ms646275(v=vs.85).aspx)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue