]> khamidou — GitHub mirrors - electron.git/commitdiff
gtk: Fix focusing on file dialog
authorCheng Zhao <zcbenz@gmail.com>
Wed, 1 Oct 2014 09:02:00 +0000 (17:02 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 1 Oct 2014 09:02:00 +0000 (17:02 +0800)
Fixes atom/atom#3626.

atom/browser/ui/file_dialog_gtk.cc

index 6a890322decded14f5fd037b92f1268edd988a14..747f8a7cffda3b338affd984d82096a7f34fbbe4 100644 (file)
@@ -21,6 +21,7 @@
 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
 #include "ui/aura/window.h"
 #include "ui/aura/window_tree_host.h"
+#include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
 
 namespace file_dialog {
 
@@ -114,6 +115,11 @@ class FileChooserDialog {
     g_signal_connect(dialog_, "response",
                      G_CALLBACK(OnFileDialogResponseThunk), this);
     gtk_widget_show_all(dialog_);
+
+    // We need to call gtk_window_present after making the widgets visible to
+    // make sure window gets correctly raised and gets focus.
+    int time = views::X11DesktopHandler::get()->wm_user_time_ms();
+    gtk_window_present_with_time(GTK_WINDOW(dialog_), time);
   }
 
   void RunSaveAsynchronous(const SaveDialogCallback& callback) {