From: Cheng Zhao Date: Tue, 21 Jun 2016 08:54:55 +0000 (+0000) Subject: linux: Disable parent window when showing modal dialogs (#6160) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=816b2ea8f259e098f737c27d969abb23060c9139;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git linux: Disable parent window when showing modal dialogs (#6160) --- diff --git a/atom/browser/ui/file_dialog_gtk.cc b/atom/browser/ui/file_dialog_gtk.cc index 1ad7ff5..dcb7bea 100644 --- a/atom/browser/ui/file_dialog_gtk.cc +++ b/atom/browser/ui/file_dialog_gtk.cc @@ -4,7 +4,7 @@ #include "atom/browser/ui/file_dialog.h" -#include "atom/browser/native_window.h" +#include "atom/browser/native_window_views.h" #include "base/callback.h" #include "base/files/file_util.h" #include "base/strings/string_util.h" @@ -40,7 +40,8 @@ class FileChooserDialog { const std::string& button_label, const base::FilePath& default_path, const Filters& filters) - : dialog_scope_(parent_window), + : parent_(static_cast(parent_window)), + dialog_scope_(parent_window), filters_(filters) { const char* confirm_text = GTK_STOCK_OK; @@ -58,9 +59,10 @@ class FileChooserDialog { GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, confirm_text, GTK_RESPONSE_ACCEPT, NULL); - if (parent_window) { - gfx::NativeWindow window = parent_window->GetNativeWindow(); - libgtk2ui::SetGtkTransientForAura(dialog_, window); + if (parent_) { + parent_->SetEnabled(false); + libgtk2ui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow()); + gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); } if (action == GTK_FILE_CHOOSER_ACTION_SAVE) @@ -69,8 +71,6 @@ class FileChooserDialog { if (action != GTK_FILE_CHOOSER_ACTION_OPEN) gtk_file_chooser_set_create_folders(GTK_FILE_CHOOSER(dialog_), TRUE); - gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); - if (!default_path.empty()) { if (base::DirectoryExists(default_path)) { gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog_), @@ -89,6 +89,8 @@ class FileChooserDialog { virtual ~FileChooserDialog() { gtk_widget_destroy(dialog_); + if (parent_) + parent_->SetEnabled(true); } void RunAsynchronous() { @@ -143,6 +145,7 @@ class FileChooserDialog { void AddFilters(const Filters& filters); base::FilePath AddExtensionForFilename(const gchar* filename) const; + atom::NativeWindowViews* parent_; atom::NativeWindow::DialogScope dialog_scope_; GtkWidget* dialog_; diff --git a/atom/browser/ui/message_box_gtk.cc b/atom/browser/ui/message_box_gtk.cc index b09ccdd..d08171c 100644 --- a/atom/browser/ui/message_box_gtk.cc +++ b/atom/browser/ui/message_box_gtk.cc @@ -5,7 +5,7 @@ #include "atom/browser/ui/message_box.h" #include "atom/browser/browser.h" -#include "atom/browser/native_window.h" +#include "atom/browser/native_window_views.h" #include "base/callback.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -36,7 +36,8 @@ class GtkMessageBox { const std::string& detail, const gfx::ImageSkia& icon) : dialog_scope_(parent_window), - cancel_id_(cancel_id) { + cancel_id_(cancel_id), + parent_(static_cast(parent_window)) { // Create dialog. dialog_ = gtk_message_dialog_new( nullptr, // parent @@ -75,14 +76,17 @@ class GtkMessageBox { } // Parent window. - if (parent_window) { - gfx::NativeWindow window = parent_window->GetNativeWindow(); - libgtk2ui::SetGtkTransientForAura(dialog_, window); + if (parent_) { + parent_->SetEnabled(false); + libgtk2ui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow()); + gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); } } ~GtkMessageBox() { gtk_widget_destroy(dialog_); + if (parent_) + parent_->SetEnabled(true); } GtkMessageType GetMessageType(MessageBoxType type) { @@ -123,7 +127,6 @@ class GtkMessageBox { } int RunSynchronous() { - gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); Show(); int response = gtk_dialog_run(GTK_DIALOG(dialog_)); if (response < 0) @@ -149,6 +152,7 @@ class GtkMessageBox { // The id to return when the dialog is closed without pressing buttons. int cancel_id_; + NativeWindowViews* parent_; GtkWidget* dialog_; MessageBoxCallback callback_;