]> khamidou — GitHub mirrors - electron.git/commitdiff
win: Implement window state events
authorCheng Zhao <zcbenz@gmail.com>
Tue, 25 Nov 2014 06:28:34 +0000 (14:28 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 25 Nov 2014 06:28:34 +0000 (14:28 +0800)
atom/browser/native_window_views.cc
atom/browser/native_window_views.h

index ae291b9977357dc7a5cd33cb87994278f4d76615..583c179f64db8cd2e5d10b9579a71cbc79d335df 100644 (file)
@@ -145,6 +145,9 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
       menu_bar_autohide_(false),
       menu_bar_visible_(false),
       menu_bar_alt_pressed_(false),
+#if defined(OS_WIN)
+      is_minimized_(false),
+#endif
       keyboard_event_handler_(new views::UnhandledKeyboardEventHandler),
       use_content_size_(false),
       resizable_(true) {
@@ -317,6 +320,13 @@ bool NativeWindowViews::IsMinimized() {
 
 void NativeWindowViews::SetFullscreen(bool fullscreen) {
   window_->SetFullscreen(fullscreen);
+#if defined(OS_WIN)
+  // There is no native fullscreen state on Windows.
+  if (fullscreen)
+    NotifyWindowEnterFullScreen();
+  else
+    NotifyWindowLeaveFullScreen();
+#endif
 }
 
 bool NativeWindowViews::IsFullscreen() {
@@ -720,6 +730,27 @@ views::NonClientFrameView* NativeWindowViews::CreateNonClientFrameView(
 #endif
 }
 
+#if defined(OS_WIN)
+bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
+  // Windows uses the 4 lower order bits of |command_id| for type-specific
+  // information so we must exclude this when comparing.
+  static const int sc_mask = 0xFFF0;
+  if ((command_id & sc_mask) == SC_MINIMIZE) {
+    NotifyWindowMinimize();
+    is_minimized_ = true;
+  } else if ((command_id & sc_mask) == SC_RESTORE) {
+    if (is_minimized_)
+      NotifyWindowRestore();
+    else
+      NotifyWindowUnmaximize();
+    is_minimized_ = false;
+  } else if ((command_id & sc_mask) == SC_MAXIMIZE) {
+    NotifyWindowMaximize();
+  }
+  return false;
+}
+#endif
+
 gfx::ImageSkia NativeWindowViews::GetDevToolsWindowIcon() {
   return GetWindowAppIcon();
 }
index f15f5cb7ceac85bae33fc903e157e6d1b631254a..c4e4f0b65698b17205b206fcd360228c6ad5fe82 100644 (file)
@@ -111,6 +111,9 @@ class NativeWindowViews : public NativeWindow,
   views::ClientView* CreateClientView(views::Widget* widget) override;
   views::NonClientFrameView* CreateNonClientFrameView(
       views::Widget* widget) override;
+#if defined(OS_WIN)
+  bool ExecuteWindowsCommand(int command_id) override;
+#endif
 
   // brightray::InspectableWebContentsDelegate:
   gfx::ImageSkia GetDevToolsWindowIcon() override;
@@ -148,6 +151,10 @@ class NativeWindowViews : public NativeWindow,
 
   // Handles window state events.
   scoped_ptr<WindowStateWatcher> window_state_watcher_;
+#elif defined(OS_WIN)
+  // Records window was whether restored from minimized state or maximized
+  // state.
+  bool is_minimized_;
 #endif
 
   // Handles unhandled keyboard messages coming back from the renderer process.