mac: Add win.setParentWindow(parent) API
This commit is contained in:
parent
e4d30ccfc3
commit
fd42e3dc84
7 changed files with 22 additions and 0 deletions
|
@ -650,6 +650,10 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) {
|
|||
window_->SetAspectRatio(aspect_ratio, extra_size);
|
||||
}
|
||||
|
||||
void Window::SetParentWindow(NativeWindow* parent) {
|
||||
window_->SetParentWindow(parent);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Window::GetNativeWindowHandle() {
|
||||
gfx::AcceleratedWidget handle = window_->GetAcceleratedWidget();
|
||||
return ToBuffer(
|
||||
|
@ -697,6 +701,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("setFullScreen", &Window::SetFullScreen)
|
||||
.SetMethod("isFullScreen", &Window::IsFullscreen)
|
||||
.SetMethod("setAspectRatio", &Window::SetAspectRatio)
|
||||
.SetMethod("setParentWindow", &Window::SetParentWindow)
|
||||
.SetMethod("getNativeWindowHandle", &Window::GetNativeWindowHandle)
|
||||
.SetMethod("getBounds", &Window::GetBounds)
|
||||
.SetMethod("setBounds", &Window::SetBounds)
|
||||
|
|
|
@ -159,6 +159,7 @@ class Window : public mate::TrackableObject<Window>,
|
|||
void SetMenuBarVisibility(bool visible);
|
||||
bool IsMenuBarVisible();
|
||||
void SetAspectRatio(double aspect_ratio, mate::Arguments* args);
|
||||
void SetParentWindow(NativeWindow* parent);
|
||||
v8::Local<v8::Value> GetNativeWindowHandle();
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
|
|
@ -158,6 +158,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual void SetFocusable(bool focusable);
|
||||
virtual void SetMenu(ui::MenuModel* menu);
|
||||
virtual bool HasModalDialog();
|
||||
virtual void SetParentWindow(NativeWindow* parent) = 0;
|
||||
virtual gfx::NativeWindow GetNativeWindow() = 0;
|
||||
virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0;
|
||||
|
||||
|
|
|
@ -78,6 +78,7 @@ class NativeWindowMac : public NativeWindow {
|
|||
bool IsDocumentEdited() override;
|
||||
void SetIgnoreMouseEvents(bool ignore) override;
|
||||
bool HasModalDialog() override;
|
||||
void SetParentWindow(NativeWindow* parent) override;
|
||||
gfx::NativeWindow GetNativeWindow() override;
|
||||
gfx::AcceleratedWidget GetAcceleratedWidget() override;
|
||||
void SetProgressBar(double progress) override;
|
||||
|
|
|
@ -911,6 +911,16 @@ bool NativeWindowMac::HasModalDialog() {
|
|||
return [window_ attachedSheet] != nil;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetParentWindow(NativeWindow* parent) {
|
||||
// Remove current parent window.
|
||||
if ([window_ parentWindow])
|
||||
[[window_ parentWindow] removeChildWindow:window_];
|
||||
|
||||
// Set new current window.
|
||||
if (parent)
|
||||
[parent->GetNativeWindow() addChildWindow:window_ ordered:NSWindowAbove];
|
||||
}
|
||||
|
||||
gfx::NativeWindow NativeWindowMac::GetNativeWindow() {
|
||||
return window_;
|
||||
}
|
||||
|
|
|
@ -772,6 +772,9 @@ void NativeWindowViews::SetMenu(ui::MenuModel* menu_model) {
|
|||
Layout();
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetParentWindow(NativeWindow* parent) {
|
||||
}
|
||||
|
||||
gfx::NativeWindow NativeWindowViews::GetNativeWindow() {
|
||||
return window_->GetNativeWindow();
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ class NativeWindowViews : public NativeWindow,
|
|||
void SetIgnoreMouseEvents(bool ignore) override;
|
||||
void SetFocusable(bool focusable) override;
|
||||
void SetMenu(ui::MenuModel* menu_model) override;
|
||||
void SetParentWindow(NativeWindow* parent) override;
|
||||
gfx::NativeWindow GetNativeWindow() override;
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) override;
|
||||
|
|
Loading…
Reference in a new issue