*prevent_default = Emit("close");
}
+void Window::WillDestoryNativeObject() {
+ // Close all child windows before closing current window.
+ v8::Locker locker(isolate());
+ v8::HandleScope handle_scope(isolate());
+ for (v8::Local<v8::Value> value : child_windows_.Values(isolate())) {
+ mate::Handle<Window> child;
+ if (mate::ConvertFromV8(isolate(), value, &child))
+ child->window_->CloseImmediately();
+ }
+}
+
void Window::OnWindowClosed() {
api_web_contents_->DestroyWebContents();
parent->Disable();
else
parent->Enable();
+ window_->SetModal(modal);
is_modal_ = modal;
}
// NativeWindowObserver:
void WillCloseWindow(bool* prevent_default) override;
+ void WillDestoryNativeObject() override;
void OnWindowClosed() override;
void OnWindowBlur() override;
void OnWindowFocus() override;
inspectable_web_contents_ = nullptr;
Observe(nullptr);
+ FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
+ WillDestoryNativeObject());
+
// When the web contents is gone, close the window immediately, but the
// memory will not be freed until you call delete.
// In this way, it would be safe to manage windows via smart pointers. If you
virtual void SetParentWindow(NativeWindow* parent) = 0;
virtual void BeginSheet(NativeWindow* sheet);
virtual void EndSheet(NativeWindow* sheet);
+ virtual void SetModal(bool modal) = 0;
virtual gfx::NativeWindow GetNativeWindow() = 0;
virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0;
void SetParentWindow(NativeWindow* parent) override;
void BeginSheet(NativeWindow* sheet) override;
void EndSheet(NativeWindow* sheet) override;
+ void SetModal(bool modal) override;
gfx::NativeWindow GetNativeWindow() override;
gfx::AcceleratedWidget GetAcceleratedWidget() override;
void SetProgressBar(double progress) override;
}
void NativeWindowMac::CloseImmediately() {
- // Close all child windows before closing this window.
- for (NSWindow* child in [window_ childWindows])
- [child close];
-
[window_ close];
}
sheet->CloseImmediately();
}
+void NativeWindowMac::SetModal(bool modal) {
+}
+
gfx::NativeWindow NativeWindowMac::GetNativeWindow() {
return window_;
}
// Called when the window is gonna closed.
virtual void WillCloseWindow(bool* prevent_default) {}
+ // Called before the native window object is going to be destroyed.
+ virtual void WillDestoryNativeObject() {}
+
// Called when the window is closed.
virtual void OnWindowClosed() {}
if (options.Get(options::kFocusable, &focusable) && !focusable)
params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
+#if defined(OS_WIN)
if (parent)
params.parent = parent->GetNativeWindow();
-#if defined(OS_WIN)
params.native_widget =
new views::DesktopNativeWidgetAura(window_.get());
atom_desktop_window_tree_host_win_ = new AtomDesktopWindowTreeHostWin(
std::string window_type;
if (options.Get(options::kType, &window_type))
SetWindowType(GetAcceleratedWidget(), window_type);
+
+ if (parent)
+ SetParentWindow(parent);
#endif
// Add web view.
}
void NativeWindowViews::Disable() {
+#if defined(OS_WIN)
::EnableWindow(GetAcceleratedWidget(), FALSE);
+#elif defined(USE_X11)
+#endif
}
void NativeWindowViews::Enable() {
+#if defined(OS_WIN)
::EnableWindow(GetAcceleratedWidget(), TRUE);
+#elif defined(USE_X11)
+#endif
}
bool NativeWindowViews::IsEnabled() {
+#if defined(OS_WIN)
return ::IsWindowEnabled(GetAcceleratedWidget());
+#else
+ return false;
+#endif
}
void NativeWindowViews::Maximize() {
}
void NativeWindowViews::SetParentWindow(NativeWindow* parent) {
+#if defined(USE_X11)
+ XDisplay* xdisplay = gfx::GetXDisplay();
+ XSetTransientForHint(
+ xdisplay, GetAcceleratedWidget(),
+ parent? parent->GetAcceleratedWidget() : DefaultRootWindow(xdisplay));
+#elif defined(OS_WIN) && defined(DEBUG)
// Should work, but does not, it seems that the views toolkit doesn't support
// reparenting on desktop.
-#if defined(DEBUG)
if (parent) {
::SetParent(GetAcceleratedWidget(), parent->GetAcceleratedWidget());
views::Widget::ReparentNativeView(GetNativeWindow(),
} else {
if (!GetNativeWindow()->parent())
return;
+ ::SetParent(GetAcceleratedWidget(), NULL);
views::Widget::ReparentNativeView(GetNativeWindow(), nullptr);
wm::RemoveTransientChild(GetNativeWindow()->parent(), GetNativeWindow());
}
#endif
}
+void NativeWindowViews::SetModal(bool modal) {
+#if defined(USE_X11)
+ SetWMSpecState(GetAcceleratedWidget(), modal,
+ GetAtom("_NET_WM_STATE_MODAL"));
+ SetWindowType(GetAcceleratedWidget(), modal ? "dialog" : "normal");
+#endif
+}
+
gfx::NativeWindow NativeWindowViews::GetNativeWindow() {
return window_->GetNativeWindow();
}
void SetFocusable(bool focusable) override;
void SetMenu(ui::MenuModel* menu_model) override;
void SetParentWindow(NativeWindow* parent) override;
+ void SetModal(bool modal) override;
gfx::NativeWindow GetNativeWindow() override;
void SetOverlayIcon(const gfx::Image& overlay,
const std::string& description) override;
})
describe('win.setParentWindow(parent)', function () {
- if (process.platform !== 'darwin') return
+ if (process.platform === 'win32') return
beforeEach(function () {
if (c != null) c.destroy()