don't show the dummy window for the rest of the dialogs too on mac
This commit is contained in:
parent
5373afa472
commit
71b36ef54d
7 changed files with 51 additions and 20 deletions
|
@ -144,6 +144,7 @@ void Window::Init(v8::Isolate* isolate,
|
|||
options,
|
||||
parent.IsEmpty() ? nullptr : parent->window_.get()));
|
||||
web_contents->SetOwnerWindow(window_.get());
|
||||
window_->SetIsOffScreenDummy(api_web_contents_->IsOffScreen());
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
// Sets the window icon.
|
||||
|
|
|
@ -41,8 +41,7 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
|||
buttons.push_back("Cancel");
|
||||
}
|
||||
|
||||
atom::ShowMessageBox(api_web_contents_->IsOffScreen() ? nullptr :
|
||||
NativeWindow::FromWebContents(web_contents),
|
||||
atom::ShowMessageBox(NativeWindow::FromWebContents(web_contents),
|
||||
atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1,
|
||||
0, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
|
||||
base::UTF16ToUTF8(message_text), "", "", false,
|
||||
|
|
|
@ -65,6 +65,7 @@ NativeWindow::NativeWindow(
|
|||
aspect_ratio_(0.0),
|
||||
parent_(parent),
|
||||
is_modal_(false),
|
||||
is_osr_dummy_(false),
|
||||
inspectable_web_contents_(inspectable_web_contents),
|
||||
weak_factory_(this) {
|
||||
options.Get(options::kFrame, &has_frame_);
|
||||
|
|
|
@ -237,6 +237,12 @@ class NativeWindow : public base::SupportsUserData,
|
|||
const std::vector<base::string16>& values,
|
||||
const std::vector<base::string16>& labels) {}
|
||||
virtual void HideAutofillPopup(content::RenderFrameHost* frame_host) {}
|
||||
void SetIsOffScreenDummy(bool is_dummy) {
|
||||
is_osr_dummy_ = is_dummy;
|
||||
}
|
||||
bool IsOffScreenDummy() {
|
||||
return is_osr_dummy_;
|
||||
}
|
||||
|
||||
// Public API used by platform-dependent delegates and observers to send UI
|
||||
// related notifications.
|
||||
|
@ -368,6 +374,9 @@ class NativeWindow : public base::SupportsUserData,
|
|||
// Is this a modal window.
|
||||
bool is_modal_;
|
||||
|
||||
// Is this a dummy window for an offscreen WebContents.
|
||||
bool is_osr_dummy_;
|
||||
|
||||
// The page this window is viewing.
|
||||
brightray::InspectableWebContents* inspectable_web_contents_;
|
||||
|
||||
|
|
|
@ -1361,8 +1361,6 @@ void NativeWindowViews::ShowAutofillPopup(
|
|||
const gfx::RectF& bounds,
|
||||
const std::vector<base::string16>& values,
|
||||
const std::vector<base::string16>& labels) {
|
||||
// auto wc = atom::api::WebContents::FromWrappedClass(
|
||||
// v8::Isolate::GetCurrent(), web_contents());
|
||||
autofill_popup_->CreateView(
|
||||
frame_host,
|
||||
web_contents->IsOffScreenOrEmbedderOffscreen(),
|
||||
|
|
|
@ -112,7 +112,8 @@ void SetupDialogForProperties(NSOpenPanel* dialog, int properties) {
|
|||
// Run modal dialog with parent window and return user's choice.
|
||||
int RunModalDialog(NSSavePanel* dialog, atom::NativeWindow* parent_window) {
|
||||
__block int chosen = NSFileHandlingPanelCancelButton;
|
||||
if (!parent_window || !parent_window->GetNativeWindow()) {
|
||||
if (!parent_window || !parent_window->GetNativeWindow() ||
|
||||
parent_window->IsOffScreenDummy()) {
|
||||
chosen = [dialog runModal];
|
||||
} else {
|
||||
NSWindow* window = parent_window->GetNativeWindow();
|
||||
|
@ -164,9 +165,18 @@ void ShowOpenDialog(const DialogSettings& settings,
|
|||
// only store the pointer, by duplication we can force gcd to store a copy.
|
||||
__block OpenDialogCallback callback = c;
|
||||
|
||||
NSWindow* window = settings.parent_window ?
|
||||
settings.parent_window->GetNativeWindow() :
|
||||
nullptr;
|
||||
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
||||
settings.parent_window->IsOffScreenDummy()) {
|
||||
int chosen = [dialog runModal];
|
||||
if (chosen == NSFileHandlingPanelCancelButton) {
|
||||
callback.Run(false, std::vector<base::FilePath>());
|
||||
} else {
|
||||
std::vector<base::FilePath> paths;
|
||||
ReadDialogPaths(dialog, &paths);
|
||||
callback.Run(true, paths);
|
||||
}
|
||||
} else {
|
||||
NSWindow* window = settings.parent_window->GetNativeWindow();
|
||||
[dialog beginSheetModalForWindow:window
|
||||
completionHandler:^(NSInteger chosen) {
|
||||
if (chosen == NSFileHandlingPanelCancelButton) {
|
||||
|
@ -178,6 +188,7 @@ void ShowOpenDialog(const DialogSettings& settings,
|
|||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
bool ShowSaveDialog(const DialogSettings& settings,
|
||||
base::FilePath* path) {
|
||||
|
@ -203,9 +214,17 @@ void ShowSaveDialog(const DialogSettings& settings,
|
|||
|
||||
__block SaveDialogCallback callback = c;
|
||||
|
||||
NSWindow* window = settings.parent_window ?
|
||||
settings.parent_window->GetNativeWindow() :
|
||||
nullptr;
|
||||
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
||||
settings.parent_window->IsOffScreenDummy()) {
|
||||
int chosen = [dialog runModal];
|
||||
if (chosen == NSFileHandlingPanelCancelButton) {
|
||||
callback.Run(false, base::FilePath());
|
||||
} else {
|
||||
std::string path = base::SysNSStringToUTF8([[dialog URL] path]);
|
||||
callback.Run(true, base::FilePath(path));
|
||||
}
|
||||
} else {
|
||||
NSWindow* window = settings.parent_window->GetNativeWindow();
|
||||
[dialog beginSheetModalForWindow:window
|
||||
completionHandler:^(NSInteger chosen) {
|
||||
if (chosen == NSFileHandlingPanelCancelButton) {
|
||||
|
@ -216,5 +235,6 @@ void ShowSaveDialog(const DialogSettings& settings,
|
|||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace file_dialog
|
||||
|
|
|
@ -146,7 +146,8 @@ int ShowMessageBox(NativeWindow* parent_window,
|
|||
|
||||
// Use runModal for synchronous alert without parent, since we don't have a
|
||||
// window to wait for.
|
||||
if (!parent_window || !parent_window->GetNativeWindow())
|
||||
if (!parent_window || !parent_window->GetNativeWindow() ||
|
||||
parent_window->IsOffScreenDummy())
|
||||
return [[alert autorelease] runModal];
|
||||
|
||||
int ret_code = -1;
|
||||
|
@ -184,8 +185,10 @@ void ShowMessageBox(NativeWindow* parent_window,
|
|||
|
||||
// Use runModal for synchronous alert without parent, since we don't have a
|
||||
// window to wait for.
|
||||
if (!parent_window || !parent_window->GetNativeWindow()) {
|
||||
[[alert autorelease] runModal];
|
||||
if (!parent_window || !parent_window->GetNativeWindow() ||
|
||||
parent_window->IsOffScreenDummy()) {
|
||||
int ret = [[alert autorelease] runModal];
|
||||
callback.Run(ret, false);
|
||||
} else {
|
||||
ModalDelegate* delegate = [[ModalDelegate alloc] initWithCallback:callback
|
||||
andAlert:alert
|
||||
|
|
Loading…
Add table
Reference in a new issue