diff options
Diffstat (limited to 'libjava/classpath/native/jni')
45 files changed, 1736 insertions, 1031 deletions
diff --git a/libjava/classpath/native/jni/Makefile.am b/libjava/classpath/native/jni/Makefile.am index 41d9a913bd1..fce6b1a6f42 100644 --- a/libjava/classpath/native/jni/Makefile.am +++ b/libjava/classpath/native/jni/Makefile.am @@ -8,13 +8,17 @@ if CREATE_GTK_PEER_LIBRARIES GTKDIR = gtk-peer endif +if CREATE_QT_PEER_LIBRARIES + CLASSPATH_QT_PEER_DIR = qt-peer +endif + if CREATE_XMLJ_LIBRARY XMLJDIR = xmlj endif -SUBDIRS = classpath $(JNIDIRS) $(GTKDIR) $(XMLJDIR) +SUBDIRS = classpath $(JNIDIRS) $(GTKDIR) $(CLASSPATH_QT_PEER_DIR) $(XMLJDIR) DIST_SUBDIRS = classpath java-io java-lang java-net java-nio java-util \ - gtk-peer xmlj + gtk-peer qt-peer xmlj all-local: - cd $(top_srcdir) && scripts/check_jni_methods.sh + cd $(top_srcdir) && $(SHELL) ./scripts/check_jni_methods.sh diff --git a/libjava/classpath/native/jni/Makefile.in b/libjava/classpath/native/jni/Makefile.in index 4b263fc8a04..825dda3a178 100644 --- a/libjava/classpath/native/jni/Makefile.in +++ b/libjava/classpath/native/jni/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.9.5 from Makefile.am. +# Makefile.in generated by automake 1.9.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. +# 2003, 2004 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -90,8 +90,14 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@ CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@ CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@ CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@ +CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@ +CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@ CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@ CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATE = @DATE@ DEFS = @DEFS@ @@ -153,6 +159,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ +MOC = @MOC@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -164,12 +171,13 @@ PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@ PANGOFT2_LIBS = @PANGOFT2_LIBS@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@ REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@ REMOVE = @REMOVE@ SET_MAKE = @SET_MAKE@ -SH = @SH@ SHELL = @SHELL@ STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@ STRIP = @STRIP@ @@ -191,10 +199,13 @@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ZIP = @ZIP@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -236,10 +247,11 @@ target_vendor = @target_vendor@ vm_classes = @vm_classes@ @CREATE_CORE_JNI_LIBRARIES_TRUE@JNIDIRS = java-io java-lang java-net java-nio java-util @CREATE_GTK_PEER_LIBRARIES_TRUE@GTKDIR = gtk-peer +@CREATE_QT_PEER_LIBRARIES_TRUE@CLASSPATH_QT_PEER_DIR = qt-peer @CREATE_XMLJ_LIBRARY_TRUE@XMLJDIR = xmlj -SUBDIRS = classpath $(JNIDIRS) $(GTKDIR) $(XMLJDIR) +SUBDIRS = classpath $(JNIDIRS) $(GTKDIR) $(CLASSPATH_QT_PEER_DIR) $(XMLJDIR) DIST_SUBDIRS = classpath java-io java-lang java-net java-nio java-util \ - gtk-peer xmlj + gtk-peer qt-peer xmlj all: all-recursive @@ -291,13 +303,7 @@ uninstall-info-am: # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ + @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ @@ -309,7 +315,7 @@ $(RECURSIVE_TARGETS): local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ @@ -317,13 +323,7 @@ $(RECURSIVE_TARGETS): mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ + @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ @@ -344,7 +344,7 @@ maintainer-clean-recursive: local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ @@ -551,7 +551,7 @@ uninstall-info: uninstall-info-recursive all-local: - cd $(top_srcdir) && scripts/check_jni_methods.sh + cd $(top_srcdir) && $(SHELL) ./scripts/check_jni_methods.sh # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/libjava/classpath/native/jni/classpath/Makefile.am b/libjava/classpath/native/jni/classpath/Makefile.am index 0171d3728e0..2baa60abcdc 100644 --- a/libjava/classpath/native/jni/classpath/Makefile.am +++ b/libjava/classpath/native/jni/classpath/Makefile.am @@ -1,3 +1,6 @@ +# Header needed for jawt implementations such as the one found in ../gtk-peer. +EXTRA_DIST = classpath_jawt.h + noinst_LTLIBRARIES = libclasspath.la libclasspath_la_SOURCES = jcl.c jcl.h \ diff --git a/libjava/classpath/native/jni/classpath/Makefile.in b/libjava/classpath/native/jni/classpath/Makefile.in index 3d55605f495..f402cedd17c 100644 --- a/libjava/classpath/native/jni/classpath/Makefile.in +++ b/libjava/classpath/native/jni/classpath/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.9.5 from Makefile.am. +# Makefile.in generated by automake 1.9.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. +# 2003, 2004 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -103,8 +103,14 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@ CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@ CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@ CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@ +CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@ +CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@ CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@ CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATE = @DATE@ DEFS = @DEFS@ @@ -166,6 +172,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ +MOC = @MOC@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -177,12 +184,13 @@ PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@ PANGOFT2_LIBS = @PANGOFT2_LIBS@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@ REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@ REMOVE = @REMOVE@ SET_MAKE = @SET_MAKE@ -SH = @SH@ SHELL = @SHELL@ STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@ STRIP = @STRIP@ @@ -204,10 +212,13 @@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ZIP = @ZIP@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -247,6 +258,9 @@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ vm_classes = @vm_classes@ + +# Header needed for jawt implementations such as the one found in ../gtk-peer. +EXTRA_DIST = classpath_jawt.h noinst_LTLIBRARIES = libclasspath.la libclasspath_la_SOURCES = jcl.c jcl.h \ jnilink.c jnilink.h \ diff --git a/libjava/classpath/native/jni/classpath/classpath_jawt.h b/libjava/classpath/native/jni/classpath/classpath_jawt.h index 6ff5c53355e..32a04dc5cd7 100644 --- a/libjava/classpath/native/jni/classpath/classpath_jawt.h +++ b/libjava/classpath/native/jni/classpath/classpath_jawt.h @@ -1,39 +1,39 @@ /* classpath_awt.h -- libjawt's interface to the peer library Copyright (C) 2005 Free Software Foundation, Inc. - This file is part of GNU Classpath. +This file is part of GNU Classpath. - GNU Classpath is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. - GNU Classpath is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNU Classpath; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. - - Linking this library statically or dynamically with other modules is - making a combined work based on this library. Thus, the terms and - conditions of the GNU General Public License cover the whole - combination. - - As a special exception, the copyright holders of this library give you - permission to link this library with independent modules to produce an - executable, regardless of the license terms of these independent - modules, and to copy and distribute the resulting executable under - terms of your choice, provided that you also meet, for each linked - independent module, the terms and conditions of the license of that - module. An independent module is a module which is not derived from - or based on this library. If you modify this library, you may extend - this exception to your version of the library, but you are not - obligated to do so. If you do not wish to do so, delete this - exception statement from your version. */ +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ /* * libjawt.so is linked directly to the peer library with -l. This @@ -50,15 +50,11 @@ #define CLASSPATH_JAWT_VERSION 0x10004 -jint classpath_jawt_get_awt_version (); +jint classpath_jawt_get_awt_version (void); Display* classpath_jawt_get_default_display (JNIEnv* env, jobject canvas); Drawable classpath_jawt_get_drawable (JNIEnv* env, jobject canvas); VisualID classpath_jawt_get_visualID (JNIEnv* env, jobject canvas); -jint classpath_jawt_object_lock (jobject lock); -void classpath_jawt_object_unlock (jobject lock); -jint classpath_jawt_lock (); -void classpath_jawt_unlock (); -jobject classpath_jawt_create_lock (); -void classpath_jawt_destroy_lock (jobject lock); +jint classpath_jawt_lock (void); +void classpath_jawt_unlock (void); #endif /* __classpath_jawt_h__ */ diff --git a/libjava/classpath/native/jni/classpath/jcl.c b/libjava/classpath/native/jni/classpath/jcl.c index 03f9b3753cc..4821770ed05 100644 --- a/libjava/classpath/native/jni/classpath/jcl.c +++ b/libjava/classpath/native/jni/classpath/jcl.c @@ -178,3 +178,94 @@ JCL_FindClass (JNIEnv * env, const char *className) } return retval; } + + +/* + * Build a Pointer object. The function caches the class type + */ + +static jclass rawDataClass; +static jfieldID rawData_fid; +static jmethodID rawData_mid; + +JNIEXPORT jobject JNICALL +JCL_NewRawDataObject (JNIEnv * env, void *data) +{ + if (rawDataClass == NULL) + { +#ifdef POINTERS_ARE_64BIT + rawDataClass = (*env)->FindClass (env, "gnu/classpath/Pointer64"); + if (rawDataClass == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal class"); + return NULL; + } + + rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(J)V"); + if (rawData_mid == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal constructor"); + return NULL; + } + + rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "J"); + if (rawData_fid == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal field"); + return NULL; + } +#else + rawDataClass = (*env)->FindClass (env, "gnu/classpath/Pointer32"); + if (rawDataClass == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal class"); + return NULL; + } + + rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(I)V"); + if (rawData_mid == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal constructor"); + return NULL; + } + + rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "I"); + if (rawData_fid == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal field"); + return NULL; + } + +#endif + (*env)->DeleteLocalRef(env, rawDataClass); + rawDataClass = (*env)->NewGlobalRef (env, rawDataClass); + if (rawDataClass == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to create an internal global ref"); + return NULL; + } + } + +#ifdef POINTERS_ARE_64BIT + return (*env)->NewObject (env, rawDataClass, rawData_mid, (jlong) data); +#else + return (*env)->NewObject (env, rawDataClass, rawData_mid, (jint) data); +#endif +} + +JNIEXPORT void * JNICALL +JCL_GetRawData (JNIEnv * env, jobject rawdata) +{ +#ifdef POINTERS_ARE_64BIT + return (void *) (*env)->GetLongField (env, rawdata, rawData_fid); +#else + return (void *) (*env)->GetIntField (env, rawdata, rawData_fid); +#endif +} diff --git a/libjava/classpath/native/jni/classpath/jcl.h b/libjava/classpath/native/jni/classpath/jcl.h index e526b293966..25662c06b53 100644 --- a/libjava/classpath/native/jni/classpath/jcl.h +++ b/libjava/classpath/native/jni/classpath/jcl.h @@ -42,6 +42,14 @@ exception statement from your version. */ #include <jni.h> #include <config.h> +#if SIZEOF_VOID_P == 4 +typedef jint jpointer; +#elif SIZEOF_VOID_P == 8 +typedef jlong jpointer; +#else +#error "Unknown pointer size" +#endif + JNIEXPORT jclass JNICALL JCL_FindClass (JNIEnv * env, const char *className); JNIEXPORT void JNICALL JCL_ThrowException (JNIEnv * env, const char *className, @@ -56,6 +64,9 @@ JNIEXPORT void JNICALL JCL_free_cstring (JNIEnv * env, jstring s, JNIEXPORT jint JNICALL JCL_MonitorEnter (JNIEnv * env, jobject o); JNIEXPORT jint JNICALL JCL_MonitorExit (JNIEnv * env, jobject o); +JNIEXPORT jobject JNICALL JCL_NewRawDataObject (JNIEnv * env, void *data); +JNIEXPORT void * JNICALL JCL_GetRawData (JNIEnv * env, jobject rawdata); + #define JCL_RETHROW_EXCEPTION(env) if((*(env))->ExceptionOccurred((env)) != NULL) return NULL; /* Simple debug macro */ diff --git a/libjava/classpath/native/jni/classpath/native_state.c b/libjava/classpath/native/jni/classpath/native_state.c index 3c11b8343de..2cb43d614cc 100644 --- a/libjava/classpath/native/jni/classpath/native_state.c +++ b/libjava/classpath/native/jni/classpath/native_state.c @@ -36,6 +36,7 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include <stdlib.h> +#include <assert.h> #include <jni.h> #include "native_state.h" @@ -165,6 +166,18 @@ add_node (struct state_node **head, jint obj_id, void *state) *head = new_node; } +#ifndef NDEBUG +static void +cp_gtk_check_compat (JNIEnv * env, jobject obj, struct state_table *table) +{ + jclass objclazz; + + objclazz = (*env)->GetObjectClass(env, obj); + assert ((*env)->IsAssignableFrom(env, objclazz, table->clazz)); + (*env)->DeleteLocalRef(env, objclazz); +} +#endif + void cp_gtk_set_state_oid (JNIEnv * env, jobject lock, struct state_table *table, jint obj_id, void *state) @@ -214,6 +227,11 @@ int cp_gtk_set_state (JNIEnv * env, jobject obj, struct state_table *table, void *state) { jint obj_id; + +#ifndef NDEBUG + cp_gtk_check_compat(env, obj, table); +#endif + obj_id = (*env)->GetIntField (env, obj, table->hash); if ((*env)->ExceptionOccurred (env) != NULL) @@ -227,6 +245,11 @@ void * cp_gtk_get_state (JNIEnv * env, jobject obj, struct state_table *table) { jint obj_id; + +#ifndef NDEBUG + cp_gtk_check_compat(env, obj, table); +#endif + obj_id = (*env)->GetIntField (env, obj, table->hash); if ((*env)->ExceptionOccurred (env) != NULL) @@ -239,6 +262,11 @@ void * cp_gtk_remove_state_slot (JNIEnv * env, jobject obj, struct state_table *table) { jint obj_id; + +#ifndef NDEBUG + cp_gtk_check_compat(env, obj, table); +#endif + obj_id = (*env)->GetIntField (env, obj, table->hash); if ((*env)->ExceptionOccurred (env) != NULL) diff --git a/libjava/classpath/native/jni/gtk-peer/Makefile.am b/libjava/classpath/native/jni/gtk-peer/Makefile.am index f4e7bdfcce1..6f21057c152 100644 --- a/libjava/classpath/native/jni/gtk-peer/Makefile.am +++ b/libjava/classpath/native/jni/gtk-peer/Makefile.am @@ -39,6 +39,7 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \ gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c \ gnu_java_awt_peer_gtk_GtkScrollbarPeer.c \ gnu_java_awt_peer_gtk_GtkScrollPanePeer.c \ + gnu_java_awt_peer_gtk_GtkSelection.c \ gnu_java_awt_peer_gtk_GtkTextAreaPeer.c \ gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \ gnu_java_awt_peer_gtk_GtkToolkit.c \ @@ -47,6 +48,7 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \ gdkfont.h \ gthread-jni.h \ gtkcairopeer.h \ + gtk_jawt.c \ gtkpeer.h libgtkpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/native_state.lo \ diff --git a/libjava/classpath/native/jni/gtk-peer/Makefile.in b/libjava/classpath/native/jni/gtk-peer/Makefile.in index fdf3fd1ddeb..f49d2a52817 100644 --- a/libjava/classpath/native/jni/gtk-peer/Makefile.in +++ b/libjava/classpath/native/jni/gtk-peer/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.9.5 from Makefile.am. +# Makefile.in generated by automake 1.9.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. +# 2003, 2004 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -96,11 +96,12 @@ am__libgtkpeer_la_SOURCES_DIST = \ gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c \ gnu_java_awt_peer_gtk_GtkScrollbarPeer.c \ gnu_java_awt_peer_gtk_GtkScrollPanePeer.c \ + gnu_java_awt_peer_gtk_GtkSelection.c \ gnu_java_awt_peer_gtk_GtkTextAreaPeer.c \ gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \ gnu_java_awt_peer_gtk_GtkToolkit.c \ gnu_java_awt_peer_gtk_GtkWindowPeer.c gthread-jni.c gdkfont.h \ - gthread-jni.h gtkcairopeer.h gtkpeer.h + gthread-jni.h gtkcairopeer.h gtk_jawt.c gtkpeer.h @GTK_CAIRO_TRUE@am__objects_1 = \ @GTK_CAIRO_TRUE@ gnu_java_awt_peer_gtk_GdkGraphics2D.lo am_libgtkpeer_la_OBJECTS = $(am__objects_1) \ @@ -134,10 +135,12 @@ am_libgtkpeer_la_OBJECTS = $(am__objects_1) \ gnu_java_awt_peer_gtk_GtkPopupMenuPeer.lo \ gnu_java_awt_peer_gtk_GtkScrollbarPeer.lo \ gnu_java_awt_peer_gtk_GtkScrollPanePeer.lo \ + gnu_java_awt_peer_gtk_GtkSelection.lo \ gnu_java_awt_peer_gtk_GtkTextAreaPeer.lo \ gnu_java_awt_peer_gtk_GtkTextFieldPeer.lo \ gnu_java_awt_peer_gtk_GtkToolkit.lo \ - gnu_java_awt_peer_gtk_GtkWindowPeer.lo gthread-jni.lo + gnu_java_awt_peer_gtk_GtkWindowPeer.lo gthread-jni.lo \ + gtk_jawt.lo libgtkpeer_la_OBJECTS = $(am_libgtkpeer_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -185,8 +188,14 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@ CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@ CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@ CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@ +CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@ +CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@ CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@ CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATE = @DATE@ DEFS = @DEFS@ @@ -248,6 +257,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ +MOC = @MOC@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -259,12 +269,13 @@ PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@ PANGOFT2_LIBS = @PANGOFT2_LIBS@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@ REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@ REMOVE = @REMOVE@ SET_MAKE = @SET_MAKE@ -SH = @SH@ SHELL = @SHELL@ STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@ STRIP = @STRIP@ @@ -286,10 +297,13 @@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ZIP = @ZIP@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -367,6 +381,7 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \ gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c \ gnu_java_awt_peer_gtk_GtkScrollbarPeer.c \ gnu_java_awt_peer_gtk_GtkScrollPanePeer.c \ + gnu_java_awt_peer_gtk_GtkSelection.c \ gnu_java_awt_peer_gtk_GtkTextAreaPeer.c \ gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \ gnu_java_awt_peer_gtk_GtkToolkit.c \ @@ -375,6 +390,7 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \ gdkfont.h \ gthread-jni.h \ gtkcairopeer.h \ + gtk_jawt.c \ gtkpeer.h libgtkpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/native_state.lo \ @@ -488,11 +504,13 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkScrollPanePeer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkScrollbarPeer.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkSelection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkTextAreaPeer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkTextFieldPeer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkToolkit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkWindowPeer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gthread-jni.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtk_jawt.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c index 401d62337b3..6f2a1ae7272 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c @@ -150,12 +150,8 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_getGlyphVector if (i == NULL) { - gdk_threads_leave (); - java_extents = (*env)->NewDoubleArray (env, 0); java_codes = (*env)->NewIntArray (env, 0); - - gdk_threads_enter (); } else { @@ -177,13 +173,9 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_getGlyphVector int x = 0; double scale = ((double) PANGO_SCALE); - gdk_threads_leave (); - java_extents = (*env)->NewDoubleArray (env, glyphs->num_glyphs * NUM_GLYPH_METRICS); java_codes = (*env)->NewIntArray (env, glyphs->num_glyphs); - gdk_threads_enter (); - native_extents = (*env)->GetDoubleArrayElements (env, java_extents, NULL); native_codes = (*env)->GetIntArrayElements (env, java_codes, NULL); diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c index 9b2f16e7145..b122eb01544 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c @@ -41,7 +41,7 @@ exception statement from your version. */ #include <gdk/gdkprivate.h> #include <gdk/gdkx.h> -static jmethodID initComponentGraphicsID; +static jmethodID initComponentGraphicsUnlockedID; void cp_gtk_graphics_init_jni (void) @@ -51,9 +51,44 @@ cp_gtk_graphics_init_jni (void) gdkgraphics = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(), "gnu/java/awt/peer/gtk/GdkGraphics"); - initComponentGraphicsID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics, - "initComponentGraphics", - "()V"); + initComponentGraphicsUnlockedID = + (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics, + "initComponentGraphicsUnlocked", + "()V"); +} + +struct state_table *cp_gtk_native_graphics_state_table; + +static struct state_table *native_graphics_global_ref_table; + +#define NSA_GLOBAL_G_INIT(env, clazz) \ + native_graphics_global_ref_table = cp_gtk_init_state_table (env, clazz) + +#define NSA_GET_GLOBAL_G_REF(env, obj) \ + cp_gtk_get_state (env, obj, native_graphics_global_ref_table) + +#define NSA_SET_GLOBAL_G_REF(env, obj) \ + do {jobject *globRefPtr; \ + globRefPtr = (jobject *) malloc (sizeof (jobject)); \ + *globRefPtr = (*env)->NewGlobalRef (env, obj); \ + cp_gtk_set_state (env, obj, native_graphics_global_ref_table, (void *)globRefPtr);} while (0) + +#define NSA_DEL_GLOBAL_G_REF(env, obj) \ + do {jobject *globRefPtr = cp_gtk_get_state (env, obj, native_graphics_global_ref_table); \ + cp_gtk_remove_state_slot (env, obj, native_graphics_global_ref_table); \ + (*env)->DeleteGlobalRef (env, *globRefPtr); \ + free (globRefPtr);} while (0) + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics_initStaticState + (JNIEnv *env, jclass clazz) +{ + gdk_threads_enter(); + + NSA_G_INIT (env, clazz); + NSA_GLOBAL_G_INIT (env, clazz); + + gdk_threads_leave(); } #define GDK_STABLE_IS_PIXMAP(d) (GDK_IS_PIXMAP(d)) @@ -73,7 +108,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_copyState gdk_threads_enter (); g = (struct graphics *) g_malloc (sizeof (struct graphics)); - g_old = (struct graphics *) NSA_GET_PTR (env, old); + g_old = (struct graphics *) NSA_GET_G_PTR (env, old); *g = *g_old; @@ -87,7 +122,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_copyState gdk_colormap_ref (g->cm); - NSA_SET_PTR (env, obj, g); + NSA_SET_G_PTR (env, obj, g); gdk_threads_leave (); } @@ -109,7 +144,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II gdk_colormap_ref (g->cm); g->gc = gdk_gc_new (g->drawable); - NSA_SET_PTR (env, obj, g); + NSA_SET_G_PTR (env, obj, g); gdk_threads_leave (); } @@ -136,15 +171,13 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage gdk_colormap_ref (g->cm); g->gc = gdk_gc_new (g->drawable); - NSA_SET_PTR (env, obj, g); + NSA_SET_G_PTR (env, obj, g); gdk_threads_leave (); } -/* copy the native state of the peer (GtkWidget *) to the native state - of the graphics object */ JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 +Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked (JNIEnv *env, jobject obj, jobject peer) { struct graphics *g = NULL; @@ -152,8 +185,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComp GtkWidget *widget = NULL; GdkColor color; - gdk_threads_enter (); - g = (struct graphics *) g_malloc (sizeof (struct graphics)); ptr = NSA_GET_PTR (env, peer); g->x_offset = 0; @@ -169,8 +200,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComp gdk_gc_copy (g->gc, widget->style->fg_gc[GTK_STATE_NORMAL]); color = widget->style->fg[GTK_STATE_NORMAL]; - NSA_SET_PTR (env, obj, g); + NSA_SET_G_PTR (env, obj, g); +} +/* copy the native state of the peer (GtkWidget *) to the native state + of the graphics object */ +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 + (JNIEnv *env, jobject obj, jobject peer) +{ + gdk_threads_enter (); + Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked + (env, obj, peer); gdk_threads_leave (); } @@ -183,8 +224,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_connectSignals gdk_threads_enter (); - NSA_SET_GLOBAL_REF (env, obj); - gref = NSA_GET_GLOBAL_REF (env, obj); + NSA_SET_GLOBAL_G_REF (env, obj); + gref = NSA_GET_GLOBAL_G_REF (env, obj); ptr = NSA_GET_PTR (env, peer); @@ -202,7 +243,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_dispose gdk_threads_enter (); - g = (struct graphics *) NSA_DEL_PTR (env, obj); + g = (struct graphics *) NSA_DEL_G_PTR (env, obj); /* check if dispose has been called already */ if (!g) @@ -235,7 +276,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_translateNative gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); g->x_offset += x; g->y_offset += y; @@ -255,7 +296,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); g_assert (g != NULL); pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, font); @@ -292,7 +333,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawLine gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); gdk_draw_line (g->drawable, g->gc, x + g->x_offset, y + g->y_offset, @@ -310,7 +351,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_fillRect gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); gdk_draw_rectangle (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, width, height); @@ -327,7 +368,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawRect gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); gdk_draw_rectangle (g->drawable, g->gc, FALSE, x + g->x_offset, y + g->y_offset, width, height); @@ -345,7 +386,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); gdk_window_copy_area ((GdkWindow *)g->drawable, g->gc, @@ -369,7 +410,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); if (!g) { @@ -408,7 +449,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_setFunction gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); gdk_gc_set_function (g->gc, func); @@ -429,7 +470,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_setFGColor color.green = green << 8; color.blue = blue << 8; - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); gdk_color_alloc (g->cm, &color); gdk_gc_set_foreground (g->gc, &color); @@ -446,7 +487,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawArc gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); gdk_draw_arc (g->drawable, g->gc, FALSE, x + g->x_offset, y + g->y_offset, @@ -493,7 +534,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolyline gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); points = translate_points (env, xpoints, ypoints, npoints, g->x_offset, g->y_offset); @@ -515,7 +556,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolygon gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); points = translate_points (env, xpoints, ypoints, npoints, g->x_offset, g->y_offset); @@ -542,7 +583,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_fillPolygon gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); points = translate_points (env, xpoints, ypoints, npoints, g->x_offset, g->y_offset); gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints); @@ -562,7 +603,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_fillArc gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); gdk_draw_arc (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, @@ -580,7 +621,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawOval gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); gdk_draw_arc (g->drawable, g->gc, FALSE, x + g->x_offset, y + g->y_offset, @@ -598,7 +639,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_fillOval gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); gdk_draw_arc (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, @@ -617,7 +658,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle gdk_threads_enter (); - g = (struct graphics *) NSA_GET_PTR (env, obj); + g = (struct graphics *) NSA_GET_G_PTR (env, obj); rectangle.x = x + g->x_offset; rectangle.y = y + g->y_offset; @@ -632,11 +673,9 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle static void realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject jgraphics) { - gdk_threads_leave (); + (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), + jgraphics, + initComponentGraphicsUnlockedID); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), jgraphics, initComponentGraphicsID); - - NSA_DEL_GLOBAL_REF (cp_gtk_gdk_env(), jgraphics); - - gdk_threads_enter (); + NSA_DEL_GLOBAL_G_REF (cp_gtk_gdk_env(), jgraphics); } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c index b4bd676e7b9..fe9980ffd02 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c @@ -52,7 +52,7 @@ #include <stdio.h> #include <stdlib.h> -static jmethodID initComponentGraphics2DID; +static jmethodID initComponentGraphics2DUnlockedID; void cp_gtk_graphics2d_init_jni (void) @@ -62,8 +62,8 @@ cp_gtk_graphics2d_init_jni (void) gdkgraphics2d = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(), "gnu/java/awt/peer/gtk/GdkGraphics2D"); - initComponentGraphics2DID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics2d, - "initComponentGraphics2D", + initComponentGraphics2DUnlockedID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics2d, + "initComponentGraphics2DUnlocked", "()V"); } @@ -369,11 +369,9 @@ check_for_debug (struct graphics2d *gr) static void realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject peer) { - gdk_threads_leave (); - - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, initComponentGraphics2DID); - - gdk_threads_enter (); + (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), + peer, + initComponentGraphics2DUnlockedID); } JNIEXPORT void JNICALL @@ -593,6 +591,43 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable } JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStateUnlocked + (JNIEnv *env, jobject obj, jobject peer) +{ + struct graphics2d *gr = NULL; + GtkWidget *widget = NULL; + void *ptr = NULL; + + if (peer_is_disposed(env, obj)) + return; + + ptr = NSA_GET_PTR (env, peer); + g_assert (ptr != NULL); + + gr = (struct graphics2d *) g_malloc (sizeof (struct graphics2d)); + g_assert (gr != NULL); + memset (gr, 0, sizeof(struct graphics2d)); + + check_for_debug (gr); + + widget = GTK_WIDGET (ptr); + g_assert (widget != NULL); + + grab_current_drawable (widget, &(gr->drawable), &(gr->win)); + g_assert (gr->drawable != NULL); + + gr->width = widget->allocation.width; + gr->height = widget->allocation.height; + + if (x_server_has_render_extension ()) + init_graphics2d_as_renderable (gr); + else + init_graphics2d_as_pixbuf (gr); + + NSA_SET_G2D_PTR (env, obj, gr); +} + +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (JNIEnv *env, jobject obj, jobject peer) { @@ -711,21 +746,36 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient jint r2, jint g2, jint b2, jint a2, jboolean cyclic) { + gdk_threads_enter(); + Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked + (env, obj, + x1, y1, x2, y2, + r1, g1, b1, a1, + r2, g2, b2, a2, + cyclic); + + gdk_threads_leave(); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked + (JNIEnv *env, jobject obj, + jdouble x1, jdouble y1, + jdouble x2, jdouble y2, + jint r1, jint g1, jint b1, jint a1, + jint r2, jint g2, jint b2, jint a2, + jboolean cyclic) +{ struct graphics2d *gr = NULL; cairo_surface_t *surf = NULL; cairo_t *cr2 = NULL; cairo_matrix_t mat; - gdk_threads_enter(); - gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); g_assert (gr != NULL); if (peer_is_disposed(env, obj)) - { - gdk_threads_leave (); - return; - } + return; if (gr->debug) printf ("setGradient (%f,%f) -> (%f,%f); (%d,%d,%d,%d) -> (%d,%d,%d,%d)\n", x1, y1, @@ -826,24 +876,29 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient gr->pattern = cairo_pattern_create_for_surface(surf); cairo_set_source (gr->cr, gr->pattern); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels + (JNIEnv *env, jobject obj, jintArray jarr, jint w, jint h, jint stride) +{ + gdk_threads_enter(); + + Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked + (env, obj, jarr, w, h, stride); gdk_threads_leave(); } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked (JNIEnv *env, jobject obj, jintArray jarr, jint w, jint h, jint stride) { struct graphics2d *gr = NULL; jint *jpixels = NULL; - gdk_threads_enter(); - if (peer_is_disposed(env, obj)) - { - gdk_threads_leave (); - return; - } + return; gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); g_assert (gr != NULL); @@ -880,8 +935,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels gr->pattern = cairo_pattern_create_for_surface (gr->pattern_surface); g_assert (gr->pattern != NULL); cairo_set_source (gr->cr, gr->pattern); - - gdk_threads_leave(); } JNIEXPORT void JNICALL @@ -996,26 +1049,30 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix (JNIEnv *env, jobject obj, jdoubleArray java_matrix) { + gdk_threads_enter(); + + Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked + (env, obj, java_matrix); + + gdk_threads_leave(); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked + (JNIEnv *env, jobject obj, jdoubleArray java_matrix) +{ struct graphics2d *gr = NULL; jdouble *native_matrix = NULL; - gdk_threads_enter(); - if (peer_is_disposed(env, obj)) - { - gdk_threads_leave (); - return; - } + return; gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); /* cairoSetMatrix was called before this graphics object's component was realized. */ if (gr == NULL) - { - gdk_threads_leave (); - return; - } + return; native_matrix = (*env)->GetDoubleArrayElements (env, java_matrix, NULL); g_assert (native_matrix != NULL); @@ -1039,8 +1096,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix (*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0); update_pattern_transform (gr); - - gdk_threads_leave(); } static void @@ -1357,15 +1412,22 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor (JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b, jdouble a) { - struct graphics2d *gr = NULL; - gdk_threads_enter(); + Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked + (env, obj, r, g, b, a); + + gdk_threads_leave(); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked + (JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b, jdouble a) +{ + struct graphics2d *gr = NULL; + if (peer_is_disposed(env, obj)) - { - gdk_threads_leave (); - return; - } + return; gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); g_assert (gr != NULL); @@ -1381,8 +1443,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor cairo_set_source_rgba (gr->cr, b, g, r, a); else cairo_set_source_rgba (gr->cr, r, g, b, a); - - gdk_threads_leave(); } JNIEXPORT void JNICALL @@ -1419,10 +1479,20 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth (JNIEnv *env, jobject obj, jdouble width) { - struct graphics2d *gr = NULL; - gdk_threads_enter(); + Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidthUnlocked + (env, obj, width); + + gdk_threads_leave(); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidthUnlocked + (JNIEnv *env, jobject obj, jdouble width) +{ + struct graphics2d *gr = NULL; + if (peer_is_disposed(env, obj)) return; @@ -1430,23 +1500,28 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth g_assert (gr != NULL); if (gr->debug) printf ("cairo_set_line_width %f\n", width); cairo_set_line_width (gr->cr, width); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap + (JNIEnv *env, jobject obj, jint cap) +{ + gdk_threads_enter(); + + Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked + (env, obj, cap); gdk_threads_leave(); } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked (JNIEnv *env, jobject obj, jint cap) { struct graphics2d *gr = NULL; - gdk_threads_enter(); - if (peer_is_disposed(env, obj)) - { - gdk_threads_leave (); - return; - } + return; gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); g_assert (gr != NULL); @@ -1465,23 +1540,28 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap cairo_set_line_cap (gr->cr, CAIRO_LINE_CAP_SQUARE); break; } +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin + (JNIEnv *env, jobject obj, jint join) +{ + gdk_threads_enter(); + + Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked + (env, obj, join); gdk_threads_leave(); } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked (JNIEnv *env, jobject obj, jint join) { struct graphics2d *gr = NULL; - gdk_threads_enter(); - if (peer_is_disposed(env, obj)) - { - gdk_threads_leave (); - return; - } + return; gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); g_assert (gr != NULL); @@ -1500,24 +1580,29 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin cairo_set_line_join (gr->cr, CAIRO_LINE_JOIN_BEVEL); break; } +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash + (JNIEnv *env, jobject obj, jdoubleArray dashes, jint ndash, jdouble offset) +{ + gdk_threads_enter(); + + Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked + (env, obj, dashes, ndash, offset); gdk_threads_leave(); } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked (JNIEnv *env, jobject obj, jdoubleArray dashes, jint ndash, jdouble offset) { struct graphics2d *gr = NULL; jdouble *dasharr = NULL; - gdk_threads_enter(); - if (peer_is_disposed(env, obj)) - { - gdk_threads_leave (); - return; - } + return; gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); g_assert (gr != NULL); @@ -1526,30 +1611,33 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash g_assert (dasharr != NULL); cairo_set_dash (gr->cr, dasharr, ndash, offset); (*env)->ReleaseDoubleArrayElements (env, dashes, dasharr, 0); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit + (JNIEnv *env, jobject obj, jdouble miter) +{ + gdk_threads_enter(); + + Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimitUnlocked + (env, obj, miter); gdk_threads_leave(); } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimitUnlocked (JNIEnv *env, jobject obj, jdouble miter) { struct graphics2d *gr = NULL; - gdk_threads_enter(); - if (peer_is_disposed(env, obj)) - { - gdk_threads_leave (); - return; - } + return; gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); g_assert (gr != NULL); if (gr->debug) printf ("cairo_set_miter_limit %f\n", miter); cairo_set_miter_limit (gr->cr, miter); - - gdk_threads_leave(); } JNIEXPORT void JNICALL @@ -1845,15 +1933,22 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter (JNIEnv *env, jobject obj, jint filter) { - struct graphics2d *gr = NULL; - gdk_threads_enter(); + Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked + (env, obj, filter); + + gdk_threads_leave(); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked + (JNIEnv *env, jobject obj, jint filter) +{ + struct graphics2d *gr = NULL; + if (peer_is_disposed(env, obj)) - { - gdk_threads_leave (); - return; - } + return; gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); g_assert (gr != NULL); @@ -1876,6 +1971,4 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BEST); break; } - - gdk_threads_leave(); } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c index 648cd6603d1..74103b5daab 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c @@ -97,14 +97,10 @@ area_prepared_cb (GdkPixbufLoader *loader, e.jni_env = &env; (*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1); - gdk_threads_leave (); - (*env)->CallVoidMethod (env, *decoder, areaPreparedID, width, height); - - gdk_threads_enter (); } static void @@ -143,12 +139,8 @@ area_updated_cb (GdkPixbufLoader *loader, e.jni_env = &env; (*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1); - gdk_threads_leave (); - jpixels = (*env)->NewIntArray (env, n_pixels); - gdk_threads_enter (); - java_pixels = (*env)->GetIntArrayElements (env, jpixels, NULL); memcpy (java_pixels, @@ -165,8 +157,6 @@ area_updated_cb (GdkPixbufLoader *loader, g_object_unref (pixbuf); - gdk_threads_leave (); - (*env)->ReleaseIntArrayElements (env, jpixels, java_pixels, 0); (*env)->CallVoidMethod (env, @@ -178,8 +168,6 @@ area_updated_cb (GdkPixbufLoader *loader, stride_pixels); (*env)->DeleteLocalRef(env, jpixels); - - gdk_threads_enter (); } static void @@ -190,12 +178,8 @@ closed_cb (GdkPixbufLoader *loader __attribute__((unused)), jobject *decoder) e.jni_env = &env; (*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1); - gdk_threads_leave (); - (*env)->DeleteGlobalRef (env, *decoder); g_free (decoder); - - gdk_threads_enter (); } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c index 8c0ac6ce35f..7389fa3a460 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c @@ -311,12 +311,8 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_nativeGetRGBPixels n_pixels = height * stride_pixels; gdk_pixels = gdk_pixbuf_get_pixels (pixbuf); - gdk_threads_leave (); - jpixels = (*env)->NewIntArray (env, n_pixels); - gdk_threads_enter (); - java_pixels = (*env)->GetIntArrayElements (env, jpixels, NULL); memcpy (java_pixels, diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c index 5e8ab26c3ed..6a9066cbe53 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c @@ -39,9 +39,8 @@ exception statement from your version. */ #include "gtkpeer.h" #include "gnu_java_awt_peer_gtk_GtkButtonPeer.h" -static jmethodID beginNativeRepaintID; -static jmethodID endNativeRepaintID; - +static jmethodID postActionEventID; + void cp_gtk_button_init_jni (void) { @@ -50,16 +49,13 @@ cp_gtk_button_init_jni (void) gtkbuttonpeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(), "gnu/java/awt/peer/gtk/GtkButtonPeer"); - beginNativeRepaintID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkbuttonpeer, - "beginNativeRepaint", - "()V"); - - endNativeRepaintID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkbuttonpeer, - "endNativeRepaint", "()V"); + postActionEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), + gtkbuttonpeer, + "postActionEvent", "(I)V"); } -static void block_expose_event_cb (GtkWidget *widget, - jobject peer); +static void clicked_cb (GtkButton *button, + jobject peer); JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_create @@ -86,6 +82,56 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_create gdk_threads_leave (); } +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetGetPreferredDimensions + (JNIEnv *env, jobject obj, jintArray jdims) +{ + void *ptr; + jint *dims; + GtkWidget *button; + GtkWidget *label; + GtkRequisition current_req; + GtkRequisition current_label_req; + GtkRequisition natural_req; + + gdk_threads_enter (); + + ptr = NSA_GET_PTR (env, obj); + + button = gtk_bin_get_child (GTK_BIN (ptr)); + label = gtk_bin_get_child (GTK_BIN (button)); + + dims = (*env)->GetIntArrayElements (env, jdims, 0); + dims[0] = dims[1] = 0; + + /* Save the button's current size request. */ + gtk_widget_size_request (GTK_WIDGET (button), ¤t_req); + + /* Save the label's current size request. */ + gtk_widget_size_request (GTK_WIDGET (label), ¤t_label_req); + + /* Get the widget's "natural" size request. */ + gtk_widget_set_size_request (GTK_WIDGET (button), -1, -1); + gtk_widget_set_size_request (GTK_WIDGET (label), -1, -1); + + gtk_widget_size_request (GTK_WIDGET (button), &natural_req); + + /* Reset the button's size request. */ + gtk_widget_set_size_request (GTK_WIDGET (button), + current_req.width, current_req.height); + + /* Reset the label's size request. */ + gtk_widget_set_size_request (GTK_WIDGET (label), + current_label_req.width, current_label_req.height); + + dims[0] = natural_req.width; + dims[1] = natural_req.height; + + (*env)->ReleaseIntArrayElements (env, jdims, dims, 0); + + gdk_threads_leave (); +} + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_connectSignals (JNIEnv *env, jobject obj) @@ -102,11 +148,8 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_connectSignals button = gtk_bin_get_child (GTK_BIN (ptr)); /* Button signals */ - g_signal_connect_after (G_OBJECT (button), "pressed", - G_CALLBACK (block_expose_event_cb), *gref); - - g_signal_connect_after (G_OBJECT (button), "released", - G_CALLBACK (block_expose_event_cb), *gref); + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (clicked_cb), *gref); /* Component signals */ cp_gtk_component_connect_signals (G_OBJECT (button), gref); @@ -318,21 +361,17 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_setNativeBounds } static void -block_expose_event_cb (GtkWidget *widget, jobject peer) +clicked_cb (GtkButton* button __attribute__((unused)), + jobject peer) { - gdk_threads_leave (); + GdkEventButton* event; - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, - beginNativeRepaintID); - - gdk_threads_enter (); - - gdk_window_process_updates (widget->window, TRUE); - - gdk_threads_leave (); + event = (GdkEventButton*) gtk_get_current_event (); + g_assert (event); (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, - endNativeRepaintID); + postActionEventID, + cp_gtk_state_to_awt_mods (event->state)); - gdk_threads_enter (); + gdk_event_free ((GdkEvent*) event); } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c index cf883dd3307..7012bd82115 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c @@ -227,14 +227,10 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkButtonSetLabel static void item_toggled_cb (GtkToggleButton *item, jobject peer) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postItemEventID, peer, item->active ? (jint) AWT_ITEM_SELECTED : (jint) AWT_ITEM_DESELECTED); - - gdk_threads_enter (); } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c index ed9df543332..c5bf5a353ff 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c @@ -187,18 +187,26 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeRemoveAll } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkChoicePeer_select +Java_gnu_java_awt_peer_gtk_GtkChoicePeer_selectNative (JNIEnv *env, jobject obj, jint index) { - void *ptr; - gdk_threads_enter (); + Java_gnu_java_awt_peer_gtk_GtkChoicePeer_selectNativeUnlocked + (env, obj, index); + + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkChoicePeer_selectNativeUnlocked + (JNIEnv *env, jobject obj, jint index) +{ + void *ptr; + ptr = NSA_GET_PTR (env, obj); gtk_combo_box_set_active (GTK_COMBO_BOX (ptr), index); - - gdk_threads_leave (); } JNIEXPORT jint JNICALL @@ -219,7 +227,8 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeGetSelected return index; } -static void selection_changed_cb (GtkComboBox *combobox, jobject peer) +static void +selection_changed_cb (GtkComboBox *combobox, jobject peer) { jstring label; GtkTreeModel *model; @@ -236,13 +245,9 @@ static void selection_changed_cb (GtkComboBox *combobox, jobject peer) gtk_tree_model_get (model, &iter, 0, &selected, -1); label = (*cp_gtk_gdk_env())->NewStringUTF (cp_gtk_gdk_env(), selected); - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postChoiceItemEventID, label, (jint) AWT_ITEM_SELECTED); - - gdk_threads_enter (); } } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c index dea9d4cc7c2..f10a80d580b 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c @@ -1,5 +1,5 @@ /* gtkclipboard.c - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -36,169 +36,377 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ +#include "jcl.h" #include "gtkpeer.h" #include "gnu_java_awt_peer_gtk_GtkClipboard.h" -static jmethodID stringSelectionReceivedID; -static jmethodID stringSelectionHandlerID; -static jmethodID selectionClearID; +#define OBJECT_TARGET 1 +#define TEXT_TARGET 2 +#define IMAGE_TARGET 3 +#define URI_TARGET 4 -static void selection_received_cb (GtkWidget *, GtkSelectionData *, - guint, gpointer); -static void selection_get_cb (GtkWidget *, GtkSelectionData *, guint, - guint, gpointer); -static gint selection_clear_cb (GtkWidget *, GdkEventSelection *); +/* The clipboard and standard (string targets) shared with GtkSelection. */ +GtkClipboard *cp_gtk_clipboard; -static GtkWidget *clipboard; -static jobject cb_obj; +jstring cp_gtk_stringTarget; +jstring cp_gtk_imageTarget; +jstring cp_gtk_filesTarget; -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env, - jobject obj) -{ - gdk_threads_enter (); +/* Simple id to keep track of the selection we are currently managing. */ +static int current_selection = 0; - if (!stringSelectionReceivedID) - { - jclass gtkclipboard; - - gtkclipboard = (*env)->FindClass (env, - "gnu/java/awt/peer/gtk/GtkClipboard"); - stringSelectionReceivedID = (*env)->GetMethodID (env, gtkclipboard, - "stringSelectionReceived", - "(Ljava/lang/String;)V"); - stringSelectionHandlerID = (*env)->GetMethodID (env, gtkclipboard, - "stringSelectionHandler", - "()Ljava/lang/String;"); - selectionClearID = (*env)->GetMethodID (env, gtkclipboard, - "selectionClear", "()V"); - } +/* Whether we "own" the clipboard. And may clear it. */ +static int owner = 0; - cb_obj = (*env)->NewGlobalRef (env, obj); +static jclass gtk_clipboard_class; +static jmethodID setSystemContentsID; - clipboard = gtk_window_new (GTK_WINDOW_TOPLEVEL); +static jobject gtk_clipboard_instance = NULL; +static jmethodID provideContentID; +static jmethodID provideTextID; +static jmethodID provideImageID; +static jmethodID provideURIsID; - g_signal_connect (G_OBJECT(clipboard), "selection_received", - G_CALLBACK (selection_received_cb), NULL); - - g_signal_connect (G_OBJECT(clipboard), "selection_clear_event", - G_CALLBACK (selection_clear_cb), NULL); - - gtk_selection_add_target (clipboard, GDK_SELECTION_PRIMARY, - GDK_TARGET_STRING, 0); +/* Called when clipboard owner changes. Used to update available targets. */ +#if GTK_MINOR_VERSION > 4 +static void +clipboard_owner_change_cb (GtkClipboard *clipboard __attribute__((unused)), + GdkEvent *event __attribute__((unused)), + gpointer user_data __attribute__((unused))) +{ + /* These are only interesting when we are not the owner. Otherwise + we will have the set and clear functions doing the updating. */ + JNIEnv *env = cp_gtk_gdk_env (); + if (!owner) + (*env)->CallStaticVoidMethod (env, gtk_clipboard_class, + setSystemContentsID); +} +#endif + +JNIEXPORT jboolean JNICALL +Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env, + jclass gtkclipboard, + jstring string, + jstring image, + jstring files) +{ + GdkDisplay* display; + jboolean can_cache; - g_signal_connect (G_OBJECT(clipboard), "selection_get", - G_CALLBACK (selection_get_cb), NULL); + gtk_clipboard_class = gtkclipboard; + setSystemContentsID = (*env)->GetStaticMethodID (env, gtk_clipboard_class, + "setSystemContents", + "()V"); + if (setSystemContentsID == NULL) + return JNI_FALSE; - gdk_threads_leave (); -} + cp_gtk_stringTarget = (*env)->NewGlobalRef(env, string); + cp_gtk_imageTarget = (*env)->NewGlobalRef(env, image); + cp_gtk_filesTarget = (*env)->NewGlobalRef(env, files); -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkClipboard_requestStringConversion - (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused))) -{ gdk_threads_enter (); + cp_gtk_clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - gtk_selection_convert (clipboard, GDK_SELECTION_PRIMARY, - GDK_TARGET_STRING, GDK_CURRENT_TIME); - + display = gtk_clipboard_get_display (cp_gtk_clipboard); + /* Check for support for clipboard owner changes. */ +#if GTK_MINOR_VERSION > 4 + if (gdk_display_supports_selection_notification (display)) + { + g_signal_connect (cp_gtk_clipboard, "owner-change", + G_CALLBACK (clipboard_owner_change_cb), NULL); + gdk_display_request_selection_notification (display, + GDK_SELECTION_CLIPBOARD); + can_cache = JNI_TRUE; + } + else +#endif + can_cache = JNI_FALSE; gdk_threads_leave (); + + return can_cache; } static void -selection_received_cb (GtkWidget *widget __attribute__((unused)), - GtkSelectionData *selection_data __attribute__((unused)), - guint time __attribute__((unused)), - gpointer data __attribute__((unused))) +clipboard_get_func (GtkClipboard *clipboard __attribute__((unused)), + GtkSelectionData *selection, + guint info, + gpointer user_data __attribute__((unused))) { - /* Check to see if retrieval succeeded */ - if (selection_data->length < 0 - || selection_data->type != GDK_SELECTION_TYPE_STRING) + JNIEnv *env = cp_gtk_gdk_env (); + + if (info == OBJECT_TARGET) { - gdk_threads_leave (); - - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), cb_obj, stringSelectionReceivedID, - NULL); + const gchar *target_name; + jstring target_string; + jbyteArray bytes; + jint len; + jbyte *barray; + + target_name = gdk_atom_name (selection->target); + if (target_name == NULL) + return; + target_string = (*env)->NewStringUTF (env, target_name); + if (target_string == NULL) + return; + bytes = (*env)->CallObjectMethod(env, + gtk_clipboard_instance, + provideContentID, + target_string); + if (bytes == NULL) + return; + len = (*env)->GetArrayLength(env, bytes); + if (len <= 0) + return; + barray = (*env)->GetByteArrayElements(env, bytes, NULL); + if (barray == NULL) + return; + gtk_selection_data_set (selection, selection->target, 8, + (guchar *) barray, len); + + (*env)->ReleaseByteArrayElements(env, bytes, barray, 0); - gdk_threads_enter (); } - else + else if (info == TEXT_TARGET) + { + jstring string; + const gchar *text; + int len; + string = (*env)->CallObjectMethod(env, + gtk_clipboard_instance, + provideTextID); + if (string == NULL) + return; + len = (*env)->GetStringUTFLength (env, string); + if (len == -1) + return; + text = (*env)->GetStringUTFChars (env, string, NULL); + if (text == NULL) + return; + + gtk_selection_data_set_text (selection, text, len); + (*env)->ReleaseStringUTFChars (env, string, text); + } + /* Images and URIs/Files support only available with gtk+2.6 or higher. */ +#if GTK_MINOR_VERSION > 4 + else if (info == IMAGE_TARGET) { - char *str = (char *) selection_data->data; + jobject gtkimage; + GdkPixbuf *pixbuf = NULL; - gdk_threads_leave (); - - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), cb_obj, stringSelectionReceivedID, - (*cp_gtk_gdk_env())->NewStringUTF (cp_gtk_gdk_env(), str)); - - gdk_threads_enter (); + gtkimage = (*env)->CallObjectMethod(env, + gtk_clipboard_instance, + provideImageID); + if (gtkimage == NULL) + return; + + pixbuf = cp_gtk_image_get_pixbuf (env, gtkimage); + if (pixbuf != NULL) + { + gtk_selection_data_set_pixbuf (selection, pixbuf); + + /* if the GtkImage is offscreen, this is a temporary pixbuf + which should be thrown out. */ + if(cp_gtk_image_is_offscreen (env, gtkimage) == JNI_TRUE) + gdk_pixbuf_unref (pixbuf); + } } - - return; + else if (info == URI_TARGET) + { + jobjectArray uris; + jint count; + int i; + gchar **list; + + uris = (*env)->CallObjectMethod(env, + gtk_clipboard_instance, + provideURIsID); + if (uris == NULL) + return; + count = (*env)->GetArrayLength (env, uris); + if (count <= 0) + return; + + list = (gchar **) JCL_malloc (env, (count + 1) * sizeof (gchar *)); + for (i = 0; i < count; i++) + { + const char *text; + jstring uri; + + /* Mark NULL in so case of some error we can find the end. */ + list[i] = NULL; + uri = (*env)->GetObjectArrayElement (env, uris, i); + if (uri == NULL) + break; + text = (*env)->GetStringUTFChars (env, uri, NULL); + if (text == NULL) + break; + list[i] = strdup (text); + (*env)->ReleaseStringUTFChars (env, uri, text); + } + + if (i == count) + { + list[count] = NULL; + gtk_selection_data_set_uris (selection, list); + } + + for (i = 0; list[i] != NULL; i++) + free (list[i]); + JCL_free (env, list); + } +#endif } static void -selection_get_cb (GtkWidget *widget __attribute__((unused)), - GtkSelectionData *selection_data, - guint info __attribute__((unused)), - guint time __attribute__((unused)), - gpointer data __attribute__((unused))) +clipboard_clear_func (GtkClipboard *clipboard __attribute__((unused)), + gpointer user_data) { - jstring jstr; - const char *utf; - jsize utflen; - - gdk_threads_leave (); - - jstr = (*cp_gtk_gdk_env())->CallObjectMethod (cp_gtk_gdk_env(), cb_obj, - stringSelectionHandlerID); - - gdk_threads_enter (); - - if (!jstr) + if (owner && (int) user_data == current_selection) { - gtk_selection_data_set (selection_data, - GDK_TARGET_STRING, 8, NULL, 0); - return; + JNIEnv *env = cp_gtk_gdk_env(); + owner = 0; + (*env)->CallStaticVoidMethod (env, gtk_clipboard_class, + setSystemContentsID); } - - utflen = (*cp_gtk_gdk_env())->GetStringUTFLength (cp_gtk_gdk_env(), jstr); - utf = (*cp_gtk_gdk_env())->GetStringUTFChars (cp_gtk_gdk_env(), jstr, NULL); - - gtk_selection_data_set (selection_data, GDK_TARGET_STRING, 8, - (const unsigned char*)utf, utflen); - - (*cp_gtk_gdk_env())->ReleaseStringUTFChars (cp_gtk_gdk_env(), jstr, utf); } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkClipboard_selectionGet - (JNIEnv *env, jclass clazz __attribute__((unused))) +Java_gnu_java_awt_peer_gtk_GtkClipboard_advertiseContent +(JNIEnv *env, + jobject instance, + jobjectArray mime_array, +#if GTK_MINOR_VERSION > 4 + jboolean add_text, jboolean add_images, jboolean add_uris) +#else + jboolean add_text __attribute__((unused)), + jboolean add_images __attribute__((unused)), + jboolean add_uris __attribute__((unused))) +#endif { - GdkWindow *owner; + GtkTargetList *target_list; + GList *list; + GtkTargetEntry *targets; + gint n, i; gdk_threads_enter (); + target_list = gtk_target_list_new (NULL, 0); - /* if we already own the clipboard, we need to tell the old data object - that we're no longer going to be using him */ - owner = gdk_selection_owner_get (GDK_SELECTION_PRIMARY); - if (owner && owner == clipboard->window) - (*env)->CallVoidMethod (env, cb_obj, selectionClearID); - - gtk_selection_owner_set (clipboard, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME); + if (mime_array != NULL) + { + n = (*env)->GetArrayLength (env, mime_array); + for (i = 0; i < n; i++) + { + const char *text; + jstring target; + GdkAtom atom; + + target = (*env)->GetObjectArrayElement (env, mime_array, i); + if (target == NULL) + break; + text = (*env)->GetStringUTFChars (env, target, NULL); + if (text == NULL) + break; + + atom = gdk_atom_intern (text, FALSE); + gtk_target_list_add (target_list, atom, 0, OBJECT_TARGET); + + (*env)->ReleaseStringUTFChars (env, target, text); + } + } - gdk_threads_leave (); -} + /* Add extra targets that gtk+ can provide/translate for us. */ +#if GTK_MINOR_VERSION > 4 + if (add_text) + gtk_target_list_add_text_targets (target_list, TEXT_TARGET); + if (add_images) + gtk_target_list_add_image_targets (target_list, IMAGE_TARGET, TRUE); + if (add_uris) + gtk_target_list_add_uri_targets (target_list, URI_TARGET); +#else + if (add_text) + gtk_target_list_add (target_list, + gdk_atom_intern ("STRING", FALSE), + 0, TEXT_TARGET); +#endif + + + /* Turn list into a target table. */ + n = g_list_length (target_list->list); + if (n > 0) + { + targets = g_new (GtkTargetEntry, n); + for (list = target_list->list, i = 0; + list != NULL; + list = list->next, i++) + { + GtkTargetPair *pair = (GtkTargetPair *) list->data; + targets[i].target = gdk_atom_name (pair->target); + targets[i].flags = pair->flags; + targets[i].info = pair->info; + } + + /* Set the targets plus callback functions and ask for the clipboard + to be stored when the application exists if supported. */ + current_selection++; + if (gtk_clipboard_set_with_data (cp_gtk_clipboard, targets, n, + clipboard_get_func, + clipboard_clear_func, + (gpointer) current_selection)) + { + owner = 1; + if (gtk_clipboard_instance == NULL) + { + JNIEnv *env = cp_gtk_gdk_env (); + gtk_clipboard_instance = (*env)->NewGlobalRef(env, instance); + + provideContentID + = (*env)->GetMethodID (env, gtk_clipboard_class, + "provideContent", + "(Ljava/lang/String;)[B"); + if (provideContentID == NULL) + return; + + provideTextID + = (*env)->GetMethodID (env, gtk_clipboard_class, + "provideText", "()Ljava/lang/String;"); + if (provideTextID == NULL) + return; + + provideImageID + = (*env)->GetMethodID (env, gtk_clipboard_class, + "provideImage", + "()Lgnu/java/awt/peer/gtk/GtkImage;"); + if (provideImageID == NULL) + return; + + provideURIsID + = (*env)->GetMethodID (env, gtk_clipboard_class, + "provideURIs", + "()[Ljava/lang/String;"); + if (provideURIsID == NULL) + return; + } +#if GTK_MINOR_VERSION > 4 + gtk_clipboard_set_can_store (cp_gtk_clipboard, NULL, 0); +#endif + } + else + { + owner = 0; + (*env)->CallStaticVoidMethod (env, gtk_clipboard_class, + setSystemContentsID); + } + + for (i = 0; i < n; i++) + g_free (targets[i].target); + g_free (targets); + } + else if (owner) + { + gtk_clipboard_clear (cp_gtk_clipboard); + owner = 0; + } -static gint -selection_clear_cb (GtkWidget *widget __attribute__((unused)), - GdkEventSelection *event __attribute__((unused))) -{ + gtk_target_list_unref (target_list); gdk_threads_leave (); - - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), cb_obj, selectionClearID); - - gdk_threads_enter (); - - return TRUE; } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c index bd9dde39283..f832da5a462 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c @@ -145,8 +145,8 @@ button_to_awt_mods (int button) return 0; } -static jint -state_to_awt_mods (guint state) +jint +cp_gtk_state_to_awt_mods (guint state) { jint result = 0; @@ -185,13 +185,23 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor (JNIEnv *env, jobject obj, jint type) { + gdk_threads_enter (); + + Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked + (env, obj, type); + + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked + (JNIEnv *env, jobject obj, jint type) +{ void *ptr; GtkWidget *widget; GdkCursorType gdk_cursor_type; GdkCursor *gdk_cursor; - gdk_threads_enter (); - ptr = NSA_GET_PTR (env, obj); switch (type) @@ -244,8 +254,6 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor gdk_cursor = gdk_cursor_new (gdk_cursor_type); gdk_window_set_cursor (widget->window, gdk_cursor); gdk_cursor_destroy (gdk_cursor); - - gdk_threads_leave (); } JNIEXPORT void JNICALL @@ -602,12 +610,8 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetBackground bg = GTK_WIDGET (ptr)->style->bg[GTK_STATE_NORMAL]; - gdk_threads_leave (); - array = (*env)->NewIntArray (env, 3); - gdk_threads_enter (); - rgb = (*env)->GetIntArrayElements (env, array, NULL); /* convert color data from 16 bit values down to 8 bit values */ rgb[0] = bg.red >> 8; @@ -635,12 +639,8 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetForeground fg = GTK_WIDGET (ptr)->style->fg[GTK_STATE_NORMAL]; - gdk_threads_leave (); - array = (*env)->NewIntArray (env, 3); - gdk_threads_enter (); - rgb = (*env)->GetIntArrayElements (env, array, NULL); /* convert color data from 16 bit values down to 8 bit values */ rgb[0] = fg.red >> 8; @@ -711,33 +711,29 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetForeground } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_show - (JNIEnv *env, jobject obj) +Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setVisibleNative + (JNIEnv *env, jobject obj, jboolean visible) { - void *ptr; - gdk_threads_enter(); - ptr = NSA_GET_PTR (env, obj); - - gtk_widget_show (GTK_WIDGET (ptr)); + Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setVisibleNativeUnlocked + (env, obj, visible); gdk_threads_leave(); } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_hide - (JNIEnv *env, jobject obj) +Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setVisibleNativeUnlocked + (JNIEnv *env, jobject obj, jboolean visible) { void *ptr; - gdk_threads_enter(); - ptr = NSA_GET_PTR (env, obj); - gtk_widget_hide (GTK_WIDGET (ptr)); - - gdk_threads_leave(); + if (visible) + gtk_widget_show (GTK_WIDGET (ptr)); + else + gtk_widget_hide (GTK_WIDGET (ptr)); } JNIEXPORT jboolean JNICALL @@ -940,13 +936,11 @@ component_button_press_cb (GtkWidget *widget __attribute__((unused)), button_window = event->window; button_number = event->button; - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postMouseEventID, AWT_MOUSE_PRESSED, (jlong)event->time, - state_to_awt_mods (event->state) + cp_gtk_state_to_awt_mods (event->state) | button_to_awt_mods (event->button), (jint)event->x, (jint)event->y, @@ -954,8 +948,6 @@ component_button_press_cb (GtkWidget *widget __attribute__((unused)), (event->button == 3) ? JNI_TRUE : JNI_FALSE); - gdk_threads_enter (); - hasBeenDragged = FALSE; return FALSE; @@ -968,21 +960,17 @@ component_button_release_cb (GtkWidget *widget __attribute__((unused)), { int width, height; - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postMouseEventID, AWT_MOUSE_RELEASED, (jlong)event->time, - state_to_awt_mods (event->state) + cp_gtk_state_to_awt_mods (event->state) | button_to_awt_mods (event->button), (jint)event->x, (jint)event->y, click_count, JNI_FALSE); - gdk_threads_enter (); - /* Generate an AWT click event only if the release occured in the window it was pressed in, and the mouse has not been dragged since the last time it was pressed. */ @@ -993,20 +981,16 @@ component_button_release_cb (GtkWidget *widget __attribute__((unused)), && event->x <= width && event->y <= height) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postMouseEventID, AWT_MOUSE_CLICKED, (jlong)event->time, - state_to_awt_mods (event->state) + cp_gtk_state_to_awt_mods (event->state) | button_to_awt_mods (event->button), (jint)event->x, (jint)event->y, click_count, JNI_FALSE); - - gdk_threads_enter (); } return FALSE; } @@ -1022,8 +1006,6 @@ component_motion_notify_cb (GtkWidget *widget __attribute__((unused)), | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK)) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postMouseEventID, AWT_MOUSE_DRAGGED, @@ -1034,24 +1016,18 @@ component_motion_notify_cb (GtkWidget *widget __attribute__((unused)), 0, JNI_FALSE); - gdk_threads_enter (); - hasBeenDragged = TRUE; } else { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postMouseEventID, AWT_MOUSE_MOVED, (jlong)event->time, - state_to_awt_mods (event->state), + cp_gtk_state_to_awt_mods (event->state), (jint)event->x, (jint)event->y, 0, JNI_FALSE); - - gdk_threads_enter (); } return FALSE; } @@ -1065,8 +1041,6 @@ component_enter_notify_cb (GtkWidget *widget __attribute__((unused)), grab/ungrab and not to actually crossing boundaries */ if (event->mode == GDK_CROSSING_NORMAL) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postMouseEventID, AWT_MOUSE_ENTERED, (jlong)event->time, @@ -1075,8 +1049,6 @@ component_enter_notify_cb (GtkWidget *widget __attribute__((unused)), (jint)event->y, 0, JNI_FALSE); - - gdk_threads_enter (); } return FALSE; } @@ -1090,8 +1062,6 @@ component_leave_notify_cb (GtkWidget *widget __attribute__((unused)), grab/ungrab and not to actually crossing boundaries */ if (event->mode == GDK_CROSSING_NORMAL) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postMouseEventID, AWT_MOUSE_EXITED, @@ -1101,8 +1071,6 @@ component_leave_notify_cb (GtkWidget *widget __attribute__((unused)), (jint)event->y, 0, JNI_FALSE); - - gdk_threads_enter (); } return FALSE; } @@ -1112,8 +1080,6 @@ component_expose_cb (GtkWidget *widget __attribute__((unused)), GdkEventExpose *event, jobject peer) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postExposeEventID, (jint)event->area.x, @@ -1121,8 +1087,6 @@ component_expose_cb (GtkWidget *widget __attribute__((unused)), (jint)event->area.width, (jint)event->area.height); - gdk_threads_enter (); - return FALSE; } @@ -1131,15 +1095,11 @@ component_focus_in_cb (GtkWidget *widget __attribute((unused)), GdkEventFocus *event __attribute((unused)), jobject peer) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postFocusEventID, AWT_FOCUS_GAINED, JNI_FALSE); - gdk_threads_enter (); - return FALSE; } @@ -1148,14 +1108,10 @@ component_focus_out_cb (GtkWidget *widget __attribute((unused)), GdkEventFocus *event __attribute((unused)), jobject peer) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postFocusEventID, AWT_FOCUS_LOST, JNI_FALSE); - gdk_threads_enter (); - return FALSE; } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c index 48478d3b9bb..b9fd54abbcd 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c @@ -40,17 +40,57 @@ exception statement from your version. */ #include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" #include "gnu_java_awt_peer_gtk_GtkFileDialogPeer.h" +#define AWT_FILEDIALOG_LOAD 0 +#define AWT_FILEDIALOG_SAVE 1 + static void handle_response_cb (GtkDialog *dialog, gint responseId, jobject peer_obj); +static jmethodID gtkSetFilenameID; +static jmethodID gtkHideFileDialogID; +static jmethodID gtkDisposeFileDialogID; +static jmethodID filenameFilterCallbackID; + +void +cp_gtk_filedialog_init_jni (void) +{ + jclass gtkfiledialogpeer; + + gtkfiledialogpeer = + (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(), + "gnu/java/awt/peer/gtk/GtkFileDialogPeer"); + + gtkDisposeFileDialogID = + (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), + gtkfiledialogpeer, + "gtkDisposeFileDialog", "()V"); + + gtkHideFileDialogID = + (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), + gtkfiledialogpeer, + "gtkHideFileDialog", "()V"); + + gtkSetFilenameID = + (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), + gtkfiledialogpeer, + "gtkSetFilename", + "(Ljava/lang/String;)V"); + + filenameFilterCallbackID = + (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), + gtkfiledialogpeer, + "filenameFilterCallback", + "(Ljava/lang/String;)Z"); +} + /* * Make a new file selection dialog */ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_create - (JNIEnv *env, jobject obj, jobject parent) + (JNIEnv *env, jobject obj, jobject parent, int mode) { void *parentp; gpointer widget; @@ -62,19 +102,31 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_create parentp = NSA_GET_PTR(env, parent); - /* FIXME: we should be using the default gnome-vfs backend but it is - not currently thread-safe. See: - http://bugzilla.gnome.org/show_bug.cgi?id=166852 */ - widget = gtk_file_chooser_dialog_new_with_backend - ("Open File", - GTK_WINDOW(parentp), - GTK_FILE_CHOOSER_ACTION_OPEN, - "gtk+", - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL); - - /* GtkFileSelect is not modal by default */ + if (mode == AWT_FILEDIALOG_LOAD) + widget = gtk_file_chooser_dialog_new + ("Open File", + GTK_WINDOW(parentp), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + else + { + widget = gtk_file_chooser_dialog_new + ("Save File", + GTK_WINDOW(parentp), + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, + NULL); +#if GTK_MINOR_VERSION >= 8 + gtk_file_chooser_set_do_overwrite_confirmation + (GTK_FILE_CHOOSER (widget), TRUE); +#endif + } + + + /* GtkFileChooserDialog is not modal by default */ gtk_window_set_modal (GTK_WINDOW (widget), TRUE); /* We must add this window to the group so input in the others are @@ -132,25 +184,17 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeGetDirectory This function extracts the filename from the GtkFileFilterInfo object, and passes it to the Java method. The Java method will call the filter's accept() method and will give back the return value. */ -static gboolean filenameFilterCallback (const GtkFileFilterInfo *filter_info, +static gboolean filename_filter_cb (const GtkFileFilterInfo *filter_info, gpointer obj) { - jclass cx; - jmethodID id; jstring *filename; gboolean accepted; - cx = (*cp_gtk_gdk_env())->GetObjectClass (cp_gtk_gdk_env(), (jobject) obj); - id = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), cx, "filenameFilterCallback", - "(Ljava/lang/String;)Z"); - filename = (*cp_gtk_gdk_env())->NewStringUTF(cp_gtk_gdk_env(), filter_info->filename); - gdk_threads_leave(); - - accepted = (*cp_gtk_gdk_env())->CallBooleanMethod(cp_gtk_gdk_env(), obj, id, filename); - - gdk_threads_enter(); + accepted = (*cp_gtk_gdk_env())->CallBooleanMethod(cp_gtk_gdk_env(), obj, + filenameFilterCallbackID, + filename); return accepted; } @@ -168,7 +212,7 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeSetFilenameFilter filter = gtk_file_filter_new(); gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME, - filenameFilterCallback, obj, NULL); + filename_filter_cb, obj, NULL); gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(ptr), filter); @@ -220,11 +264,6 @@ handle_response_cb (GtkDialog *dialog __attribute__((unused)), gint responseId, jobject peer_obj) { - static int isDisposeIDSet = 0; - static int isIDSet = 0; - static jmethodID gtkSetFilenameID; - static jmethodID hideID; - static jmethodID disposeID; void *ptr; G_CONST_RETURN gchar *fileName; jstring str_fileName = NULL; @@ -240,42 +279,24 @@ handle_response_cb (GtkDialog *dialog __attribute__((unused)), if (responseId == GTK_RESPONSE_DELETE_EVENT) { - if (!isDisposeIDSet) - { - jclass cx = (*cp_gtk_gdk_env())->GetObjectClass (cp_gtk_gdk_env(), peer_obj); - disposeID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), cx, "gtkDisposeFileDialog", "()V"); - isDisposeIDSet = 1; - } - /* We can dispose of the dialog now (and unblock show) */ - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, disposeID); - gdk_threads_enter (); + (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, + gtkDisposeFileDialogID); return; } - if (responseId == GTK_RESPONSE_ACCEPT) { - fileName = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (GTK_WIDGET (ptr))); - str_fileName = (*cp_gtk_gdk_env())->NewStringUTF (cp_gtk_gdk_env(), fileName); - } - - if (!isIDSet) + if (responseId == GTK_RESPONSE_ACCEPT) { - jclass cx = (*cp_gtk_gdk_env())->GetObjectClass (cp_gtk_gdk_env(), peer_obj); - hideID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), cx, "gtkHideFileDialog", "()V"); - gtkSetFilenameID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), cx, - "gtkSetFilename", "(Ljava/lang/String;)V"); - isIDSet = 1; + fileName = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (GTK_WIDGET (ptr))); + str_fileName = (*cp_gtk_gdk_env())->NewStringUTF (cp_gtk_gdk_env(), fileName); } /* Set the Java object field 'file' with this value. */ - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, gtkSetFilenameID, str_fileName); + (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, + gtkSetFilenameID, str_fileName); /* We can hide the dialog now (and unblock show) */ - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, hideID); - - gdk_threads_enter (); + (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, + gtkHideFileDialogID); } - diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c index 41dfcea67b2..c60f48f51bb 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c @@ -85,11 +85,15 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarPeer gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - mptr = NSA_GET_PTR (env, menubar); - fixed = gtk_container_get_children (GTK_CONTAINER (ptr))->data; - gtk_fixed_put (GTK_FIXED (fixed), mptr, 0, 0); - gtk_widget_show (mptr); + if (menubar) + { + mptr = NSA_GET_PTR (env, menubar); + + fixed = gtk_container_get_children (GTK_CONTAINER (ptr))->data; + gtk_fixed_put (GTK_FIXED (fixed), mptr, 0, 0); + gtk_widget_show (mptr); + } gdk_threads_leave (); } @@ -114,24 +118,35 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_getMenuBarHeight JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidth + (JNIEnv *env, jobject obj, jobject menubar, jint width) +{ + gdk_threads_enter (); + + Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidthUnlocked + (env, obj, menubar, width); + + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidthUnlocked (JNIEnv *env, jobject obj __attribute__((unused)), jobject menubar, jint width) { GtkWidget *ptr; GtkRequisition natural_req; - gdk_threads_enter (); - - ptr = NSA_GET_PTR (env, menubar); - - /* Get the menubar's natural size request. */ - gtk_widget_set_size_request (GTK_WIDGET (ptr), -1, -1); - gtk_widget_size_request (GTK_WIDGET (ptr), &natural_req); + if (menubar) + { + ptr = NSA_GET_PTR (env, menubar); - /* Set the menubar's size request to width by natural_req.height. */ - gtk_widget_set_size_request (GTK_WIDGET (ptr), - width, natural_req.height); + /* Get the menubar's natural size request. */ + gtk_widget_set_size_request (GTK_WIDGET (ptr), -1, -1); + gtk_widget_size_request (GTK_WIDGET (ptr), &natural_req); - gdk_threads_leave (); + /* Set the menubar's size request to width by natural_req.height. */ + gtk_widget_set_size_request (GTK_WIDGET (ptr), + width, natural_req.height); + } } JNIEXPORT void JNICALL diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c index 0fae1da42b4..c8fb53040e8 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c @@ -58,13 +58,6 @@ Java_gnu_java_awt_peer_gtk_GtkGenericPeer_dispose NSA_DEL_PTR (env, obj); gdk_threads_leave (); - - /* - * Wake up the main thread, to make sure it re-checks the window - * destruction condition. - */ - - g_main_context_wakeup (NULL); } JNIEXPORT void JNICALL diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c index 86cad1487c6..fdc73ccdba5 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c @@ -35,6 +35,7 @@ this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ +#include "jcl.h" #include "gtkpeer.h" #include "gnu_java_awt_peer_gtk_GtkImage.h" #include <gdk-pixbuf/gdk-pixbuf.h> @@ -96,6 +97,67 @@ Java_gnu_java_awt_peer_gtk_GtkImage_loadPixbuf return JNI_TRUE; } +/* + * Creates the image from an array of java bytes. + */ +JNIEXPORT jboolean JNICALL +Java_gnu_java_awt_peer_gtk_GtkImage_loadImageFromData + (JNIEnv *env, jobject obj, jbyteArray data) +{ + jbyte *src; + GdkPixbuf* pixbuf; + GdkPixbufLoader* loader; + int len; + int width; + int height; + + gdk_threads_enter (); + + src = (*env)->GetByteArrayElements (env, data, NULL); + len = (*env)->GetArrayLength (env, data); + + loader = gdk_pixbuf_loader_new (); + + gdk_pixbuf_loader_write (loader, (guchar *)src, len, NULL); + gdk_pixbuf_loader_close (loader, NULL); + + (*env)->ReleaseByteArrayElements (env, data, src, 0); + + pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); + + if (pixbuf == NULL) + { + createRawData (env, obj, NULL); + + gdk_threads_leave (); + + return JNI_FALSE; + } + + width = gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + + createRawData (env, obj, pixbuf); + setWidthHeight(env, obj, width, height); + + gdk_threads_leave (); + + return JNI_TRUE; +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkImage_createFromPixbuf +(JNIEnv *env, jobject obj) +{ + int width, heigth; + GdkPixbuf *pixbuf = (GdkPixbuf *) getData (env, obj); + gdk_threads_enter (); + width = gdk_pixbuf_get_width (pixbuf); + heigth = gdk_pixbuf_get_height (pixbuf); + gdk_threads_leave (); + setWidthHeight(env, obj, width, heigth); +} + /** * Returns a copy of the pixel data as a java array. */ @@ -116,15 +178,8 @@ Java_gnu_java_awt_peer_gtk_GtkImage_getPixels(JNIEnv *env, jobject obj) height = gdk_pixbuf_get_height (pixbuf); rowstride = gdk_pixbuf_get_rowstride (pixbuf); - /* Must release the GDK lock before allocating memory through the - JVM, since some JVMs use the same lock for allocations and - finalization. Deadlock can occur on those JVMs. */ - gdk_threads_leave (); - result_array = (*env)->NewIntArray (env, (width * height)); - gdk_threads_enter (); - dst = result_array_iter = (*env)->GetIntArrayElements (env, result_array, NULL); @@ -307,10 +362,16 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled gdk_threads_enter (); + if (width <= 0 || height <= 0) + { + gdk_threads_leave (); + return; + } + bgColor = ((bg_red & 0xFF) << 16) | ((bg_green & 0xFF) << 8) | (bg_blue & 0xFF); - g = (struct graphics *) NSA_GET_PTR (env, gc_obj); + g = (struct graphics *) NSA_GET_G_PTR (env, gc_obj); if (!g || !GDK_IS_DRAWABLE (g->drawable)) { @@ -368,7 +429,12 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped (JNIEnv *env, jobject obj, jobject gc_obj, jint bg_red, jint bg_green, jint bg_blue, +#if GTK_MINOR_VERSION > 4 jboolean flipx, jboolean flipy, +#else + jboolean flipx __attribute__((unused)), + jboolean flipy __attribute__((unused)), +#endif jint srcx, jint srcy, jint srcwidth, jint srcheight, jint dstx, jint dsty, jint dstwidth, jint dstheight, jboolean composite) @@ -380,10 +446,17 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped gdk_threads_enter (); + if (srcwidth <= 0 || srcheight <= 0 + || dstwidth <= 0 || dstheight <= 0) + { + gdk_threads_leave (); + return; + } + bgColor = ((bg_red & 0xFF) << 16) | ((bg_green & 0xFF) << 8) | (bg_blue & 0xFF); - g = (struct graphics *) NSA_GET_PTR (env, gc_obj); + g = (struct graphics *) NSA_GET_G_PTR (env, gc_obj); if (!g || !GDK_IS_DRAWABLE (g->drawable)) { @@ -573,24 +646,15 @@ static void createRawData (JNIEnv * env, jobject obj, void *ptr) { jclass cls; - jmethodID method; jobject data; jfieldID data_fid; cls = (*env)->GetObjectClass (env, obj); data_fid = (*env)->GetFieldID (env, cls, "pixmap", - "Lgnu/classpath/RawData;"); + "Lgnu/classpath/Pointer;"); g_assert (data_fid != 0); -#if SIZEOF_VOID_P == 8 - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - method = (*env)->GetMethodID (env, cls, "<init>", "(J)V"); - data = (*env)->NewObject (env, cls, method, (jlong) ptr); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - method = (*env)->GetMethodID (env, cls, "<init>", "(I)V"); - data = (*env)->NewObject (env, cls, method, (jint) ptr); -#endif + data = JCL_NewRawDataObject (env, ptr); (*env)->SetObjectField (env, obj, data_fid, data); } @@ -599,23 +663,14 @@ static void * getData (JNIEnv * env, jobject obj) { jclass cls; - jfieldID field; jfieldID data_fid; jobject data; cls = (*env)->GetObjectClass (env, obj); data_fid = (*env)->GetFieldID (env, cls, "pixmap", - "Lgnu/classpath/RawData;"); + "Lgnu/classpath/Pointer;"); g_assert (data_fid != 0); data = (*env)->GetObjectField (env, obj, data_fid); -#if SIZEOF_VOID_P == 8 - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - field = (*env)->GetFieldID (env, cls, "data", "J"); - return (void *) (*env)->GetLongField (env, data, field); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - field = (*env)->GetFieldID (env, cls, "data", "I"); - return (void *) (*env)->GetIntField (env, data, field); -#endif + return JCL_GetRawData (env, data); } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c index 7968ca77371..74180a78447 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c @@ -66,6 +66,44 @@ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_create gdk_threads_leave (); } +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkWidgetGetPreferredDimensions + (JNIEnv *env, jobject obj, jintArray jdims) +{ + void *ptr; + jint *dims; + GtkWidget *label; + GtkRequisition current_req; + GtkRequisition natural_req; + + gdk_threads_enter (); + + ptr = NSA_GET_PTR (env, obj); + + label = gtk_bin_get_child (GTK_BIN (ptr)); + + dims = (*env)->GetIntArrayElements (env, jdims, 0); + dims[0] = dims[1] = 0; + + /* Save the widget's current size request. */ + gtk_widget_size_request (GTK_WIDGET (label), ¤t_req); + + /* Get the widget's "natural" size request. */ + gtk_widget_set_size_request (GTK_WIDGET (label), -1, -1); + gtk_widget_size_request (GTK_WIDGET (label), &natural_req); + + /* Reset the widget's size request. */ + gtk_widget_set_size_request (GTK_WIDGET (label), + current_req.width, current_req.height); + + dims[0] = natural_req.width; + dims[1] = natural_req.height; + + (*env)->ReleaseIntArrayElements (env, jdims, dims, 0); + + gdk_threads_leave (); +} + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkWidgetModifyFont (JNIEnv *env, jobject obj, jstring name, jint style, jint size) diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c index d513176bed1..fc89ab71ced 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c @@ -423,12 +423,8 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_getSelectedIndexes { current_row = rows = gtk_tree_selection_get_selected_rows (selection, NULL); - gdk_threads_leave (); - result_array = (*env)->NewIntArray (env, count); - gdk_threads_enter (); - result_array_iter = (*env)->GetIntArrayElements (env, result_array, NULL); for (i = 0; i < count; i++) @@ -513,25 +509,17 @@ item_highlighted_cb (GtkTreeSelection *selection __attribute__((unused)), if (!path_currently_selected) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postListItemEventID, row, (jint) AWT_ITEM_SELECTED); - - gdk_threads_enter (); } else { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postListItemEventID, row, (jint) AWT_ITEM_DESELECTED); - - gdk_threads_enter (); } } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c index 2746f1e4a70..d2ae148a9a4 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c @@ -186,8 +186,6 @@ Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_setLabel static void item_activate_cb (GtkMenuItem *item __attribute__((unused)), jobject peer_obj) { - gdk_threads_leave (); (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, - postMenuActionEventID); - gdk_threads_enter (); + postMenuActionEventID); } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c index eb658339dab..0ddab05c388 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c @@ -417,7 +417,5 @@ static void textcomponent_changed_cb (GtkEditable *editable __attribute__((unused)), jobject peer) { - gdk_threads_leave (); (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postTextEventID); - gdk_threads_enter (); } diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c index a8e1957ee20..040cc92ff1e 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c @@ -40,8 +40,7 @@ exception statement from your version. */ #include "gnu_java_awt_peer_gtk_GtkToolkit.h" #include "gthread-jni.h" #include "jcl.h" - -#include <sys/time.h> +#include <gdk/gdkx.h> #define RC_FILE ".classpath-gtkrc" @@ -157,6 +156,10 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env, gtk_init (&argc, &argv); +#if SYNCHRONIZE_GDK + XSynchronize (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), True); +#endif + gdk_rgb_init (); gtk_widget_set_default_colormap (gdk_rgb_get_cmap ()); gtk_widget_set_default_visual (gdk_rgb_get_visual ()); @@ -190,6 +193,7 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env, cp_gtk_checkbox_init_jni (); cp_gtk_choice_init_jni (); cp_gtk_component_init_jni (); + cp_gtk_filedialog_init_jni (); cp_gtk_list_init_jni (); cp_gtk_menuitem_init_jni (); cp_gtk_scrollbar_init_jni (); @@ -292,20 +296,6 @@ dpi_changed_cb (GtkSettings *settings, PANGO_SCALE * 72.0 / (int_dpi / PANGO_SCALE); } -static int -within_human_latency_tolerance(struct timeval *init) -{ - struct timeval curr; - unsigned long milliseconds_elapsed; - - gettimeofday(&curr, NULL); - - milliseconds_elapsed = (((curr.tv_sec * 1000) + (curr.tv_usec / 1000)) - - ((init->tv_sec * 1000) + (init->tv_usec / 1000))); - - return milliseconds_elapsed < 100; -} - #if GTK_MINOR_VERSION > 4 static void glog_func (const gchar *log_domain, @@ -332,69 +322,15 @@ glog_func (const gchar *log_domain, } #endif -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkToolkit_iterateNativeQueue -(JNIEnv *env, - jobject self __attribute__((unused)), - jobject lockedQueue, - jboolean block) -{ - /* We're holding an EventQueue lock, and we're about to acquire the GDK - * lock before dropping the EventQueue lock. This can deadlock if someone - * holds the GDK lock and wants to acquire the EventQueue lock; however - * all callbacks from GTK happen with the GDK lock released, so this - * would only happen in an odd case such as some JNI helper code - * acquiring the GDK lock and calling back into - * EventQueue.getNextEvent(). - */ - - struct timeval init; - gettimeofday(&init, NULL); - - gdk_threads_enter (); - (*env)->MonitorExit (env, lockedQueue); - - if (block) - { - - /* If we're blocking-when-empty, we want a do .. while loop. */ - do - gtk_main_iteration (); - while (within_human_latency_tolerance (&init) - && gtk_events_pending ()); - } - else - { - /* If we're not blocking-when-empty, we want a while loop. */ - while (within_human_latency_tolerance (&init) - && gtk_events_pending ()) - gtk_main_iteration (); - } - - (*env)->MonitorEnter (env, lockedQueue); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkToolkit_wakeNativeQueue - (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused))) -{ - g_main_context_wakeup (NULL); -} - -JNIEXPORT jboolean JNICALL -Java_gnu_java_awt_peer_gtk_GtkToolkit_nativeQueueEmpty - (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused))) +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkMain +(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused))) { - jboolean empty = FALSE; - gdk_threads_enter (); - empty = ! gtk_events_pending(); + gtk_main (); gdk_threads_leave (); - - return empty; } @@ -466,7 +402,11 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_loadSystemColors jint *colors; GtkStyle *style; + /* FIXME: this was deadlocking so assume it is thread-safe for now; + we need to replace this call with a .properties file anyway. */ +#if 0 gdk_threads_enter (); +#endif colors = (*env)->GetIntArrayElements (env, jcolors, 0); @@ -501,7 +441,9 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_loadSystemColors (*env)->ReleaseIntArrayElements(env, jcolors, colors, 0); +#if 0 gdk_threads_leave (); +#endif } #undef CONVERT diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c index 650d9b6030e..0f623d1655f 100644 --- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c +++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c @@ -260,20 +260,12 @@ static jmethodID postConfigureEventID; static jmethodID postInsetsChangedEventID; static jmethodID windowGetWidthID; static jmethodID windowGetHeightID; -static jmethodID setBoundsCallbackID; void cp_gtk_window_init_jni (void) { - jclass window; jclass gtkwindowpeer; - window = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(), "java/awt/Window"); - - setBoundsCallbackID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), window, - "setBoundsCallback", - "(IIII)V"); - gtkwindowpeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(), "gnu/java/awt/peer/gtk/GtkWindowPeer"); @@ -302,9 +294,10 @@ cp_gtk_window_init_jni (void) } /* Get the first keyval in the keymap for this event's keycode. The - first keyval corresponds roughly to Java's notion of a virtual - key. Returns the uppercase version of the first keyval. */ -static guint + first keyval corresponds roughly to Java's notion of a virtual key. + Returns the uppercase version of the first keyval or -1 if no + keyval was found for the given hardware keycode. */ +static gint get_first_keyval_from_keymap (GdkEventKey *event) { guint keyval; @@ -317,10 +310,8 @@ get_first_keyval_from_keymap (GdkEventKey *event) &keyvals, &n_entries)) { - g_warning ("No keyval found for hardware keycode %d\n", - event->hardware_keycode); - /* Try to recover by using the keyval in the event structure. */ - keyvals = &(event->keyval); + /* No keyval found for hardware keycode */ + return -1; } keyval = keyvals[0]; g_free (keyvals); @@ -328,16 +319,22 @@ get_first_keyval_from_keymap (GdkEventKey *event) return gdk_keyval_to_upper (keyval); } +/* Return the AWT key code for the given keysym or -1 if no keyval was + found for the given hardware keycode. */ #ifdef __GNUC__ __inline #endif static jint keysym_to_awt_keycode (GdkEventKey *event) { - guint ukeyval; + gint ukeyval; guint state; ukeyval = get_first_keyval_from_keymap (event); + + if (ukeyval < 0) + return -1; + state = event->state; /* VK_A through VK_Z */ @@ -736,13 +733,18 @@ keysym_to_awt_keycode (GdkEventKey *event) } } +/* Return the AWT key location code for the given keysym or -1 if no + keyval was found for the given hardware keycode. */ static jint keysym_to_awt_keylocation (GdkEventKey *event) { - guint ukeyval; + gint ukeyval; ukeyval = get_first_keyval_from_keymap (event); + if (ukeyval < 0) + return -1; + /* VK_A through VK_Z */ if (ukeyval >= GDK_A && ukeyval <= GDK_Z) return AWT_KEY_LOCATION_STANDARD; @@ -1052,8 +1054,6 @@ window_configure_cb (GtkWidget *widget __attribute__((unused)), GdkEventConfigure *event, jobject peer) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postConfigureEventID, (jint) event->x, @@ -1061,8 +1061,6 @@ window_configure_cb (GtkWidget *widget __attribute__((unused)), (jint) event->width, (jint) event->height); - gdk_threads_enter (); - return FALSE; } @@ -1071,18 +1069,25 @@ key_press_cb (GtkWidget *widget __attribute__((unused)), GdkEventKey *event, jobject peer) { - gdk_threads_leave (); + jint keycode; + jint keylocation; + + keycode = keysym_to_awt_keycode (event); + keylocation = keysym_to_awt_keylocation (event); + + /* Return immediately if an error occurs translating a hardware + keycode to a keyval. */ + if (keycode < 0 || keylocation < 0) + return TRUE; (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postKeyEventID, (jint) AWT_KEY_PRESSED, (jlong) event->time, keyevent_state_to_awt_mods (event), - keysym_to_awt_keycode (event), + keycode, keyevent_to_awt_keychar (event), - keysym_to_awt_keylocation (event)); - - gdk_threads_enter (); + keylocation); /* FIXME: generation of key typed events needs to be moved to GtkComponentPeer.postKeyEvent. If the key in a key @@ -1098,18 +1103,25 @@ key_release_cb (GtkWidget *widget __attribute__((unused)), GdkEventKey *event, jobject peer) { - gdk_threads_leave (); + jint keycode; + jint keylocation; + + keycode = keysym_to_awt_keycode (event); + keylocation = keysym_to_awt_keylocation (event); + + /* Return immediately if an error occurs translating a hardware + keycode to a keyval. */ + if (keycode < 0 || keylocation < 0) + return TRUE; (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postKeyEventID, (jint) AWT_KEY_RELEASED, (jlong) event->time, keyevent_state_to_awt_mods (event), - keysym_to_awt_keycode (event), + keycode, keyevent_to_awt_keychar (event), - keysym_to_awt_keylocation (event)); - - gdk_threads_enter (); + keylocation); return TRUE; } @@ -1218,23 +1230,31 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetModal } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisible +Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setVisibleNative (JNIEnv *env, jobject obj, jboolean visible) { - void *ptr; - gdk_threads_enter (); + Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setVisibleNativeUnlocked + (env, obj, visible); + + gdk_flush (); + + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setVisibleNativeUnlocked + (JNIEnv *env, jobject obj, jboolean visible) +{ + void *ptr; + ptr = NSA_GET_PTR (env, obj); if (visible) gtk_widget_show (GTK_WIDGET (ptr)); else gtk_widget_hide (GTK_WIDGET (ptr)); - - XFlush (GDK_DISPLAY ()); - - gdk_threads_leave (); } JNIEXPORT void JNICALL @@ -1349,17 +1369,6 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_toFront (JNIEnv *env, } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setBoundsCallback - (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)), - jobject window, jint x, jint y, jint width, jint height) -{ - /* Circumvent package-private access to call Window's - setBoundsCallback method. */ - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), window, setBoundsCallbackID, - x, y, width, height); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setSize (JNIEnv *env, jobject obj, jint width, jint height) { @@ -1382,10 +1391,20 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBounds (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height) { - void *ptr; - gdk_threads_enter (); + Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBoundsUnlocked + (env, obj, x, y, width, height); + + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBoundsUnlocked + (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height) +{ + void *ptr; + ptr = NSA_GET_PTR (env, obj); /* Avoid GTK runtime assertion failures. */ @@ -1414,8 +1433,6 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBounds by the program and the window's "resizable" property is true then the size request will not be honoured. */ gtk_window_resize (GTK_WINDOW (ptr), width, height); - - gdk_threads_leave (); } static void @@ -1427,10 +1444,20 @@ window_get_frame_extents (GtkWidget *window, /* Guess frame extents in case _NET_FRAME_EXTENTS is not supported. */ - *top = 23; - *left = 6; - *bottom = 6; - *right = 6; + if (gtk_window_get_decorated (GTK_WINDOW (window))) + { + *top = 23; + *left = 6; + *bottom = 6; + *right = 6; + } + else + { + *top = 0; + *left = 0; + *bottom = 0; + *right = 0; + } /* Request that the window manager set window's _NET_FRAME_EXTENTS property. */ @@ -1531,15 +1558,11 @@ window_delete_cb (GtkWidget *widget __attribute__((unused)), GdkEvent *event __attribute__((unused)), jobject peer) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postWindowEventID, (jint) AWT_WINDOW_CLOSING, (jobject) NULL, (jint) 0); - gdk_threads_enter (); - /* Prevents that the Window dissappears ("destroy" not being signalled). This is necessary because it should be up to a WindowListener implementation @@ -1552,28 +1575,20 @@ window_destroy_cb (GtkWidget *widget __attribute__((unused)), GdkEvent *event __attribute__((unused)), jobject peer) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postWindowEventID, (jint) AWT_WINDOW_CLOSED, (jobject) NULL, (jint) 0); - - gdk_threads_enter (); } static void window_show_cb (GtkWidget *widget __attribute__((unused)), jobject peer) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postWindowEventID, (jint) AWT_WINDOW_OPENED, (jobject) NULL, (jint) 0); - - gdk_threads_enter (); } static void @@ -1606,8 +1621,6 @@ window_focus_state_change_cb (GtkWidget *widget, GParamSpec *pspec __attribute__((unused)), jobject peer) { - gdk_threads_leave (); - if (GTK_WINDOW (widget)->has_toplevel_focus) (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postWindowEventID, @@ -1618,8 +1631,6 @@ window_focus_state_change_cb (GtkWidget *widget, postWindowEventID, (jint) AWT_WINDOW_DEACTIVATED, (jobject) NULL, (jint) 0); - - gdk_threads_enter (); } static gboolean @@ -1627,15 +1638,11 @@ window_focus_in_cb (GtkWidget * widget __attribute__((unused)), GdkEventFocus *event __attribute__((unused)), jobject peer) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postWindowEventID, (jint) AWT_WINDOW_GAINED_FOCUS, (jobject) NULL, (jint) 0); - gdk_threads_enter (); - return FALSE; } @@ -1644,15 +1651,11 @@ window_focus_out_cb (GtkWidget * widget __attribute__((unused)), GdkEventFocus *event __attribute__((unused)), jobject peer) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postWindowEventID, (jint) AWT_WINDOW_LOST_FOCUS, (jobject) NULL, (jint) 0); - gdk_threads_enter (); - return FALSE; } @@ -1670,26 +1673,18 @@ window_window_state_cb (GtkWidget *widget, if (event->window_state.new_window_state & GDK_WINDOW_STATE_ICONIFIED) { /* We've been iconified. */ - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postWindowEventID, (jint) AWT_WINDOW_ICONIFIED, (jobject) NULL, (jint) 0); - - gdk_threads_enter (); } else { /* We've been deiconified. */ - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postWindowEventID, (jint) AWT_WINDOW_DEICONIFIED, (jobject) NULL, (jint) 0); - - gdk_threads_enter (); } } @@ -1702,15 +1697,11 @@ window_window_state_cb (GtkWidget *widget, new_state |= window_get_new_state (widget); - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postWindowEventID, (jint) AWT_WINDOW_STATE_CHANGED, (jobject) NULL, new_state); - gdk_threads_enter (); - return TRUE; } @@ -1776,16 +1767,12 @@ window_property_changed_cb (GtkWidget *widget __attribute__((unused)), NULL, gu_ex.gu_extents)) { - gdk_threads_leave (); - (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postInsetsChangedEventID, (jint) extents[2], /* top */ (jint) extents[0], /* left */ (jint) extents[3], /* bottom */ (jint) extents[1]); /* right */ - - gdk_threads_enter (); } diff --git a/libjava/classpath/native/jni/gtk-peer/gtkpeer.h b/libjava/classpath/native/jni/gtk-peer/gtkpeer.h index f291d82ef4b..2b16d99b455 100644 --- a/libjava/classpath/native/jni/gtk-peer/gtkpeer.h +++ b/libjava/classpath/native/jni/gtk-peer/gtkpeer.h @@ -83,6 +83,20 @@ extern struct state_table *cp_gtk_native_global_ref_table; (*env)->DeleteGlobalRef (env, *globRefPtr); \ free (globRefPtr);} while (0) +extern struct state_table *cp_gtk_native_graphics_state_table; + +#define NSA_G_INIT(env, clazz) \ + cp_gtk_native_graphics_state_table = cp_gtk_init_state_table (env, clazz) + +#define NSA_GET_G_PTR(env, obj) \ + cp_gtk_get_state (env, obj, cp_gtk_native_graphics_state_table) + +#define NSA_SET_G_PTR(env, obj, ptr) \ + cp_gtk_set_state (env, obj, cp_gtk_native_graphics_state_table, (void *)ptr) + +#define NSA_DEL_G_PTR(env, obj) \ + cp_gtk_remove_state_slot (env, obj, cp_gtk_native_graphics_state_table) + #define SWAPU32(w) \ (((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24)) @@ -142,6 +156,14 @@ JNIEnv *cp_gtk_gdk_env(void); extern double cp_gtk_dpi_conversion_factor; extern GtkWindowGroup *cp_gtk_global_window_group; +/* Shared global clipboard for GtkClipboard and GtkSelection. */ +extern GtkClipboard *cp_gtk_clipboard; + +/* Standard target (strings) for GtkClipboard and GtkSelection. */ +extern jstring cp_gtk_stringTarget; +extern jstring cp_gtk_imageTarget; +extern jstring cp_gtk_filesTarget; + /* Union used for type punning. */ union widget_union { @@ -149,8 +171,9 @@ union widget_union GtkWidget **widget; }; -/* Keycode helpers */ +/* Constant conversion helpers */ guint cp_gtk_awt_keycode_to_keysym (jint keyCode, jint keyLocation); +jint cp_gtk_state_to_awt_mods (guint state); /* Image helpers */ GdkPixbuf *cp_gtk_image_get_pixbuf (JNIEnv *env, jobject obj); @@ -166,6 +189,7 @@ void cp_gtk_button_init_jni (void); void cp_gtk_checkbox_init_jni (void); void cp_gtk_choice_init_jni (void); void cp_gtk_component_init_jni (void); +void cp_gtk_filedialog_init_jni (void); void cp_gtk_list_init_jni (void); void cp_gtk_menuitem_init_jni (void); void cp_gtk_scrollbar_init_jni (void); @@ -182,6 +206,8 @@ void cp_gtk_textcomponent_connect_signals (GObject *ptr, jobject *gref); /* Debugging */ void cp_gtk_print_current_thread (void); +#define SYNCHRONIZE_GDK 0 + #define DEBUG_LOCKING 0 #if DEBUG_LOCKING diff --git a/libjava/classpath/native/jni/java-io/Makefile.in b/libjava/classpath/native/jni/java-io/Makefile.in index a48c78f33a2..9f0e0175b86 100644 --- a/libjava/classpath/native/jni/java-io/Makefile.in +++ b/libjava/classpath/native/jni/java-io/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.9.5 from Makefile.am. +# Makefile.in generated by automake 1.9.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. +# 2003, 2004 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -112,8 +112,14 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@ CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@ CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@ CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@ +CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@ +CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@ CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@ CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATE = @DATE@ DEFS = @DEFS@ @@ -175,6 +181,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ +MOC = @MOC@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -186,12 +193,13 @@ PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@ PANGOFT2_LIBS = @PANGOFT2_LIBS@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@ REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@ REMOVE = @REMOVE@ SET_MAKE = @SET_MAKE@ -SH = @SH@ SHELL = @SHELL@ STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@ STRIP = @STRIP@ @@ -213,10 +221,13 @@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ZIP = @ZIP@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ diff --git a/libjava/classpath/native/jni/java-lang/Makefile.in b/libjava/classpath/native/jni/java-lang/Makefile.in index c8e8ef8f170..2e9ffddd939 100644 --- a/libjava/classpath/native/jni/java-lang/Makefile.in +++ b/libjava/classpath/native/jni/java-lang/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.9.5 from Makefile.am. +# Makefile.in generated by automake 1.9.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. +# 2003, 2004 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -117,8 +117,14 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@ CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@ CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@ CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@ +CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@ +CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@ CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@ CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATE = @DATE@ DEFS = @DEFS@ @@ -180,6 +186,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ +MOC = @MOC@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -191,12 +198,13 @@ PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@ PANGOFT2_LIBS = @PANGOFT2_LIBS@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@ REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@ REMOVE = @REMOVE@ SET_MAKE = @SET_MAKE@ -SH = @SH@ SHELL = @SHELL@ STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@ STRIP = @STRIP@ @@ -218,10 +226,13 @@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ZIP = @ZIP@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ diff --git a/libjava/classpath/native/jni/java-lang/java_lang_VMDouble.c b/libjava/classpath/native/jni/java-lang/java_lang_VMDouble.c index 6b4aed42d27..846df2e6a4f 100644 --- a/libjava/classpath/native/jni/java-lang/java_lang_VMDouble.c +++ b/libjava/classpath/native/jni/java-lang/java_lang_VMDouble.c @@ -348,12 +348,7 @@ Java_java_lang_VMDouble_parseDouble struct _Jv_reent reent; memset (&reent, 0, sizeof reent); -#ifdef KISSME_LINUX_USER - /* FIXME: The libc strtod may not be reliable. */ - val = strtod (p, &endptr); -#else val = _strtod_r (&reent, p, &endptr); -#endif #ifdef DEBUG fprintf (stderr, "java.lang.VMDouble.parseDouble val = %g\n", val); diff --git a/libjava/classpath/native/jni/java-net/Makefile.in b/libjava/classpath/native/jni/java-net/Makefile.in index aa4df4fd7cb..c4970ec7c77 100644 --- a/libjava/classpath/native/jni/java-net/Makefile.in +++ b/libjava/classpath/native/jni/java-net/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.9.5 from Makefile.am. +# Makefile.in generated by automake 1.9.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. +# 2003, 2004 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -114,8 +114,14 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@ CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@ CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@ CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@ +CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@ +CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@ CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@ CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATE = @DATE@ DEFS = @DEFS@ @@ -177,6 +183,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ +MOC = @MOC@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -188,12 +195,13 @@ PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@ PANGOFT2_LIBS = @PANGOFT2_LIBS@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@ REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@ REMOVE = @REMOVE@ SET_MAKE = @SET_MAKE@ -SH = @SH@ SHELL = @SHELL@ STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@ STRIP = @STRIP@ @@ -215,10 +223,13 @@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ZIP = @ZIP@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ diff --git a/libjava/classpath/native/jni/java-net/gnu_java_net_PlainSocketImpl.c b/libjava/classpath/native/jni/java-net/gnu_java_net_PlainSocketImpl.c index a5261514dce..f5f22ab77e7 100644 --- a/libjava/classpath/native/jni/java-net/gnu_java_net_PlainSocketImpl.c +++ b/libjava/classpath/native/jni/java-net/gnu_java_net_PlainSocketImpl.c @@ -50,6 +50,7 @@ exception statement from your version. */ #include "target_native.h" #ifndef WITHOUT_NETWORK +#include "target_native_file.h" /* Get FIONREAD on Solaris. */ #include "target_native_network.h" #endif /* WITHOUT_NETWORK */ diff --git a/libjava/classpath/native/jni/java-nio/Makefile.in b/libjava/classpath/native/jni/java-nio/Makefile.in index cd3568f9375..2fd5d856a86 100644 --- a/libjava/classpath/native/jni/java-nio/Makefile.in +++ b/libjava/classpath/native/jni/java-nio/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.9.5 from Makefile.am. +# Makefile.in generated by automake 1.9.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. +# 2003, 2004 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -119,8 +119,14 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@ CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@ CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@ CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@ +CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@ +CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@ CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@ CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATE = @DATE@ DEFS = @DEFS@ @@ -182,6 +188,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ +MOC = @MOC@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -193,12 +200,13 @@ PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@ PANGOFT2_LIBS = @PANGOFT2_LIBS@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@ REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@ REMOVE = @REMOVE@ SET_MAKE = @SET_MAKE@ -SH = @SH@ SHELL = @SHELL@ STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@ STRIP = @STRIP@ @@ -220,10 +228,13 @@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ZIP = @ZIP@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ diff --git a/libjava/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c b/libjava/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c index 743e12a8f30..a9894994bb8 100644 --- a/libjava/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c +++ b/libjava/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c @@ -56,6 +56,10 @@ exception statement from your version. */ #include <fcntl.h> #endif /* HAVE_FCNTL_H */ +#ifdef HAVE_SYS_MMAN_H +#include <sys/mman.h> +#endif /* HAVE_SYS_MMAN_H */ + /* These values must be kept in sync with FileChannelImpl.java. */ #define FILECHANNELIMPL_READ 1 #define FILECHANNELIMPL_WRITE 2 @@ -91,6 +95,10 @@ exception statement from your version. */ #define CONVERT_SSIZE_T_TO_JINT(x) ((jint)(x & 0xFFFFFFFF)) #define CONVERT_JINT_TO_SSIZE_T(x) (x) +/* Align a value up or down to a multiple of the pagesize. */ +#define ALIGN_DOWN(p,s) ((p) - ((p) % (s))) +#define ALIGN_UP(p,s) ((p) + ((s) - ((p) % (s)))) + /* cached fieldID of gnu.java.nio.channels.FileChannelImpl.fd */ static jfieldID native_fd_fieldID; @@ -105,12 +113,12 @@ get_native_fd (JNIEnv * env, jobject obj) * static initialization. */ JNIEXPORT void JNICALL -Java_gnu_java_nio_channels_FileChannelImpl_init (JNIEnv * env, jclass clazz) +Java_gnu_java_nio_channels_FileChannelImpl_init (JNIEnv * env, + jclass clazz + __attribute__ ((__unused__))) { jclass clazz_fc; jfieldID field; - jmethodID constructor; - jobject obj; /* Initialize native_fd_fieldID so we only compute it once! */ clazz_fc = (*env)->FindClass (env, "gnu/java/nio/channels/FileChannelImpl"); @@ -128,28 +136,6 @@ Java_gnu_java_nio_channels_FileChannelImpl_init (JNIEnv * env, jclass clazz) } native_fd_fieldID = field; - - constructor = (*env)->GetMethodID (env, clazz, "<init>", "(II)V"); - if (!constructor) - return; - -#define INIT_FIELD(FIELDNAME, FDVALUE, MODE) \ - field = (*env)->GetStaticFieldID (env, clazz, FIELDNAME, \ - "Lgnu/java/nio/channels/FileChannelImpl;"); \ - if (! field) \ - return; \ - obj = (*env)->NewObject (env, clazz, constructor, FDVALUE, MODE); \ - if (! obj) \ - return; \ - (*env)->SetStaticObjectField (env, clazz, field, obj); \ - if ((*env)->ExceptionOccurred (env)) \ - return; - - INIT_FIELD ("in", 0, FILECHANNELIMPL_READ); - INIT_FIELD ("out", 1, FILECHANNELIMPL_WRITE); - INIT_FIELD ("err", 2, FILECHANNELIMPL_WRITE); - -#undef INIT_FIELD } /* @@ -218,17 +204,22 @@ Java_gnu_java_nio_channels_FileChannelImpl_open (JNIEnv * env, #endif TARGET_NATIVE_FILE_OPEN (filename, native_fd, flags, permissions, result); - JCL_free_cstring (env, name, filename); if (result != TARGET_NATIVE_OK) { - /* We can only throw FileNotFoundException. */ + char message[256]; /* Fixed size we don't need to malloc. */ + char *error_string = TARGET_NATIVE_LAST_ERROR_STRING (); + + snprintf(message, 256, "%s: %s", error_string, filename); + /* We are only allowed to throw FileNotFoundException. */ JCL_ThrowException (env, "java/io/FileNotFoundException", - TARGET_NATIVE_LAST_ERROR_STRING ()); + message); + JCL_free_cstring (env, name, filename); return TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1; } + JCL_free_cstring (env, name, filename); return native_fd; } @@ -245,12 +236,19 @@ Java_gnu_java_nio_channels_FileChannelImpl_implCloseChannel (JNIEnv * env, native_fd = get_native_fd (env, obj); - TARGET_NATIVE_FILE_CLOSE (native_fd, result); - if (result != TARGET_NATIVE_OK) + do { - JCL_ThrowException (env, IO_EXCEPTION, - TARGET_NATIVE_LAST_ERROR_STRING ()); + TARGET_NATIVE_FILE_CLOSE (native_fd, result); + if (result != TARGET_NATIVE_OK + && (TARGET_NATIVE_LAST_ERROR () + != TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL)) + { + JCL_ThrowException (env, IO_EXCEPTION, + TARGET_NATIVE_LAST_ERROR_STRING ()); + return; + } } + while (result != TARGET_NATIVE_OK); } /* @@ -267,13 +265,19 @@ Java_gnu_java_nio_channels_FileChannelImpl_available (JNIEnv * env, native_fd = get_native_fd (env, obj); - TARGET_NATIVE_FILE_AVAILABLE (native_fd, bytes_available, result); - if (result != TARGET_NATIVE_OK) + do { - JCL_ThrowException (env, IO_EXCEPTION, - TARGET_NATIVE_LAST_ERROR_STRING ()); - return 0; + TARGET_NATIVE_FILE_AVAILABLE (native_fd, bytes_available, result); + if (result != TARGET_NATIVE_OK + && (TARGET_NATIVE_LAST_ERROR () + != TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL)) + { + JCL_ThrowException (env, IO_EXCEPTION, + TARGET_NATIVE_LAST_ERROR_STRING ()); + return 0; + } } + while (result != TARGET_NATIVE_OK); /* FIXME NYI ??? why only jint and not jlong? */ return TARGET_NATIVE_MATH_INT_INT64_TO_INT32 (bytes_available); @@ -503,13 +507,91 @@ Java_gnu_java_nio_channels_FileChannelImpl_implTruncate (JNIEnv * env, } JNIEXPORT jobject JNICALL -Java_gnu_java_nio_channels_FileChannelImpl_mapImpl (JNIEnv * env, - jobject obj - __attribute__ ((__unused__)), jchar mode __attribute__ ((__unused__)), jlong position __attribute__ ((__unused__)), jint size __attribute__ ((__unused__))) +Java_gnu_java_nio_channels_FileChannelImpl_mapImpl (JNIEnv *env, jobject obj, + jchar mode, jlong position, jint size) { +#ifdef HAVE_MMAP + jclass MappedByteBufferImpl_class; + jmethodID MappedByteBufferImpl_init = NULL; + jobject Pointer_instance; + volatile jobject buffer; + long pagesize; + int prot, flags; + int fd; + void *p; + void *address; + + /* FIXME: should we just assume we're on an OS modern enough to + have 'sysconf'? And not check for 'getpagesize'? */ +#if defined(HAVE_GETPAGESIZE) + pagesize = getpagesize (); +#elif defined(HAVE_SYSCONF) + pagesize = sysconf (_SC_PAGESIZE); +#else JCL_ThrowException (env, IO_EXCEPTION, - "java.nio.FileChannelImpl.nio_mmap_file(): not implemented"); + "can't determine memory page size"); + return NULL; +#endif /* HAVE_GETPAGESIZE/HAVE_SYSCONF */ + + if ((*env)->ExceptionOccurred (env)) + { + return NULL; + } + + prot = PROT_READ; + if (mode == '+') + prot |= PROT_WRITE; + flags = (mode == 'c' ? MAP_PRIVATE : MAP_SHARED); + fd = get_native_fd (env, obj); + p = mmap (NULL, (size_t) ALIGN_UP (size, pagesize), prot, flags, + fd, ALIGN_DOWN (position, pagesize)); + if (p == MAP_FAILED) + { + JCL_ThrowException (env, IO_EXCEPTION, strerror (errno)); + return NULL; + } + + /* Unalign the mapped value back up, since we aligned offset + down to a multiple of the page size. */ + address = (void *) ((char *) p + (position % pagesize)); + + Pointer_instance = JCL_NewRawDataObject(env, address); + + MappedByteBufferImpl_class = (*env)->FindClass (env, + "java/nio/MappedByteBufferImpl"); + if (MappedByteBufferImpl_class != NULL) + { + MappedByteBufferImpl_init = + (*env)->GetMethodID (env, MappedByteBufferImpl_class, + "<init>", "(Lgnu/classpath/Pointer;IZ)V"); + } + + if ((*env)->ExceptionOccurred (env)) + { + munmap (p, ALIGN_UP (size, pagesize)); + return NULL; + } + if (MappedByteBufferImpl_init == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "could not get MappedByteBufferImpl constructor"); + munmap (p, ALIGN_UP (size, pagesize)); + return NULL; + } + + buffer = (*env)->NewObject (env, MappedByteBufferImpl_class, + MappedByteBufferImpl_init, Pointer_instance, + (jint) size, mode == 'r'); + return buffer; +#else + (void) obj; + (void) mode; + (void) position; + (void) size; + JCL_ThrowException (env, IO_EXCEPTION, + "memory-mapped files not implemented"); return 0; +#endif /* HAVE_MMAP */ } /* @@ -735,17 +817,23 @@ Java_gnu_java_nio_channels_FileChannelImpl_lock (JNIEnv *env, jobject obj, flock.l_type = shared ? F_RDLCK : F_WRLCK; flock.l_whence = SEEK_SET; flock.l_start = (off_t) position; - flock.l_len = (off_t) size; + /* Long.MAX_VALUE means lock everything possible starting at pos. */ + if (size == 9223372036854775807LL) + flock.l_len = 0; + else + flock.l_len = (off_t) size; ret = fcntl (fd, cmd, &flock); + /* fprintf(stderr, "fd %d, wait %d, shared %d, ret %d, position %lld, size %lld, l_start %ld, l_len %ld\n", fd, wait, shared,ret, position, size, (long) flock.l_start, (long) flock.l_len); */ if (ret) { /* Linux man pages for fcntl state that errno might be either EACCES or EAGAIN if we try F_SETLK, and another process has - an overlapping lock. */ + an overlapping lock. We should not get an unexpected errno. */ if (errno != EACCES && errno != EAGAIN) { - JCL_ThrowException (env, IO_EXCEPTION, strerror (errno)); + JCL_ThrowException (env, "java/lang/InternalError", + strerror (errno)); } return JNI_FALSE; } @@ -776,12 +864,17 @@ Java_gnu_java_nio_channels_FileChannelImpl_unlock (JNIEnv *env, flock.l_type = F_UNLCK; flock.l_whence = SEEK_SET; flock.l_start = (off_t) position; - flock.l_len = (off_t) length; + /* Long.MAX_VALUE means unlock everything possible starting at pos. */ + if (length == 9223372036854775807LL) + flock.l_len = 0; + else + flock.l_len = (off_t) length; ret = fcntl (fd, F_SETLK, &flock); if (ret) { - JCL_ThrowException (env, IO_EXCEPTION, strerror (errno)); + JCL_ThrowException (env, "java/lang/InternalError", + strerror (errno)); } #else (void) obj; diff --git a/libjava/classpath/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c b/libjava/classpath/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c index 8c3f83accff..2541e81ea44 100644 --- a/libjava/classpath/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c +++ b/libjava/classpath/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c @@ -173,23 +173,14 @@ static void createRawData (JNIEnv * env, jobject obj, void *ptr) { jclass cls; - jmethodID method; jobject data; jfieldID data_fid; cls = (*env)->GetObjectClass (env, obj); - data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/RawData;"); + data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/Pointer;"); assert (data_fid != 0); -#ifdef POINTERS_ARE_64BIT - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - method = (*env)->GetMethodID (env, cls, "<init>", "(J)V"); - data = (*env)->NewObject (env, cls, method, (jlong) ptr); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - method = (*env)->GetMethodID (env, cls, "<init>", "(I)V"); - data = (*env)->NewObject (env, cls, method, (jint) ptr); -#endif + data = JCL_NewRawDataObject(env, ptr); (*env)->SetObjectField (env, obj, data_fid, data); } @@ -198,22 +189,13 @@ static void * getData (JNIEnv * env, jobject obj) { jclass cls; - jfieldID field; jfieldID data_fid; jobject data; cls = (*env)->GetObjectClass (env, obj); - data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/RawData;"); + data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/Pointer;"); assert (data_fid != 0); data = (*env)->GetObjectField (env, obj, data_fid); -#if SIZEOF_VOID_P == 8 - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - field = (*env)->GetFieldID (env, cls, "data", "J"); - return (void *) (*env)->GetLongField (env, data, field); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - field = (*env)->GetFieldID (env, cls, "data", "I"); - return (void *) (*env)->GetIntField (env, data, field); -#endif + return JCL_GetRawData(env, data); } diff --git a/libjava/classpath/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c b/libjava/classpath/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c index cd5d48656f7..7a98e7eee1e 100644 --- a/libjava/classpath/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c +++ b/libjava/classpath/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c @@ -173,23 +173,14 @@ static void createRawData (JNIEnv * env, jobject obj, void *ptr) { jclass cls; - jmethodID method; jobject data; jfieldID data_fid; cls = (*env)->GetObjectClass (env, obj); - data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/RawData;"); + data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/Pointer;"); assert (data_fid != 0); - -#ifdef POINTERS_ARE_64BIT - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - method = (*env)->GetMethodID (env, cls, "<init>", "(J)V"); - data = (*env)->NewObject (env, cls, method, (jlong) ptr); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - method = (*env)->GetMethodID (env, cls, "<init>", "(I)V"); - data = (*env)->NewObject (env, cls, method, (jint) ptr); -#endif + + data = JCL_NewRawDataObject (env, ptr); (*env)->SetObjectField (env, obj, data_fid, data); } @@ -198,22 +189,13 @@ static void * getData (JNIEnv * env, jobject obj) { jclass cls; - jfieldID field; jfieldID data_fid; jobject data; cls = (*env)->GetObjectClass (env, obj); - data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/RawData;"); + data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/Pointer;"); assert (data_fid != 0); data = (*env)->GetObjectField (env, obj, data_fid); -#if SIZEOF_VOID_P == 8 - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - field = (*env)->GetFieldID (env, cls, "data", "J"); - return (void *) (*env)->GetLongField (env, data, field); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - field = (*env)->GetFieldID (env, cls, "data", "I"); - return (void *) (*env)->GetIntField (env, data, field); -#endif + return JCL_GetRawData(env, data); } diff --git a/libjava/classpath/native/jni/java-nio/java_nio_MappedByteBufferImpl.c b/libjava/classpath/native/jni/java-nio/java_nio_MappedByteBufferImpl.c index e1ba1e454f0..b4909198267 100644 --- a/libjava/classpath/native/jni/java-nio/java_nio_MappedByteBufferImpl.c +++ b/libjava/classpath/native/jni/java-nio/java_nio_MappedByteBufferImpl.c @@ -1,5 +1,5 @@ /* java_nio_MappedByteBufferImpl.c - Native methods for MappedByteBufferImpl - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004,2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,41 +43,200 @@ exception statement from your version. */ #include "java_nio_MappedByteBufferImpl.h" +#include <errno.h> +#include <string.h> +#include <stdlib.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif /* HAVE_UNISTD_H */ +#ifdef HAVE_SYS_MMAN_H +#include <sys/mman.h> +#endif /* HAVE_SYS_MMAN_H */ + #define IO_EXCEPTION "java/io/IOException" +/* FIXME these are defined in gnu_java_nio_channels_FileChannelImpl + too; should be someplace common. */ +#define ALIGN_DOWN(p,s) ((jpointer)(p) - ((jpointer)(p) % (s))) +#define ALIGN_UP(p,s) ((jpointer)(p) + ((s) - ((jpointer)(p) % (s)))) + +/** + * Returns the memory page size of this platform. + * + * \return The page size. + */ +static long +get_pagesize (void) +{ + /* FIXME can we just try HAVE_SYSCONF? */ +#if defined(HAVE_GETPAGESIZE) + return getpagesize (); +#elif defined (HAVE_SYSCONF) + return sysconf (_SC_PAGESIZE); +#endif /* HAVE_GETPAGESIZE / HAVE_SYSCONF */ +} + +/** + * Retrieve the 'address' and 'cap' (the mapped size) fields of this + * buffer. + * + * This function will align the address down to the nearest page + * boundary, and the size up to the nearest page boundary. Thus, it is + * safe to use these values in 'mman' functions. + * + * \param env The JNI environment pointer. + * \param this The MappedByteBufferImpl instance. + * \param address A pointer to where the actual pointer should be + * stored. + * \param size A pointer to where the mapped region's size should be + * stored + */ +static void +get_raw_values (JNIEnv *env, jobject this, void **address, size_t *size) +{ + const long pagesize = get_pagesize (); + jfieldID MappedByteBufferImpl_address; + jfieldID MappedByteBufferImpl_size; + jobject MappedByteBufferImpl_address_value = NULL; + + *address = NULL; + /* 'address' is declared in java.nio.Buffer */ + MappedByteBufferImpl_address + = (*env)->GetFieldID (env, (*env)->GetObjectClass (env, this), + "address", "Lgnu/classpath/Pointer;"); + /* 'cap' -- likewise, the capacity */ + MappedByteBufferImpl_size + = (*env)->GetFieldID (env, (*env)->GetObjectClass (env, this), + "cap", "I"); + if (MappedByteBufferImpl_address != NULL) + { + MappedByteBufferImpl_address_value = + (*env)->GetObjectField (env, this, MappedByteBufferImpl_address); + } + if ((*env)->ExceptionOccurred (env)) + return; + if (MappedByteBufferImpl_address_value == NULL) + { + JCL_ThrowException (env, "java/lang/NullPointerException", + "mapped address is NULL"); + return; + } + + *address = (void *) + ALIGN_DOWN (JCL_GetRawData (env, MappedByteBufferImpl_address_value), pagesize); + *size = (size_t) + ALIGN_UP ((*env)->GetIntField (env, this, MappedByteBufferImpl_size), + pagesize); +} + JNIEXPORT void JNICALL -Java_java_nio_MappedByteBufferImpl_unmapImpl (JNIEnv * env, - jclass class - __attribute__ ((__unused__))) +Java_java_nio_MappedByteBufferImpl_unmapImpl (JNIEnv *env, jobject this) { +#ifdef HAVE_MUNMAP + void *address; + size_t size; + + get_raw_values (env, this, &address, &size); + + if (address == NULL) + return; + + if (munmap (address, size) != 0) + { + JCL_ThrowException (env, IO_EXCEPTION, strerror (errno)); + return; + } +#else JCL_ThrowException (env, IO_EXCEPTION, - "java.nio.MappedByteBufferImpl.unmapImpl(): not implemented"); + "unmapping files not implemented"); +#endif /* HAVE_MUNMAP */ } JNIEXPORT jboolean JNICALL -Java_java_nio_MappedByteBufferImpl_isLoadedImpl (JNIEnv * env, - jclass class - __attribute__ ((__unused__))) +Java_java_nio_MappedByteBufferImpl_isLoadedImpl (JNIEnv * env, jobject this) { - JCL_ThrowException (env, IO_EXCEPTION, - "java.nio.MappedByteBufferImpl.isLoadedImpl(): not implemented"); - return 0; +#ifdef HAVE_MINCORE + void *address; + size_t size; + char *vec; + size_t count, i; + const long pagesize = get_pagesize (); + + /* + * FIXME on Darwin this does not work if the mapped region is + * exactly one page long; i.e., 'mincore' tells us it isn't loaded. + */ + get_raw_values (env, this, &address, &size); + if (address == NULL) + return JNI_FALSE; + count = (size_t) ((size + pagesize - 1) / pagesize); + vec = (char *) malloc (count * sizeof (unsigned char)); + + /* + * Darwin (and BSD?) define argument 3 of 'mincore' to be 'char *', + * while GNU libc defines it to be 'unsigned char *'. Casting the + * argument to 'void *' fixes this, but not with C++. So you might + * be SOL if you compile this with g++ (!) on GNU with -Werror. + */ +#ifdef __cplusplus + if (mincore (address, size, vec) != 0) +#else + if (mincore (address, size, (void *) vec) != 0) +#endif /* __cplusplus */ + { + free (vec); + JCL_ThrowException (env, IO_EXCEPTION, strerror (errno)); + return JNI_FALSE; + } + + for (i = 0; i < count; i++) + { + if ((vec[i] & 1) == 0) + return JNI_FALSE; + } + return JNI_TRUE; +#else + return JNI_FALSE; +#endif } JNIEXPORT void JNICALL -Java_java_nio_MappedByteBufferImpl_loadImpl (JNIEnv * env, - jclass clazz - __attribute__ ((__unused__))) +Java_java_nio_MappedByteBufferImpl_loadImpl (JNIEnv *env, jobject this) { +#ifdef HAVE_MADVISE + void *address; + size_t size; + + get_raw_values (env, this, &address, &size); + if (address == NULL) + return; + + madvise (address, size, MADV_WILLNEED); +#else JCL_ThrowException (env, IO_EXCEPTION, - "java.nio.MappedByteBufferImpl.loadImpl(): not implemented"); + "forcing mapped files into core not implemented"); +#endif /* HAVE_MADVISE */ } JNIEXPORT void JNICALL -Java_java_nio_MappedByteBufferImpl_forceImpl (JNIEnv * env, - jclass class - __attribute__ ((__unused__))) +Java_java_nio_MappedByteBufferImpl_forceImpl (JNIEnv *env, jobject this) { +#ifdef HAVE_MSYNC + void *address; + size_t size; + + get_raw_values (env, this, &address, &size); + + if (address == NULL) + return; + + /* FIXME: is using MS_SYNC ok? Should we use MS_INVALIDATE? */ + if (msync (address, size, MS_SYNC) != 0) + { + JCL_ThrowException (env, IO_EXCEPTION, strerror (errno)); + } +#else JCL_ThrowException (env, IO_EXCEPTION, - "java.nio.MappedByteBufferImpl.forceImpl(): not implemented"); + "forcing mapped files to disk not implemented"); +#endif /* HAVE_MSYNC */ } diff --git a/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c b/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c index 3eb5677e646..06e29906a33 100644 --- a/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c +++ b/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c @@ -45,106 +45,6 @@ exception statement from your version. */ #include "java_nio_VMDirectByteBuffer.h" -static jclass classRawData; -static jmethodID methodRawDataInit; -static jfieldID fieldNativePointer; - -static void *NIOGetPointer (JNIEnv *, jobject); -static jobject NIOGetRawData (JNIEnv *, void *pointer); - -static void * -NIOGetPointer (JNIEnv * env, jobject rawdata) -{ -#if SIZEOF_VOID_P == 4 - return (void *) (*env)->GetIntField (env, rawdata, fieldNativePointer); -#elif SIZEOF_VOID_P == 8 - return (void *) (*env)->GetLongField (env, rawdata, fieldNativePointer); -#else -#error unsupported pointer size -#endif -} - -static jobject -NIOGetRawData (JNIEnv * env, void *pointer) -{ -#if SIZEOF_VOID_P == 4 - return (*env)->NewObject (env, classRawData, methodRawDataInit, - (jint) pointer); -#elif SIZEOF_VOID_P == 8 - return (*env)->NewObject (env, classRawData, methodRawDataInit, - (jlong) pointer); -#else -#error unsupported pointer size -#endif -} - -JNIEXPORT void JNICALL -Java_java_nio_VMDirectByteBuffer_init - (JNIEnv * env, jclass clazz __attribute__ ((__unused__))) -{ -#if SIZEOF_VOID_P == 4 - classRawData = (*env)->FindClass (env, "gnu/classpath/RawData32"); - if (classRawData == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal class"); - return; - } - - methodRawDataInit = (*env)->GetMethodID (env, classRawData, - "<init>", "(I)V"); - if (methodRawDataInit == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal constructor"); - return; - } - - fieldNativePointer = (*env)->GetFieldID (env, classRawData, "data", "I"); - if (fieldNativePointer == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal field"); - return; - } -#elif SIZEOF_VOID_P == 8 - classRawData = (*env)->FindClass (env, "gnu/classpath/RawData64"); - if (classRawData == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal class"); - return; - } - - methodRawDataInit = (*env)->GetMethodID (env, classRawData, - "<init>", "(J)V"); - if (methodRawDataInit == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal constructor"); - return; - } - - fieldNativePointer = (*env)->GetFieldID (env, classRawData, "data", "J"); - if (fieldNativePointer == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal field"); - return; - } -#else -#error unsupported pointer size -#endif - - /* We need to wrap the jclass in global reference to make it persistent */ - if ((classRawData = (*env)->NewGlobalRef (env, classRawData)) == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "failed to create global reference"); - return; - } -} - JNIEXPORT jobject JNICALL Java_java_nio_VMDirectByteBuffer_allocate (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jint capacity) @@ -160,41 +60,53 @@ Java_java_nio_VMDirectByteBuffer_allocate return 0; } - return NIOGetRawData (env, buffer); + return JCL_NewRawDataObject (env, buffer); } JNIEXPORT void JNICALL Java_java_nio_VMDirectByteBuffer_free (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address) { - free (NIOGetPointer (env, address)); + free (JCL_GetRawData (env, address)); } JNIEXPORT jbyte JNICALL -Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_RawData_2I +Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_Pointer_2I (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address, jint index) { - return ((jbyte *) NIOGetPointer (env, address))[index]; + return ((jbyte *) JCL_GetRawData (env, address))[index]; } JNIEXPORT void JNICALL -Java_java_nio_VMDirectByteBuffer_put +Java_java_nio_VMDirectByteBuffer_put__Lgnu_classpath_Pointer_2IB (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address, jint index, jbyte value) { - jbyte *pointer = (jbyte *) NIOGetPointer (env, address) + index; + jbyte *pointer = (jbyte *) JCL_GetRawData (env, address) + index; *pointer = value; } JNIEXPORT void JNICALL -Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_RawData_2I_3BII +Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_Pointer_2I_3BII (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address, jint index, jbyteArray dst, jint dst_offset, jint dst_len) { - jbyte *src = (jbyte *) NIOGetPointer (env, address) + index; - memcpy ((*env)->GetByteArrayElements (env, dst, NULL) + dst_offset, src, - dst_len); + jbyte *src = (jbyte *) JCL_GetRawData (env, address) + index; + jbyte *_dst = (*env)->GetByteArrayElements (env, dst, NULL) + dst_offset; + memcpy (_dst, src, dst_len); + (*env)->ReleaseByteArrayElements (env, dst, _dst, 0); +} + +JNIEXPORT void JNICALL +Java_java_nio_VMDirectByteBuffer_put__Lgnu_classpath_Pointer_2I_3BII + (JNIEnv *env, jclass clazz __attribute__ ((__unused__)), + jobject address, jint index, jbyteArray src, jint src_offset, jint src_len) +{ + jbyte *_src = (*env)->GetByteArrayElements (env, src, NULL) + src_offset; + jbyte *dst = (jbyte *)JCL_GetRawData (env, address) + index; + (*env)->ReleaseByteArrayElements (env, src, _src, 0); + memcpy (dst, _src, src_len); } JNIEXPORT void JNICALL @@ -202,8 +114,8 @@ Java_java_nio_VMDirectByteBuffer_shiftDown (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address, jint dst_offset, jint src_offset, jint count) { - jbyte *dst = (jbyte *) NIOGetPointer (env, address) + dst_offset; - jbyte *src = (jbyte *) NIOGetPointer (env, address) + src_offset; + jbyte *dst = (jbyte *) JCL_GetRawData (env, address) + dst_offset; + jbyte *src = (jbyte *) JCL_GetRawData (env, address) + src_offset; memmove (dst, src, count); } @@ -212,5 +124,5 @@ Java_java_nio_VMDirectByteBuffer_adjustAddress (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address, jint offset) { - return NIOGetRawData (env, (jbyte *) NIOGetPointer (env, address) + offset); + return JCL_NewRawDataObject (env, (jbyte *) JCL_GetRawData (env, address) + offset); } diff --git a/libjava/classpath/native/jni/java-util/Makefile.in b/libjava/classpath/native/jni/java-util/Makefile.in index e283db3dcf6..53cd65e23b9 100644 --- a/libjava/classpath/native/jni/java-util/Makefile.in +++ b/libjava/classpath/native/jni/java-util/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.9.5 from Makefile.am. +# Makefile.in generated by automake 1.9.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. +# 2003, 2004 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -110,8 +110,14 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@ CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@ CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@ CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@ +CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@ +CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@ CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@ CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATE = @DATE@ DEFS = @DEFS@ @@ -173,6 +179,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ +MOC = @MOC@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -184,12 +191,13 @@ PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@ PANGOFT2_LIBS = @PANGOFT2_LIBS@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@ REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@ REMOVE = @REMOVE@ SET_MAKE = @SET_MAKE@ -SH = @SH@ SHELL = @SHELL@ STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@ STRIP = @STRIP@ @@ -211,10 +219,13 @@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ZIP = @ZIP@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ diff --git a/libjava/classpath/native/jni/xmlj/Makefile.in b/libjava/classpath/native/jni/xmlj/Makefile.in index 5b9de9008de..694a842ebd0 100644 --- a/libjava/classpath/native/jni/xmlj/Makefile.in +++ b/libjava/classpath/native/jni/xmlj/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.9.5 from Makefile.am. +# Makefile.in generated by automake 1.9.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. +# 2003, 2004 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -112,8 +112,14 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@ CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@ CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@ CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@ +CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@ +CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@ CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@ CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATE = @DATE@ DEFS = @DEFS@ @@ -175,6 +181,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ +MOC = @MOC@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -186,12 +193,13 @@ PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@ PANGOFT2_LIBS = @PANGOFT2_LIBS@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@ REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@ REMOVE = @REMOVE@ SET_MAKE = @SET_MAKE@ -SH = @SH@ SHELL = @SHELL@ STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@ STRIP = @STRIP@ @@ -213,10 +221,13 @@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ZIP = @ZIP@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ diff --git a/libjava/classpath/native/jni/xmlj/xmlj_util.c b/libjava/classpath/native/jni/xmlj/xmlj_util.c index 498cb70923c..409eb6e75ab 100644 --- a/libjava/classpath/native/jni/xmlj/xmlj_util.c +++ b/libjava/classpath/native/jni/xmlj/xmlj_util.c @@ -39,6 +39,7 @@ exception statement from your version. */ #include "xmlj_error.h" #include <libxml/tree.h> #include <unistd.h> +#include <jcl.h> /* xmlChar->jstring cache */ #ifdef XMLJ_STRING_CACHE @@ -218,35 +219,13 @@ jmethodID xmljGetMethodID (JNIEnv *env, void * xmljAsPointer (JNIEnv *env, jobject ptr) { - jclass cls; - jfieldID field; - -#if defined XMLJ_64BIT_POINTER - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - field = (*env)->GetFieldID (env, cls, "data", "J"); - return (void *) (*env)->GetLongField (env, ptr, field); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - field = (*env)->GetFieldID (env, cls, "data", "I"); - return (void *) (*env)->GetIntField (env, ptr, field); -#endif + return JCL_GetRawData(env, ptr); } jobject xmljAsField (JNIEnv *env, void * ptr) { - jclass cls; - jmethodID method; - -#if defined XMLJ_64BIT_POINTER - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - method = (*env)->GetMethodID (env, cls, "<init>", "(J)V"); - return (*env)->NewObject (env, cls, method, (jlong) ptr); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - method = (*env)->GetMethodID (env, cls, "<init>", "(I)V"); - return (*env)->NewObject (env, cls, method, (jint) ptr); -#endif + return JCL_NewRawDataObject(env, ptr); } JNIEnv * |