don't show osr dummy window when dialog is shown on mac
This commit is contained in:
parent
35dc6d03b9
commit
13b86598e8
3 changed files with 29 additions and 13 deletions
|
@ -41,7 +41,8 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||||
buttons.push_back("Cancel");
|
buttons.push_back("Cancel");
|
||||||
}
|
}
|
||||||
|
|
||||||
atom::ShowMessageBox(NativeWindow::FromWebContents(web_contents),
|
atom::ShowMessageBox(api_web_contents_->IsOffScreen() ? nullptr :
|
||||||
|
NativeWindow::FromWebContents(web_contents),
|
||||||
atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1,
|
atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1,
|
||||||
0, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
|
0, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
|
||||||
base::UTF16ToUTF8(message_text), "", "", false,
|
base::UTF16ToUTF8(message_text), "", "", false,
|
||||||
|
|
|
@ -181,6 +181,12 @@ void ShowMessageBox(NativeWindow* parent_window,
|
||||||
NSAlert* alert =
|
NSAlert* alert =
|
||||||
CreateNSAlert(parent_window, type, buttons, default_id, cancel_id, title,
|
CreateNSAlert(parent_window, type, buttons, default_id, cancel_id, title,
|
||||||
message, detail, checkbox_label, checkbox_checked, icon);
|
message, detail, checkbox_label, checkbox_checked, icon);
|
||||||
|
|
||||||
|
// 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];
|
||||||
|
} else {
|
||||||
ModalDelegate* delegate = [[ModalDelegate alloc] initWithCallback:callback
|
ModalDelegate* delegate = [[ModalDelegate alloc] initWithCallback:callback
|
||||||
andAlert:alert
|
andAlert:alert
|
||||||
callEndModal:false];
|
callEndModal:false];
|
||||||
|
@ -190,6 +196,7 @@ void ShowMessageBox(NativeWindow* parent_window,
|
||||||
modalDelegate:delegate
|
modalDelegate:delegate
|
||||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||||
contextInfo:nil];
|
contextInfo:nil];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowErrorBox(const base::string16& title, const base::string16& content) {
|
void ShowErrorBox(const base::string16& title, const base::string16& content) {
|
||||||
|
|
|
@ -443,11 +443,15 @@ ipcMain.on('ELECTRON_BROWSER_WINDOW_ALERT', function (event, message, title) {
|
||||||
if (message == null) message = ''
|
if (message == null) message = ''
|
||||||
if (title == null) title = ''
|
if (title == null) title = ''
|
||||||
|
|
||||||
event.returnValue = electron.dialog.showMessageBox(event.sender.getOwnerBrowserWindow(), {
|
const dialogProperties = {
|
||||||
message: `${message}`,
|
message: `${message}`,
|
||||||
title: `${title}`,
|
title: `${title}`,
|
||||||
buttons: ['OK']
|
buttons: ['OK']
|
||||||
})
|
}
|
||||||
|
event.returnValue = event.sender.isOffscreen() ?
|
||||||
|
electron.dialog.showMessageBox(dialogProperties) :
|
||||||
|
electron.dialog.showMessageBox(
|
||||||
|
event.sender.getOwnerBrowserWindow(), dialogProperties)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Implements window.confirm(message, title)
|
// Implements window.confirm(message, title)
|
||||||
|
@ -455,12 +459,16 @@ ipcMain.on('ELECTRON_BROWSER_WINDOW_CONFIRM', function (event, message, title) {
|
||||||
if (message == null) message = ''
|
if (message == null) message = ''
|
||||||
if (title == null) title = ''
|
if (title == null) title = ''
|
||||||
|
|
||||||
event.returnValue = !electron.dialog.showMessageBox(event.sender.getOwnerBrowserWindow(), {
|
const dialogProperties = {
|
||||||
message: `${message}`,
|
message: `${message}`,
|
||||||
title: `${title}`,
|
title: `${title}`,
|
||||||
buttons: ['OK', 'Cancel'],
|
buttons: ['OK', 'Cancel'],
|
||||||
cancelId: 1
|
cancelId: 1
|
||||||
})
|
}
|
||||||
|
event.returnValue = !(event.sender.isOffscreen() ?
|
||||||
|
electron.dialog.showMessageBox(dialogProperties) :
|
||||||
|
electron.dialog.showMessageBox(
|
||||||
|
event.sender.getOwnerBrowserWindow(), dialogProperties))
|
||||||
})
|
})
|
||||||
|
|
||||||
// Implements window.close()
|
// Implements window.close()
|
||||||
|
|
Loading…
Add table
Reference in a new issue