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");
|
||||
}
|
||||
|
||||
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,
|
||||
0, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
|
||||
base::UTF16ToUTF8(message_text), "", "", false,
|
||||
|
|
|
@ -181,15 +181,22 @@ void ShowMessageBox(NativeWindow* parent_window,
|
|||
NSAlert* alert =
|
||||
CreateNSAlert(parent_window, type, buttons, default_id, cancel_id, title,
|
||||
message, detail, checkbox_label, checkbox_checked, icon);
|
||||
ModalDelegate* delegate = [[ModalDelegate alloc] initWithCallback:callback
|
||||
andAlert:alert
|
||||
callEndModal:false];
|
||||
|
||||
NSWindow* window = parent_window ? parent_window->GetNativeWindow() : nil;
|
||||
[alert beginSheetModalForWindow:window
|
||||
modalDelegate:delegate
|
||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:nil];
|
||||
// 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
|
||||
andAlert:alert
|
||||
callEndModal:false];
|
||||
|
||||
NSWindow* window = parent_window ? parent_window->GetNativeWindow() : nil;
|
||||
[alert beginSheetModalForWindow:window
|
||||
modalDelegate:delegate
|
||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:nil];
|
||||
}
|
||||
}
|
||||
|
||||
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 (title == null) title = ''
|
||||
|
||||
event.returnValue = electron.dialog.showMessageBox(event.sender.getOwnerBrowserWindow(), {
|
||||
const dialogProperties = {
|
||||
message: `${message}`,
|
||||
title: `${title}`,
|
||||
buttons: ['OK']
|
||||
})
|
||||
}
|
||||
event.returnValue = event.sender.isOffscreen() ?
|
||||
electron.dialog.showMessageBox(dialogProperties) :
|
||||
electron.dialog.showMessageBox(
|
||||
event.sender.getOwnerBrowserWindow(), dialogProperties)
|
||||
})
|
||||
|
||||
// Implements window.confirm(message, title)
|
||||
|
@ -455,12 +459,16 @@ ipcMain.on('ELECTRON_BROWSER_WINDOW_CONFIRM', function (event, message, title) {
|
|||
if (message == null) message = ''
|
||||
if (title == null) title = ''
|
||||
|
||||
event.returnValue = !electron.dialog.showMessageBox(event.sender.getOwnerBrowserWindow(), {
|
||||
const dialogProperties = {
|
||||
message: `${message}`,
|
||||
title: `${title}`,
|
||||
buttons: ['OK', 'Cancel'],
|
||||
cancelId: 1
|
||||
})
|
||||
}
|
||||
event.returnValue = !(event.sender.isOffscreen() ?
|
||||
electron.dialog.showMessageBox(dialogProperties) :
|
||||
electron.dialog.showMessageBox(
|
||||
event.sender.getOwnerBrowserWindow(), dialogProperties))
|
||||
})
|
||||
|
||||
// Implements window.close()
|
||||
|
|
Loading…
Add table
Reference in a new issue