src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -21,19 +21,22 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
+#include <X11/Xlib.h>
 #include <jni.h>
 #include <stdio.h>
 #include <jni_util.h>
 #include <string.h>
 #include "gtk2_interface.h"
 #include "sun_awt_X11_GtkFileDialogPeer.h"
 #include "java_awt_FileDialog.h"
 #include "debug_assert.h"
 
+extern Display *awt_display;
+
 static JavaVM *jvm;
 
 /* To cache some method IDs */
 static jmethodID filenameFilterCallbackMethodID = NULL;
 static jmethodID setFileInternalMethodID = NULL;

@@ -286,10 +289,11 @@
  * Method:    run
  * Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;ZII)V
  */
 JNIEXPORT void JNICALL
 Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
+        jlong owner,
         jstring jtitle, jint mode, jstring jdir, jstring jfile,
         jobject jfilter, jboolean multiple, int x, int y)
 {
     GtkWidget *dialog = NULL;
     GtkFileFilter *filter;

@@ -368,10 +372,15 @@
     fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
             handle_response), jpeer);
 
     (*env)->SetLongField(env, jpeer, widgetFieldID, ptr_to_jlong(dialog));
 
+    if (owner && dialog) {
+        fp_gtk_widget_realize(dialog);
+        XSetTransientForHint(awt_display, fp_gdk_x11_drawable_get_xid(dialog->window), owner);
+    }
+
     fp_gtk_widget_show(dialog);
 
     fp_gtk_main();
     fp_gdk_threads_leave();
 }