 c8dc2d3730
			
		
	
	
	c8dc2d3730
	
	
	
		
			
			The new `will-resize` event can be used to prevent the resize from happening before the native window is actually resized. This is in contrast to the existing the `resize` event, which is sent *after* the native window has already been resized. For apps with e.g. custom window snapping logic, the `resize` event is not sufficient because it will result in flickering between the dragged size and the snapped size. `will-resize` is only emitted on macOS and Windows.
		
			
				
	
	
		
			99 lines
		
	
	
	
		
			3.1 KiB
			
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			99 lines
		
	
	
	
		
			3.1 KiB
			
		
	
	
	
		
			C++
		
	
	
	
	
	
| // Copyright (c) 2013 GitHub, Inc.
 | |
| // Use of this source code is governed by the MIT license that can be
 | |
| // found in the LICENSE file.
 | |
| 
 | |
| #ifndef ATOM_BROWSER_NATIVE_WINDOW_OBSERVER_H_
 | |
| #define ATOM_BROWSER_NATIVE_WINDOW_OBSERVER_H_
 | |
| 
 | |
| #include <string>
 | |
| 
 | |
| #include "base/strings/string16.h"
 | |
| #include "base/values.h"
 | |
| #include "ui/base/window_open_disposition.h"
 | |
| #include "url/gurl.h"
 | |
| 
 | |
| #if defined(OS_WIN)
 | |
| #include <windows.h>
 | |
| #endif
 | |
| 
 | |
| namespace gfx {
 | |
| class Rect;
 | |
| }
 | |
| 
 | |
| namespace atom {
 | |
| 
 | |
| class NativeWindowObserver {
 | |
|  public:
 | |
|   virtual ~NativeWindowObserver() {}
 | |
| 
 | |
|   // Called when the web page in window wants to create a popup window.
 | |
|   virtual void WillCreatePopupWindow(const base::string16& frame_name,
 | |
|                                      const GURL& target_url,
 | |
|                                      const std::string& partition_id,
 | |
|                                      WindowOpenDisposition disposition) {}
 | |
| 
 | |
|   // Called when user is starting an navigation in web page.
 | |
|   virtual void WillNavigate(bool* prevent_default, const GURL& url) {}
 | |
| 
 | |
|   // Called when the window is gonna closed.
 | |
|   virtual void WillCloseWindow(bool* prevent_default) {}
 | |
| 
 | |
|   // Called when the window wants to know the preferred width.
 | |
|   virtual void RequestPreferredWidth(int* width) {}
 | |
| 
 | |
|   // Called when closed button is clicked.
 | |
|   virtual void OnCloseButtonClicked(bool* prevent_default) {}
 | |
| 
 | |
|   // Called when the window is closed.
 | |
|   virtual void OnWindowClosed() {}
 | |
| 
 | |
|   // Called when Windows sends WM_ENDSESSION message
 | |
|   virtual void OnWindowEndSession() {}
 | |
| 
 | |
|   // Called when window loses focus.
 | |
|   virtual void OnWindowBlur() {}
 | |
| 
 | |
|   // Called when window gains focus.
 | |
|   virtual void OnWindowFocus() {}
 | |
| 
 | |
|   // Called when window is shown.
 | |
|   virtual void OnWindowShow() {}
 | |
| 
 | |
|   // Called when window is hidden.
 | |
|   virtual void OnWindowHide() {}
 | |
| 
 | |
|   // Called when window state changed.
 | |
|   virtual void OnWindowMaximize() {}
 | |
|   virtual void OnWindowUnmaximize() {}
 | |
|   virtual void OnWindowMinimize() {}
 | |
|   virtual void OnWindowRestore() {}
 | |
|   virtual void OnWindowWillResize(const gfx::Rect& new_bounds,
 | |
|                                   bool* prevent_default) {}
 | |
|   virtual void OnWindowResize() {}
 | |
|   virtual void OnWindowMove() {}
 | |
|   virtual void OnWindowMoved() {}
 | |
|   virtual void OnWindowScrollTouchBegin() {}
 | |
|   virtual void OnWindowScrollTouchEnd() {}
 | |
|   virtual void OnWindowSwipe(const std::string& direction) {}
 | |
|   virtual void OnWindowSheetBegin() {}
 | |
|   virtual void OnWindowSheetEnd() {}
 | |
|   virtual void OnWindowEnterFullScreen() {}
 | |
|   virtual void OnWindowLeaveFullScreen() {}
 | |
|   virtual void OnWindowEnterHtmlFullScreen() {}
 | |
|   virtual void OnWindowLeaveHtmlFullScreen() {}
 | |
|   virtual void OnTouchBarItemResult(const std::string& item_id,
 | |
|                                     const base::DictionaryValue& details) {}
 | |
|   virtual void OnNewWindowForTab() {}
 | |
| 
 | |
| // Called when window message received
 | |
| #if defined(OS_WIN)
 | |
|   virtual void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {}
 | |
| #endif
 | |
| 
 | |
|   // Called on Windows when App Commands arrive (WM_APPCOMMAND)
 | |
|   virtual void OnExecuteWindowsCommand(const std::string& command_name) {}
 | |
| };
 | |
| 
 | |
| }  // namespace atom
 | |
| 
 | |
| #endif  // ATOM_BROWSER_NATIVE_WINDOW_OBSERVER_H_
 |