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
|
@ -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,11 +165,9 @@ 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;
|
||||
[dialog beginSheetModalForWindow:window
|
||||
completionHandler:^(NSInteger chosen) {
|
||||
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 {
|
||||
|
@ -176,7 +175,19 @@ void ShowOpenDialog(const DialogSettings& settings,
|
|||
ReadDialogPaths(dialog, &paths);
|
||||
callback.Run(true, paths);
|
||||
}
|
||||
}];
|
||||
} else {
|
||||
NSWindow* window = settings.parent_window->GetNativeWindow();
|
||||
[dialog beginSheetModalForWindow:window
|
||||
completionHandler:^(NSInteger chosen) {
|
||||
if (chosen == NSFileHandlingPanelCancelButton) {
|
||||
callback.Run(false, std::vector<base::FilePath>());
|
||||
} else {
|
||||
std::vector<base::FilePath> paths;
|
||||
ReadDialogPaths(dialog, &paths);
|
||||
callback.Run(true, paths);
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
bool ShowSaveDialog(const DialogSettings& settings,
|
||||
|
@ -203,18 +214,27 @@ void ShowSaveDialog(const DialogSettings& settings,
|
|||
|
||||
__block SaveDialogCallback callback = c;
|
||||
|
||||
NSWindow* window = settings.parent_window ?
|
||||
settings.parent_window->GetNativeWindow() :
|
||||
nullptr;
|
||||
[dialog beginSheetModalForWindow:window
|
||||
completionHandler:^(NSInteger chosen) {
|
||||
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) {
|
||||
callback.Run(false, base::FilePath());
|
||||
} else {
|
||||
std::string path = base::SysNSStringToUTF8([[dialog URL] path]);
|
||||
callback.Run(true, base::FilePath(path));
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
} // 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
Add a link
Reference in a new issue