| Index: chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc
|
| diff --git a/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc b/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc
|
| index 4cea81df9fd4eb23814576c79c8d4b6a2d8c500a..d37f9be03c1e32e364f41512be8e72cbd2f3e610 100644
|
| --- a/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc
|
| +++ b/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h"
|
|
|
| +#include <gdk/gdkx.h>
|
| #include <gtk/gtk.h>
|
| #include <stddef.h>
|
| #include <sys/stat.h>
|
| @@ -33,6 +34,7 @@
|
| #include "ui/events/platform/x11/x11_event_source.h"
|
| #include "ui/shell_dialogs/select_file_dialog.h"
|
| #include "ui/strings/grit/ui_strings.h"
|
| +#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
|
|
|
| namespace {
|
|
|
| @@ -48,6 +50,12 @@ void OnFileFilterDataDestroyed(std::string* file_extension) {
|
| delete file_extension;
|
| }
|
|
|
| +// Runs DesktopWindowTreeHostX11::EnableEventListening() when the file-picker
|
| +// is closed.
|
| +void OnFilePickerDestroy(base::Closure* callback) {
|
| + callback->Run();
|
| +}
|
| +
|
| } // namespace
|
|
|
| namespace libgtk2ui {
|
| @@ -161,8 +169,16 @@ void SelectFileDialogImplGTK::SelectFileImpl(
|
|
|
| params_map_[dialog] = params;
|
|
|
| - // TODO(erg): Figure out how to fake GTK window-to-parent modality without
|
| - // having the parent be a real GtkWindow.
|
| + // Disable input events handling in the host window to make this dialog modal.
|
| + views::DesktopWindowTreeHostX11* host =
|
| + views::DesktopWindowTreeHostX11::GetHostForXID(
|
| + owning_window->GetHost()->GetAcceleratedWidget());
|
| + std::unique_ptr<base::Closure> callback = host->DisableEventListening(
|
| + GDK_WINDOW_XID(gtk_widget_get_window(dialog)));
|
| + // OnFilePickerDestroy() is called when |dialog| destroyed, which allows to
|
| + // invoke the callback function to re-enable events on the owning window.
|
| + g_object_set_data_full(G_OBJECT(dialog), "callback", callback.release(),
|
| + reinterpret_cast<GDestroyNotify>(OnFilePickerDestroy));
|
| gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
|
|
|
| gtk_widget_show_all(dialog);
|
|
|