]> khamidou — GitHub mirrors - electron.git/commitdiff
Use SetGtkTransientForAura from libgtk2ui
authorCheng Zhao <zcbenz@gmail.com>
Tue, 7 Jul 2015 07:07:18 +0000 (15:07 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 7 Jul 2015 07:12:08 +0000 (15:12 +0800)
atom/browser/ui/file_dialog_gtk.cc

index 40c14028d4fa0413f3b40a2683bb5583d2d3dc5b..48b9ec53430828c99690b9b89292e6a955a95a29 100644 (file)
@@ -4,49 +4,18 @@
 
 #include "atom/browser/ui/file_dialog.h"
 
-#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-// This conflicts with mate::Converter,
-#undef True
-#undef False
-// and V8.
-#undef None
-
 #include "atom/browser/native_window.h"
 #include "base/callback.h"
 #include "base/files/file_util.h"
 #include "base/strings/string_util.h"
 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_tree_host.h"
+#include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
 
 namespace file_dialog {
 
 namespace {
 
-const char kAuraTransientParent[] = "aura-transient-parent";
-
-void SetGtkTransientForAura(GtkWidget* dialog, aura::Window* parent) {
-  if (!parent || !parent->GetHost())
-    return;
-
-  gtk_widget_realize(dialog);
-  GdkWindow* gdk_window = gtk_widget_get_window(dialog);
-
-  // TODO(erg): Check to make sure we're using X11 if wayland or some other
-  // display server ever happens. Otherwise, this will crash.
-  XSetTransientForHint(GDK_WINDOW_XDISPLAY(gdk_window),
-                       GDK_WINDOW_XID(gdk_window),
-                       parent->GetHost()->GetAcceleratedWidget());
-
-  // We also set the |parent| as a property of |dialog|, so that we can unlink
-  // the two later.
-  g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, parent);
-}
-
 // Makes sure that .jpg also shows .JPG.
 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info,
                                    std::string* file_extension) {
@@ -81,7 +50,7 @@ class FileChooserDialog {
         NULL);
     if (parent_window) {
       gfx::NativeWindow window = parent_window->GetNativeWindow();
-      SetGtkTransientForAura(dialog_, window);
+      libgtk2ui::SetGtkTransientForAura(dialog_, window);
     }
 
     if (action == GTK_FILE_CHOOSER_ACTION_SAVE)