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, |       options, | ||||||
|       parent.IsEmpty() ? nullptr : parent->window_.get())); |       parent.IsEmpty() ? nullptr : parent->window_.get())); | ||||||
|   web_contents->SetOwnerWindow(window_.get()); |   web_contents->SetOwnerWindow(window_.get()); | ||||||
|  |   window_->SetIsOffScreenDummy(api_web_contents_->IsOffScreen()); | ||||||
| 
 | 
 | ||||||
| #if defined(TOOLKIT_VIEWS) | #if defined(TOOLKIT_VIEWS) | ||||||
|   // Sets the window icon.
 |   // Sets the window icon.
 | ||||||
|  |  | ||||||
|  | @ -41,8 +41,7 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog( | ||||||
|     buttons.push_back("Cancel"); |     buttons.push_back("Cancel"); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   atom::ShowMessageBox(api_web_contents_->IsOffScreen() ? nullptr : |   atom::ShowMessageBox(NativeWindow::FromWebContents(web_contents), | ||||||
|                         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, | ||||||
|  |  | ||||||
|  | @ -65,6 +65,7 @@ NativeWindow::NativeWindow( | ||||||
|       aspect_ratio_(0.0), |       aspect_ratio_(0.0), | ||||||
|       parent_(parent), |       parent_(parent), | ||||||
|       is_modal_(false), |       is_modal_(false), | ||||||
|  |       is_osr_dummy_(false), | ||||||
|       inspectable_web_contents_(inspectable_web_contents), |       inspectable_web_contents_(inspectable_web_contents), | ||||||
|       weak_factory_(this) { |       weak_factory_(this) { | ||||||
|   options.Get(options::kFrame, &has_frame_); |   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>& values, | ||||||
|     const std::vector<base::string16>& labels) {} |     const std::vector<base::string16>& labels) {} | ||||||
|   virtual void HideAutofillPopup(content::RenderFrameHost* frame_host) {} |   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
 |   // Public API used by platform-dependent delegates and observers to send UI
 | ||||||
|   // related notifications.
 |   // related notifications.
 | ||||||
|  | @ -368,6 +374,9 @@ class NativeWindow : public base::SupportsUserData, | ||||||
|   // Is this a modal window.
 |   // Is this a modal window.
 | ||||||
|   bool is_modal_; |   bool is_modal_; | ||||||
| 
 | 
 | ||||||
|  |   // Is this a dummy window for an offscreen WebContents.
 | ||||||
|  |   bool is_osr_dummy_; | ||||||
|  | 
 | ||||||
|   // The page this window is viewing.
 |   // The page this window is viewing.
 | ||||||
|   brightray::InspectableWebContents* inspectable_web_contents_; |   brightray::InspectableWebContents* inspectable_web_contents_; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1361,8 +1361,6 @@ void NativeWindowViews::ShowAutofillPopup( | ||||||
|     const gfx::RectF& bounds, |     const gfx::RectF& bounds, | ||||||
|     const std::vector<base::string16>& values, |     const std::vector<base::string16>& values, | ||||||
|     const std::vector<base::string16>& labels) { |     const std::vector<base::string16>& labels) { | ||||||
|   // auto wc = atom::api::WebContents::FromWrappedClass(
 |  | ||||||
|   //   v8::Isolate::GetCurrent(), web_contents());
 |  | ||||||
|   autofill_popup_->CreateView( |   autofill_popup_->CreateView( | ||||||
|     frame_host, |     frame_host, | ||||||
|     web_contents->IsOffScreenOrEmbedderOffscreen(), |     web_contents->IsOffScreenOrEmbedderOffscreen(), | ||||||
|  |  | ||||||
|  | @ -112,7 +112,8 @@ void SetupDialogForProperties(NSOpenPanel* dialog, int properties) { | ||||||
| // Run modal dialog with parent window and return user's choice. | // Run modal dialog with parent window and return user's choice. | ||||||
| int RunModalDialog(NSSavePanel* dialog, atom::NativeWindow* parent_window) { | int RunModalDialog(NSSavePanel* dialog, atom::NativeWindow* parent_window) { | ||||||
|   __block int chosen = NSFileHandlingPanelCancelButton; |   __block int chosen = NSFileHandlingPanelCancelButton; | ||||||
|   if (!parent_window || !parent_window->GetNativeWindow()) { |   if (!parent_window || !parent_window->GetNativeWindow() || | ||||||
|  |       parent_window->IsOffScreenDummy()) { | ||||||
|     chosen = [dialog runModal]; |     chosen = [dialog runModal]; | ||||||
|   } else { |   } else { | ||||||
|     NSWindow* window = parent_window->GetNativeWindow(); |     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. |   // only store the pointer, by duplication we can force gcd to store a copy. | ||||||
|   __block OpenDialogCallback callback = c; |   __block OpenDialogCallback callback = c; | ||||||
| 
 | 
 | ||||||
|   NSWindow* window = settings.parent_window ? |   if (!settings.parent_window || !settings.parent_window->GetNativeWindow() || | ||||||
|       settings.parent_window->GetNativeWindow() : |       settings.parent_window->IsOffScreenDummy()) { | ||||||
|       nullptr; |     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 |     [dialog beginSheetModalForWindow:window | ||||||
|                    completionHandler:^(NSInteger chosen) { |                    completionHandler:^(NSInteger chosen) { | ||||||
|       if (chosen == NSFileHandlingPanelCancelButton) { |       if (chosen == NSFileHandlingPanelCancelButton) { | ||||||
|  | @ -177,6 +187,7 @@ void ShowOpenDialog(const DialogSettings& settings, | ||||||
|         callback.Run(true, paths); |         callback.Run(true, paths); | ||||||
|       } |       } | ||||||
|     }]; |     }]; | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool ShowSaveDialog(const DialogSettings& settings, | bool ShowSaveDialog(const DialogSettings& settings, | ||||||
|  | @ -203,9 +214,17 @@ void ShowSaveDialog(const DialogSettings& settings, | ||||||
| 
 | 
 | ||||||
|   __block SaveDialogCallback callback = c; |   __block SaveDialogCallback callback = c; | ||||||
| 
 | 
 | ||||||
|   NSWindow* window = settings.parent_window ? |   if (!settings.parent_window || !settings.parent_window->GetNativeWindow() || | ||||||
|     settings.parent_window->GetNativeWindow() : |       settings.parent_window->IsOffScreenDummy()) { | ||||||
|     nullptr; |     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 |     [dialog beginSheetModalForWindow:window | ||||||
|                    completionHandler:^(NSInteger chosen) { |                    completionHandler:^(NSInteger chosen) { | ||||||
|       if (chosen == NSFileHandlingPanelCancelButton) { |       if (chosen == NSFileHandlingPanelCancelButton) { | ||||||
|  | @ -215,6 +234,7 @@ void ShowSaveDialog(const DialogSettings& settings, | ||||||
|         callback.Run(true, base::FilePath(path)); |         callback.Run(true, base::FilePath(path)); | ||||||
|       } |       } | ||||||
|     }]; |     }]; | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| }  // namespace file_dialog | }  // 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 |   // Use runModal for synchronous alert without parent, since we don't have a | ||||||
|   // window to wait for. |   // window to wait for. | ||||||
|   if (!parent_window || !parent_window->GetNativeWindow()) |   if (!parent_window || !parent_window->GetNativeWindow() || | ||||||
|  |       parent_window->IsOffScreenDummy()) | ||||||
|     return [[alert autorelease] runModal]; |     return [[alert autorelease] runModal]; | ||||||
| 
 | 
 | ||||||
|   int ret_code = -1; |   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 |   // Use runModal for synchronous alert without parent, since we don't have a | ||||||
|   // window to wait for. |   // window to wait for. | ||||||
|   if (!parent_window || !parent_window->GetNativeWindow()) { |   if (!parent_window || !parent_window->GetNativeWindow() || | ||||||
|     [[alert autorelease] runModal]; |       parent_window->IsOffScreenDummy()) { | ||||||
|  |     int ret = [[alert autorelease] runModal]; | ||||||
|  |     callback.Run(ret, false); | ||||||
|   } else { |   } else { | ||||||
|     ModalDelegate* delegate = [[ModalDelegate alloc] initWithCallback:callback |     ModalDelegate* delegate = [[ModalDelegate alloc] initWithCallback:callback | ||||||
|                                                              andAlert:alert |                                                              andAlert:alert | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Heilig Benedek
				Heilig Benedek