OLD | NEW |
---|---|
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 <gdk/gdkx.h> | |
5 #include <gtk/gtk.h> | 6 #include <gtk/gtk.h> |
6 #include <map> | 7 #include <map> |
7 #include <set> | 8 #include <set> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 // Xlib defines RootWindow | 11 // Xlib defines RootWindow |
11 #undef RootWindow | 12 #undef RootWindow |
12 | 13 |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
17 #include "base/strings/sys_string_conversions.h" | 18 #include "base/strings/sys_string_conversions.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #include "base/threading/thread.h" | 20 #include "base/threading/thread.h" |
20 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
21 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" | 22 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" |
22 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 23 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" |
23 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" | 24 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" |
24 #include "ui/aura/window_observer.h" | 25 #include "ui/aura/window_observer.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/shell_dialogs/select_file_dialog.h" | 27 #include "ui/shell_dialogs/select_file_dialog.h" |
27 #include "ui/strings/grit/ui_strings.h" | 28 #include "ui/strings/grit/ui_strings.h" |
29 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | |
28 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | 30 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" |
29 | 31 |
30 namespace { | 32 namespace { |
31 | 33 |
32 // Makes sure that .jpg also shows .JPG. | 34 // Makes sure that .jpg also shows .JPG. |
33 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, | 35 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, |
34 std::string* file_extension) { | 36 std::string* file_extension) { |
35 return base::EndsWith(file_info->filename, *file_extension, | 37 return base::EndsWith(file_info->filename, *file_extension, |
36 base::CompareCase::INSENSITIVE_ASCII); | 38 base::CompareCase::INSENSITIVE_ASCII); |
37 } | 39 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 | 268 |
267 preview_ = gtk_image_new(); | 269 preview_ = gtk_image_new(); |
268 g_signal_connect(dialog, "destroy", | 270 g_signal_connect(dialog, "destroy", |
269 G_CALLBACK(OnFileChooserDestroyThunk), this); | 271 G_CALLBACK(OnFileChooserDestroyThunk), this); |
270 g_signal_connect(dialog, "update-preview", | 272 g_signal_connect(dialog, "update-preview", |
271 G_CALLBACK(OnUpdatePreviewThunk), this); | 273 G_CALLBACK(OnUpdatePreviewThunk), this); |
272 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); | 274 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); |
273 | 275 |
274 params_map_[dialog] = params; | 276 params_map_[dialog] = params; |
275 | 277 |
276 // TODO(erg): Figure out how to fake GTK window-to-parent modality without | 278 // Disable input events handling in the host window to make this dialog modal. |
277 // having the parent be a real GtkWindow. | 279 views::DesktopWindowTreeHostX11* host = |
278 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); | 280 views::DesktopWindowTreeHostX11::GetHostForXID( |
281 owning_window->GetHost()->GetAcceleratedWidget()); | |
sadrul
2015/07/19 01:25:36
From the code and comment above, looks like owning
| |
282 host->DisableEventListening(GDK_WINDOW_XID(gtk_widget_get_window(dialog))); | |
279 | 283 |
280 gtk_widget_show_all(dialog); | 284 gtk_widget_show_all(dialog); |
281 | 285 |
282 // We need to call gtk_window_present after making the widgets visible to make | 286 // We need to call gtk_window_present after making the widgets visible to make |
283 // sure window gets correctly raised and gets focus. | 287 // sure window gets correctly raised and gets focus. |
284 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); | 288 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); |
285 gtk_window_present_with_time(GTK_WINDOW(dialog), time); | 289 gtk_window_present_with_time(GTK_WINDOW(dialog), time); |
286 } | 290 } |
287 | 291 |
288 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { | 292 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 dialogs_.erase(dialog); | 524 dialogs_.erase(dialog); |
521 | 525 |
522 // Parent may be NULL in a few cases: 1) on shutdown when | 526 // Parent may be NULL in a few cases: 1) on shutdown when |
523 // AllBrowsersClosed() trigger this handler after all the browser | 527 // AllBrowsersClosed() trigger this handler after all the browser |
524 // windows got destroyed, or 2) when the parent tab has been opened by | 528 // windows got destroyed, or 2) when the parent tab has been opened by |
525 // 'Open Link in New Tab' context menu on a downloadable item and | 529 // 'Open Link in New Tab' context menu on a downloadable item and |
526 // the tab has no content (see the comment in SelectFile as well). | 530 // the tab has no content (see the comment in SelectFile as well). |
527 aura::Window* parent = GetAuraTransientParent(dialog); | 531 aura::Window* parent = GetAuraTransientParent(dialog); |
528 if (!parent) | 532 if (!parent) |
529 return; | 533 return; |
534 | |
535 views::DesktopWindowTreeHostX11* host = | |
536 views::DesktopWindowTreeHostX11::GetHostForXID( | |
537 parent->GetHost()->GetAcceleratedWidget()); | |
538 host->EnableEventListening(); | |
539 | |
530 std::set<aura::Window*>::iterator iter = parents_.find(parent); | 540 std::set<aura::Window*>::iterator iter = parents_.find(parent); |
531 if (iter != parents_.end()) { | 541 if (iter != parents_.end()) { |
532 (*iter)->RemoveObserver(this); | 542 (*iter)->RemoveObserver(this); |
533 parents_.erase(iter); | 543 parents_.erase(iter); |
534 } else { | 544 } else { |
535 NOTREACHED(); | 545 NOTREACHED(); |
536 } | 546 } |
537 } | 547 } |
538 | 548 |
539 bool SelectFileDialogImplGTK::IsCancelResponse(gint response_id) { | 549 bool SelectFileDialogImplGTK::IsCancelResponse(gint response_id) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 g_free(filename); | 639 g_free(filename); |
630 if (pixbuf) { | 640 if (pixbuf) { |
631 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); | 641 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); |
632 g_object_unref(pixbuf); | 642 g_object_unref(pixbuf); |
633 } | 643 } |
634 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), | 644 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), |
635 pixbuf ? TRUE : FALSE); | 645 pixbuf ? TRUE : FALSE); |
636 } | 646 } |
637 | 647 |
638 } // namespace libgtk2ui | 648 } // namespace libgtk2ui |
OLD | NEW |