--- old/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java 2014-01-20 19:02:01.443224199 +0400 +++ new/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java 2014-01-20 19:02:01.307224200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, 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 @@ -24,7 +24,8 @@ */ package sun.awt.X11; -import java.awt.FileDialog; +import java.awt.*; +import java.awt.event.ComponentEvent; import java.awt.peer.FileDialogPeer; import java.io.File; import java.io.FilenameFilter; @@ -52,8 +53,9 @@ initIDs(); } - private native void run(String title, int mode, String dir, String file, + private native void run(long ownerWindow, String title, int mode, String dir, String file, FilenameFilter filter, boolean isMultipleMode, int x, int y); + private native void quit(); @Override @@ -95,6 +97,38 @@ /** * Called exclusively by the native C code. */ + private void notifyConfigure(long window, int x, int y, int width, int height) { + XToolkit.awtLock(); + try { + Insets insets = XWM.getInsetsFromExtents(window); + if (insets == null) { + insets = new Insets(0,0,0,0); + } + + int resX = x - insets.left; + int resY = y - insets.top; + int resWidth = width + insets.left + insets.right; + int resHeight = height + insets.top + insets.bottom; + + Rectangle bounds = target.getBounds(); + + if (bounds.x != resX || bounds.y != resY) { + AWTAccessor.getComponentAccessor().setLocation(target, resX, resY); + postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED)); + } + + if (bounds.width != resWidth || bounds.height != resHeight) { + AWTAccessor.getComponentAccessor().setSize(target, resWidth, resHeight); + postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED)); + } + } finally { + XToolkit.awtUnlock(); + } + } + + /** + * Called exclusively by the native C code. + */ private boolean filenameFilterCallback(String fullname) { if (fd.getFilenameFilter() == null) { // no filter, accept all. @@ -152,6 +186,13 @@ } private void showNativeDialog() { + long ownerWindow = 0L; + + XWindowPeer ownerPeer = getOwnerPeer(); + if (ownerPeer != null) { + ownerWindow = ownerPeer.getWindow(); + } + String dirname = fd.getDirectory(); // File path has a priority against directory path. String filename = fd.getFile(); @@ -171,7 +212,8 @@ dirname = file.getParent(); } } - run(fd.getTitle(), fd.getMode(), dirname, filename, - fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY()); + + run(ownerWindow, fd.getTitle(), fd.getMode(), dirname, filename, + fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY()); } } --- old/src/solaris/native/sun/awt/gtk2_interface.c 2014-01-20 19:02:01.867224195 +0400 +++ new/src/solaris/native/sun/awt/gtk2_interface.c 2014-01-20 19:02:01.731224196 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -332,7 +332,6 @@ GtkWidget *child); static void (*fp_gtk_menu_item_set_submenu)(GtkMenuItem *menu_item, GtkWidget *submenu); -static void (*fp_gtk_widget_realize)(GtkWidget *widget); static GdkPixbuf* (*fp_gtk_widget_render_icon)(GtkWidget *widget, const gchar *stock_id, GtkIconSize size, const gchar *detail); static void (*fp_gtk_widget_set_name)(GtkWidget *widget, const gchar *name); @@ -789,6 +788,7 @@ fp_gdk_threads_enter = dl_symbol("gdk_threads_enter"); fp_gdk_threads_leave = dl_symbol("gdk_threads_leave"); + fp_gdk_x11_drawable_get_xid = dl_symbol("gdk_x11_drawable_get_xid"); /** * Functions for sun_awt_X11_GtkFileDialogPeer.c */ --- old/src/solaris/native/sun/awt/gtk2_interface.h 2014-01-20 19:02:02.259224191 +0400 +++ new/src/solaris/native/sun/awt/gtk2_interface.h 2014-01-20 19:02:02.131224193 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -27,6 +27,7 @@ #include #include +#include #define _G_TYPE_CIC(ip, gt, ct) ((ct*) ip) #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) @@ -637,6 +638,22 @@ G_CONNECT_AFTER = 1 << 0, G_CONNECT_SWAPPED = 1 << 1 } GConnectFlags; +typedef enum +{ + GDK_CONFIGURE +} GdkEventType; + +typedef struct _GdkEventConfigure GdkEventConfigure; +struct _GdkEventConfigure +{ + GdkEventType type; + GdkWindow *window; + gint8 send_event; + gint x, y; + gint width; + gint height; +}; + typedef struct _GThreadFunctions GThreadFunctions; /* @@ -777,6 +794,7 @@ int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf); int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf); GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error); +void (*fp_gtk_widget_realize)(GtkWidget *widget); void (*fp_gtk_widget_destroy)(GtkWidget *widget); void (*fp_gtk_window_present)(GtkWindow *window); void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y); @@ -830,6 +848,8 @@ void (*fp_gdk_threads_enter)(void); void (*fp_gdk_threads_leave)(void); +XID (*fp_gdk_x11_drawable_get_xid)(GdkDrawable *drawable); + gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri, guint32 timestamp, GError **error); --- old/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c 2014-01-20 19:02:02.643224188 +0400 +++ new/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c 2014-01-20 19:02:02.515224189 +0400 @@ -1,5 +1,5 @@ /* - * 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 @@ -23,6 +23,7 @@ * questions. */ +#include #include #include #include @@ -32,11 +33,14 @@ #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; +static jmethodID notifyConfigureMethodID = NULL; static jfieldID widgetFieldID = NULL; JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs @@ -50,6 +54,10 @@ "setFileInternal", "(Ljava/lang/String;[Ljava/lang/String;)V"); DASSERT(setFileInternalMethodID != NULL); + notifyConfigureMethodID = (*env)->GetMethodID(env, cx, + "notifyConfigure", "(JIIII)V"); + DASSERT(notifyConfigureMethodID != NULL); + widgetFieldID = (*env)->GetFieldID(env, cx, "widget", "J"); DASSERT(widgetFieldID != NULL); } @@ -281,6 +289,15 @@ quit(env, (jobject)obj, TRUE); } +gboolean handle_configure(GtkWidget *dialog, GdkEventConfigure *e, gpointer obj) { + JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2); + + (*env)->CallVoidMethod(env, obj, notifyConfigureMethodID, + fp_gdk_x11_drawable_get_xid(dialog->window), e->x, e->y, e->width, e->height); + + return FALSE; +} + /* * Class: sun_awt_X11_GtkFileDialogPeer * Method: run @@ -288,6 +305,7 @@ */ 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) { @@ -365,10 +383,17 @@ // as it seems like the file chooser overrides the size internally } + (*env)->SetLongField(env, jpeer, widgetFieldID, ptr_to_jlong(dialog)); + fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK( handle_response), jpeer); + fp_g_signal_connect(G_OBJECT(dialog), "configure-event", G_CALLBACK( + handle_configure), 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);