Browse Source

first pass at api method to enable window

Shelley Vohr 7 years ago
parent
commit
97589bbe33
2 changed files with 8 additions and 4 deletions
  1. 7 4
      atom/browser/api/atom_api_window.cc
  2. 1 0
      atom/browser/api/atom_api_window.h

+ 7 - 4
atom/browser/api/atom_api_window.cc

@@ -9,6 +9,7 @@
 #include "atom/browser/api/atom_api_web_contents.h"
 #include "atom/browser/browser.h"
 #include "atom/browser/native_window.h"
+#include "atom/browser/native_window_views.h"
 #include "atom/browser/web_contents_preferences.h"
 #include "atom/common/native_mate_converters/callback.h"
 #include "atom/common/native_mate_converters/file_path_converter.h"
@@ -26,10 +27,6 @@
 #include "native_mate/dictionary.h"
 #include "ui/gfx/geometry/rect.h"
 
-#if defined(TOOLKIT_VIEWS)
-#include "atom/browser/native_window_views.h"
-#endif
-
 #if defined(OS_WIN)
 #include "atom/browser/ui/win/taskbar_host.h"
 #include "ui/base/win/shell.h"
@@ -393,6 +390,11 @@ bool Window::IsEnabled() {
   return window_->IsEnabled();
 }
 
+void Window::SetEnabled(bool enable) {
+  auto window = static_cast<NativeWindowViews*>(window_.get());
+  window->SetEnabled(enable);
+}
+
 void Window::Maximize() {
   window_->Maximize();
 }
@@ -1008,6 +1010,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
       .SetMethod("hide", &Window::Hide)
       .SetMethod("isVisible", &Window::IsVisible)
       .SetMethod("isEnabled", &Window::IsEnabled)
+      .SetMethod("setEnabled", & Window::SetEnabled)
       .SetMethod("maximize", &Window::Maximize)
       .SetMethod("unmaximize", &Window::Unmaximize)
       .SetMethod("isMaximized", &Window::IsMaximized)

+ 1 - 0
atom/browser/api/atom_api_window.h

@@ -112,6 +112,7 @@ class Window : public mate::TrackableObject<Window>,
   void Hide();
   bool IsVisible();
   bool IsEnabled();
+  void SetEnabled(bool enable);
   void Maximize();
   void Unmaximize();
   bool IsMaximized();