| 
									
										
										
										
											2014-10-31 11:17:05 -07:00
										 |  |  | // Copyright (c) 2013 GitHub, Inc.
 | 
					
						
							| 
									
										
										
										
											2014-04-25 17:49:37 +08:00
										 |  |  | // Use of this source code is governed by the MIT license that can be
 | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  | // found in the LICENSE file.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-16 08:30:26 +08:00
										 |  |  | #include "atom/browser/native_window.h"
 | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-12 17:37:31 +02:00
										 |  |  | #include <algorithm>
 | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  | #include <string>
 | 
					
						
							| 
									
										
										
										
											2014-03-16 09:13:06 +08:00
										 |  |  | #include <utility>
 | 
					
						
							|  |  |  | #include <vector>
 | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 14:17:33 -07:00
										 |  |  | #include "atom/browser/browser.h"
 | 
					
						
							| 
									
										
										
										
											2014-03-16 08:30:26 +08:00
										 |  |  | #include "atom/browser/window_list.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-06 13:21:47 +09:00
										 |  |  | #include "atom/common/color_util.h"
 | 
					
						
							| 
									
										
										
										
											2014-04-04 22:04:42 +08:00
										 |  |  | #include "atom/common/options_switches.h"
 | 
					
						
							| 
									
										
										
										
											2014-06-23 21:51:42 +08:00
										 |  |  | #include "native_mate/dictionary.h"
 | 
					
						
							| 
									
										
										
										
											2018-05-12 21:33:47 +02:00
										 |  |  | #include "ui/views/widget/widget.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if defined(OS_WIN)
 | 
					
						
							| 
									
										
										
										
											2018-05-12 17:37:31 +02:00
										 |  |  | #include "ui/base/win/shell.h"
 | 
					
						
							|  |  |  | #include "ui/display/win/screen_win.h"
 | 
					
						
							| 
									
										
										
										
											2018-05-12 21:33:47 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace atom { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-12 17:37:31 +02:00
										 |  |  | namespace { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if defined(OS_WIN)
 | 
					
						
							| 
									
										
										
										
											2018-05-12 19:51:19 +02:00
										 |  |  | gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) { | 
					
						
							|  |  |  |   if (!window->transparent() || !ui::win::IsAeroGlassEnabled()) | 
					
						
							|  |  |  |     return size; | 
					
						
							| 
									
										
										
										
											2018-05-12 17:37:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-12 19:51:19 +02:00
										 |  |  |   gfx::Size min_size = display::win::ScreenWin::ScreenToDIPSize( | 
					
						
							| 
									
										
										
										
											2018-05-12 17:37:31 +02:00
										 |  |  |       window->GetAcceleratedWidget(), gfx::Size(64, 64)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-12 19:51:19 +02:00
										 |  |  |   // Some AMD drivers can't display windows that are less than 64x64 pixels,
 | 
					
						
							|  |  |  |   // so expand them to be at least that size. http://crbug.com/286609
 | 
					
						
							|  |  |  |   gfx::Size expanded(std::max(size.width(), min_size.width()), | 
					
						
							|  |  |  |                      std::max(size.height(), min_size.height())); | 
					
						
							|  |  |  |   return expanded; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-05-12 17:37:31 +02:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }  // namespace
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-10 15:23:16 +09:00
										 |  |  | NativeWindow::NativeWindow(const mate::Dictionary& options, | 
					
						
							|  |  |  |                            NativeWindow* parent) | 
					
						
							| 
									
										
										
										
											2018-05-22 00:18:38 +02:00
										 |  |  |     : widget_(new views::Widget), parent_(parent), weak_factory_(this) { | 
					
						
							| 
									
										
										
										
											2015-11-13 13:58:31 +08:00
										 |  |  |   options.Get(options::kFrame, &has_frame_); | 
					
						
							|  |  |  |   options.Get(options::kTransparent, &transparent_); | 
					
						
							|  |  |  |   options.Get(options::kEnableLargerThanScreen, &enable_larger_than_screen_); | 
					
						
							| 
									
										
										
										
											2013-09-05 21:43:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-20 14:49:24 +09:00
										 |  |  |   if (parent) | 
					
						
							|  |  |  |     options.Get("modal", &is_modal_); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-02 22:54:09 +08:00
										 |  |  |   WindowList::AddWindow(this); | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | NativeWindow::~NativeWindow() { | 
					
						
							| 
									
										
										
										
											2013-05-02 20:08:23 +08:00
										 |  |  |   // It's possible that the windows gets destroyed before it's closed, in that
 | 
					
						
							| 
									
										
										
										
											2018-07-22 23:12:57 +05:30
										 |  |  |   // case we need to ensure the Widget delegate gets destroyed and
 | 
					
						
							|  |  |  |   // OnWindowClosed message is still notified.
 | 
					
						
							|  |  |  |   if (widget_->widget_delegate()) | 
					
						
							|  |  |  |     widget_->OnNativeWidgetDestroyed(); | 
					
						
							| 
									
										
										
										
											2013-05-02 20:08:23 +08:00
										 |  |  |   NotifyWindowClosed(); | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-23 21:51:42 +08:00
										 |  |  | void NativeWindow::InitFromOptions(const mate::Dictionary& options) { | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  |   // Setup window from options.
 | 
					
						
							| 
									
										
										
										
											2013-07-01 22:01:17 +08:00
										 |  |  |   int x = -1, y = -1; | 
					
						
							| 
									
										
										
										
											2013-05-10 20:34:05 +08:00
										 |  |  |   bool center; | 
					
						
							| 
									
										
										
										
											2015-11-13 13:58:31 +08:00
										 |  |  |   if (options.Get(options::kX, &x) && options.Get(options::kY, &y)) { | 
					
						
							| 
									
										
										
										
											2016-01-15 17:31:31 +01:00
										 |  |  |     SetPosition(gfx::Point(x, y)); | 
					
						
							| 
									
										
										
										
											2017-10-30 11:19:50 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-31 10:31:05 -07:00
										 |  |  | #if defined(OS_WIN)
 | 
					
						
							| 
									
										
										
										
											2017-11-01 11:30:32 -07:00
										 |  |  |     // FIXME(felixrieseberg): Dirty, dirty workaround for
 | 
					
						
							| 
									
										
										
										
											2017-10-30 11:19:50 -07:00
										 |  |  |     // https://github.com/electron/electron/issues/10862
 | 
					
						
							|  |  |  |     // Somehow, we need to call `SetBounds` twice to get
 | 
					
						
							|  |  |  |     // usable results. The root cause is still unknown.
 | 
					
						
							|  |  |  |     SetPosition(gfx::Point(x, y)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-11-13 13:58:31 +08:00
										 |  |  |   } else if (options.Get(options::kCenter, ¢er) && center) { | 
					
						
							| 
									
										
										
										
											2013-05-10 20:34:05 +08:00
										 |  |  |     Center(); | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-01-31 03:19:47 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   bool use_content_size = false; | 
					
						
							|  |  |  |   options.Get(options::kUseContentSize, &use_content_size); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-15 16:35:50 +08:00
										 |  |  |   // On Linux and Window we may already have maximum size defined.
 | 
					
						
							| 
									
										
										
										
											2019-01-31 03:19:47 +01:00
										 |  |  |   extensions::SizeConstraints size_constraints( | 
					
						
							|  |  |  |       use_content_size ? GetContentSizeConstraints() : GetSizeConstraints()); | 
					
						
							| 
									
										
										
										
											2014-08-19 21:43:18 +08:00
										 |  |  |   int min_height = 0, min_width = 0; | 
					
						
							| 
									
										
										
										
											2015-11-13 13:58:31 +08:00
										 |  |  |   if (options.Get(options::kMinHeight, &min_height) | | 
					
						
							|  |  |  |       options.Get(options::kMinWidth, &min_width)) { | 
					
						
							| 
									
										
										
										
											2015-10-05 20:36:28 +08:00
										 |  |  |     size_constraints.set_minimum_size(gfx::Size(min_width, min_height)); | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-03-26 12:23:38 +08:00
										 |  |  |   int max_height = INT_MAX, max_width = INT_MAX; | 
					
						
							| 
									
										
										
										
											2015-11-13 13:58:31 +08:00
										 |  |  |   if (options.Get(options::kMaxHeight, &max_height) | | 
					
						
							|  |  |  |       options.Get(options::kMaxWidth, &max_width)) { | 
					
						
							| 
									
										
										
										
											2015-10-05 20:36:28 +08:00
										 |  |  |     size_constraints.set_maximum_size(gfx::Size(max_width, max_height)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (use_content_size) { | 
					
						
							|  |  |  |     SetContentSizeConstraints(size_constraints); | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     SetSizeConstraints(size_constraints); | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-11-13 00:35:39 +01:00
										 |  |  | #if defined(OS_WIN) || defined(USE_X11)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 13:48:33 -08:00
										 |  |  |   bool resizable; | 
					
						
							|  |  |  |   if (options.Get(options::kResizable, &resizable)) { | 
					
						
							|  |  |  |     SetResizable(resizable); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-01-18 23:46:35 +01:00
										 |  |  |   bool closable; | 
					
						
							|  |  |  |   if (options.Get(options::kClosable, &closable)) { | 
					
						
							|  |  |  |     SetClosable(closable); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-10-06 15:23:23 +08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-01-23 02:23:18 -08:00
										 |  |  |   bool movable; | 
					
						
							| 
									
										
										
										
											2016-01-23 03:35:30 -08:00
										 |  |  |   if (options.Get(options::kMovable, &movable)) { | 
					
						
							| 
									
										
										
										
											2016-01-23 02:23:18 -08:00
										 |  |  |     SetMovable(movable); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-01-23 02:55:12 -08:00
										 |  |  |   bool has_shadow; | 
					
						
							|  |  |  |   if (options.Get(options::kHasShadow, &has_shadow)) { | 
					
						
							|  |  |  |     SetHasShadow(has_shadow); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-09-29 11:26:02 +09:00
										 |  |  |   double opacity; | 
					
						
							|  |  |  |   if (options.Get(options::kOpacity, &opacity)) { | 
					
						
							|  |  |  |     SetOpacity(opacity); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  |   bool top; | 
					
						
							| 
									
										
										
										
											2015-11-13 13:58:31 +08:00
										 |  |  |   if (options.Get(options::kAlwaysOnTop, &top) && top) { | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  |     SetAlwaysOnTop(true); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-02-22 10:23:56 +01:00
										 |  |  |   bool fullscreenable = true; | 
					
						
							|  |  |  |   bool fullscreen = false; | 
					
						
							| 
									
										
										
										
											2016-05-30 09:12:16 +09:00
										 |  |  |   if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) { | 
					
						
							|  |  |  |     // Disable fullscreen button if 'fullscreen' is specified to false.
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | #if defined(OS_MACOSX)
 | 
					
						
							| 
									
										
										
										
											2016-02-22 10:23:56 +01:00
										 |  |  |     fullscreenable = false; | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-05-30 09:12:16 +09:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-03-05 21:54:41 +09:00
										 |  |  |   // Overriden by 'fullscreenable'.
 | 
					
						
							|  |  |  |   options.Get(options::kFullScreenable, &fullscreenable); | 
					
						
							| 
									
										
										
										
											2016-02-22 10:23:56 +01:00
										 |  |  |   SetFullScreenable(fullscreenable); | 
					
						
							| 
									
										
										
										
											2016-03-05 21:54:41 +09:00
										 |  |  |   if (fullscreen) { | 
					
						
							| 
									
										
										
										
											2014-11-25 14:34:14 +08:00
										 |  |  |     SetFullScreen(true); | 
					
						
							| 
									
										
										
										
											2016-03-05 21:54:41 +09:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2014-06-16 10:29:51 +08:00
										 |  |  |   bool skip; | 
					
						
							| 
									
										
										
										
											2016-06-13 17:24:45 +09:00
										 |  |  |   if (options.Get(options::kSkipTaskbar, &skip)) { | 
					
						
							| 
									
										
										
										
											2014-06-16 10:29:51 +08:00
										 |  |  |     SetSkipTaskbar(skip); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  |   bool kiosk; | 
					
						
							| 
									
										
										
										
											2015-11-13 13:58:31 +08:00
										 |  |  |   if (options.Get(options::kKiosk, &kiosk) && kiosk) { | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  |     SetKiosk(kiosk); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-04-10 16:54:07 +09:00
										 |  |  | #if defined(OS_MACOSX)
 | 
					
						
							|  |  |  |   std::string type; | 
					
						
							|  |  |  |   if (options.Get(options::kVibrancyType, &type)) { | 
					
						
							|  |  |  |     SetVibrancy(type); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-10-23 11:35:33 +08:00
										 |  |  |   std::string color; | 
					
						
							| 
									
										
										
										
											2015-11-13 13:58:31 +08:00
										 |  |  |   if (options.Get(options::kBackgroundColor, &color)) { | 
					
						
							| 
									
										
										
										
											2018-03-06 13:21:47 +09:00
										 |  |  |     SetBackgroundColor(ParseHexColor(color)); | 
					
						
							| 
									
										
										
										
											2016-04-14 19:35:31 +09:00
										 |  |  |   } else if (!transparent()) { | 
					
						
							|  |  |  |     // For normal window, use white as default background.
 | 
					
						
							| 
									
										
										
										
											2018-03-06 13:21:47 +09:00
										 |  |  |     SetBackgroundColor(SK_ColorWHITE); | 
					
						
							| 
									
										
										
										
											2015-10-23 11:35:33 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-06-08 14:17:33 -07:00
										 |  |  |   std::string title(Browser::Get()->GetName()); | 
					
						
							| 
									
										
										
										
											2015-11-13 13:58:31 +08:00
										 |  |  |   options.Get(options::kTitle, &title); | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  |   SetTitle(title); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Then show it.
 | 
					
						
							|  |  |  |   bool show = true; | 
					
						
							| 
									
										
										
										
											2015-11-13 13:58:31 +08:00
										 |  |  |   options.Get(options::kShow, &show); | 
					
						
							| 
									
										
										
										
											2015-10-01 17:46:11 +08:00
										 |  |  |   if (show) | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  |     Show(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 16:47:47 -07:00
										 |  |  | bool NativeWindow::IsClosed() const { | 
					
						
							|  |  |  |   return is_closed_; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-15 05:54:12 +01:00
										 |  |  | void NativeWindow::SetSize(const gfx::Size& size, bool animate) { | 
					
						
							|  |  |  |   SetBounds(gfx::Rect(GetPosition(), size), animate); | 
					
						
							| 
									
										
										
										
											2015-05-04 12:43:40 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gfx::Size NativeWindow::GetSize() { | 
					
						
							|  |  |  |   return GetBounds().size(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-15 05:54:12 +01:00
										 |  |  | void NativeWindow::SetPosition(const gfx::Point& position, bool animate) { | 
					
						
							|  |  |  |   SetBounds(gfx::Rect(position, GetSize()), animate); | 
					
						
							| 
									
										
										
										
											2015-05-04 12:43:40 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gfx::Point NativeWindow::GetPosition() { | 
					
						
							|  |  |  |   return GetBounds().origin(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-15 05:54:12 +01:00
										 |  |  | void NativeWindow::SetContentSize(const gfx::Size& size, bool animate) { | 
					
						
							| 
									
										
										
										
											2016-08-04 12:10:01 -07:00
										 |  |  |   SetSize(ContentBoundsToWindowBounds(gfx::Rect(size)).size(), animate); | 
					
						
							| 
									
										
										
										
											2015-10-05 16:19:01 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gfx::Size NativeWindow::GetContentSize() { | 
					
						
							| 
									
										
										
										
											2016-08-04 10:58:59 -07:00
										 |  |  |   return GetContentBounds().size(); | 
					
						
							| 
									
										
										
										
											2016-08-04 12:02:24 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::SetContentBounds(const gfx::Rect& bounds, bool animate) { | 
					
						
							|  |  |  |   SetBounds(ContentBoundsToWindowBounds(bounds), animate); | 
					
						
							| 
									
										
										
										
											2016-08-04 10:58:59 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gfx::Rect NativeWindow::GetContentBounds() { | 
					
						
							|  |  |  |   return WindowBoundsToContentBounds(GetBounds()); | 
					
						
							| 
									
										
										
										
											2015-10-05 16:19:01 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-24 23:33:27 +02:00
										 |  |  | bool NativeWindow::IsNormal() { | 
					
						
							|  |  |  |   return !IsMinimized() && !IsMaximized() && !IsFullscreen(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-05 16:19:01 +08:00
										 |  |  | void NativeWindow::SetSizeConstraints( | 
					
						
							|  |  |  |     const extensions::SizeConstraints& window_constraints) { | 
					
						
							| 
									
										
										
										
											2016-07-12 10:05:32 -07:00
										 |  |  |   extensions::SizeConstraints content_constraints(GetContentSizeConstraints()); | 
					
						
							| 
									
										
										
										
											2016-08-04 10:58:59 -07:00
										 |  |  |   if (window_constraints.HasMaximumSize()) { | 
					
						
							|  |  |  |     gfx::Rect max_bounds = WindowBoundsToContentBounds( | 
					
						
							|  |  |  |         gfx::Rect(window_constraints.GetMaximumSize())); | 
					
						
							|  |  |  |     content_constraints.set_maximum_size(max_bounds.size()); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (window_constraints.HasMinimumSize()) { | 
					
						
							|  |  |  |     gfx::Rect min_bounds = WindowBoundsToContentBounds( | 
					
						
							|  |  |  |         gfx::Rect(window_constraints.GetMinimumSize())); | 
					
						
							|  |  |  |     content_constraints.set_minimum_size(min_bounds.size()); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-10-05 16:19:01 +08:00
										 |  |  |   SetContentSizeConstraints(content_constraints); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 20:57:19 +02:00
										 |  |  | extensions::SizeConstraints NativeWindow::GetSizeConstraints() const { | 
					
						
							| 
									
										
										
										
											2015-10-05 16:19:01 +08:00
										 |  |  |   extensions::SizeConstraints content_constraints = GetContentSizeConstraints(); | 
					
						
							|  |  |  |   extensions::SizeConstraints window_constraints; | 
					
						
							| 
									
										
										
										
											2016-08-04 10:58:59 -07:00
										 |  |  |   if (content_constraints.HasMaximumSize()) { | 
					
						
							|  |  |  |     gfx::Rect max_bounds = ContentBoundsToWindowBounds( | 
					
						
							|  |  |  |         gfx::Rect(content_constraints.GetMaximumSize())); | 
					
						
							| 
									
										
										
										
											2016-08-04 12:14:23 -07:00
										 |  |  |     window_constraints.set_maximum_size(max_bounds.size()); | 
					
						
							| 
									
										
										
										
											2016-08-04 10:58:59 -07:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (content_constraints.HasMinimumSize()) { | 
					
						
							|  |  |  |     gfx::Rect min_bounds = ContentBoundsToWindowBounds( | 
					
						
							|  |  |  |         gfx::Rect(content_constraints.GetMinimumSize())); | 
					
						
							|  |  |  |     window_constraints.set_minimum_size(min_bounds.size()); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-10-05 16:19:01 +08:00
										 |  |  |   return window_constraints; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::SetContentSizeConstraints( | 
					
						
							|  |  |  |     const extensions::SizeConstraints& size_constraints) { | 
					
						
							|  |  |  |   size_constraints_ = size_constraints; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 20:57:19 +02:00
										 |  |  | extensions::SizeConstraints NativeWindow::GetContentSizeConstraints() const { | 
					
						
							| 
									
										
										
										
											2015-10-05 16:19:01 +08:00
										 |  |  |   return size_constraints_; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::SetMinimumSize(const gfx::Size& size) { | 
					
						
							|  |  |  |   extensions::SizeConstraints size_constraints; | 
					
						
							|  |  |  |   size_constraints.set_minimum_size(size); | 
					
						
							|  |  |  |   SetSizeConstraints(size_constraints); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 20:57:19 +02:00
										 |  |  | gfx::Size NativeWindow::GetMinimumSize() const { | 
					
						
							| 
									
										
										
										
											2015-10-05 16:19:01 +08:00
										 |  |  |   return GetSizeConstraints().GetMinimumSize(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::SetMaximumSize(const gfx::Size& size) { | 
					
						
							|  |  |  |   extensions::SizeConstraints size_constraints; | 
					
						
							|  |  |  |   size_constraints.set_maximum_size(size); | 
					
						
							|  |  |  |   SetSizeConstraints(size_constraints); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 20:57:19 +02:00
										 |  |  | gfx::Size NativeWindow::GetMaximumSize() const { | 
					
						
							| 
									
										
										
										
											2015-10-05 16:19:01 +08:00
										 |  |  |   return GetSizeConstraints().GetMaximumSize(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-12 17:37:31 +02:00
										 |  |  | gfx::Size NativeWindow::GetContentMinimumSize() const { | 
					
						
							|  |  |  |   return GetContentSizeConstraints().GetMinimumSize(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gfx::Size NativeWindow::GetContentMaximumSize() const { | 
					
						
							|  |  |  |   gfx::Size maximum_size = GetContentSizeConstraints().GetMaximumSize(); | 
					
						
							|  |  |  | #if defined(OS_WIN)
 | 
					
						
							| 
									
										
										
										
											2018-05-21 02:56:45 +02:00
										 |  |  |   return GetContentSizeConstraints().HasMaximumSize() | 
					
						
							|  |  |  |              ? GetExpandedWindowSize(this, maximum_size) | 
					
						
							|  |  |  |              : maximum_size; | 
					
						
							| 
									
										
										
										
											2018-05-12 22:05:25 +02:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2018-05-12 17:37:31 +02:00
										 |  |  |   return maximum_size; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-19 20:19:08 -07:00
										 |  |  | void NativeWindow::SetSheetOffset(const double offsetX, const double offsetY) { | 
					
						
							| 
									
										
										
										
											2016-05-18 23:39:16 -07:00
										 |  |  |   sheet_offset_x_ = offsetX; | 
					
						
							|  |  |  |   sheet_offset_y_ = offsetY; | 
					
						
							| 
									
										
										
										
											2016-04-18 22:39:12 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-18 23:39:16 -07:00
										 |  |  | double NativeWindow::GetSheetOffsetX() { | 
					
						
							|  |  |  |   return sheet_offset_x_; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | double NativeWindow::GetSheetOffsetY() { | 
					
						
							|  |  |  |   return sheet_offset_y_; | 
					
						
							| 
									
										
										
										
											2016-04-18 22:39:12 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::SetRepresentedFilename(const std::string& filename) {} | 
					
						
							| 
									
										
										
										
											2014-05-27 14:15:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-18 21:42:26 +08:00
										 |  |  | std::string NativeWindow::GetRepresentedFilename() { | 
					
						
							|  |  |  |   return ""; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::SetDocumentEdited(bool edited) {} | 
					
						
							| 
									
										
										
										
											2014-05-27 14:15:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-21 21:00:49 +08:00
										 |  |  | bool NativeWindow::IsDocumentEdited() { | 
					
						
							|  |  |  |   return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::SetFocusable(bool focusable) {} | 
					
						
							| 
									
										
										
										
											2016-06-13 17:10:28 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::SetMenu(AtomMenuModel* menu) {} | 
					
						
							| 
									
										
										
										
											2014-02-10 20:07:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-20 14:49:24 +09:00
										 |  |  | void NativeWindow::SetParentWindow(NativeWindow* parent) { | 
					
						
							|  |  |  |   parent_ = parent; | 
					
						
							| 
									
										
										
										
											2016-06-18 22:53:41 +09:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::SetAutoHideCursor(bool auto_hide) {} | 
					
						
							| 
									
										
										
										
											2016-11-28 11:38:40 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::SelectPreviousTab() {} | 
					
						
							| 
									
										
										
										
											2017-08-21 00:46:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::SelectNextTab() {} | 
					
						
							| 
									
										
										
										
											2017-08-21 00:46:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::MergeAllWindows() {} | 
					
						
							| 
									
										
										
										
											2017-08-21 00:46:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::MoveTabToNewWindow() {} | 
					
						
							| 
									
										
										
										
											2017-08-21 00:46:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::ToggleTabBar() {} | 
					
						
							| 
									
										
										
										
											2017-08-21 00:46:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 13:00:42 -08:00
										 |  |  | bool NativeWindow::AddTabbedWindow(NativeWindow* window) { | 
					
						
							|  |  |  |   return true;  // for non-Mac platforms
 | 
					
						
							| 
									
										
										
										
											2017-09-13 12:15:14 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::SetVibrancy(const std::string& filename) {} | 
					
						
							| 
									
										
										
										
											2016-11-10 11:59:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-28 16:14:02 -08:00
										 |  |  | void NativeWindow::SetTouchBar( | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  |     const std::vector<mate::PersistentDictionary>& items) {} | 
					
						
							| 
									
										
										
										
											2016-11-27 16:57:01 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::RefreshTouchBarItem(const std::string& item_id) {} | 
					
						
							| 
									
										
										
										
											2016-12-16 17:24:51 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 12:41:49 -07:00
										 |  |  | void NativeWindow::SetEscapeTouchBarItem( | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  |     const mate::PersistentDictionary& item) {} | 
					
						
							| 
									
										
										
										
											2017-03-27 11:22:52 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {} | 
					
						
							| 
									
										
										
										
											2015-09-18 13:49:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | bool NativeWindow::IsMenuBarAutoHide() { | 
					
						
							|  |  |  |   return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::SetMenuBarVisibility(bool visible) {} | 
					
						
							| 
									
										
										
										
											2015-09-18 13:49:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | bool NativeWindow::IsMenuBarVisible() { | 
					
						
							|  |  |  |   return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-03 10:20:56 +02:00
										 |  |  | bool NativeWindow::SetWindowButtonVisibility(bool visible) { | 
					
						
							|  |  |  |   return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-18 13:49:33 +08:00
										 |  |  | double NativeWindow::GetAspectRatio() { | 
					
						
							|  |  |  |   return aspect_ratio_; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gfx::Size NativeWindow::GetAspectRatioExtraSize() { | 
					
						
							|  |  |  |   return aspect_ratio_extraSize_; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::SetAspectRatio(double aspect_ratio, | 
					
						
							|  |  |  |                                   const gfx::Size& extra_size) { | 
					
						
							|  |  |  |   aspect_ratio_ = aspect_ratio; | 
					
						
							|  |  |  |   aspect_ratio_extraSize_ = extra_size; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-14 09:42:50 -07:00
										 |  |  | void NativeWindow::PreviewFile(const std::string& path, | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  |                                const std::string& display_name) {} | 
					
						
							| 
									
										
										
										
											2016-10-11 18:08:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::CloseFilePreview() {} | 
					
						
							| 
									
										
										
										
											2016-11-21 13:30:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-06 12:03:12 +09:00
										 |  |  | void NativeWindow::NotifyWindowRequestPreferredWith(int* width) { | 
					
						
							|  |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.RequestPreferredWidth(width); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-22 16:15:21 +09:00
										 |  |  | void NativeWindow::NotifyWindowCloseButtonClicked() { | 
					
						
							|  |  |  |   // First ask the observers whether we want to close.
 | 
					
						
							|  |  |  |   bool prevent_default = false; | 
					
						
							|  |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.WillCloseWindow(&prevent_default); | 
					
						
							|  |  |  |   if (prevent_default) { | 
					
						
							|  |  |  |     WindowList::WindowCloseCancelled(this); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Then ask the observers how should we close the window.
 | 
					
						
							|  |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnCloseButtonClicked(&prevent_default); | 
					
						
							|  |  |  |   if (prevent_default) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   CloseImmediately(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-02 20:08:23 +08:00
										 |  |  | void NativeWindow::NotifyWindowClosed() { | 
					
						
							|  |  |  |   if (is_closed_) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-27 17:01:20 +08:00
										 |  |  |   WindowList::RemoveWindow(this); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-02 20:08:23 +08:00
										 |  |  |   is_closed_ = true; | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowClosed(); | 
					
						
							| 
									
										
										
										
											2013-05-02 20:08:23 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-21 20:45:30 +00:00
										 |  |  | void NativeWindow::NotifyWindowEndSession() { | 
					
						
							|  |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowEndSession(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-24 17:51:15 +08:00
										 |  |  | void NativeWindow::NotifyWindowBlur() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowBlur(); | 
					
						
							| 
									
										
										
										
											2013-05-24 17:51:15 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-21 13:46:13 -04:00
										 |  |  | void NativeWindow::NotifyWindowFocus() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowFocus(); | 
					
						
							| 
									
										
										
										
											2014-05-21 13:46:13 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-08 11:11:17 -08:00
										 |  |  | void NativeWindow::NotifyWindowShow() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowShow(); | 
					
						
							| 
									
										
										
										
											2016-03-08 11:11:17 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::NotifyWindowHide() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowHide(); | 
					
						
							| 
									
										
										
										
											2016-03-08 11:11:17 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-25 12:43:25 +08:00
										 |  |  | void NativeWindow::NotifyWindowMaximize() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowMaximize(); | 
					
						
							| 
									
										
										
										
											2014-11-25 12:43:25 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::NotifyWindowUnmaximize() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowUnmaximize(); | 
					
						
							| 
									
										
										
										
											2014-11-25 12:43:25 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::NotifyWindowMinimize() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowMinimize(); | 
					
						
							| 
									
										
										
										
											2014-11-25 12:43:25 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::NotifyWindowRestore() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowRestore(); | 
					
						
							| 
									
										
										
										
											2014-11-25 12:43:25 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-27 11:53:01 +02:00
										 |  |  | void NativeWindow::NotifyWindowWillResize(const gfx::Rect& new_bounds, | 
					
						
							|  |  |  |                                           bool* prevent_default) { | 
					
						
							|  |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowWillResize(new_bounds, prevent_default); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-28 09:44:10 -04:00
										 |  |  | void NativeWindow::NotifyWindowWillMove(const gfx::Rect& new_bounds, | 
					
						
							|  |  |  |                                         bool* prevent_default) { | 
					
						
							|  |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowWillMove(new_bounds, prevent_default); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-09 21:25:10 +05:30
										 |  |  | void NativeWindow::NotifyWindowResize() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowResize(); | 
					
						
							| 
									
										
										
										
											2015-05-09 21:25:10 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::NotifyWindowMove() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowMove(); | 
					
						
							| 
									
										
										
										
											2015-05-09 21:25:10 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-20 14:07:13 +05:30
										 |  |  | void NativeWindow::NotifyWindowMoved() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowMoved(); | 
					
						
							| 
									
										
										
										
											2015-05-20 14:07:13 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-25 12:43:25 +08:00
										 |  |  | void NativeWindow::NotifyWindowEnterFullScreen() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowEnterFullScreen(); | 
					
						
							| 
									
										
										
										
											2014-11-25 12:43:25 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-21 16:31:09 -08:00
										 |  |  | void NativeWindow::NotifyWindowScrollTouchBegin() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowScrollTouchBegin(); | 
					
						
							| 
									
										
										
										
											2016-01-21 09:40:21 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-21 16:31:09 -08:00
										 |  |  | void NativeWindow::NotifyWindowScrollTouchEnd() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							| 
									
										
										
										
											2017-02-13 11:24:47 -08:00
										 |  |  |     observer.OnWindowScrollTouchEnd(); | 
					
						
							| 
									
										
										
										
											2016-01-21 09:40:21 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-23 15:20:11 +00:00
										 |  |  | void NativeWindow::NotifyWindowSwipe(const std::string& direction) { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowSwipe(direction); | 
					
						
							| 
									
										
										
										
											2016-03-18 15:20:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 10:31:25 -07:00
										 |  |  | void NativeWindow::NotifyWindowSheetBegin() { | 
					
						
							|  |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowSheetBegin(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::NotifyWindowSheetEnd() { | 
					
						
							|  |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowSheetEnd(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-25 12:43:25 +08:00
										 |  |  | void NativeWindow::NotifyWindowLeaveFullScreen() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowLeaveFullScreen(); | 
					
						
							| 
									
										
										
										
											2014-11-25 12:43:25 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-21 10:39:31 +05:30
										 |  |  | void NativeWindow::NotifyWindowEnterHtmlFullScreen() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowEnterHtmlFullScreen(); | 
					
						
							| 
									
										
										
										
											2015-05-21 10:39:31 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NativeWindow::NotifyWindowLeaveHtmlFullScreen() { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowLeaveHtmlFullScreen(); | 
					
						
							| 
									
										
										
										
											2015-05-21 10:39:31 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-04 11:02:16 -07:00
										 |  |  | void NativeWindow::NotifyWindowAlwaysOnTopChanged() { | 
					
						
							|  |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowAlwaysOnTopChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-05 09:35:59 -08:00
										 |  |  | void NativeWindow::NotifyWindowExecuteAppCommand(const std::string& command) { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							| 
									
										
										
										
											2018-12-05 09:35:59 -08:00
										 |  |  |     observer.OnExecuteAppCommand(command); | 
					
						
							| 
									
										
										
										
											2015-08-05 12:46:32 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-27 16:57:01 +11:00
										 |  |  | void NativeWindow::NotifyTouchBarItemInteraction( | 
					
						
							| 
									
										
										
										
											2017-02-28 15:37:15 -08:00
										 |  |  |     const std::string& item_id, | 
					
						
							|  |  |  |     const base::DictionaryValue& details) { | 
					
						
							| 
									
										
										
										
											2017-02-27 09:20:25 -08:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							| 
									
										
										
										
											2017-02-28 15:37:15 -08:00
										 |  |  |     observer.OnTouchBarItemResult(item_id, details); | 
					
						
							| 
									
										
										
										
											2017-02-27 09:20:25 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-11-27 16:57:01 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 01:19:01 -07:00
										 |  |  | void NativeWindow::NotifyNewWindowForTab() { | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							| 
									
										
										
										
											2017-06-11 01:19:01 -07:00
										 |  |  |     observer.OnNewWindowForTab(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-27 03:12:01 +02:00
										 |  |  | #if defined(OS_WIN)
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  | void NativeWindow::NotifyWindowMessage(UINT message, | 
					
						
							|  |  |  |                                        WPARAM w_param, | 
					
						
							|  |  |  |                                        LPARAM l_param) { | 
					
						
							| 
									
										
										
										
											2017-01-24 12:34:39 +09:00
										 |  |  |   for (NativeWindowObserver& observer : observers_) | 
					
						
							|  |  |  |     observer.OnWindowMessage(message, w_param, l_param); | 
					
						
							| 
									
										
										
										
											2015-10-27 03:12:01 +02:00
										 |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-25 16:05:43 +09:00
										 |  |  | views::Widget* NativeWindow::GetWidget() { | 
					
						
							|  |  |  |   return widget(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const views::Widget* NativeWindow::GetWidget() const { | 
					
						
							|  |  |  |   return widget(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-02 15:14:43 -07:00
										 |  |  | // static
 | 
					
						
							|  |  |  | void NativeWindowRelay::CreateForWebContents( | 
					
						
							|  |  |  |     content::WebContents* web_contents, | 
					
						
							|  |  |  |     base::WeakPtr<NativeWindow> window) { | 
					
						
							|  |  |  |   DCHECK(web_contents); | 
					
						
							| 
									
										
										
										
											2019-01-21 22:26:54 +05:30
										 |  |  |   if (!web_contents->GetUserData(UserDataKey())) { | 
					
						
							|  |  |  |     web_contents->SetUserData(UserDataKey(), | 
					
						
							|  |  |  |                               base::WrapUnique(new NativeWindowRelay(window))); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-10-02 15:14:43 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 16:37:22 -07:00
										 |  |  | NativeWindowRelay::NativeWindowRelay(base::WeakPtr<NativeWindow> window) | 
					
						
							| 
									
										
										
										
											2018-10-02 15:14:43 -07:00
										 |  |  |     : native_window_(window) {} | 
					
						
							| 
									
										
										
										
											2018-04-17 16:37:22 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | NativeWindowRelay::~NativeWindowRelay() = default; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 22:26:54 +05:30
										 |  |  | WEB_CONTENTS_USER_DATA_KEY_IMPL(NativeWindowRelay) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-12 15:04:46 +08:00
										 |  |  | }  // namespace atom
 |