Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7860)

Unified Diff: chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc

Issue 1624793002: Make File-Picker modal on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a link error in component builds Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 95f9a448378e6fb26e64a904fa3117dfbd12a730..828321ba19ad708e95345bb8275865b74b80e1e3 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>
@@ -32,6 +33,7 @@
#include "ui/base/l10n/l10n_util.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"
#include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
namespace {
@@ -48,6 +50,13 @@ void OnFileFilterDataDestroyed(std::string* file_extension) {
delete file_extension;
}
+// Runs DesktopWindowTreeHostX11::EnableEventListening() by calling the
+// destructor of ScopedHandle class when the file-picker is closed.
+void OnFilePickerDestroy(views::DesktopWindowTreeHostX11::ScopedHandle*
+ scoped_handle) {
+ delete scoped_handle;
+}
+
} // namespace
namespace libgtk2ui {
@@ -164,10 +173,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.
- gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
-
+ // Disable input events handling in the host window to make this dialog modal.
+ views::DesktopWindowTreeHostX11* host =
+ views::DesktopWindowTreeHostX11::GetHostForXID(
+ owning_window->GetHost()->GetAcceleratedWidget());
sadrul 2016/04/19 14:56:11 owning_window can be null, right? (see code/commen
joone 2016/04/19 22:29:56 I tried to reproduce the bug, but the file-picker
sadrul 2016/05/11 05:27:47 Update the code/comment from above too (lines 128:
joone 2016/05/11 19:18:05 I already did it: https://codereview.chromium.org/
+ std::unique_ptr<views::DesktopWindowTreeHostX11::ScopedHandle> scoped_handle =
+ host->DisableEventListening(
+ GDK_WINDOW_XID(gtk_widget_get_window(dialog)));
+ g_object_set_data_full(G_OBJECT(dialog), "scoped_handle",
+ scoped_handle.release(),
+ reinterpret_cast<GDestroyNotify>(OnFilePickerDestroy));
sadrul 2016/04/19 14:56:11 Add a comment here: // OnFilePickerDestroy() is
gtk_widget_show_all(dialog);
// We need to call gtk_window_present after making the widgets visible to make

Powered by Google App Engine
This is Rietveld 408576698