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

Side by Side 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: Reverted CL Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/libgtk2ui/select_file_dialog_interactive_uitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h" 5 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h"
6 6
7 #include <gdk/gdkx.h>
7 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
8 #include <stddef.h> 9 #include <stddef.h>
9 #include <sys/stat.h> 10 #include <sys/stat.h>
10 #include <sys/types.h> 11 #include <sys/types.h>
11 #include <unistd.h> 12 #include <unistd.h>
12 13
13 #include <map> 14 #include <map>
14 #include <set> 15 #include <set>
15 #include <vector> 16 #include <vector>
16 17
17 // Xlib defines RootWindow 18 // Xlib defines RootWindow
18 #undef RootWindow 19 #undef RootWindow
19 20
20 #include "base/logging.h" 21 #include "base/logging.h"
21 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
22 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
23 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
24 #include "base/strings/sys_string_conversions.h" 25 #include "base/strings/sys_string_conversions.h"
25 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
26 #include "base/threading/thread.h" 27 #include "base/threading/thread.h"
27 #include "base/threading/thread_restrictions.h" 28 #include "base/threading/thread_restrictions.h"
28 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" 29 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
29 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" 30 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
30 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" 31 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h"
31 #include "ui/aura/window_observer.h" 32 #include "ui/aura/window_observer.h"
32 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/shell_dialogs/select_file_dialog.h" 34 #include "ui/shell_dialogs/select_file_dialog.h"
34 #include "ui/strings/grit/ui_strings.h" 35 #include "ui/strings/grit/ui_strings.h"
36 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
35 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" 37 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
36 38
37 namespace { 39 namespace {
38 40
39 // Makes sure that .jpg also shows .JPG. 41 // Makes sure that .jpg also shows .JPG.
40 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, 42 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info,
41 std::string* file_extension) { 43 std::string* file_extension) {
42 return base::EndsWith(file_info->filename, *file_extension, 44 return base::EndsWith(file_info->filename, *file_extension,
43 base::CompareCase::INSENSITIVE_ASCII); 45 base::CompareCase::INSENSITIVE_ASCII);
44 } 46 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 159
158 preview_ = gtk_image_new(); 160 preview_ = gtk_image_new();
159 g_signal_connect(dialog, "destroy", 161 g_signal_connect(dialog, "destroy",
160 G_CALLBACK(OnFileChooserDestroyThunk), this); 162 G_CALLBACK(OnFileChooserDestroyThunk), this);
161 g_signal_connect(dialog, "update-preview", 163 g_signal_connect(dialog, "update-preview",
162 G_CALLBACK(OnUpdatePreviewThunk), this); 164 G_CALLBACK(OnUpdatePreviewThunk), this);
163 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); 165 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_);
164 166
165 params_map_[dialog] = params; 167 params_map_[dialog] = params;
166 168
167 // TODO(erg): Figure out how to fake GTK window-to-parent modality without 169 // Disable input events handling in the host window to make this dialog modal.
168 // having the parent be a real GtkWindow. 170 views::DesktopWindowTreeHostX11* host =
169 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); 171 views::DesktopWindowTreeHostX11::GetHostForXID(
172 owning_window->GetHost()->GetAcceleratedWidget());
173 host->DisableEventListening(GDK_WINDOW_XID(gtk_widget_get_window(dialog)));
170 174
171 gtk_widget_show_all(dialog); 175 gtk_widget_show_all(dialog);
172 176
173 // We need to call gtk_window_present after making the widgets visible to make 177 // We need to call gtk_window_present after making the widgets visible to make
174 // sure window gets correctly raised and gets focus. 178 // sure window gets correctly raised and gets focus.
175 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); 179 int time = views::X11DesktopHandler::get()->wm_user_time_ms();
176 gtk_window_present_with_time(GTK_WINDOW(dialog), time); 180 gtk_window_present_with_time(GTK_WINDOW(dialog), time);
177 } 181 }
178 182
179 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { 183 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 dialogs_.erase(dialog); 422 dialogs_.erase(dialog);
419 423
420 // Parent may be NULL in a few cases: 1) on shutdown when 424 // Parent may be NULL in a few cases: 1) on shutdown when
421 // AllBrowsersClosed() trigger this handler after all the browser 425 // AllBrowsersClosed() trigger this handler after all the browser
422 // windows got destroyed, or 2) when the parent tab has been opened by 426 // windows got destroyed, or 2) when the parent tab has been opened by
423 // 'Open Link in New Tab' context menu on a downloadable item and 427 // 'Open Link in New Tab' context menu on a downloadable item and
424 // the tab has no content (see the comment in SelectFile as well). 428 // the tab has no content (see the comment in SelectFile as well).
425 aura::Window* parent = GetAuraTransientParent(dialog); 429 aura::Window* parent = GetAuraTransientParent(dialog);
426 if (!parent) 430 if (!parent)
427 return; 431 return;
432
joone 2016/01/23 02:52:57 when the users open a file-picker from a child win
433 views::DesktopWindowTreeHostX11* host =
434 views::DesktopWindowTreeHostX11::GetHostForXID(
435 parent->GetHost()->GetAcceleratedWidget());
436 host->EnableEventListening();
437
428 std::set<aura::Window*>::iterator iter = parents_.find(parent); 438 std::set<aura::Window*>::iterator iter = parents_.find(parent);
429 if (iter != parents_.end()) { 439 if (iter != parents_.end()) {
430 (*iter)->RemoveObserver(this); 440 (*iter)->RemoveObserver(this);
431 parents_.erase(iter); 441 parents_.erase(iter);
432 } else { 442 } else {
433 NOTREACHED(); 443 NOTREACHED();
434 } 444 }
435 } 445 }
436 446
437 bool SelectFileDialogImplGTK::IsCancelResponse(gint response_id) { 447 bool SelectFileDialogImplGTK::IsCancelResponse(gint response_id) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 g_free(filename); 551 g_free(filename);
542 if (pixbuf) { 552 if (pixbuf) {
543 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); 553 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf);
544 g_object_unref(pixbuf); 554 g_object_unref(pixbuf);
545 } 555 }
546 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), 556 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser),
547 pixbuf ? TRUE : FALSE); 557 pixbuf ? TRUE : FALSE);
548 } 558 }
549 559
550 } // namespace libgtk2ui 560 } // namespace libgtk2ui
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/libgtk2ui/select_file_dialog_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698