summaryrefslogtreecommitdiff
path: root/native
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2005-08-02 20:12:05 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2005-08-02 20:12:05 +0000
commit33bace404a240c1335ab1f6e95bd6616e22c0ecd (patch)
tree004ab1587e14d3df272c6944ce325d3584b95aa5 /native
parentd30622846e00f908cb5d4beac7de4e5e78dcd630 (diff)
downloadclasspath-33bace404a240c1335ab1f6e95bd6616e22c0ecd.tar.gz
2005-08-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD --> generics-branch for 2005/06/05 - 2005/07/31. See patch on classpath-patches@gnu.org for a full ChangeLog.
Diffstat (limited to 'native')
-rw-r--r--native/fdlibm/Makefile.am1
-rw-r--r--native/fdlibm/s_finite.c31
-rw-r--r--native/jni/classpath/classpath_jawt.h64
-rw-r--r--native/jni/classpath/jcl.c48
-rw-r--r--native/jni/classpath/jcl.h7
-rw-r--r--native/jni/classpath/jnilink.c4
-rw-r--r--native/jni/classpath/jnilink.h4
-rw-r--r--native/jni/classpath/native_state.c56
-rw-r--r--native/jni/classpath/native_state.h20
-rw-r--r--native/jni/classpath/primlib.c4
-rw-r--r--native/jni/classpath/primlib.h4
-rw-r--r--native/jni/gtk-peer/Makefile.am7
-rw-r--r--native/jni/gtk-peer/gdkfont.h32
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c4
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c41
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c322
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c742
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c21
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c133
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c21
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c15
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c141
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c14
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c12
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c16
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c97
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c91
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c93
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c915
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c16
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c1176
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c107
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c39
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c23
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c103
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c44
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c220
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c24
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c4
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c73
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c31
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c60
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c14
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c36
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c (renamed from native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c)66
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c330
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c498
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c260
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c272
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c1555
-rw-r--r--native/jni/gtk-peer/gthread-jni.c54
-rw-r--r--native/jni/gtk-peer/gthread-jni.h8
-rw-r--r--native/jni/gtk-peer/gtkcairopeer.h5
-rw-r--r--native/jni/gtk-peer/gtkpeer.h460
-rw-r--r--native/jni/java-io/java_io_VMFile.c4
-rw-r--r--native/jni/java-io/java_io_VMObjectInputStream.c4
-rw-r--r--native/jni/java-io/java_io_VMObjectStreamClass.c4
-rw-r--r--native/jni/java-io/javaio.c4
-rw-r--r--native/jni/java-io/javaio.h4
-rw-r--r--native/jni/java-lang/java_lang_Math.c4
-rw-r--r--native/jni/java-lang/java_lang_VMDouble.c4
-rw-r--r--native/jni/java-lang/java_lang_VMFloat.c4
-rw-r--r--native/jni/java-lang/java_lang_VMProcess.c4
-rw-r--r--native/jni/java-lang/java_lang_VMSystem.c4
-rw-r--r--native/jni/java-lang/java_lang_reflect_Array.c4
-rw-r--r--native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c76
-rw-r--r--native/jni/java-net/gnu_java_net_PlainSocketImpl.c4
-rw-r--r--native/jni/java-net/java_net_VMInetAddress.c4
-rw-r--r--native/jni/java-net/java_net_VMNetworkInterface.c4
-rw-r--r--native/jni/java-net/javanet.c168
-rw-r--r--native/jni/java-net/javanet.h4
-rw-r--r--native/jni/java-nio/gnu_java_nio_VMPipe.c4
-rw-r--r--native/jni/java-nio/gnu_java_nio_VMSelector.c4
-rw-r--r--native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c328
-rw-r--r--native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c4
-rw-r--r--native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c4
-rw-r--r--native/jni/java-nio/java_nio.c4
-rw-r--r--native/jni/java-nio/java_nio_MappedByteBufferImpl.c216
-rw-r--r--native/jni/java-nio/java_nio_VMDirectByteBuffer.c22
-rw-r--r--native/jni/java-util/java_util_VMTimeZone.c4
-rw-r--r--native/jni/xmlj/xmlj_dom.c4
-rw-r--r--native/jni/xmlj/xmlj_dom.h4
-rw-r--r--native/jni/xmlj/xmlj_error.c4
-rw-r--r--native/jni/xmlj/xmlj_error.h4
-rw-r--r--native/jni/xmlj/xmlj_io.c4
-rw-r--r--native/jni/xmlj/xmlj_io.h4
-rw-r--r--native/jni/xmlj/xmlj_node.c4
-rw-r--r--native/jni/xmlj/xmlj_node.h4
-rw-r--r--native/jni/xmlj/xmlj_sax.c4
-rw-r--r--native/jni/xmlj/xmlj_sax.h4
-rw-r--r--native/jni/xmlj/xmlj_transform.c4
-rw-r--r--native/jni/xmlj/xmlj_util.c4
-rw-r--r--native/jni/xmlj/xmlj_util.h4
-rw-r--r--native/jni/xmlj/xmlj_xpath.c4
-rw-r--r--native/target/Linux/target_native.h4
-rw-r--r--native/target/Linux/target_native_file.h4
-rw-r--r--native/target/Linux/target_native_io.h4
-rw-r--r--native/target/Linux/target_native_math_float.h4
-rw-r--r--native/target/Linux/target_native_math_int.h4
-rw-r--r--native/target/Linux/target_native_misc.h4
-rw-r--r--native/target/Linux/target_native_network.h4
-rw-r--r--native/target/generic/target_generic.h4
-rw-r--r--native/target/generic/target_generic_file.h4
-rw-r--r--native/target/generic/target_generic_io.h4
-rw-r--r--native/target/generic/target_generic_math_float.h4
-rw-r--r--native/target/generic/target_generic_math_int.h4
-rw-r--r--native/target/generic/target_generic_misc.h4
-rw-r--r--native/target/generic/target_generic_network.h27
-rw-r--r--native/testsuite/guile-jvm.c2
-rwxr-xr-xnative/vmi/vmi.c4
-rwxr-xr-xnative/vmi/vmi.h4
111 files changed, 5415 insertions, 4062 deletions
diff --git a/native/fdlibm/Makefile.am b/native/fdlibm/Makefile.am
index c4f460a16..e3e3eecd2 100644
--- a/native/fdlibm/Makefile.am
+++ b/native/fdlibm/Makefile.am
@@ -28,6 +28,7 @@ libfdlibm_la_SOURCES = \
s_cos.c \
s_fabs.c \
sf_fabs.c \
+ s_finite.c \
s_floor.c \
sf_rint.c \
s_rint.c \
diff --git a/native/fdlibm/s_finite.c b/native/fdlibm/s_finite.c
new file mode 100644
index 000000000..3e6c8122b
--- /dev/null
+++ b/native/fdlibm/s_finite.c
@@ -0,0 +1,31 @@
+
+/* @(#)s_finite.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * finite(x) returns 1 is x is finite, else 0;
+ * no branching!
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+ int finite(double x)
+#else
+ int finite(x)
+ double x;
+#endif
+{
+ uint32_t high;
+ GET_HIGH_WORD(high,x);
+ return (unsigned)((high&0x7fffffff)-0x7ff00000)>>31;
+}
diff --git a/native/jni/classpath/classpath_jawt.h b/native/jni/classpath/classpath_jawt.h
new file mode 100644
index 000000000..66ba9c70a
--- /dev/null
+++ b/native/jni/classpath/classpath_jawt.h
@@ -0,0 +1,64 @@
+/* classpath_awt.h -- libjawt's interface to the peer library
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+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 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
+ * header declares all the functions that libjawt.so needs -- X-based
+ * peer libraries wanting to support libjawt.so must implement these
+ * functions.
+ */
+
+#ifndef __classpath_jawt_h__
+#define __classpath_jawt_h__
+
+#include <jni.h>
+#include <X11/Xlib.h>
+
+#define CLASSPATH_JAWT_VERSION 0x10004
+
+jint classpath_jawt_get_awt_version ();
+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);
+
+#endif /* __classpath_jawt_h__ */
diff --git a/native/jni/classpath/jcl.c b/native/jni/classpath/jcl.c
index 1f2d38f48..ab66a2e71 100644
--- a/native/jni/classpath/jcl.c
+++ b/native/jni/classpath/jcl.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -178,3 +178,47 @@ JCL_FindClass (JNIEnv * env, const char *className)
}
return retval;
}
+
+
+/*
+ * Build a RawData 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/RawData64");
+ rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(J)V");
+ rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "J");
+#else
+ rawDataClass = (*env)->FindClass (env, "gnu/classpath/RawData32");
+ rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(I)V");
+ rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "I");
+#endif
+ (*env)->DeleteLocalRef(env, rawDataClass);
+ rawDataClass = (*env)->NewGlobalRef (env, rawDataClass);
+ }
+
+#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/native/jni/classpath/jcl.h b/native/jni/classpath/jcl.h
index 86af28391..c4b2c44a6 100644
--- a/native/jni/classpath/jcl.h
+++ b/native/jni/classpath/jcl.h
@@ -15,8 +15,8 @@ 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.
+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
@@ -56,6 +56,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/native/jni/classpath/jnilink.c b/native/jni/classpath/jnilink.c
index 64f26a1dc..15e73a721 100644
--- a/native/jni/classpath/jnilink.c
+++ b/native/jni/classpath/jnilink.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/classpath/jnilink.h b/native/jni/classpath/jnilink.h
index 56c98176a..dd94b3a7a 100644
--- a/native/jni/classpath/jnilink.h
+++ b/native/jni/classpath/jnilink.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/classpath/native_state.c b/native/jni/classpath/native_state.c
index 3853cce2c..2cb43d614 100644
--- a/native/jni/classpath/native_state.c
+++ b/native/jni/classpath/native_state.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -36,13 +36,14 @@ 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"
#define DEFAULT_TABLE_SIZE 97
struct state_table *
-init_state_table_with_size (JNIEnv * env, jclass clazz, jint size)
+cp_gtk_init_state_table_with_size (JNIEnv * env, jclass clazz, jint size)
{
struct state_table *table;
jfieldID hash;
@@ -67,9 +68,9 @@ init_state_table_with_size (JNIEnv * env, jclass clazz, jint size)
}
struct state_table *
-init_state_table (JNIEnv * env, jclass clazz)
+cp_gtk_init_state_table (JNIEnv * env, jclass clazz)
{
- return init_state_table_with_size (env, clazz, DEFAULT_TABLE_SIZE);
+ return cp_gtk_init_state_table_with_size (env, clazz, DEFAULT_TABLE_SIZE);
}
static void *
@@ -165,8 +166,20 @@ 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
-set_state_oid (JNIEnv * env, jobject lock, struct state_table *table,
+cp_gtk_set_state_oid (JNIEnv * env, jobject lock, struct state_table *table,
jint obj_id, void *state)
{
jint hash;
@@ -179,7 +192,7 @@ set_state_oid (JNIEnv * env, jobject lock, struct state_table *table,
}
void *
-get_state_oid (JNIEnv * env, jobject lock, struct state_table *table,
+cp_gtk_get_state_oid (JNIEnv * env, jobject lock, struct state_table *table,
jint obj_id)
{
jint hash;
@@ -195,7 +208,7 @@ get_state_oid (JNIEnv * env, jobject lock, struct state_table *table,
}
void *
-remove_state_oid (JNIEnv * env, jobject lock, struct state_table *table,
+cp_gtk_remove_state_oid (JNIEnv * env, jobject lock, struct state_table *table,
jint obj_id)
{
jint hash;
@@ -211,38 +224,53 @@ remove_state_oid (JNIEnv * env, jobject lock, struct state_table *table,
}
int
-set_state (JNIEnv * env, jobject obj, struct state_table *table, void *state)
+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)
return -1;
- set_state_oid (env, table->clazz, table, obj_id, state);
+ cp_gtk_set_state_oid (env, table->clazz, table, obj_id, state);
return 0;
}
void *
-get_state (JNIEnv * env, jobject obj, struct state_table *table)
+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)
return NULL;
- return get_state_oid (env, table->clazz, table, obj_id);
+ return cp_gtk_get_state_oid (env, table->clazz, table, obj_id);
}
void *
-remove_state_slot (JNIEnv * env, jobject obj, struct state_table *table)
+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)
return NULL;
- return remove_state_oid (env, table->clazz, table, obj_id);
+ return cp_gtk_remove_state_oid (env, table->clazz, table, obj_id);
}
diff --git a/native/jni/classpath/native_state.h b/native/jni/classpath/native_state.h
index 19b52d0be..641e58882 100644
--- a/native/jni/classpath/native_state.h
+++ b/native/jni/classpath/native_state.h
@@ -15,8 +15,8 @@ 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.
+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
@@ -55,17 +55,17 @@ struct state_node
struct state_node *next;
};
-struct state_table *init_state_table_with_size (JNIEnv *, jclass, jint);
-struct state_table *init_state_table (JNIEnv *, jclass);
+struct state_table *cp_gtk_init_state_table_with_size (JNIEnv *, jclass, jint);
+struct state_table *cp_gtk_init_state_table (JNIEnv *, jclass);
/* lowlevel api */
-void set_state_oid (JNIEnv *, jobject, struct state_table *, jint, void *);
-void *get_state_oid (JNIEnv *, jobject, struct state_table *, jint);
-void *remove_state_oid (JNIEnv *, jobject, struct state_table *, jint);
+void cp_gtk_set_state_oid (JNIEnv *, jobject, struct state_table *, jint, void *);
+void *cp_gtk_get_state_oid (JNIEnv *, jobject, struct state_table *, jint);
+void *cp_gtk_remove_state_oid (JNIEnv *, jobject, struct state_table *, jint);
/* highlevel api */
-int set_state (JNIEnv *, jobject, struct state_table *, void *);
-void *get_state (JNIEnv *, jobject, struct state_table *);
-void *remove_state_slot (JNIEnv *, jobject, struct state_table *);
+int cp_gtk_set_state (JNIEnv *, jobject, struct state_table *, void *);
+void *cp_gtk_get_state (JNIEnv *, jobject, struct state_table *);
+void *cp_gtk_remove_state_slot (JNIEnv *, jobject, struct state_table *);
#endif
diff --git a/native/jni/classpath/primlib.c b/native/jni/classpath/primlib.c
index 5236335be..e6773ba53 100644
--- a/native/jni/classpath/primlib.c
+++ b/native/jni/classpath/primlib.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/classpath/primlib.h b/native/jni/classpath/primlib.h
index 0cd0b284f..3cdaaa4a1 100644
--- a/native/jni/classpath/primlib.h
+++ b/native/jni/classpath/primlib.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/gtk-peer/Makefile.am b/native/jni/gtk-peer/Makefile.am
index 8c3965b1b..f4e7bdfcc 100644
--- a/native/jni/gtk-peer/Makefile.am
+++ b/native/jni/gtk-peer/Makefile.am
@@ -25,7 +25,6 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
gnu_java_awt_peer_gtk_GtkClipboard.c \
gnu_java_awt_peer_gtk_GtkComponentPeer.c \
gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c \
- gnu_java_awt_peer_gtk_GtkEvents.c \
gnu_java_awt_peer_gtk_GtkFileDialogPeer.c \
gnu_java_awt_peer_gtk_GtkFramePeer.c \
gnu_java_awt_peer_gtk_GtkGenericPeer.c \
@@ -38,10 +37,9 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
gnu_java_awt_peer_gtk_GtkMenuPeer.c \
gnu_java_awt_peer_gtk_GtkPanelPeer.c \
gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c \
- gnu_java_awt_peer_gtk_GtkScrollBarPeer.c \
+ gnu_java_awt_peer_gtk_GtkScrollbarPeer.c \
gnu_java_awt_peer_gtk_GtkScrollPanePeer.c \
gnu_java_awt_peer_gtk_GtkTextAreaPeer.c \
- gnu_java_awt_peer_gtk_GtkTextComponentPeer.c \
gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \
gnu_java_awt_peer_gtk_GtkToolkit.c \
gnu_java_awt_peer_gtk_GtkWindowPeer.c \
@@ -51,7 +49,8 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
gtkcairopeer.h \
gtkpeer.h
-libgtkpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/native_state.lo
+libgtkpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/native_state.lo \
+ $(top_builddir)/native/jni/classpath/jcl.lo
AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @CAIRO_LIBS@ @PANGOFT2_LIBS@ @X_LIBS@ -lXtst
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
diff --git a/native/jni/gtk-peer/gdkfont.h b/native/jni/gtk-peer/gdkfont.h
index 3370152e4..cf2333015 100644
--- a/native/jni/gtk-peer/gdkfont.h
+++ b/native/jni/gtk-peer/gdkfont.h
@@ -18,8 +18,8 @@
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.
+ 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
@@ -45,47 +45,47 @@
#include <pango/pango-fontmap.h>
#include <pango/pangoft2.h>
-extern struct state_table *native_font_state_table;
+extern struct state_table *cp_gtk_native_font_state_table;
extern struct state_table *native_glyphvector_state_table;
-extern struct state_table *native_text_layout_state_table;
+extern struct state_table *cp_gtk_native_text_layout_state_table;
#define NSA_FONT_INIT(env, clazz) \
- native_font_state_table = init_state_table (env, clazz)
+ cp_gtk_native_font_state_table = cp_gtk_init_state_table (env, clazz)
#define NSA_GET_FONT_PTR(env, obj) \
- get_state (env, obj, native_font_state_table)
+ cp_gtk_get_state (env, obj, cp_gtk_native_font_state_table)
#define NSA_SET_FONT_PTR(env, obj, ptr) \
- set_state (env, obj, native_font_state_table, (void *)ptr)
+ cp_gtk_set_state (env, obj, cp_gtk_native_font_state_table, (void *)ptr)
#define NSA_DEL_FONT_PTR(env, obj) \
- remove_state_slot (env, obj, native_font_state_table)
+ cp_gtk_remove_state_slot (env, obj, cp_gtk_native_font_state_table)
#define NSA_GV_INIT(env, clazz) \
- native_glyphvector_state_table = init_state_table (env, clazz)
+ native_glyphvector_state_table = cp_gtk_init_state_table (env, clazz)
#define NSA_GET_GV_PTR(env, obj) \
- get_state (env, obj, native_glyphvector_state_table)
+ cp_gtk_get_state (env, obj, native_glyphvector_state_table)
#define NSA_SET_GV_PTR(env, obj, ptr) \
- set_state (env, obj, native_glyphvector_state_table, (void *)ptr)
+ cp_gtk_set_state (env, obj, native_glyphvector_state_table, (void *)ptr)
#define NSA_DEL_GV_PTR(env, obj) \
- remove_state_slot (env, obj, native_glyphvector_state_table)
+ cp_gtk_remove_state_slot (env, obj, native_glyphvector_state_table)
#define NSA_TEXT_LAYOUT_INIT(env, clazz) \
- native_text_layout_state_table = init_state_table (env, clazz)
+ cp_gtk_native_text_layout_state_table = cp_gtk_init_state_table (env, clazz)
#define NSA_GET_TEXT_LAYOUT_PTR(env, obj) \
- get_state (env, obj, native_text_layout_state_table)
+ cp_gtk_get_state (env, obj, cp_gtk_native_text_layout_state_table)
#define NSA_SET_TEXT_LAYOUT_PTR(env, obj, ptr) \
- set_state (env, obj, native_text_layout_state_table, (void *)ptr)
+ cp_gtk_set_state (env, obj, cp_gtk_native_text_layout_state_table, (void *)ptr)
#define NSA_DEL_TEXT_LAYOUT_PTR(env, obj) \
- remove_state_slot (env, obj, native_text_layout_state_table)
+ cp_gtk_remove_state_slot (env, obj, cp_gtk_native_text_layout_state_table)
#define FONT_METRICS_ASCENT 0
#define FONT_METRICS_MAX_ASCENT 1
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c
index 7787eb4c4..595c1a28a 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
index 7a8a2ceef..401d62337 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
@@ -15,8 +15,8 @@
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.
+ 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
@@ -38,7 +38,7 @@
#include "gdkfont.h"
#include "gnu_java_awt_peer_gtk_GdkFontPeer.h"
-struct state_table *native_font_state_table;
+struct state_table *cp_gtk_native_font_state_table;
enum java_awt_font_style {
java_awt_font_PLAIN = 0,
@@ -75,11 +75,14 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_initState
(JNIEnv *env, jobject self)
{
struct peerfont *pfont = NULL;
+
gdk_threads_enter ();
+
g_assert (self != NULL);
pfont = (struct peerfont *) g_malloc0 (sizeof (struct peerfont));
g_assert (pfont != NULL);
NSA_SET_FONT_PTR (env, self, pfont);
+
gdk_threads_leave ();
}
@@ -91,6 +94,7 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_dispose
struct peerfont *pfont = NULL;
gdk_threads_enter ();
+
pfont = (struct peerfont *)NSA_DEL_FONT_PTR (env, self);
g_assert (pfont != NULL);
if (pfont->layout != NULL)
@@ -102,6 +106,7 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_dispose
if (pfont->desc != NULL)
pango_font_description_free (pfont->desc);
g_free (pfont);
+
gdk_threads_leave ();
}
@@ -114,11 +119,13 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_getGlyphVector
jobject fontRenderContext)
{
struct peerfont *pfont = NULL;
- GList *items = NULL, *i = NULL;
+ GList *items = NULL;
+ GList *i = NULL;
gchar *str = NULL;
- int len, j;
- double *native_extents;
- int *native_codes;
+ int len = 0;
+ int j = 0;
+ double *native_extents = NULL;
+ int *native_codes = NULL;
jintArray java_codes = NULL;
jdoubleArray java_extents = NULL;
@@ -127,7 +134,7 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_getGlyphVector
pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, self);
g_assert (pfont != NULL);
- len = (*gdk_env())->GetStringUTFLength (env, chars);
+ len = (*cp_gtk_gdk_env())->GetStringUTFLength (env, chars);
str = (gchar *)(*env)->GetStringUTFChars (env, chars, NULL);
g_assert (str != NULL);
@@ -143,8 +150,12 @@ 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
{
@@ -166,8 +177,13 @@ 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);
@@ -227,7 +243,7 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_getFontMetrics
{
struct peerfont *pfont = NULL;
jdouble *native_metrics = NULL;
- PangoFontMetrics *pango_metrics;
+ PangoFontMetrics *pango_metrics = NULL;
gdk_threads_enter();
@@ -329,9 +345,10 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont
struct peerfont *pfont = NULL;
char const *family_name = NULL;
enum java_awt_font_style style;
- PangoFT2FontMap *ft2_map;
+ PangoFT2FontMap *ft2_map = NULL;
gdk_threads_enter ();
+
style = (enum java_awt_font_style) style_int;
g_assert (self != NULL);
@@ -372,8 +389,8 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont
else
{
/* GDK uses a slightly different DPI setting. */
- pango_font_description_set_size (pfont->desc,
- size * dpi_conversion_factor);
+ pango_font_description_set_size (pfont->desc,
+ size * cp_gtk_dpi_conversion_factor);
if (pfont->ctx == NULL)
pfont->ctx = gdk_pango_context_get();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
index f80343f22..4a87aa744 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -41,25 +41,75 @@ exception statement from your version. */
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
+static jmethodID initComponentGraphicsID;
+
+void
+cp_gtk_graphics_init_jni (void)
+{
+ jclass gdkgraphics;
+
+ 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");
+}
+
+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))
-GdkPoint *
-translate_points (JNIEnv *env, jintArray xpoints, jintArray ypoints,
- jint npoints, jint x_offset, jint y_offset);
-static void realize_cb (GtkWidget *widget, jobject peer);
+static GdkPoint *translate_points (JNIEnv *env, jintArray xpoints,
+ jintArray ypoints, jint npoints,
+ jint x_offset, jint y_offset);
+static void realize_cb (GtkWidget *widget, jobject jgraphics);
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_copyState
(JNIEnv *env, jobject obj, jobject old)
{
- struct graphics *g, *g_old;
+ struct graphics *g = NULL;
+ struct graphics *g_old = NULL;
- g = (struct graphics *) malloc (sizeof (struct graphics));
- g_old = (struct graphics *) NSA_GET_PTR (env, old);
+ gdk_threads_enter ();
- *g = *g_old;
+ g = (struct graphics *) g_malloc (sizeof (struct graphics));
+ g_old = (struct graphics *) NSA_GET_G_PTR (env, old);
- gdk_threads_enter ();
+ *g = *g_old;
g->gc = gdk_gc_new (g->drawable);
gdk_gc_copy (g->gc, g_old->gc);
@@ -71,56 +121,58 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_copyState
gdk_colormap_ref (g->cm);
- gdk_threads_leave ();
+ NSA_SET_G_PTR (env, obj, g);
- NSA_SET_PTR (env, obj, g);
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II
(JNIEnv *env, jobject obj, jint width, jint height)
{
- struct graphics *g;
+ struct graphics *g = NULL;
+
+ gdk_threads_enter ();
- g = (struct graphics *) malloc (sizeof (struct graphics));
+ g = (struct graphics *) g_malloc (sizeof (struct graphics));
g->x_offset = g->y_offset = 0;
- gdk_threads_enter ();
g->drawable = (GdkDrawable *) gdk_pixmap_new (NULL, width, height,
gdk_rgb_get_visual ()->depth);
g->cm = gdk_rgb_get_cmap ();
gdk_colormap_ref (g->cm);
g->gc = gdk_gc_new (g->drawable);
- gdk_threads_leave ();
+ NSA_SET_G_PTR (env, obj, g);
- NSA_SET_PTR (env, obj, g);
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage
(JNIEnv *env, jobject obj, jobject source)
{
- struct graphics *g;
- GdkPixmap *pixmap =
- gnu_java_awt_peer_gtk_GtkImage_getPixmap(env, source);
+ struct graphics *g = NULL;
+ GdkPixmap *pixmap = NULL;
+
+ gdk_threads_enter ();
+
+ pixmap = cp_gtk_image_get_pixmap (env, source);
g_assert(pixmap != NULL);
gdk_pixmap_ref (pixmap);
- g = (struct graphics *) malloc (sizeof (struct graphics));
+ g = (struct graphics *) g_malloc (sizeof (struct graphics));
g->x_offset = g->y_offset = 0;
- gdk_threads_enter ();
-
g->drawable = (GdkDrawable *)pixmap;
g->cm = gdk_drawable_get_colormap (g->drawable);
gdk_colormap_ref (g->cm);
g->gc = gdk_gc_new (g->drawable);
- gdk_threads_leave ();
+ NSA_SET_G_PTR (env, obj, g);
- NSA_SET_PTR (env, obj, g);
+ gdk_threads_leave ();
}
/* copy the native state of the peer (GtkWidget *) to the native state
@@ -129,16 +181,18 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2
(JNIEnv *env, jobject obj, jobject peer)
{
- struct graphics *g = (struct graphics *) malloc (sizeof (struct graphics));
- void *ptr;
- GtkWidget *widget;
+ struct graphics *g = NULL;
+ void *ptr = NULL;
+ GtkWidget *widget = NULL;
GdkColor color;
- ptr = NSA_GET_PTR (env, peer);
- g->x_offset = g->y_offset = 0;
-
gdk_threads_enter ();
+ g = (struct graphics *) g_malloc (sizeof (struct graphics));
+ ptr = NSA_GET_PTR (env, peer);
+ g->x_offset = 0;
+ g->y_offset = 0;
+
widget = GTK_WIDGET (ptr);
g->drawable = (GdkDrawable *) widget->window;
@@ -149,24 +203,24 @@ 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];
- gdk_threads_leave ();
+ NSA_SET_G_PTR (env, obj, g);
- NSA_SET_PTR (env, obj, g);
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_connectSignals
(JNIEnv *env, jobject obj, jobject peer)
{
- void *ptr;
- jobject *gref;
+ void *ptr = NULL;
+ jobject *gref = NULL;
- NSA_SET_GLOBAL_REF (env, obj);
- gref = NSA_GET_GLOBAL_REF (env, obj);
+ gdk_threads_enter ();
- ptr = NSA_GET_PTR (env, peer);
+ NSA_SET_GLOBAL_G_REF (env, obj);
+ gref = NSA_GET_GLOBAL_G_REF (env, obj);
- gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, peer);
g_signal_connect_after (G_OBJECT (ptr), "realize",
G_CALLBACK (realize_cb), *gref);
@@ -178,14 +232,19 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_dispose
(JNIEnv *env, jobject obj)
{
- struct graphics *g;
+ struct graphics *g = NULL;
-
- g = (struct graphics *) NSA_DEL_PTR (env, obj);
-
- if (!g) return; /* dispose has been called more than once */
-
gdk_threads_enter ();
+
+ g = (struct graphics *) NSA_DEL_G_PTR (env, obj);
+
+ /* check if dispose has been called already */
+ if (!g)
+ {
+ gdk_threads_leave ();
+ return;
+ }
+
XFlush (GDK_DISPLAY ());
gdk_gc_destroy (g->gc);
@@ -197,22 +256,21 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_dispose
gdk_colormap_unref (g->cm);
- gdk_threads_leave ();
-
+ g_free (g);
- free (g);
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_translateNative
(JNIEnv *env, jobject obj, jint x, jint y)
{
- struct graphics *g;
-
- g = (struct graphics *) NSA_GET_PTR (env, obj);
+ struct graphics *g = NULL;
gdk_threads_enter ();
+ g = (struct graphics *) NSA_GET_G_PTR (env, obj);
+
g->x_offset += x;
g->y_offset += y;
@@ -224,12 +282,14 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString
(JNIEnv *env, jobject obj, jobject font, jstring str, jint x, jint y)
{
struct peerfont *pfont = NULL;
- struct graphics *g;
- const char *cstr;
- int baseline_y;
- PangoLayoutIter *iter;
+ struct graphics *g = NULL;
+ const char *cstr = NULL;
+ int baseline_y = 0;
+ PangoLayoutIter *iter = NULL;
+
+ 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);
@@ -237,8 +297,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString
cstr = (*env)->GetStringUTFChars (env, str, NULL);
- gdk_threads_enter ();
-
pango_layout_set_font_description (pfont->layout, pfont->desc);
pango_layout_set_text (pfont->layout, cstr, -1);
iter = pango_layout_get_iter (pfont->layout);
@@ -254,24 +312,27 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString
pango_layout_set_text (pfont->layout, "", -1);
gdk_flush ();
- gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, str, cstr);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_drawLine
(JNIEnv *env, jobject obj, jint x, jint y, jint x2, jint y2)
{
- struct graphics *g;
-
- g = (struct graphics *) NSA_GET_PTR (env, obj);
+ struct graphics *g = NULL;
gdk_threads_enter ();
+
+ g = (struct graphics *) NSA_GET_G_PTR (env, obj);
+
gdk_draw_line (g->drawable, g->gc,
x + g->x_offset, y + g->y_offset,
x2 + g->x_offset, y2 + g->y_offset);
gdk_flush ();
+
gdk_threads_leave ();
}
@@ -279,15 +340,16 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_fillRect
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
- struct graphics *g;
-
- g = (struct graphics *) NSA_GET_PTR (env, obj);
+ struct graphics *g = NULL;
gdk_threads_enter ();
+ 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);
gdk_flush ();
+
gdk_threads_leave ();
}
@@ -295,14 +357,16 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_drawRect
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
- struct graphics *g;
-
- g = (struct graphics *) NSA_GET_PTR (env, obj);
+ struct graphics *g = NULL;
gdk_threads_enter ();
+
+ 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);
gdk_flush ();
+
gdk_threads_leave ();
}
@@ -311,11 +375,12 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea
(JNIEnv *env, jobject obj, jint x, jint y,
jint width, jint height, jint dx, jint dy)
{
- struct graphics *g;
-
- g = (struct graphics *) NSA_GET_PTR (env, obj);
+ struct graphics *g = NULL;
gdk_threads_enter ();
+
+ g = (struct graphics *) NSA_GET_G_PTR (env, obj);
+
gdk_window_copy_area ((GdkWindow *)g->drawable,
g->gc,
x + g->x_offset + dx, y + g->y_offset + dy,
@@ -323,6 +388,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea
x + g->x_offset, y + g->y_offset,
width, height);
gdk_flush ();
+
gdk_threads_leave ();
}
@@ -330,20 +396,21 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
- struct graphics *g;
+ struct graphics *g = NULL;
GdkGCValues saved;
- GtkWidget *widget;
+ GtkWidget *widget = NULL;
union widget_union w;
- g = (struct graphics *) NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ g = (struct graphics *) NSA_GET_G_PTR (env, obj);
+
if (!g)
{
gdk_threads_leave ();
return;
}
+
if (GDK_IS_WINDOW (g->drawable))
{
w.widget = &widget;
@@ -363,6 +430,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect
}
gdk_flush ();
+
gdk_threads_leave ();
}
@@ -370,11 +438,14 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_setFunction
(JNIEnv *env, jobject obj, jint func)
{
- struct graphics *g;
- g = (struct graphics *) NSA_GET_PTR (env, obj);
-
+ struct graphics *g = NULL;
+
gdk_threads_enter ();
+
+ g = (struct graphics *) NSA_GET_G_PTR (env, obj);
+
gdk_gc_set_function (g->gc, func);
+
gdk_threads_leave ();
}
@@ -384,15 +455,16 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_setFGColor
(JNIEnv *env, jobject obj, jint red, jint green, jint blue)
{
GdkColor color;
- struct graphics *g;
+ struct graphics *g = NULL;
+
+ gdk_threads_enter ();
color.red = red << 8;
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_threads_enter ();
gdk_color_alloc (g->cm, &color);
gdk_gc_set_foreground (g->gc, &color);
@@ -404,19 +476,21 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawArc
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height,
jint angle1, jint angle2)
{
- struct graphics *g;
-
- g = (struct graphics *) NSA_GET_PTR (env, obj);
+ struct graphics *g = NULL;
gdk_threads_enter ();
+
+ 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,
width, height, angle1 << 6, angle2 << 6);
gdk_flush ();
+
gdk_threads_leave ();
}
-GdkPoint *
+static GdkPoint *
translate_points (JNIEnv *env, jintArray xpoints, jintArray ypoints,
jint npoints, jint x_offset, jint y_offset)
{
@@ -448,19 +522,21 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolyline
(JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints,
jint npoints)
{
- struct graphics *g;
- GdkPoint *points;
+ struct graphics *g = NULL;
+ GdkPoint *points = NULL;
+
+ 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_threads_enter ();
gdk_draw_lines (g->drawable, g->gc, points, npoints);
gdk_flush ();
- gdk_threads_leave ();
g_free (points);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -468,10 +544,12 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolygon
(JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints,
jint npoints)
{
- struct graphics *g;
- GdkPoint *points;
+ struct graphics *g = NULL;
+ GdkPoint *points = NULL;
- g = (struct graphics *) NSA_GET_PTR (env, obj);
+ gdk_threads_enter ();
+
+ g = (struct graphics *) NSA_GET_G_PTR (env, obj);
points = translate_points (env, xpoints, ypoints, npoints,
g->x_offset, g->y_offset);
@@ -480,12 +558,12 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolygon
if (points[0].x != points[npoints-1].x || points[0].y != points[npoints-1].y)
points[npoints++] = points[0];
- gdk_threads_enter ();
gdk_draw_lines (g->drawable, g->gc, points, npoints);
gdk_flush ();
- gdk_threads_leave ();
g_free (points);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -493,18 +571,20 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_fillPolygon
(JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints,
jint npoints)
{
- struct graphics *g;
- GdkPoint *points;
+ struct graphics *g = NULL;
+ GdkPoint *points = NULL;
+
+ 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_threads_enter ();
gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints);
gdk_flush ();
- gdk_threads_leave ();
g_free (points);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -512,15 +592,17 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_fillArc
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height,
jint angle1, jint angle2)
{
- struct graphics *g;
-
- g = (struct graphics *) NSA_GET_PTR (env, obj);
+ struct graphics *g = NULL;
gdk_threads_enter ();
+
+ 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,
width, height, angle1 << 6, angle2 << 6);
gdk_flush ();
+
gdk_threads_leave ();
}
@@ -528,15 +610,17 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_drawOval
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
- struct graphics *g;
-
- g = (struct graphics *) NSA_GET_PTR (env, obj);
+ struct graphics *g = NULL;
gdk_threads_enter ();
+
+ 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,
width, height, 0, 23040);
gdk_flush ();
+
gdk_threads_leave ();
}
@@ -544,15 +628,17 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_fillOval
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
- struct graphics *g;
-
- g = (struct graphics *) NSA_GET_PTR (env, obj);
+ struct graphics *g = NULL;
gdk_threads_enter ();
+
+ 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,
width, height, 0, 23040);
gdk_flush ();
+
gdk_threads_leave ();
}
@@ -560,29 +646,31 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
- struct graphics *g;
+ struct graphics *g = NULL;
GdkRectangle rectangle;
- g = (struct graphics *) NSA_GET_PTR (env, obj);
+ gdk_threads_enter ();
+
+ g = (struct graphics *) NSA_GET_G_PTR (env, obj);
rectangle.x = x + g->x_offset;
rectangle.y = y + g->y_offset;
rectangle.width = width;
rectangle.height = height;
- gdk_threads_enter ();
gdk_gc_set_clip_rectangle (g->gc, &rectangle);
+
gdk_threads_leave ();
}
-static void realize_cb (GtkWidget *widget __attribute__ ((unused)),
- jobject peer)
+static void
+realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject jgraphics)
{
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer, initComponentGraphicsID);
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), jgraphics, initComponentGraphicsID);
- NSA_DEL_GLOBAL_REF (gdk_env(), peer);
+ NSA_DEL_GLOBAL_G_REF (cp_gtk_gdk_env(), jgraphics);
gdk_threads_enter ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
index e6535b463..b4bd676e7 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
@@ -15,8 +15,8 @@
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.
+ 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
@@ -41,6 +41,7 @@
#include <gdk/gdktypes.h>
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
+#include <X11/extensions/Xrender.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf/gdk-pixdata.h>
@@ -51,26 +52,43 @@
#include <stdio.h>
#include <stdlib.h>
-struct state_table *native_graphics2d_state_table;
+static jmethodID initComponentGraphics2DID;
+
+void
+cp_gtk_graphics2d_init_jni (void)
+{
+ jclass gdkgraphics2d;
+
+ 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",
+ "()V");
+}
+
+static struct state_table *native_graphics2d_state_table;
#define NSA_G2D_INIT(env, clazz) \
- native_graphics2d_state_table = init_state_table (env, clazz)
+ native_graphics2d_state_table = cp_gtk_init_state_table (env, clazz)
#define NSA_GET_G2D_PTR(env, obj) \
- get_state (env, obj, native_graphics2d_state_table)
+ cp_gtk_get_state (env, obj, native_graphics2d_state_table)
#define NSA_SET_G2D_PTR(env, obj, ptr) \
- set_state (env, obj, native_graphics2d_state_table, (void *)ptr)
+ cp_gtk_set_state (env, obj, native_graphics2d_state_table, (void *)ptr)
#define NSA_DEL_G2D_PTR(env, obj) \
- remove_state_slot (env, obj, native_graphics2d_state_table)
+ cp_gtk_remove_state_slot (env, obj, native_graphics2d_state_table)
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStaticState
(JNIEnv *env, jclass clazz)
{
gdk_threads_enter();
+
NSA_G2D_INIT (env, clazz);
+
gdk_threads_leave();
}
@@ -196,15 +214,16 @@ init_graphics2d_as_pixbuf (struct graphics2d *gr)
g_assert (gdk_pixbuf_get_bits_per_sample (gr->drawbuf) == bits_per_sample);
g_assert (gdk_pixbuf_get_n_channels (gr->drawbuf) == total_channels);
- gr->surface = cairo_surface_create_for_image ((char *) gdk_pixbuf_get_pixels (gr->drawbuf),
+ gr->surface = cairo_image_surface_create_for_data (gdk_pixbuf_get_pixels (gr->drawbuf),
CAIRO_FORMAT_ARGB32,
gdk_pixbuf_get_width (gr->drawbuf),
gdk_pixbuf_get_height (gr->drawbuf),
gdk_pixbuf_get_rowstride (gr->drawbuf));
g_assert (gr->surface != NULL);
- g_assert (gr->cr != NULL);
gr->mode = MODE_DRAWABLE_NO_RENDER;
- cairo_set_target_surface (gr->cr, gr->surface);
+ if (gr->cr != NULL)
+ cairo_destroy (gr->cr);
+ gr->cr = cairo_create (gr->surface);
}
static void
@@ -228,13 +247,12 @@ init_graphics2d_as_renderable (struct graphics2d *gr)
vis = gdk_x11_visual_get_xvisual (gdk_drawable_get_visual (gr->drawable));
g_assert (vis != NULL);
- gr->surface = cairo_xlib_surface_create (dpy, draw, vis,
- CAIRO_FORMAT_ARGB32,
- DefaultColormap (dpy, DefaultScreen (dpy)));
+ gr->surface = cairo_xlib_surface_create (dpy, draw, vis, gr->width, gr->height);
g_assert (gr->surface != NULL);
- g_assert (gr->cr != NULL);
gr->mode = MODE_DRAWABLE_WITH_RENDER;
- cairo_set_target_surface (gr->cr, gr->surface);
+ if (gr->cr != NULL)
+ cairo_destroy (gr->cr);
+ gr->cr = cairo_create (gr->surface);
}
static void
@@ -272,15 +290,18 @@ begin_drawing_operation (JNIEnv *env, struct graphics2d * gr)
break;
case MODE_JAVA_ARRAY:
- gr->javabuf = (*env)->GetIntArrayElements (env, gr->jarray, &gr->isCopy);
- gr->surface = cairo_surface_create_for_image ((char *) gr->javabuf,
- CAIRO_FORMAT_ARGB32,
- gr->width,
- gr->height,
- gr->width * 4);
- g_assert(gr->surface != NULL);
- g_assert(gr->cr != NULL);
- cairo_set_target_surface (gr->cr, gr->surface);
+ {
+ jboolean isCopy;
+ gr->javabuf = (*env)->GetPrimitiveArrayCritical (env, gr->jarray, &isCopy);
+ gr->isCopy |= isCopy;
+ if (gr->isCopy)
+ {
+ /* Make sure that the pixel buffer copy is already initalized,
+ i.e. we already failed to get direct access in initState. */
+ g_assert (gr->javabuf_copy != NULL);
+ memcpy (gr->javabuf_copy, gr->javabuf, gr->width * gr->height * 4);
+ }
+ }
break;
}
}
@@ -319,13 +340,9 @@ end_drawing_operation (JNIEnv *env, struct graphics2d * gr)
break;
case MODE_JAVA_ARRAY:
- /*
- * FIXME: Perhaps this should use the isCopy flag to try to avoid
- * tearing down the cairo surface.
- */
- cairo_surface_destroy (gr->surface);
- gr->surface = NULL;
- (*env)->ReleaseIntArrayElements (env, gr->jarray, gr->javabuf, JNI_COMMIT);
+ if (gr->isCopy)
+ memcpy (gr->javabuf, gr->javabuf_copy, gr->width * gr->height * 4);
+ (*env)->ReleasePrimitiveArrayCritical (env, gr->jarray, gr->javabuf, JNI_COMMIT);
}
}
@@ -333,21 +350,14 @@ end_drawing_operation (JNIEnv *env, struct graphics2d * gr)
static void
update_pattern_transform (struct graphics2d *gr)
{
- double a, b, c, d, tx, ty;
- cairo_matrix_t *mat = NULL;
+ cairo_matrix_t mat;
g_assert (gr != NULL);
if (gr->pattern == NULL)
return;
- return;
- /* temporarily disabled: ambiguous behavior */
- /* cairo_get_matrix (gr->cr, &a, &b, &c, &d, &tx, &ty); */
- mat = cairo_matrix_create ();
- g_assert (mat != NULL);
- cairo_matrix_set_affine (mat, a, b, c, d, tx, ty);
- cairo_pattern_set_matrix (gr->pattern, mat);
- cairo_matrix_destroy (mat);
+ cairo_get_matrix (gr->cr, &mat);
+ cairo_pattern_set_matrix (gr->pattern, &mat);
}
static void
@@ -361,7 +371,7 @@ realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject peer)
{
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer, initComponentGraphics2DID);
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, initComponentGraphics2DID);
gdk_threads_enter ();
}
@@ -373,7 +383,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_copyState
struct graphics2d *g = NULL, *g_old = NULL;
gdk_threads_enter();
- g = (struct graphics2d *) malloc (sizeof (struct graphics2d));
+
+ g = (struct graphics2d *) g_malloc (sizeof (struct graphics2d));
g_assert (g != NULL);
memset (g, 0, sizeof(struct graphics2d));
@@ -385,20 +396,32 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_copyState
g->debug = g_old->debug;
g->mode = g_old->mode;
+ g->width = g_old->width;
+ g->height = g_old->height;
+
if (g_old->mode == MODE_JAVA_ARRAY)
{
- g->width = g_old->width;
- g->height = g_old->height;
- g->jarray = (*env)->NewGlobalRef(env, g_old->jarray);
+ jint size = g->width * g->height * 4;
+
+ g->jarray = (*env)->NewGlobalRef (env, g_old->jarray);
+ g->javabuf = (*env)->GetIntArrayElements (env, g->jarray, &g->isCopy);
+ g->isCopy = JNI_TRUE;
+ g->javabuf_copy = (jint *) g_malloc (size);
+ memcpy (g->javabuf_copy, g->javabuf, size);
+ g->surface = cairo_image_surface_create_for_data ((unsigned char *) g->javabuf,
+ CAIRO_FORMAT_ARGB32,
+ g->width,
+ g->height,
+ g->width * 4);
+ g_assert (g->surface != NULL);
+ g->cr = cairo_create (g->surface);
+ g_assert (g->cr != NULL);
+ (*env)->ReleaseIntArrayElements (env, g->jarray, g->javabuf, JNI_ABORT);
}
else
{
g->drawable = g_old->drawable;
-
g_object_ref (g->drawable);
-
- g->cr = cairo_create();
- g_assert (g->cr != NULL);
if (x_server_has_render_extension ())
init_graphics2d_as_renderable (g);
@@ -406,9 +429,11 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_copyState
init_graphics2d_as_pixbuf (g);
}
- cairo_surface_set_filter (g->surface, CAIRO_FILTER_FAST);
+ if (g->pattern)
+ cairo_pattern_set_filter (g->pattern, CAIRO_FILTER_FAST);
NSA_SET_G2D_PTR (env, obj, g);
+
gdk_threads_leave();
}
@@ -417,10 +442,12 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState___3III
(JNIEnv *env, jobject obj, jintArray jarr, jint width, jint height)
{
- struct graphics2d *gr;
+ struct graphics2d *gr = NULL;
+ jint *cairobuf = NULL;
gdk_threads_enter();
- gr = (struct graphics2d *) malloc (sizeof (struct graphics2d));
+
+ gr = (struct graphics2d *) g_malloc (sizeof (struct graphics2d));
g_assert (gr != NULL);
memset (gr, 0, sizeof(struct graphics2d));
@@ -428,19 +455,42 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState___3III
if (gr->debug) printf ("constructing java-backed image of size (%d,%d)\n",
width, height);
-
- gr->cr = cairo_create();
- g_assert (gr->cr != NULL);
gr->width = width;
gr->height = height;
gr->jarray = (*env)->NewGlobalRef(env, jarr);
+ gr->javabuf = (*env)->GetPrimitiveArrayCritical (env, gr->jarray, &gr->isCopy);
+ if (gr->isCopy)
+ {
+ /* We didn't get direct access to the pixel buffer, so we'll have to
+ maintain a separate copy for Cairo. */
+ jint size = gr->width * gr->height * 4;
+ gr->javabuf_copy = (jint *) g_malloc (size);
+ memcpy (gr->javabuf_copy, gr->javabuf, size);
+ cairobuf = gr->javabuf_copy;
+ }
+ else
+ {
+ /* Have Cairo write directly to the Java array. */
+ cairobuf = gr->javabuf;
+ }
+ gr->surface = cairo_image_surface_create_for_data ((unsigned char *) cairobuf,
+ CAIRO_FORMAT_ARGB32,
+ gr->width,
+ gr->height,
+ gr->width * 4);
+ g_assert (gr->surface != NULL);
+ gr->cr = cairo_create (gr->surface);
+ g_assert (gr->cr != NULL);
+ (*env)->ReleasePrimitiveArrayCritical (env, gr->jarray, gr->javabuf, JNI_COMMIT);
+
gr->mode = MODE_JAVA_ARRAY;
if (gr->debug) printf ("constructed java-backed image of size (%d,%d)\n",
width, height);
NSA_SET_G2D_PTR (env, obj, gr);
+
gdk_threads_leave();
}
@@ -448,10 +498,11 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__II
(JNIEnv *env, jobject obj, jint width, jint height)
{
- struct graphics2d *gr;
+ struct graphics2d *gr = NULL;
gdk_threads_enter();
- gr = (struct graphics2d *) malloc (sizeof (struct graphics2d));
+
+ gr = (struct graphics2d *) g_malloc (sizeof (struct graphics2d));
g_assert (gr != NULL);
memset (gr, 0, sizeof(struct graphics2d));
@@ -464,8 +515,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__II
gdk_rgb_get_visual ()->depth);
g_assert (gr->drawable != NULL);
- gr->cr = cairo_create();
- g_assert (gr->cr != NULL);
+ gr->width = width;
+ gr->height = height;
if (x_server_has_render_extension ())
init_graphics2d_as_renderable (gr);
@@ -475,6 +526,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__II
if (gr->debug) printf ("constructed offscreen drawable of size (%d,%d)\n",
width, height);
NSA_SET_G2D_PTR (env, obj, gr);
+
gdk_threads_leave();
}
@@ -482,13 +534,25 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
(JNIEnv *env, jobject self, jobject other, jint x, jint y)
{
- struct graphics2d *src = NULL, *dst = NULL;
- gint s_height, s_width, d_height, d_width, height, width;
- cairo_matrix_t *matrix;
+ struct graphics2d *src = NULL;
+ struct graphics2d *dst = NULL;
+ gint s_height;
+ gint s_width;
+ gint d_height;
+ gint d_width;
+ gint height;
+ gint width;
+ cairo_matrix_t matrix;
cairo_operator_t tmp_op;
gdk_threads_enter();
- if (peer_is_disposed(env, self)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, self))
+ {
+ gdk_threads_leave();
+ return;
+ }
+
src = (struct graphics2d *)NSA_GET_G2D_PTR (env, other);
dst = (struct graphics2d *)NSA_GET_G2D_PTR (env, self);
g_assert (src != NULL);
@@ -505,25 +569,26 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
width = min (s_width, d_width);
height = min (s_height, d_height);
- matrix = cairo_matrix_create ();
- cairo_surface_get_matrix (src->surface, matrix);
- cairo_matrix_translate (matrix, (double)-x, (double)-y);
- cairo_surface_set_matrix (src->surface, matrix);
-
- tmp_op = cairo_current_operator (dst->cr);
- cairo_set_operator(dst->cr, CAIRO_OPERATOR_SRC);
- cairo_show_surface (dst->cr, src->surface, width, height);
+ cairo_get_matrix (src->cr, &matrix);
+ cairo_matrix_translate (&matrix, (double)-x, (double)-y);
+ if (src->pattern)
+ cairo_pattern_set_matrix (src->pattern, &matrix);
+ tmp_op = cairo_get_operator (dst->cr);
+ cairo_set_operator(dst->cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_surface (dst->cr, src->surface, 0, 0);
+ cairo_paint (dst->cr);
cairo_set_operator(dst->cr, tmp_op);
- cairo_matrix_translate (matrix, (double)x, (double)y);
- cairo_surface_set_matrix (src->surface, matrix);
- cairo_matrix_destroy (matrix);
+ cairo_matrix_translate (&matrix, (double)x, (double)y);
+ if (src->pattern)
+ cairo_pattern_set_matrix (src->pattern, &matrix);
gdk_flush();
end_drawing_operation(env, dst);
if (src->debug) printf ("copied %d x %d pixels from offscreen drawable\n", width, height);
+
gdk_threads_leave();
}
@@ -536,31 +601,38 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkCo
void *ptr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave ();
+ return;
+ }
+
ptr = NSA_GET_PTR (env, peer);
g_assert (ptr != NULL);
- gr = (struct graphics2d *) malloc (sizeof (struct graphics2d));
+ gr = (struct graphics2d *) g_malloc (sizeof (struct graphics2d));
g_assert (gr != NULL);
memset (gr, 0, sizeof(struct graphics2d));
check_for_debug (gr);
- gr->cr = cairo_create();
- g_assert (gr->cr != NULL);
-
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);
+
gdk_threads_leave();
}
@@ -570,10 +642,10 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_connectSignals
{
void *ptr;
- ptr = NSA_GET_PTR (env, peer);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, peer);
+
g_signal_connect_after (G_OBJECT (ptr), "realize",
G_CALLBACK (realize_cb), obj);
@@ -587,7 +659,9 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose
struct graphics2d *gr = NULL;
gdk_threads_enter();
+
gr = (struct graphics2d *) NSA_DEL_G2D_PTR (env, obj);
+
if (gr == NULL)
{
gdk_threads_leave();
@@ -602,7 +676,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose
if (gr->drawbuf)
g_object_unref (gr->drawbuf);
- g_object_unref (gr->drawable);
+ if (gr->drawable)
+ g_object_unref (gr->drawable);
if (gr->pattern)
cairo_pattern_destroy (gr->pattern);
@@ -611,18 +686,22 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose
cairo_surface_destroy (gr->pattern_surface);
if (gr->pattern_pixels)
- free (gr->pattern_pixels);
+ g_free (gr->pattern_pixels);
if (gr->mode == MODE_JAVA_ARRAY)
- (*env)->DeleteGlobalRef(env, gr->jarray);
+ {
+ (*env)->DeleteGlobalRef (env, gr->jarray);
+ if (gr->javabuf_copy)
+ g_free (gr->javabuf_copy);
+ }
if (gr->debug) printf ("disposed of graphics2d\n");
- free (gr);
+ g_free (gr);
+
gdk_threads_leave();
}
-
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient
(JNIEnv *env, jobject obj,
@@ -634,50 +713,52 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient
{
struct graphics2d *gr = NULL;
cairo_surface_t *surf = NULL;
- cairo_matrix_t *mat = 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);
- gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave ();
+ return;
+ }
+
if (gr->debug) printf ("setGradient (%f,%f) -> (%f,%f); (%d,%d,%d,%d) -> (%d,%d,%d,%d)\n",
x1, y1,
x2, y2,
r1, g1, b1, a1,
r2, g2, b2, a2);
- cairo_save (gr->cr);
-
if (cyclic)
surf = cairo_surface_create_similar (gr->surface, CAIRO_FORMAT_ARGB32, 3, 2);
else
surf = cairo_surface_create_similar (gr->surface, CAIRO_FORMAT_ARGB32, 2, 2);
g_assert (surf != NULL);
- cairo_set_target_surface (gr->cr, surf);
+ cr2 = cairo_create (surf);
- cairo_identity_matrix (gr->cr);
+ cairo_identity_matrix (cr2);
- cairo_set_rgb_color (gr->cr, r1 / 255.0, g1 / 255.0, b1 / 255.0);
- cairo_set_alpha (gr->cr, a1 / 255.0);
- cairo_rectangle (gr->cr, 0, 0, 1, 2);
- cairo_fill (gr->cr);
+ cairo_set_source_rgba (cr2, r1 / 255.0, g1 / 255.0, b1 / 255.0, a1 / 255.0);
+ cairo_rectangle (cr2, 0, 0, 1, 2);
+ cairo_fill (cr2);
- cairo_set_rgb_color (gr->cr, r2 / 255.0, g2 / 255.0, b2 / 255.0);
- cairo_set_alpha (gr->cr, a2 / 255.0);
- cairo_rectangle (gr->cr, 1, 0, 1, 2);
- cairo_fill (gr->cr);
+ cairo_set_source_rgba (cr2, r2 / 255.0, g2 / 255.0, b2 / 255.0, a2 / 255.0);
+ cairo_rectangle (cr2, 1, 0, 1, 2);
+ cairo_fill (cr2);
if (cyclic)
{
- cairo_set_rgb_color (gr->cr, r1 / 255.0, g1 / 255.0, b1 / 255.0);
- cairo_set_alpha (gr->cr, a1 / 255.0);
- cairo_rectangle (gr->cr, 2, 0, 1, 2);
- cairo_fill (gr->cr);
+ cairo_set_source_rgba (cr2, r1 / 255.0, g1 / 255.0, b1 / 255.0, a1 / 255.0);
+ cairo_rectangle (cr2, 2, 0, 1, 2);
+ cairo_fill (cr2);
}
- mat = cairo_matrix_create ();
- g_assert (mat != NULL);
+ cairo_matrix_init_identity (&mat);
/*
consider the vector [x2 - x1, y2 - y1] = [p,q]
@@ -716,15 +797,16 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient
double c = (y2 - y1 == 0.) ? 0. : (1. / (y2 - y1));
double dx = (x1 == 0.) ? 0. : 1. / x1;
double dy = (y1 == 0.) ? 0. : 1. / y1;
+ cairo_pattern_t *p;
- cairo_matrix_set_affine (mat,
- a, 0.,
- c, 0.,
- dx, dy);
+ cairo_matrix_init (&mat,
+ a, 0.,
+ c, 0.,
+ dx, dy);
- cairo_surface_set_matrix (surf, mat);
- cairo_matrix_destroy (mat);
- cairo_surface_set_filter (surf, CAIRO_FILTER_BILINEAR);
+ p = cairo_pattern_create_for_surface (surf);
+ cairo_pattern_set_matrix (p, &mat);
+ cairo_pattern_set_filter (p, CAIRO_FILTER_BILINEAR);
}
/* FIXME: repeating gradients (not to mention hold gradients) don't seem to work. */
@@ -737,14 +819,14 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient
cairo_surface_destroy (gr->pattern_surface);
if (gr->pattern_pixels)
- free (gr->pattern_pixels);
+ g_free (gr->pattern_pixels);
gr->pattern_pixels = NULL;
gr->pattern_surface = surf;
gr->pattern = cairo_pattern_create_for_surface(surf);
- cairo_restore (gr->cr);
- cairo_set_pattern (gr->cr, gr->pattern);
+ cairo_set_source (gr->cr, gr->pattern);
+
gdk_threads_leave();
}
@@ -756,7 +838,13 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
jint *jpixels = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave ();
+ return;
+ }
+
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -770,13 +858,13 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
cairo_surface_destroy (gr->pattern_surface);
if (gr->pattern_pixels)
- free (gr->pattern_pixels);
+ g_free (gr->pattern_pixels);
gr->pattern = NULL;
gr->pattern_surface = NULL;
gr->pattern_pixels = NULL;
- gr->pattern_pixels = (char *) malloc (h * stride * 4);
+ gr->pattern_pixels = (char *) g_malloc (h * stride * 4);
g_assert (gr->pattern_pixels != NULL);
jpixels = (*env)->GetIntArrayElements (env, jarr, NULL);
@@ -784,14 +872,15 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
memcpy (gr->pattern_pixels, jpixels, h * stride * 4);
(*env)->ReleaseIntArrayElements (env, jarr, jpixels, 0);
- gr->pattern_surface = cairo_surface_create_for_image (gr->pattern_pixels,
+ gr->pattern_surface = cairo_image_surface_create_for_data ((unsigned char *)gr->pattern_pixels,
CAIRO_FORMAT_ARGB32,
w, h, stride * 4);
g_assert (gr->pattern_surface != NULL);
- cairo_surface_set_repeat (gr->pattern_surface, 1);
+ cairo_pattern_set_extend (gr->pattern, 1);
gr->pattern = cairo_pattern_create_for_surface (gr->pattern_surface);
g_assert (gr->pattern != NULL);
- cairo_set_pattern (gr->cr, gr->pattern);
+ cairo_set_source (gr->cr, gr->pattern);
+
gdk_threads_leave();
}
@@ -805,7 +894,12 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels
jdouble *native_matrix = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -822,19 +916,24 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels
begin_drawing_operation (env, gr);
{
- cairo_matrix_t *mat = NULL;
- cairo_surface_t *surf = cairo_surface_create_for_image ((char *)native_pixels,
+ cairo_matrix_t mat;
+ cairo_pattern_t *p;
+ cairo_surface_t *surf = cairo_image_surface_create_for_data ((unsigned char *)native_pixels,
CAIRO_FORMAT_ARGB32,
w, h, stride * 4);
- mat = cairo_matrix_create ();
- cairo_matrix_set_affine (mat,
- native_matrix[0], native_matrix[1],
- native_matrix[2], native_matrix[3],
- native_matrix[4], native_matrix[5]);
- cairo_surface_set_matrix (surf, mat);
- cairo_surface_set_filter (surf, cairo_surface_get_filter(gr->surface));
- cairo_show_surface (gr->cr, surf, w, h);
- cairo_matrix_destroy (mat);
+ cairo_matrix_init_identity (&mat);
+ cairo_matrix_init (&mat,
+ native_matrix[0], native_matrix[1],
+ native_matrix[2], native_matrix[3],
+ native_matrix[4], native_matrix[5]);
+
+ p = cairo_pattern_create_for_surface (surf);
+ cairo_pattern_set_matrix (p, &mat);
+ if (gr->pattern)
+ cairo_pattern_set_filter (p, cairo_pattern_get_filter (gr->pattern));
+ cairo_set_source (gr->cr, p);
+ cairo_paint (gr->cr);
+ cairo_pattern_destroy (p);
cairo_surface_destroy (surf);
}
@@ -855,12 +954,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSave
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_save\n");
cairo_save (gr->cr);
+
gdk_threads_leave();
}
@@ -871,13 +976,19 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRestore
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_restore\n");
cairo_restore (gr->cr);
update_pattern_transform (gr);
+
gdk_threads_leave();
}
@@ -889,12 +1000,22 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix
jdouble *native_matrix = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave ();
+ 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; }
+ if (gr == NULL)
+ {
+ gdk_threads_leave ();
+ return;
+ }
native_matrix = (*env)->GetDoubleArrayElements (env, java_matrix, NULL);
g_assert (native_matrix != NULL);
@@ -906,17 +1027,19 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix
native_matrix[4], native_matrix[5]);
{
- cairo_matrix_t * mat = cairo_matrix_create ();
- cairo_matrix_set_affine (mat,
- native_matrix[0], native_matrix[1],
- native_matrix[2], native_matrix[3],
- native_matrix[4], native_matrix[5]);
- cairo_set_matrix (gr->cr, mat);
- cairo_matrix_destroy (mat);
+ cairo_matrix_t mat;
+
+ cairo_matrix_init_identity (&mat);
+ cairo_matrix_init (&mat,
+ native_matrix[0], native_matrix[1],
+ native_matrix[2], native_matrix[3],
+ native_matrix[4], native_matrix[5]);
+ cairo_set_matrix (gr->cr, &mat);
}
(*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0);
update_pattern_transform (gr);
+
gdk_threads_leave();
}
@@ -925,7 +1048,7 @@ install_font_peer(cairo_t *cr,
struct peerfont *pfont,
int debug)
{
- cairo_font_t *ft;
+ cairo_font_face_t *ft;
FT_Face face = NULL;
g_assert(cr != NULL);
@@ -936,7 +1059,7 @@ install_font_peer(cairo_t *cr,
face = pango_ft2_font_get_face (pfont->font);
g_assert (face != NULL);
- ft = cairo_ft_font_create_for_ft_face (face);
+ ft = cairo_ft_font_face_create_for_ft_face (face, 0);
g_assert (ft != NULL);
if (debug) printf ("install_font_peer made new cairo font for '%s' at %f\n",
@@ -944,19 +1067,19 @@ install_font_peer(cairo_t *cr,
(pango_font_description_get_size (pfont->desc) /
(double)PANGO_SCALE));
- cairo_set_font (cr, ft);
- cairo_font_destroy (ft);
- cairo_scale_font (cr,
+ cairo_set_font_face (cr, ft);
+ cairo_font_face_destroy (ft);
+ cairo_set_font_size (cr,
(pango_font_description_get_size (pfont->desc) /
(double)PANGO_SCALE));
- ft = cairo_current_font (cr);
+ ft = cairo_get_font_face (cr);
pfont->graphics_resource = ft;
}
else
{
if (debug) printf ("install_font_peer reused existing font resource\n");
- ft = (cairo_font_t *) pfont->graphics_resource;
- cairo_set_font (cr, ft);
+ ft = (cairo_font_face_t *) pfont->graphics_resource;
+ cairo_set_font_face (cr, ft);
}
}
@@ -967,16 +1090,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_releasePeerGraphicsResource
{
struct peerfont *pfont = NULL;
+ gdk_threads_enter();
+
g_assert(java_font != NULL);
- gdk_threads_enter();
pfont = (struct peerfont *) NSA_GET_FONT_PTR (env, java_font);
g_assert (pfont != NULL);
if (pfont->graphics_resource != NULL)
{
- cairo_font_destroy ((cairo_font_t *) pfont->graphics_resource);
+ cairo_font_face_destroy ((cairo_font_face_t *) pfont->graphics_resource);
pfont->graphics_resource = NULL;
}
+
gdk_threads_leave();
}
@@ -1053,12 +1178,17 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGlyphVector
float *native_positions;
jint i = 0;
+ gdk_threads_enter ();
+
g_assert (self != NULL);
g_assert (java_codes != NULL);
g_assert (java_positions != NULL);
- gdk_threads_enter ();
- if (peer_is_disposed(env, self)) { gdk_threads_leave(); return; }
+ if (peer_is_disposed(env, self))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *)NSA_GET_G2D_PTR (env, self);
g_assert (gr != NULL);
@@ -1068,7 +1198,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGlyphVector
install_font_peer(gr->cr, pfont, gr->debug);
- glyphs = malloc( sizeof(cairo_glyph_t) * n);
+ glyphs = g_malloc( sizeof(cairo_glyph_t) * n);
g_assert (glyphs != NULL);
native_codes = (*env)->GetIntArrayElements (env, java_codes, NULL);
@@ -1088,8 +1218,9 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGlyphVector
cairo_show_glyphs (gr->cr, glyphs, n);
end_drawing_operation (env, gr);
+ g_free(glyphs);
+
gdk_threads_leave ();
- free(glyphs);
}
JNIEXPORT void JNICALL
@@ -1108,6 +1239,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGdkTextLayout
cairo_glyph_t *glyphs = NULL;
gint n_glyphs = 0;
+ gdk_threads_enter ();
+
g_assert (self != NULL);
g_assert (java_layout != NULL);
@@ -1120,8 +1253,11 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGdkTextLayout
if (gr->debug) printf ("painting pango layout\n");
- gdk_threads_enter ();
- if (peer_is_disposed(env, self)) { gdk_threads_leave(); return; }
+ if (peer_is_disposed(env, self))
+ {
+ gdk_threads_leave();
+ return;
+ }
i = pango_layout_get_iter (tl->pango_layout);
g_assert (i != NULL);
@@ -1142,6 +1278,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGdkTextLayout
cairo_translate (gr->cr, -x, -y);
pango_layout_iter_free (i);
+
gdk_threads_leave ();
}
@@ -1152,7 +1289,12 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1164,7 +1306,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator
break;
case java_awt_alpha_composite_SRC:
- cairo_set_operator (gr->cr, CAIRO_OPERATOR_SRC);
+ cairo_set_operator (gr->cr, CAIRO_OPERATOR_SOURCE);
break;
case java_awt_alpha_composite_SRC_OVER:
@@ -1172,7 +1314,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator
break;
case java_awt_alpha_composite_DST_OVER:
- cairo_set_operator (gr->cr, CAIRO_OPERATOR_OVER_REVERSE);
+ cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_OVER);
break;
case java_awt_alpha_composite_SRC_IN:
@@ -1180,7 +1322,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator
break;
case java_awt_alpha_composite_DST_IN:
- cairo_set_operator (gr->cr, CAIRO_OPERATOR_IN_REVERSE);
+ cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_IN);
break;
case java_awt_alpha_composite_SRC_OUT:
@@ -1188,11 +1330,11 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator
break;
case java_awt_alpha_composite_DST_OUT:
- cairo_set_operator (gr->cr, CAIRO_OPERATOR_OUT_REVERSE);
+ cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_OUT);
break;
case java_awt_alpha_composite_DST:
- cairo_set_operator (gr->cr, CAIRO_OPERATOR_DST);
+ cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST);
break;
case java_awt_alpha_composite_SRC_ATOP:
@@ -1200,24 +1342,30 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator
break;
case java_awt_alpha_composite_DST_ATOP:
- cairo_set_operator (gr->cr, CAIRO_OPERATOR_ATOP_REVERSE);
+ cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_ATOP);
break;
case java_awt_alpha_composite_XOR:
cairo_set_operator (gr->cr, CAIRO_OPERATOR_XOR);
break;
}
+
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBColor
- (JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b)
+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();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave ();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1227,29 +1375,13 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBColor
draw to a PixBuf, you must exchange the R and B components of your
color. */
- if (gr->debug) printf ("cairo_set_rgb_color (%f, %f, %f)\n", r, g, b);
+ if (gr->debug) printf ("cairo_set_source_rgb (%f, %f, %f)\n", r, g, b);
if (gr->drawbuf)
- cairo_set_rgb_color (gr->cr, b, g, r);
+ cairo_set_source_rgba (gr->cr, b, g, r, a);
else
- cairo_set_rgb_color (gr->cr, r, g, b);
-
- gdk_threads_leave();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetAlpha
- (JNIEnv *env, jobject obj, jdouble a)
-{
- struct graphics2d *gr = NULL;
-
- gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+ cairo_set_source_rgba (gr->cr, r, g, b, a);
- gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
- g_assert (gr != NULL);
- if (gr->debug) printf ("cairo_set_alpha %f\n", a);
- cairo_set_alpha (gr->cr, a);
gdk_threads_leave();
}
@@ -1260,7 +1392,12 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
if (gr->debug) printf ("cairo_set_fill_rule %d\n", rule);
@@ -1274,6 +1411,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule
cairo_set_fill_rule (gr->cr, CAIRO_FILL_RULE_EVEN_ODD);
break;
}
+
gdk_threads_leave();
}
@@ -1284,12 +1422,15 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ return;
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_line_width %f\n", width);
cairo_set_line_width (gr->cr, width);
+
gdk_threads_leave();
}
@@ -1300,7 +1441,12 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave ();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1319,17 +1465,23 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap
cairo_set_line_cap (gr->cr, CAIRO_LINE_CAP_SQUARE);
break;
}
+
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
(JNIEnv *env, jobject obj, jint join)
{
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave ();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1348,6 +1500,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
cairo_set_line_join (gr->cr, CAIRO_LINE_JOIN_BEVEL);
break;
}
+
gdk_threads_leave();
}
@@ -1359,7 +1512,12 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash
jdouble *dasharr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave ();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1368,6 +1526,7 @@ 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);
+
gdk_threads_leave();
}
@@ -1378,16 +1537,21 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave ();
+ 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
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoNewPath
(JNIEnv *env, jobject obj)
@@ -1395,12 +1559,24 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoNewPath
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
- if (gr == NULL) { gdk_threads_leave (); return; }
+
+ if (gr == NULL)
+ {
+ gdk_threads_leave ();
+ return;
+ }
+
if (gr->debug) printf ("cairo_new_path\n");
cairo_new_path (gr->cr);
+
gdk_threads_leave();
}
@@ -1411,12 +1587,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoMoveTo
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_move_to (%f, %f)\n", x, y);
cairo_move_to (gr->cr, x, y);
+
gdk_threads_leave();
}
@@ -1427,12 +1609,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoLineTo
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_line_to (%f, %f)\n", x, y);
cairo_line_to (gr->cr, x, y);
+
gdk_threads_leave();
}
@@ -1443,12 +1631,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoCurveTo
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_curve_to (%f, %f), (%f, %f), (%f, %f)\n", x1, y1, x2, y2, x3, y3);
cairo_curve_to (gr->cr, x1, y1, x2, y2, x3, y3);
+
gdk_threads_leave();
}
@@ -1459,12 +1653,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRelMoveTo
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_rel_move_to (%f, %f)\n", dx, dy);
cairo_rel_move_to (gr->cr, dx, dy);
+
gdk_threads_leave();
}
@@ -1475,12 +1675,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRelLineTo
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_rel_line_to (%f, %f)\n", dx, dy);
cairo_rel_line_to (gr->cr, dx, dy);
+
gdk_threads_leave();
}
@@ -1491,12 +1697,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRelCurveTo
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_rel_curve_to (%f, %f), (%f, %f), (%f, %f)\n", dx1, dy1, dx2, dy2, dx3, dy3);
cairo_rel_curve_to (gr->cr, dx1, dy1, dx2, dy2, dx3, dy3);
+
gdk_threads_leave();
}
@@ -1507,12 +1719,24 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRectangle
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
- if (gr == NULL) { gdk_threads_leave (); return; }
+
+ if (gr == NULL)
+ {
+ gdk_threads_leave ();
+ return;
+ }
+
if (gr->debug) printf ("cairo_rectangle (%f, %f) (%f, %f)\n", x, y, width, height);
cairo_rectangle (gr->cr, x, y, width, height);
+
gdk_threads_leave();
}
@@ -1523,12 +1747,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoClosePath
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_close_path\n");
cairo_close_path (gr->cr);
+
gdk_threads_leave();
}
@@ -1539,7 +1769,12 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoStroke
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1547,6 +1782,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoStroke
begin_drawing_operation (env, gr);
cairo_stroke (gr->cr);
end_drawing_operation (env, gr);
+
gdk_threads_leave();
}
@@ -1557,7 +1793,12 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoFill
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1565,6 +1806,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoFill
begin_drawing_operation (env, gr);
cairo_fill (gr->cr);
end_drawing_operation (env, gr);
+
gdk_threads_leave();
}
@@ -1575,15 +1817,27 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoClip
struct graphics2d *gr = NULL;
gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
- if (gr == NULL) { gdk_threads_leave (); return; }
+
+ if (gr == NULL)
+ {
+ gdk_threads_leave ();
+ return;
+ }
+
if (gr->debug) printf ("cairo_clip\n");
begin_drawing_operation (env, gr);
- cairo_init_clip (gr->cr);
+ cairo_reset_clip (gr->cr);
cairo_clip (gr->cr);
end_drawing_operation (env, gr);
+
gdk_threads_leave();
}
@@ -1591,31 +1845,37 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter
(JNIEnv *env, jobject obj, jint filter)
{
- struct graphics2d *gr = NULL;
+ struct graphics2d *gr = NULL;
+
+ gdk_threads_enter();
+
+ if (peer_is_disposed(env, obj))
+ {
+ gdk_threads_leave ();
+ return;
+ }
+
+ gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
+ g_assert (gr != NULL);
+ if (gr->debug) printf ("cairo_surface_set_filter %d\n", filter);
+ switch ((enum java_awt_rendering_hints_filter) filter)
+ {
+ case java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR:
+ cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_NEAREST);
+ break;
+ case java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR:
+ cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BILINEAR);
+ break;
+ case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED:
+ cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_FAST);
+ break;
+ case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT:
+ cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_NEAREST);
+ break;
+ case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY:
+ cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BEST);
+ break;
+ }
- gdk_threads_enter();
- if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
-
- gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
- g_assert (gr != NULL);
- if (gr->debug) printf ("cairo_surface_set_filter %d\n", filter);
- switch ((enum java_awt_rendering_hints_filter) filter)
- {
- case java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR:
- cairo_surface_set_filter (gr->surface, CAIRO_FILTER_NEAREST);
- break;
- case java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR:
- cairo_surface_set_filter (gr->surface, CAIRO_FILTER_BILINEAR);
- break;
- case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED:
- cairo_surface_set_filter (gr->surface, CAIRO_FILTER_FAST);
- break;
- case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT:
- cairo_surface_set_filter (gr->surface, CAIRO_FILTER_NEAREST);
- break;
- case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY:
- cairo_surface_set_filter (gr->surface, CAIRO_FILTER_BEST);
- break;
- }
gdk_threads_leave();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
index 578acf601..0467c3c7a 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
@@ -15,8 +15,8 @@
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.
+ 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
@@ -52,9 +52,10 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetFontFamilies
(JNIEnv *env, jobject self __attribute__((unused)), jobjectArray family_name)
{
- PangoContext *context;
- PangoFontFamily **families;
- int n_families, idx;
+ PangoContext *context = NULL;
+ PangoFontFamily **families = NULL;
+ int n_families = 0;
+ int idx = 0;
gdk_threads_enter ();
@@ -72,6 +73,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetFontFamilies
(*env)->SetObjectArrayElement (env, family_name, idx, name);
}
g_free (families);
+
gdk_threads_leave ();
}
@@ -79,10 +81,10 @@ JNIEXPORT jint JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetNumFontFamilies
(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)))
{
- PangoContext *context;
- PangoFontFamily **families;
- gint n_families;
- jint num;
+ PangoContext *context = NULL;
+ PangoFontFamily **families = NULL;
+ gint n_families = 0;
+ gint num = 0;
gdk_threads_enter ();
@@ -93,6 +95,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetNumFontFamilies
num = n_families;
g_free (families);
+
gdk_threads_leave ();
return num;
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
index ab640455c..648cd6603 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
@@ -1,5 +1,5 @@
/* gdkpixbufdecoder.c
- Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@
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.
+ 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
@@ -41,13 +41,26 @@
#include <gdk-pixbuf/gdk-pixbuf-loader.h>
#include <jni.h>
+#include <jcl.h>
#include "native_state.h"
#include "gnu_java_awt_peer_gtk_GdkPixbufDecoder.h"
#include <string.h>
#include <stdlib.h>
-struct state_table *native_pixbufdecoder_state_table;
+static struct state_table *native_pixbufdecoder_state_table;
+
+#define NSA_PB_INIT(env, clazz) \
+ native_pixbufdecoder_state_table = cp_gtk_init_state_table (env, clazz)
+
+#define NSA_GET_PB_PTR(env, obj) \
+ cp_gtk_get_state (env, obj, native_pixbufdecoder_state_table)
+
+#define NSA_SET_PB_PTR(env, obj, ptr) \
+ cp_gtk_set_state (env, obj, native_pixbufdecoder_state_table, (void *)ptr)
+
+#define NSA_DEL_PB_PTR(env, obj) \
+ cp_gtk_remove_state_slot (env, obj, native_pixbufdecoder_state_table)
/* Union used for type punning. */
union env_union
@@ -64,26 +77,28 @@ static jmethodID dataOutputWriteID;
static jmethodID registerFormatID;
static void
-area_prepared (GdkPixbufLoader *loader,
+area_prepared_cb (GdkPixbufLoader *loader,
jobject *decoder)
{
- JNIEnv *env;
+ JNIEnv *env = NULL;
union env_union e;
- jint width, height;
+ jint width = 0;
+ jint height = 0;
+ GdkPixbuf *pixbuf = NULL;
- GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
- if (pixbuf == NULL)
- return;
+ pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+ g_assert (pixbuf != NULL);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
- gdk_threads_leave ();
-
g_assert (decoder != NULL);
e.jni_env = &env;
(*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1);
+
+ gdk_threads_leave ();
+
(*env)->CallVoidMethod (env,
*decoder,
areaPreparedID,
@@ -93,7 +108,7 @@ area_prepared (GdkPixbufLoader *loader,
}
static void
-area_updated (GdkPixbufLoader *loader,
+area_updated_cb (GdkPixbufLoader *loader,
gint x, gint y,
gint width, gint height,
jobject *decoder)
@@ -127,7 +142,13 @@ area_updated (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,
@@ -147,6 +168,7 @@ area_updated (GdkPixbufLoader *loader,
gdk_threads_leave ();
(*env)->ReleaseIntArrayElements (env, jpixels, java_pixels, 0);
+
(*env)->CallVoidMethod (env,
*decoder,
areaUpdatedID,
@@ -154,12 +176,14 @@ area_updated (GdkPixbufLoader *loader,
(jint) width, (jint) height,
jpixels,
stride_pixels);
+
(*env)->DeleteLocalRef(env, jpixels);
+
gdk_threads_enter ();
}
static void
-closed (GdkPixbufLoader *loader __attribute__((unused)), jobject *decoder)
+closed_cb (GdkPixbufLoader *loader __attribute__((unused)), jobject *decoder)
{
JNIEnv *env;
union env_union e;
@@ -167,8 +191,10 @@ closed (GdkPixbufLoader *loader __attribute__((unused)), jobject *decoder)
(*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1);
gdk_threads_leave ();
+
(*env)->DeleteGlobalRef (env, *decoder);
- free (decoder);
+ g_free (decoder);
+
gdk_threads_enter ();
}
@@ -181,19 +207,21 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_initState
GdkPixbufLoader *loader = NULL;
jobject *decoder = NULL;
- decoder = (jobject *) malloc (sizeof (jobject));
+ gdk_threads_enter ();
+
+ decoder = (jobject *) g_malloc (sizeof (jobject));
g_assert (decoder != NULL);
*decoder = (*env)->NewGlobalRef (env, obj);
- gdk_threads_enter ();
loader = gdk_pixbuf_loader_new ();
g_assert (loader != NULL);
- g_signal_connect (loader, "area-prepared", G_CALLBACK (area_prepared), decoder);
- g_signal_connect (loader, "area-updated", G_CALLBACK (area_updated), decoder);
- g_signal_connect (loader, "closed", G_CALLBACK (closed), decoder);
- gdk_threads_leave ();
+ g_signal_connect (loader, "area-prepared", G_CALLBACK (area_prepared_cb), decoder);
+ g_signal_connect (loader, "area-updated", G_CALLBACK (area_updated_cb), decoder);
+ g_signal_connect (loader, "closed", G_CALLBACK (closed_cb), decoder);
NSA_SET_PB_PTR (env, obj, loader);
+
+ gdk_threads_leave ();
}
static void
@@ -299,20 +327,46 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_initStaticState
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_finish
- (JNIEnv *env, jobject obj)
+(JNIEnv *env, jobject obj, jboolean needs_close)
{
GdkPixbufLoader *loader = NULL;
+ gdk_threads_enter ();
+
loader = (GdkPixbufLoader *)NSA_DEL_PB_PTR (env, obj);
if (loader == NULL)
return;
- gdk_threads_enter ();
- gdk_pixbuf_loader_close (loader, NULL);
+ if (needs_close)
+ gdk_pixbuf_loader_close (loader, NULL);
g_object_unref (loader);
+
gdk_threads_leave ();
}
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_pumpDone
+(JNIEnv *env, jobject obj)
+{
+ GError *err = NULL;
+ GdkPixbufLoader *loader = NULL;
+
+ gdk_threads_enter ();
+
+ loader = (GdkPixbufLoader *)NSA_GET_PB_PTR (env, obj);
+ g_assert (loader != NULL);
+
+ gdk_pixbuf_loader_close (loader, &err);
+
+ if (err != NULL)
+ {
+ JCL_ThrowException (env, "java/io/IOException", err->message);
+ g_error_free (err);
+ }
+
+ gdk_threads_leave ();
+}
+
struct stream_save_request
{
JNIEnv *env;
@@ -331,13 +385,16 @@ save_to_stream(const gchar *buf,
jbyte *cbuf;
gdk_threads_leave ();
+
jbuf = (*(ssr->env))->NewByteArray ((ssr->env), count);
cbuf = (*(ssr->env))->GetByteArrayElements ((ssr->env), jbuf, NULL);
memcpy (cbuf, buf, count);
(*(ssr->env))->ReleaseByteArrayElements ((ssr->env), jbuf, cbuf, 0);
(*(ssr->env))->CallVoidMethod ((ssr->env), *(ssr->stream),
dataOutputWriteID, jbuf);
+
gdk_threads_enter ();
+
return TRUE;
}
@@ -354,8 +411,10 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_streamImage
GError *err = NULL;
const char *enctype;
int i;
-
struct stream_save_request ssr;
+
+ gdk_threads_enter ();
+
ssr.stream = &stream;
ssr.env = env;
@@ -399,7 +458,6 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_streamImage
*p++ = a;
}
- gdk_threads_enter ();
pixbuf = gdk_pixbuf_new_from_data (pix,
GDK_COLORSPACE_RGB,
(gboolean) hasAlpha,
@@ -416,31 +474,42 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_streamImage
g_object_unref (pixbuf);
- gdk_threads_leave ();
g_free(pix);
(*env)->ReleaseStringUTFChars (env, jenctype, enctype);
(*env)->ReleaseIntArrayElements (env, jarr, ints, 0);
+
+ gdk_threads_leave ();
}
+
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_pumpBytes
(JNIEnv *env, jobject obj, jbyteArray jarr, jint len)
{
GdkPixbufLoader *loader = NULL;
jbyte *bytes = NULL;
+ GError *err = NULL;
- if (len < 1)
- return;
+ gdk_threads_enter ();
+
+ g_assert (len >= 1);
+ g_assert (jarr != NULL);
bytes = (*env)->GetByteArrayElements (env, jarr, NULL);
g_assert (bytes != NULL);
loader = (GdkPixbufLoader *)NSA_GET_PB_PTR (env, obj);
g_assert (loader != NULL);
- gdk_threads_enter ();
- gdk_pixbuf_loader_write (loader, (const guchar *) bytes, len, NULL);
- gdk_threads_leave ();
+ gdk_pixbuf_loader_write (loader, (const guchar *) bytes, len, &err);
(*env)->ReleaseByteArrayElements (env, jarr, bytes, 0);
+
+ if (err != NULL)
+ {
+ JCL_ThrowException (env, "java/io/IOException", err->message);
+ g_error_free (err);
+ }
+
+ gdk_threads_leave ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c
index 6b1b4a9f3..8c0ac6ce3 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -102,6 +102,7 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mouseMove
x, y, CurrentTime);
XFlush (xdisplay);
+
gdk_threads_leave ();
}
@@ -123,6 +124,7 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mousePress
True, CurrentTime);
XFlush (xdisplay);
+
gdk_threads_leave ();
}
@@ -144,6 +146,7 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mouseRelease
False, CurrentTime);
XFlush (xdisplay);
+
gdk_threads_leave ();
}
@@ -182,6 +185,7 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mouseWheel
}
XFlush (xdisplay);
+
gdk_threads_leave ();
}
@@ -201,7 +205,8 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyPress
display = gdk_display_get_default ();
xdisplay = GDK_DISPLAY_XDISPLAY (display);
- lookup_keyval = awt_keycode_to_keysym (keycode, AWT_KEY_LOCATION_LEFT);
+ lookup_keyval = cp_gtk_awt_keycode_to_keysym (keycode,
+ AWT_KEY_LOCATION_LEFT);
if (!gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default (),
lookup_keyval,
@@ -225,6 +230,7 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyPress
g_free (keymap_keys);
XFlush (xdisplay);
+
gdk_threads_leave ();
}
@@ -244,7 +250,8 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyRelease
display = gdk_display_get_default ();
xdisplay = GDK_DISPLAY_XDISPLAY (display);
- lookup_keyval = awt_keycode_to_keysym (keycode, AWT_KEY_LOCATION_LEFT);
+ lookup_keyval = cp_gtk_awt_keycode_to_keysym (keycode,
+ AWT_KEY_LOCATION_LEFT);
if (!gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default (),
lookup_keyval,
@@ -268,6 +275,7 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyRelease
g_free (keymap_keys);
XFlush (xdisplay);
+
gdk_threads_leave ();
}
@@ -303,7 +311,12 @@ 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/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
index d09d155b4..918ecfd0a 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
@@ -15,8 +15,8 @@
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.
+ 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
@@ -42,7 +42,7 @@
#include "gdkfont.h"
#include "gnu_java_awt_peer_gtk_GdkTextLayout.h"
-struct state_table *native_text_layout_state_table;
+struct state_table *cp_gtk_native_text_layout_state_table;
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkTextLayout_initStaticState
@@ -58,12 +58,14 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_initState
struct textlayout *tl;
gdk_threads_enter ();
+
g_assert(self != NULL);
tl = g_malloc0 (sizeof (struct textlayout));
g_assert(tl != NULL);
tl->pango_layout = pango_layout_new(gdk_pango_context_get());
g_assert(tl->pango_layout != NULL);
NSA_SET_TEXT_LAYOUT_PTR (env, self, tl);
+
gdk_threads_leave ();
}
@@ -76,6 +78,7 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_setText
gint len = 0;
gdk_threads_enter ();
+
g_assert(self != NULL);
g_assert(text != NULL);
@@ -90,6 +93,7 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_setText
pango_layout_set_text (tl->pango_layout, text, len);
(*env)->ReleaseStringUTFChars (env, text, str);
+
gdk_threads_leave ();
}
@@ -102,6 +106,7 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_indexToPos
jdouble *nativePos;
gdk_threads_enter ();
+
g_assert(self != NULL);
g_assert(javaPos != NULL);
@@ -121,6 +126,7 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_indexToPos
nativePos[3] = (jdouble) pangoPos.height;
(*env)->ReleaseDoubleArrayElements (env, javaPos, nativePos, 0);
+
gdk_threads_leave ();
}
@@ -133,6 +139,7 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_getExtents
jdouble *nativeInkExtents, *nativeLogExtents;
gdk_threads_enter ();
+
g_assert(self != NULL);
g_assert(javaInkExtents != NULL);
g_assert(javaLogExtents != NULL);
@@ -173,11 +180,13 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_dispose
struct textlayout *tl;
gdk_threads_enter ();
+
g_assert(self != NULL);
tl = (struct textlayout *) NSA_DEL_TEXT_LAYOUT_PTR (env, self);
g_assert(tl != NULL);
if (tl->pango_layout != NULL)
g_object_unref (tl->pango_layout);
g_free(tl);
+
gdk_threads_leave ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
index 94e98bf96..5e8ab26c3 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -39,15 +39,27 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkButtonPeer.h"
-static gboolean focus_in_cb (GtkWidget *widget,
- GdkEventFocus *event,
- jobject peer);
-static gboolean focus_out_cb (GtkWidget *widget,
- GdkEventFocus *event,
- jobject peer);
+static jmethodID beginNativeRepaintID;
+static jmethodID endNativeRepaintID;
+
+void
+cp_gtk_button_init_jni (void)
+{
+ jclass gtkbuttonpeer;
+
+ 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");
+}
-static void block_expose_events_cb (GtkWidget *widget,
- jobject peer);
+static void block_expose_event_cb (GtkWidget *widget,
+ jobject peer);
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkButtonPeer_create
@@ -57,21 +69,21 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_create
GtkWidget *eventbox;
GtkWidget *button;
+ gdk_threads_enter ();
+
NSA_SET_GLOBAL_REF (env, obj);
c_label = (*env)->GetStringUTFChars (env, label, NULL);
- gdk_threads_enter ();
-
eventbox = gtk_event_box_new ();
button = gtk_button_new_with_label (c_label);
gtk_container_add (GTK_CONTAINER (eventbox), button);
gtk_widget_show (button);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, label, c_label);
NSA_SET_PTR (env, obj, eventbox);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -82,30 +94,22 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_connectSignals
jobject *gref;
GtkWidget *button;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
gref = NSA_GET_GLOBAL_REF (env, obj);
- gdk_threads_enter ();
-
button = gtk_bin_get_child (GTK_BIN (ptr));
- g_signal_connect (G_OBJECT (ptr), "event",
- G_CALLBACK (pre_event_handler), *gref);
-
- g_signal_connect (G_OBJECT (button), "event",
- G_CALLBACK (pre_event_handler), *gref);
-
- g_signal_connect (G_OBJECT (button), "focus-in-event",
- G_CALLBACK (focus_in_cb), *gref);
-
- g_signal_connect (G_OBJECT (button), "focus-out-event",
- G_CALLBACK (focus_out_cb), *gref);
-
+ /* Button signals */
g_signal_connect_after (G_OBJECT (button), "pressed",
- G_CALLBACK (block_expose_events_cb), *gref);
+ G_CALLBACK (block_expose_event_cb), *gref);
g_signal_connect_after (G_OBJECT (button), "released",
- G_CALLBACK (block_expose_events_cb), *gref);
+ G_CALLBACK (block_expose_event_cb), *gref);
+
+ /* Component signals */
+ cp_gtk_component_connect_signals (G_OBJECT (button), gref);
gdk_threads_leave ();
}
@@ -119,19 +123,19 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkSetLabel
GtkWidget *label;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
text = (*env)->GetStringUTFChars (env, jtext, NULL);
- gdk_threads_enter ();
-
button = gtk_bin_get_child (GTK_BIN (ptr));
label = gtk_bin_get_child (GTK_BIN (button));
gtk_label_set_text (GTK_LABEL (label), text);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, jtext, text);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -144,17 +148,18 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetModifyFont
GtkWidget *label;
PangoFontDescription *font_desc;
+ gdk_threads_enter();
+
ptr = NSA_GET_PTR (env, obj);
font_name = (*env)->GetStringUTFChars (env, name, NULL);
- gdk_threads_enter();
-
button = gtk_bin_get_child (GTK_BIN (ptr));
label = gtk_bin_get_child (GTK_BIN (button));
font_desc = pango_font_description_from_string (font_name);
- pango_font_description_set_size (font_desc, size * dpi_conversion_factor);
+ pango_font_description_set_size (font_desc,
+ size * cp_gtk_dpi_conversion_factor);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
@@ -166,9 +171,9 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetModifyFont
pango_font_description_free (font_desc);
- gdk_threads_leave();
-
(*env)->ReleaseStringUTFChars (env, name, font_name);
+
+ gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -184,6 +189,8 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetSetBackground
GtkWidget *button;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
normal_color.red = (red / 255.0) * 65535;
@@ -205,8 +212,6 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetSetBackground
prelight_color.green = prelight_green > 65535 ? 65535 : prelight_green;
prelight_color.blue = prelight_blue > 65535 ? 65535 : prelight_blue;
- gdk_threads_enter ();
-
button = gtk_bin_get_child (GTK_BIN (ptr));
gtk_widget_modify_bg (button, GTK_STATE_NORMAL, &normal_color);
@@ -225,14 +230,14 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetSetForeground
GtkWidget *label;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
color.red = (red / 255.0) * 65535;
color.green = (green / 255.0) * 65535;
color.blue = (blue / 255.0) * 65535;
- gdk_threads_enter ();
-
button = gtk_bin_get_child (GTK_BIN (ptr));
label = gtk_bin_get_child (GTK_BIN (button));
@@ -250,10 +255,10 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkActivate
GtkWidget *button;
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
button = gtk_bin_get_child (GTK_BIN (ptr));
gtk_widget_activate (GTK_WIDGET (button));
@@ -267,11 +272,13 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetRequestFocus
void *ptr;
GtkWidget *button;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
button = gtk_bin_get_child (GTK_BIN (ptr));
gtk_widget_grab_focus (button);
+
gdk_threads_leave ();
}
@@ -282,10 +289,10 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_setNativeBounds
GtkWidget *widget, *child;
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
widget = GTK_WIDGET (ptr);
/* We assume that -1 is a width or height and not a request for the
@@ -310,46 +317,22 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_setNativeBounds
gdk_threads_leave ();
}
-static gboolean
-focus_in_cb (GtkWidget *widget __attribute((unused)),
- GdkEventFocus *event __attribute((unused)),
- jobject peer)
+static void
+block_expose_event_cb (GtkWidget *widget, jobject peer)
{
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postFocusEventID,
- AWT_FOCUS_GAINED,
- JNI_FALSE);
- gdk_threads_enter ();
- return FALSE;
-}
-static gboolean
-focus_out_cb (GtkWidget *widget __attribute((unused)),
- GdkEventFocus *event __attribute((unused)),
- jobject peer)
-{
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postFocusEventID,
- AWT_FOCUS_LOST,
- JNI_FALSE);
- gdk_threads_enter ();
- return FALSE;
-}
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
+ beginNativeRepaintID);
-static void
-block_expose_events_cb (GtkWidget *widget, jobject peer)
-{
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- beginNativeRepaintID);
gdk_threads_enter ();
gdk_window_process_updates (widget->window, TRUE);
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
endNativeRepaintID);
+
gdk_threads_enter ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
index 63dd94416..52922ddb8 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -45,16 +45,14 @@ Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_create
{
gpointer widget;
+ gdk_threads_enter ();
+
/* Create global reference and save it for future use */
NSA_SET_GLOBAL_REF (env, obj);
- gdk_threads_enter ();
-
widget = gtk_type_new (gtk_drawing_area_get_type ());
- gdk_threads_leave ();
-
NSA_SET_PTR (env, obj, widget);
-}
-
+ gdk_threads_leave ();
+}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c
index 90923fe3b..4f2875092 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -56,8 +56,9 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_remove
void *ptr;
GSList *list;
- ptr = NSA_GET_PTR (env, checkbox);
gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, checkbox);
button = GTK_RADIO_BUTTON (ptr);
/* Update the group to point to some other widget in the group. We
@@ -70,8 +71,7 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_remove
break;
}
- gdk_threads_leave ();
-
NSA_SET_PTR (env, obj, list ? list->data : NULL);
-}
+ gdk_threads_leave ();
+}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c
index ade743023..77836cedd 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -46,20 +46,20 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer_create
GtkWidget *widget;
const char *str;
+ gdk_threads_enter ();
+
NSA_SET_GLOBAL_REF (env, obj);
str = (*env)->GetStringUTFChars (env, label, NULL);
- gdk_threads_enter ();
-
widget = gtk_check_menu_item_new_with_label (str);
gtk_widget_show (widget);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, label, str);
NSA_SET_PTR (env, obj, widget);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -68,9 +68,11 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer_setState
{
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (ptr), state);
+
gdk_threads_leave ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
index 6c854eff8..cf883dd33 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -40,7 +40,22 @@ exception statement from your version. */
#include "gnu_java_awt_peer_gtk_GtkCheckboxPeer.h"
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
-static void item_toggled (GtkToggleButton *item, jobject peer);
+static jmethodID postItemEventID;
+
+void
+cp_gtk_checkbox_init_jni (void)
+{
+ jclass gtkcheckboxpeer;
+
+ gtkcheckboxpeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
+ "gnu/java/awt/peer/gtk/GtkCheckboxPeer");
+
+ postItemEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcheckboxpeer,
+ "postItemEvent",
+ "(Ljava/lang/Object;I)V");
+}
+
+static void item_toggled_cb (GtkToggleButton *item, jobject peer);
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_create
@@ -48,10 +63,10 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_create
{
GtkWidget *button;
- NSA_SET_GLOBAL_REF (env, obj);
-
gdk_threads_enter ();
+ NSA_SET_GLOBAL_REF (env, obj);
+
if (group == NULL)
button = gtk_check_button_new_with_label ("");
else
@@ -66,28 +81,31 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_create
}
}
- gdk_threads_leave ();
-
NSA_SET_PTR (env, obj, button);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_connectSignals
(JNIEnv *env, jobject obj)
{
- void *ptr = NSA_GET_PTR (env, obj);
- jobject *gref = NSA_GET_GLOBAL_REF (env, obj);
- g_assert (gref);
+ void *ptr = NULL;
+ jobject *gref = NULL;
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+ gref = NSA_GET_GLOBAL_REF (env, obj);
+
+ /* Checkbox signals */
g_signal_connect (G_OBJECT (ptr), "toggled",
- GTK_SIGNAL_FUNC (item_toggled), *gref);
+ G_CALLBACK (item_toggled_cb), *gref);
- gdk_threads_leave ();
+ /* Component signals */
+ cp_gtk_component_connect_signals (G_OBJECT (ptr), gref);
- /* Connect the superclass signals. */
- Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env, obj);
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -97,10 +115,10 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup
GtkRadioButton *button;
void *native_group, *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
/* FIXME: we can't yet switch between a checkbutton and a
radiobutton. However, AWT requires this. For now we just
crash. */
@@ -115,8 +133,6 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup
gtk_radio_button_group
(GTK_RADIO_BUTTON (native_group)));
- gdk_threads_leave ();
-
/* If the native group wasn't set on the new CheckboxGroup, then set
it now so that the right thing will happen with the next
radiobutton. The native state for a CheckboxGroup is a pointer
@@ -126,6 +142,8 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup
notified. */
if (native_group == NULL)
NSA_SET_PTR (env, group, native_group);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -134,10 +152,10 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkToggleButtonSetActive
{
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ptr), is_active);
gdk_threads_leave ();
@@ -153,20 +171,21 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkWidgetModifyFont
GtkWidget *label;
PangoFontDescription *font_desc;
+ gdk_threads_enter();
+
ptr = NSA_GET_PTR (env, obj);
button = GTK_WIDGET (ptr);
label = gtk_bin_get_child (GTK_BIN(button));
if (!label)
- return;
+ return;
font_name = (*env)->GetStringUTFChars (env, name, NULL);
- gdk_threads_enter();
-
font_desc = pango_font_description_from_string (font_name);
- pango_font_description_set_size (font_desc, size * dpi_conversion_factor);
+ pango_font_description_set_size (font_desc,
+ size * cp_gtk_dpi_conversion_factor);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
@@ -178,9 +197,9 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkWidgetModifyFont
pango_font_description_free (font_desc);
- gdk_threads_leave();
-
(*env)->ReleaseStringUTFChars (env, name, font_name);
+
+ gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -191,27 +210,31 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkButtonSetLabel
GtkWidget *label_widget;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
c_label = (*env)->GetStringUTFChars (env, label, NULL);
- gdk_threads_enter ();
-
label_widget = gtk_bin_get_child (GTK_BIN (ptr));
gtk_label_set_text (GTK_LABEL (label_widget), c_label);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, label, c_label);
+
+ gdk_threads_leave ();
}
static void
-item_toggled (GtkToggleButton *item, jobject peer)
+item_toggled_cb (GtkToggleButton *item, jobject peer)
{
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postItemEventID,
- peer,
- item->active ?
- (jint) AWT_ITEM_SELECTED :
- (jint) AWT_ITEM_DESELECTED);
+ 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/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
index b4e64e62d..ed9df5433 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -39,7 +39,22 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkChoicePeer.h"
-static void selection_changed (GtkComboBox *combobox, jobject peer);
+static jmethodID postChoiceItemEventID;
+
+void
+cp_gtk_choice_init_jni (void)
+{
+ jclass gtkchoicepeer;
+
+ gtkchoicepeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
+ "gnu/java/awt/peer/gtk/GtkChoicePeer");
+
+ postChoiceItemEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkchoicepeer,
+ "postChoiceItemEvent",
+ "(Ljava/lang/String;I)V");
+}
+
+static void selection_changed_cb (GtkComboBox *combobox, jobject peer);
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkChoicePeer_create
@@ -48,19 +63,38 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_create
GtkWidget *combobox;
jobject *gref;
+ gdk_threads_enter ();
+
NSA_SET_GLOBAL_REF (env, obj);
gref = NSA_GET_GLOBAL_REF (env, obj);
- gdk_threads_enter ();
-
combobox = gtk_combo_box_new_text ();
- g_signal_connect (combobox, "changed",
- G_CALLBACK (selection_changed), *gref);
+ NSA_SET_PTR (env, obj, combobox);
gdk_threads_leave ();
+}
- NSA_SET_PTR (env, obj, combobox);
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkChoicePeer_connectSignals
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr = NULL;
+ jobject *gref = NULL;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+ gref = NSA_GET_GLOBAL_REF (env, obj);
+
+ /* Choice signals */
+ g_signal_connect (G_OBJECT (ptr), "changed",
+ G_CALLBACK (selection_changed_cb), *gref);
+
+ /* Component signals */
+ cp_gtk_component_connect_signals (G_OBJECT (ptr), gref);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -70,10 +104,10 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_append
gpointer ptr;
jsize count, i;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
count = (*env)->GetArrayLength (env, items);
for (i = 0; i < count; i++)
@@ -99,15 +133,17 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeAdd
void *ptr;
const char *label;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
label = (*env)->GetStringUTFChars (env, item, 0);
- gdk_threads_enter ();
gtk_combo_box_insert_text (GTK_COMBO_BOX (ptr), index, label);
- gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, item, label);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -116,10 +152,12 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeRemove
{
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
gtk_combo_box_remove_text (GTK_COMBO_BOX (ptr), index);
+
gdk_threads_leave ();
}
@@ -131,10 +169,10 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeRemoveAll
GtkTreeModel *model;
gint count, i;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
model = gtk_combo_box_get_model (GTK_COMBO_BOX (ptr));
count = gtk_tree_model_iter_n_children (model, NULL);
@@ -154,10 +192,12 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_select
{
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
gtk_combo_box_set_active (GTK_COMBO_BOX (ptr), index);
+
gdk_threads_leave ();
}
@@ -168,16 +208,18 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeGetSelected
void *ptr;
int index;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
index = gtk_combo_box_get_active (GTK_COMBO_BOX (ptr));
+
gdk_threads_leave ();
return index;
}
-static void selection_changed (GtkComboBox *combobox, jobject peer)
+static void selection_changed_cb (GtkComboBox *combobox, jobject peer)
{
jstring label;
GtkTreeModel *model;
@@ -190,18 +232,17 @@ static void selection_changed (GtkComboBox *combobox, jobject peer)
if (index >= 0)
{
model = gtk_combo_box_get_model (combobox);
-
gtk_combo_box_get_active_iter (combobox, &iter);
-
gtk_tree_model_get (model, &iter, 0, &selected, -1);
+ label = (*cp_gtk_gdk_env())->NewStringUTF (cp_gtk_gdk_env(), selected);
gdk_threads_leave ();
- label = (*gdk_env())->NewStringUTF (gdk_env(), selected);
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- choicePostItemEventID,
- label,
- (jint) AWT_ITEM_SELECTED);
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
+ postChoiceItemEventID,
+ label,
+ (jint) AWT_ITEM_SELECTED);
+
gdk_threads_enter ();
}
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
index e05185790..dea9d4cc7 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -39,21 +39,25 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkClipboard.h"
-jmethodID stringSelectionReceivedID;
-jmethodID stringSelectionHandlerID;
-jmethodID selectionClearID;
+static jmethodID stringSelectionReceivedID;
+static jmethodID stringSelectionHandlerID;
+static jmethodID selectionClearID;
-void selection_received (GtkWidget *, GtkSelectionData *, guint, gpointer);
-void selection_get (GtkWidget *, GtkSelectionData *, guint, guint, gpointer);
-gint selection_clear (GtkWidget *, GdkEventSelection *);
+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 *);
-GtkWidget *clipboard;
-jobject cb_obj;
+static GtkWidget *clipboard;
+static jobject cb_obj;
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env,
jobject obj)
{
+ gdk_threads_enter ();
+
if (!stringSelectionReceivedID)
{
jclass gtkclipboard;
@@ -72,20 +76,19 @@ Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env,
cb_obj = (*env)->NewGlobalRef (env, obj);
- gdk_threads_enter ();
clipboard = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT(clipboard), "selection_received",
- GTK_SIGNAL_FUNC (selection_received), NULL);
+ G_CALLBACK (selection_received_cb), NULL);
g_signal_connect (G_OBJECT(clipboard), "selection_clear_event",
- GTK_SIGNAL_FUNC (selection_clear), NULL);
+ G_CALLBACK (selection_clear_cb), NULL);
gtk_selection_add_target (clipboard, GDK_SELECTION_PRIMARY,
GDK_TARGET_STRING, 0);
g_signal_connect (G_OBJECT(clipboard), "selection_get",
- GTK_SIGNAL_FUNC (selection_get), NULL);
+ G_CALLBACK (selection_get_cb), NULL);
gdk_threads_leave ();
}
@@ -95,49 +98,63 @@ Java_gnu_java_awt_peer_gtk_GtkClipboard_requestStringConversion
(JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)))
{
gdk_threads_enter ();
+
gtk_selection_convert (clipboard, GDK_SELECTION_PRIMARY,
GDK_TARGET_STRING, GDK_CURRENT_TIME);
+
gdk_threads_leave ();
}
-void
-selection_received (GtkWidget *widget __attribute__((unused)),
- GtkSelectionData *selection_data __attribute__((unused)),
- guint time __attribute__((unused)),
- gpointer data __attribute__((unused)))
+static void
+selection_received_cb (GtkWidget *widget __attribute__((unused)),
+ GtkSelectionData *selection_data __attribute__((unused)),
+ guint time __attribute__((unused)),
+ gpointer data __attribute__((unused)))
{
/* Check to see if retrieval succeeded */
if (selection_data->length < 0
|| selection_data->type != GDK_SELECTION_TYPE_STRING)
{
- (*gdk_env())->CallVoidMethod (gdk_env(), cb_obj, stringSelectionReceivedID,
+ gdk_threads_leave ();
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), cb_obj, stringSelectionReceivedID,
NULL);
+
+ gdk_threads_enter ();
}
else
{
char *str = (char *) selection_data->data;
- (*gdk_env())->CallVoidMethod (gdk_env(), cb_obj, stringSelectionReceivedID,
- (*gdk_env())->NewStringUTF (gdk_env(), str));
+ 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 ();
}
return;
}
-void
-selection_get (GtkWidget *widget __attribute__((unused)),
- GtkSelectionData *selection_data,
- guint info __attribute__((unused)),
- guint time __attribute__((unused)),
- gpointer data __attribute__((unused)))
+static void
+selection_get_cb (GtkWidget *widget __attribute__((unused)),
+ GtkSelectionData *selection_data,
+ guint info __attribute__((unused)),
+ guint time __attribute__((unused)),
+ gpointer data __attribute__((unused)))
{
jstring jstr;
const char *utf;
jsize utflen;
- jstr = (*gdk_env())->CallObjectMethod (gdk_env(), cb_obj,
+ gdk_threads_leave ();
+
+ jstr = (*cp_gtk_gdk_env())->CallObjectMethod (cp_gtk_gdk_env(), cb_obj,
stringSelectionHandlerID);
+ gdk_threads_enter ();
+
if (!jstr)
{
gtk_selection_data_set (selection_data,
@@ -145,13 +162,13 @@ selection_get (GtkWidget *widget __attribute__((unused)),
return;
}
- utflen = (*gdk_env())->GetStringUTFLength (gdk_env(), jstr);
- utf = (*gdk_env())->GetStringUTFChars (gdk_env(), jstr, NULL);
+ 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);
- (*gdk_env())->ReleaseStringUTFChars (gdk_env(), jstr, utf);
+ (*cp_gtk_gdk_env())->ReleaseStringUTFChars (cp_gtk_gdk_env(), jstr, utf);
}
JNIEXPORT void JNICALL
@@ -173,11 +190,15 @@ Java_gnu_java_awt_peer_gtk_GtkClipboard_selectionGet
gdk_threads_leave ();
}
-gint
-selection_clear (GtkWidget *widget __attribute__((unused)),
- GdkEventSelection *event __attribute__((unused)))
+static gint
+selection_clear_cb (GtkWidget *widget __attribute__((unused)),
+ GdkEventSelection *event __attribute__((unused)))
{
- (*gdk_env())->CallVoidMethod (gdk_env(), cb_obj, selectionClearID);
+ gdk_threads_leave ();
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), cb_obj, selectionClearID);
+
+ gdk_threads_enter ();
return TRUE;
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
index 4cd3f1657..bd9dde392 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -38,373 +38,148 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
+
#include <gtk/gtkprivate.h>
-#include <gdk/gdkkeysyms.h>
+
+#define AWT_DEFAULT_CURSOR 0
+#define AWT_CROSSHAIR_CURSOR 1
+#define AWT_TEXT_CURSOR 2
+#define AWT_WAIT_CURSOR 3
+#define AWT_SW_RESIZE_CURSOR 4
+#define AWT_SE_RESIZE_CURSOR 5
+#define AWT_NW_RESIZE_CURSOR 6
+#define AWT_NE_RESIZE_CURSOR 7
+#define AWT_N_RESIZE_CURSOR 8
+#define AWT_S_RESIZE_CURSOR 9
+#define AWT_W_RESIZE_CURSOR 10
+#define AWT_E_RESIZE_CURSOR 11
+#define AWT_HAND_CURSOR 12
+#define AWT_MOVE_CURSOR 13
+
+#define AWT_BUTTON1_DOWN_MASK (1 << 10)
+#define AWT_BUTTON2_DOWN_MASK (1 << 11)
+#define AWT_BUTTON3_DOWN_MASK (1 << 12)
+
+/* FIXME: use gtk-double-click-time, gtk-double-click-distance */
+#define MULTI_CLICK_TIME 250
+/* as opposed to a MULTI_PASS_TIME :) */
+
+#define AWT_MOUSE_CLICKED 500
+#define AWT_MOUSE_PRESSED 501
+#define AWT_MOUSE_RELEASED 502
+#define AWT_MOUSE_MOVED 503
+#define AWT_MOUSE_ENTERED 504
+#define AWT_MOUSE_EXITED 505
+#define AWT_MOUSE_DRAGGED 506
+
+#define AWT_FOCUS_GAINED 1004
+#define AWT_FOCUS_LOST 1005
static GtkWidget *find_fg_color_widget (GtkWidget *widget);
static GtkWidget *find_bg_color_widget (GtkWidget *widget);
-static gboolean focus_in_cb (GtkWidget *widget,
- GdkEventFocus *event,
- jobject peer);
-static gboolean focus_out_cb (GtkWidget *widget,
- GdkEventFocus *event,
- jobject peer);
-/*
- * This method returns a GDK keyval that corresponds to one of the
- * keysyms in the X keymap table. The return value is only used to
- * determine the keyval's corresponding hardware keycode, and doesn't
- * reflect an accurate translation of a Java virtual key value to a
- * GDK keyval.
- */
-#ifdef __GNUC__
-__inline
-#endif
-guint
-awt_keycode_to_keysym (jint keyCode, jint keyLocation)
-{
- /* GDK_A through GDK_Z */
- if (keyCode >= VK_A && keyCode <= VK_Z)
- return gdk_keyval_to_lower (keyCode);
+static jmethodID postMouseEventID;
+static jmethodID setCursorID;
+static jmethodID postExposeEventID;
+static jmethodID postFocusEventID;
+
+void
+cp_gtk_component_init_jni (void)
+ {
+ jclass gtkcomponentpeer;
+
+ gtkcomponentpeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
+ "gnu/java/awt/peer/gtk/GtkComponentPeer");
- /* GDK_0 through GDK_9 */
- if (keyCode >= VK_0 && keyCode <= VK_9)
- return keyCode;
+ postMouseEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcomponentpeer,
+ "postMouseEvent", "(IJIIIIZ)V");
- switch (keyCode)
+ setCursorID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcomponentpeer,
+ "setCursor", "()V");
+
+ postExposeEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcomponentpeer,
+ "postExposeEvent", "(IIII)V");
+
+ postFocusEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcomponentpeer,
+ "postFocusEvent", "(IZ)V");
+}
+
+static gboolean component_button_press_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ jobject peer);
+static gboolean component_button_release_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ jobject peer);
+static gboolean component_motion_notify_cb (GtkWidget *widget,
+ GdkEventMotion *event,
+ jobject peer);
+static gboolean component_enter_notify_cb (GtkWidget *widget,
+ GdkEventCrossing *event,
+ jobject peer);
+static gboolean component_leave_notify_cb (GtkWidget *widget,
+ GdkEventCrossing *event,
+ jobject peer);
+static gboolean component_expose_cb (GtkWidget *widget,
+ GdkEventExpose *event,
+ jobject peer);
+static gboolean component_focus_in_cb (GtkWidget *widget,
+ GdkEventFocus *event,
+ jobject peer);
+static gboolean component_focus_out_cb (GtkWidget *widget,
+ GdkEventFocus *event,
+ jobject peer);
+
+static jint
+button_to_awt_mods (int button)
+{
+ switch (button)
{
- case VK_ENTER:
- return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Enter : GDK_Return;
- case VK_BACK_SPACE:
- return GDK_BackSpace;
- case VK_TAB:
- return GDK_Tab;
- case VK_CANCEL:
- return GDK_Cancel;
- case VK_CLEAR:
- return GDK_Clear;
- case VK_SHIFT:
- return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Shift_L : GDK_Shift_R;
- case VK_CONTROL:
- return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Control_L : GDK_Control_R;
- case VK_ALT:
- return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Alt_L : GDK_Alt_R;
- case VK_PAUSE:
- return GDK_Pause;
- case VK_CAPS_LOCK:
- return GDK_Caps_Lock;
- case VK_ESCAPE:
- return GDK_Escape;
- case VK_SPACE:
- return GDK_space;
- case VK_PAGE_UP:
- return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Page_Up : GDK_Page_Up;
- case VK_PAGE_DOWN:
- return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Page_Down : GDK_Page_Down;
- case VK_END:
- return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_End : GDK_End;
- case VK_HOME:
- return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Home : GDK_Home;
- case VK_LEFT:
- return GDK_Left;
- case VK_UP:
- return GDK_Up;
- case VK_RIGHT:
- return GDK_Right;
- case VK_DOWN:
- return GDK_Down;
- case VK_COMMA:
- return GDK_comma;
- case VK_MINUS:
- return GDK_minus;
- case VK_PERIOD:
- return GDK_period;
- case VK_SLASH:
- return GDK_slash;
- /*
- case VK_0:
- case VK_1:
- case VK_2:
- case VK_3:
- case VK_4:
- case VK_5:
- case VK_6:
- case VK_7:
- case VK_8:
- case VK_9:
- */
- case VK_SEMICOLON:
- return GDK_semicolon;
- case VK_EQUALS:
- return GDK_equal;
- /*
- case VK_A:
- case VK_B:
- case VK_C:
- case VK_D:
- case VK_E:
- case VK_F:
- case VK_G:
- case VK_H:
- case VK_I:
- case VK_J:
- case VK_K:
- case VK_L:
- case VK_M:
- case VK_N:
- case VK_O:
- case VK_P:
- case VK_Q:
- case VK_R:
- case VK_S:
- case VK_T:
- case VK_U:
- case VK_V:
- case VK_W:
- case VK_X:
- case VK_Y:
- case VK_Z:
- */
- case VK_OPEN_BRACKET:
- return GDK_bracketleft;
- case VK_BACK_SLASH:
- return GDK_backslash;
- case VK_CLOSE_BRACKET:
- return GDK_bracketright;
- case VK_NUMPAD0:
- return GDK_KP_0;
- case VK_NUMPAD1:
- return GDK_KP_1;
- case VK_NUMPAD2:
- return GDK_KP_2;
- case VK_NUMPAD3:
- return GDK_KP_3;
- case VK_NUMPAD4:
- return GDK_KP_4;
- case VK_NUMPAD5:
- return GDK_KP_5;
- case VK_NUMPAD6:
- return GDK_KP_6;
- case VK_NUMPAD7:
- return GDK_KP_7;
- case VK_NUMPAD8:
- return GDK_KP_8;
- case VK_NUMPAD9:
- return GDK_KP_9;
- case VK_MULTIPLY:
- return GDK_KP_Multiply;
- case VK_ADD:
- return GDK_KP_Add;
- /*
- case VK_SEPARATER:
- */
- case VK_SEPARATOR:
- return GDK_KP_Separator;
- case VK_SUBTRACT:
- return GDK_KP_Subtract;
- case VK_DECIMAL:
- return GDK_KP_Decimal;
- case VK_DIVIDE:
- return GDK_KP_Divide;
- case VK_DELETE:
- return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Delete : GDK_Delete;
- case VK_NUM_LOCK:
- return GDK_Num_Lock;
- case VK_SCROLL_LOCK:
- return GDK_Scroll_Lock;
- case VK_F1:
- return GDK_F1;
- case VK_F2:
- return GDK_F2;
- case VK_F3:
- return GDK_F3;
- case VK_F4:
- return GDK_F4;
- case VK_F5:
- return GDK_F5;
- case VK_F6:
- return GDK_F6;
- case VK_F7:
- return GDK_F7;
- case VK_F8:
- return GDK_F8;
- case VK_F9:
- return GDK_F9;
- case VK_F10:
- return GDK_F10;
- case VK_F11:
- return GDK_F11;
- case VK_F12:
- return GDK_F12;
- case VK_F13:
- return GDK_F13;
- case VK_F14:
- return GDK_F14;
- case VK_F15:
- return GDK_F15;
- case VK_F16:
- return GDK_F16;
- case VK_F17:
- return GDK_F17;
- case VK_F18:
- return GDK_F18;
- case VK_F19:
- return GDK_F19;
- case VK_F20:
- return GDK_F20;
- case VK_F21:
- return GDK_F21;
- case VK_F22:
- return GDK_F22;
- case VK_F23:
- return GDK_F23;
- case VK_F24:
- return GDK_F24;
- case VK_PRINTSCREEN:
- return GDK_Print;
- case VK_INSERT:
- return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Insert : GDK_Insert;
- case VK_HELP:
- return GDK_Help;
- case VK_META:
- return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Meta_L : GDK_Meta_R;
- case VK_BACK_QUOTE:
- return GDK_grave;
- case VK_QUOTE:
- return GDK_apostrophe;
- case VK_KP_UP:
- return GDK_KP_Up;
- case VK_KP_DOWN:
- return GDK_KP_Down;
- case VK_KP_LEFT:
- return GDK_KP_Left;
- case VK_KP_RIGHT:
- return GDK_KP_Right;
- case VK_DEAD_GRAVE:
- return GDK_dead_grave;
- case VK_DEAD_ACUTE:
- return GDK_dead_acute;
- case VK_DEAD_CIRCUMFLEX:
- return GDK_dead_circumflex;
- case VK_DEAD_TILDE:
- return GDK_dead_tilde;
- case VK_DEAD_MACRON:
- return GDK_dead_macron;
- case VK_DEAD_BREVE:
- return GDK_dead_breve;
- case VK_DEAD_ABOVEDOT:
- return GDK_dead_abovedot;
- case VK_DEAD_DIAERESIS:
- return GDK_dead_diaeresis;
- case VK_DEAD_ABOVERING:
- return GDK_dead_abovering;
- case VK_DEAD_DOUBLEACUTE:
- return GDK_dead_doubleacute;
- case VK_DEAD_CARON:
- return GDK_dead_caron;
- case VK_DEAD_CEDILLA:
- return GDK_dead_cedilla;
- case VK_DEAD_OGONEK:
- return GDK_dead_ogonek;
- case VK_DEAD_IOTA:
- return GDK_dead_iota;
- case VK_DEAD_VOICED_SOUND:
- return GDK_dead_voiced_sound;
- case VK_DEAD_SEMIVOICED_SOUND:
- return GDK_dead_semivoiced_sound;
- case VK_AMPERSAND:
- return GDK_ampersand;
- case VK_ASTERISK:
- return GDK_asterisk;
- case VK_QUOTEDBL:
- return GDK_quotedbl;
- case VK_LESS:
- return GDK_less;
- case VK_GREATER:
- return GDK_greater;
- case VK_BRACELEFT:
- return GDK_braceleft;
- case VK_BRACERIGHT:
- return GDK_braceright;
- case VK_AT:
- return GDK_at;
- case VK_COLON:
- return GDK_colon;
- case VK_CIRCUMFLEX:
- return GDK_asciicircum;
- case VK_DOLLAR:
- return GDK_dollar;
- case VK_EURO_SIGN:
- return GDK_EuroSign;
- case VK_EXCLAMATION_MARK:
- return GDK_exclam;
- case VK_INVERTED_EXCLAMATION_MARK:
- return GDK_exclamdown;
- case VK_LEFT_PARENTHESIS:
- return GDK_parenleft;
- case VK_NUMBER_SIGN:
- return GDK_numbersign;
- case VK_PLUS:
- return GDK_plus;
- case VK_RIGHT_PARENTHESIS:
- return GDK_parenright;
- case VK_UNDERSCORE:
- return GDK_underscore;
- /*
- case VK_FINAL:
- case VK_CONVERT:
- case VK_NONCONVERT:
- case VK_ACCEPT:
- */
- case VK_MODECHANGE:
- return GDK_Mode_switch;
- /*
- case VK_KANA:
- */
- case VK_KANJI:
- return GDK_Kanji;
- /*
- case VK_ALPHANUMERIC:
- */
- case VK_KATAKANA:
- return GDK_Katakana;
- case VK_HIRAGANA:
- return GDK_Hiragana;
- /*
- case VK_FULL_WIDTH:
- case VK_HALF_WIDTH:
- case VK_ROMAN_CHARACTERS:
- case VK_ALL_CANDIDATES:
- */
- case VK_PREVIOUS_CANDIDATE:
- return GDK_PreviousCandidate;
- case VK_CODE_INPUT:
- return GDK_Codeinput;
- /*
- case VK_JAPANESE_KATAKANA:
- case VK_JAPANESE_HIRAGANA:
- case VK_JAPANESE_ROMAN:
- */
- case VK_KANA_LOCK:
- return GDK_Kana_Lock;
- /*
- case VK_INPUT_METHOD_ON_OFF:
- case VK_CUT:
- case VK_COPY:
- case VK_PASTE:
- case VK_UNDO:
- case VK_AGAIN:
- case VK_FIND:
- case VK_PROPS:
- case VK_STOP:
- case VK_COMPOSE:
- case VK_ALT_GRAPH:
- */
- default:
- return GDK_VoidSymbol;
+ case 1:
+ return AWT_BUTTON1_MASK;
+ case 2:
+ return AWT_BUTTON2_MASK;
+ case 3:
+ return AWT_BUTTON3_MASK;
}
+
+ return 0;
}
+static jint
+state_to_awt_mods (guint state)
+{
+ jint result = 0;
+
+ if (state & GDK_SHIFT_MASK)
+ result |= AWT_SHIFT_DOWN_MASK;
+ if (state & GDK_CONTROL_MASK)
+ result |= AWT_CTRL_DOWN_MASK;
+ if (state & GDK_MOD1_MASK)
+ result |= AWT_ALT_DOWN_MASK;
+
+ return result;
+}
+
+static jint
+state_to_awt_mods_with_button_states (guint state)
+{
+ jint result = 0;
+
+ if (state & GDK_SHIFT_MASK)
+ result |= AWT_SHIFT_DOWN_MASK;
+ if (state & GDK_CONTROL_MASK)
+ result |= AWT_CTRL_DOWN_MASK;
+ if (state & GDK_MOD1_MASK)
+ result |= AWT_ALT_DOWN_MASK;
+ if (state & GDK_BUTTON1_MASK)
+ result |= AWT_BUTTON1_DOWN_MASK;
+ if (state & GDK_BUTTON2_MASK)
+ result |= AWT_BUTTON2_DOWN_MASK;
+ if (state & GDK_BUTTON3_MASK)
+ result |= AWT_BUTTON3_DOWN_MASK;
+
+ return result;
+}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor
@@ -415,6 +190,8 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor
GdkCursorType gdk_cursor_type;
GdkCursor *gdk_cursor;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
switch (type)
@@ -462,8 +239,6 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor
gdk_cursor_type = GDK_LEFT_PTR;
}
- gdk_threads_enter ();
-
widget = GTK_WIDGET(ptr);
gdk_cursor = gdk_cursor_new (gdk_cursor_type);
@@ -482,11 +257,11 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetParent
GtkWidget *widget;
GtkWidget *parent_widget;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
parent_ptr = NSA_GET_PTR (env, parent);
- gdk_threads_enter ();
-
widget = GTK_WIDGET (ptr);
parent_widget = GTK_WIDGET (parent_ptr);
@@ -527,10 +302,10 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetSensitive
{
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
gtk_widget_set_sensitive (GTK_WIDGET (ptr), sensitive);
gdk_threads_leave ();
@@ -542,10 +317,12 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetRequestFocus
{
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
gtk_widget_grab_focus (GTK_WIDGET (ptr));
+
gdk_threads_leave ();
}
@@ -564,10 +341,10 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetDispatchKeyEvent
gint n_keys = 0;
guint lookup_keyval = 0;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
if (id == AWT_KEY_PRESSED)
event = gdk_event_new (GDK_KEY_PRESS);
else if (id == AWT_KEY_RELEASED)
@@ -617,7 +394,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetDispatchKeyEvent
event->key.length = 0;
event->key.string = NULL;
- lookup_keyval = awt_keycode_to_keysym (keyCode, keyLocation);
+ lookup_keyval = cp_gtk_awt_keycode_to_keysym (keyCode, keyLocation);
if (!gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default (),
lookup_keyval,
@@ -679,11 +456,11 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen
void *ptr;
jint *point;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
point = (*env)->GetIntArrayElements (env, jpoint, 0);
- gdk_threads_enter ();
-
gdk_window_get_origin (GTK_WIDGET (ptr)->window, point, point+1);
if (!GTK_IS_CONTAINER (ptr))
@@ -692,9 +469,9 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen
*(point+1) += GTK_WIDGET(ptr)->allocation.y;
}
- gdk_threads_leave ();
-
(*env)->ReleaseIntArrayElements(env, jpoint, point, 0);
+
+ gdk_threads_leave ();
}
/*
@@ -708,21 +485,21 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetDimensions
jint *dims;
GtkRequisition requisition;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
dims = (*env)->GetIntArrayElements (env, jdims, 0);
dims[0] = dims[1] = 0;
- gdk_threads_enter ();
-
gtk_widget_size_request (GTK_WIDGET (ptr), &requisition);
dims[0] = requisition.width;
dims[1] = requisition.height;
- gdk_threads_leave ();
-
(*env)->ReleaseIntArrayElements (env, jdims, dims, 0);
+
+ gdk_threads_leave ();
}
/*
@@ -737,13 +514,13 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetPreferredDimensions
GtkRequisition current_req;
GtkRequisition natural_req;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
dims = (*env)->GetIntArrayElements (env, jdims, 0);
dims[0] = dims[1] = 0;
- gdk_threads_enter ();
-
/* Widgets that extend GtkWindow such as GtkFileChooserDialog may have
a default size. These values seem more useful then the natural
requisition values, particularly for GtkFileChooserDialog. */
@@ -772,9 +549,9 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetPreferredDimensions
dims[1] = natural_req.height;
}
- gdk_threads_leave ();
-
(*env)->ReleaseIntArrayElements (env, jdims, dims, 0);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -784,10 +561,10 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeBounds
GtkWidget *widget;
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
widget = GTK_WIDGET (ptr);
/* We assume that -1 is a width or height and not a request for the
@@ -819,13 +596,18 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetBackground
int *rgb;
GdkColor bg;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
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;
@@ -833,6 +615,8 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetBackground
rgb[2] = bg.blue >> 8;
(*env)->ReleaseIntArrayElements (env, array, rgb, 0);
+ gdk_threads_leave ();
+
return array;
}
@@ -845,13 +629,18 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetForeground
jint *rgb;
GdkColor fg;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
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;
@@ -859,6 +648,8 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetForeground
rgb[2] = fg.blue >> 8;
(*env)->ReleaseIntArrayElements (env, array, rgb, 0);
+ gdk_threads_leave ();
+
return array;
}
@@ -871,6 +662,8 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetBackground
GtkWidget *widget;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
normal_color.red = (red / 255.0) * 65535;
@@ -883,8 +676,6 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetBackground
active_color.green = 0.85 * (green / 255.0) * 65535;
active_color.blue = 0.85 * (blue / 255.0) * 65535;
- gdk_threads_enter ();
-
widget = find_bg_color_widget (GTK_WIDGET (ptr));
gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &normal_color);
@@ -902,14 +693,14 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetForeground
GtkWidget *widget;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
color.red = (red / 255.0) * 65535;
color.green = (green / 255.0) * 65535;
color.blue = (blue / 255.0) * 65535;
- gdk_threads_enter ();
-
widget = find_fg_color_widget (GTK_WIDGET (ptr));
gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &color);
@@ -925,10 +716,12 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_show
{
void *ptr;
+ gdk_threads_enter();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter();
gtk_widget_show (GTK_WIDGET (ptr));
+
gdk_threads_leave();
}
@@ -938,10 +731,12 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_hide
{
void *ptr;
+ gdk_threads_enter();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter();
gtk_widget_hide (GTK_WIDGET (ptr));
+
gdk_threads_leave();
}
@@ -952,10 +747,12 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isEnabled
void *ptr;
jboolean ret_val;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
ret_val = GTK_WIDGET_IS_SENSITIVE (GTK_WIDGET (ptr));
+
gdk_threads_leave ();
return ret_val;
@@ -968,13 +765,15 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isRealized
void *ptr;
jboolean ret_val;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
if (ptr == NULL)
return FALSE;
- gdk_threads_enter ();
ret_val = GTK_WIDGET_REALIZED (GTK_WIDGET (ptr));
+
gdk_threads_leave ();
return ret_val;
@@ -988,8 +787,10 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_modalHasGrab
jboolean retval;
gdk_threads_enter ();
+
widget = gtk_grab_get_current ();
retval = (widget && GTK_IS_WINDOW (widget) && GTK_WINDOW (widget)->modal);
+
gdk_threads_leave ();
return retval;
@@ -1002,28 +803,44 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals
void *ptr;
jobject *gref;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
gref = NSA_GET_GLOBAL_REF (env, obj);
- gdk_threads_enter ();
+ cp_gtk_component_connect_signals (ptr, gref);
- /* Connect EVENT signal, which happens _before_ any specific signal. */
+ gdk_threads_leave ();
+}
- g_signal_connect (GTK_OBJECT (ptr), "event",
- G_CALLBACK (pre_event_handler), *gref);
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeEventMask
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
- g_signal_connect (G_OBJECT (ptr), "focus-in-event",
- G_CALLBACK (focus_in_cb), *gref);
+ gdk_threads_enter ();
- g_signal_connect (G_OBJECT (ptr), "focus-out-event",
- G_CALLBACK (focus_out_cb), *gref);
+ ptr = NSA_GET_PTR (env, obj);
- g_signal_connect_after (G_OBJECT (ptr), "realize",
- G_CALLBACK (connect_awt_hook_cb), *gref);
+ gtk_widget_add_events (GTK_WIDGET (ptr),
+ GDK_POINTER_MOTION_MASK
+ | GDK_BUTTON_MOTION_MASK
+ | GDK_BUTTON_PRESS_MASK
+ | GDK_BUTTON_RELEASE_MASK
+ | GDK_KEY_PRESS_MASK
+ | GDK_KEY_RELEASE_MASK
+ | GDK_ENTER_NOTIFY_MASK
+ | GDK_LEAVE_NOTIFY_MASK
+ | GDK_STRUCTURE_MASK
+ | GDK_KEY_PRESS_MASK
+ | GDK_FOCUS_CHANGE_MASK);
gdk_threads_leave ();
}
+/* FIXME: these functions should be implemented by overridding the
+ appropriate GtkComponentPeer methods. */
static GtkWidget *
find_fg_color_widget (GtkWidget *widget)
{
@@ -1049,30 +866,296 @@ find_bg_color_widget (GtkWidget *widget)
return bg_color_widget;
}
+void
+cp_gtk_component_connect_expose_signals (GObject *ptr, jobject *gref)
+{
+ g_signal_connect (G_OBJECT (ptr), "expose-event",
+ G_CALLBACK (component_expose_cb), *gref);
+}
+
+void
+cp_gtk_component_connect_focus_signals (GObject *ptr, jobject *gref)
+{
+ g_signal_connect (G_OBJECT (ptr), "focus-in-event",
+ G_CALLBACK (component_focus_in_cb), *gref);
+
+ g_signal_connect (G_OBJECT (ptr), "focus-out-event",
+ G_CALLBACK (component_focus_out_cb), *gref);
+}
+
+void
+cp_gtk_component_connect_mouse_signals (GObject *ptr, jobject *gref)
+{
+ g_signal_connect (G_OBJECT (ptr), "button-press-event",
+ G_CALLBACK (component_button_press_cb), *gref);
+
+ g_signal_connect (G_OBJECT (ptr), "button-release-event",
+ G_CALLBACK (component_button_release_cb), *gref);
+
+ g_signal_connect (G_OBJECT (ptr), "enter-notify-event",
+ G_CALLBACK (component_enter_notify_cb), *gref);
+
+ g_signal_connect (G_OBJECT (ptr), "leave-notify-event",
+ G_CALLBACK (component_leave_notify_cb), *gref);
+
+ g_signal_connect (G_OBJECT (ptr), "motion-notify-event",
+ G_CALLBACK (component_motion_notify_cb), *gref);
+}
+
+void
+cp_gtk_component_connect_signals (GObject *ptr, jobject *gref)
+{
+ cp_gtk_component_connect_expose_signals (ptr, gref);
+ cp_gtk_component_connect_focus_signals (ptr, gref);
+ cp_gtk_component_connect_mouse_signals (ptr, gref);
+}
+
+/* These variables are used to keep track of click counts. The AWT
+ allows more than a triple click to occur but GTK doesn't report
+ more-than-triple clicks. */
+static jint click_count = 1;
+static guint32 button_click_time = 0;
+static GdkWindow *button_window = NULL;
+static guint button_number = -1;
+static int hasBeenDragged;
+
static gboolean
-focus_in_cb (GtkWidget *widget __attribute((unused)),
- GdkEventFocus *event __attribute((unused)),
- jobject peer)
+component_button_press_cb (GtkWidget *widget __attribute__((unused)),
+ GdkEventButton *event,
+ jobject peer)
{
+ /* Ignore double and triple click events. */
+ if (event->type == GDK_2BUTTON_PRESS
+ || event->type == GDK_3BUTTON_PRESS)
+ return FALSE;
+
+ if ((event->time < (button_click_time + MULTI_CLICK_TIME))
+ && (event->window == button_window)
+ && (event->button == button_number))
+ click_count++;
+ else
+ click_count = 1;
+
+ button_click_time = event->time;
+ button_window = event->window;
+ button_number = event->button;
+
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postFocusEventID,
- AWT_FOCUS_GAINED,
- JNI_FALSE);
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
+ postMouseEventID,
+ AWT_MOUSE_PRESSED,
+ (jlong)event->time,
+ state_to_awt_mods (event->state)
+ | button_to_awt_mods (event->button),
+ (jint)event->x,
+ (jint)event->y,
+ click_count,
+ (event->button == 3) ? JNI_TRUE :
+ JNI_FALSE);
+
gdk_threads_enter ();
+
+ hasBeenDragged = FALSE;
+
return FALSE;
}
static gboolean
-focus_out_cb (GtkWidget *widget __attribute((unused)),
- GdkEventFocus *event __attribute((unused)),
- jobject peer)
+component_button_release_cb (GtkWidget *widget __attribute__((unused)),
+ GdkEventButton *event,
+ jobject peer)
{
+ int width, height;
+
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postFocusEventID,
- AWT_FOCUS_LOST,
- JNI_FALSE);
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
+ postMouseEventID,
+ AWT_MOUSE_RELEASED,
+ (jlong)event->time,
+ 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. */
+ gdk_window_get_size (event->window, &width, &height);
+ if (! hasBeenDragged
+ && event->x >= 0
+ && event->y >= 0
+ && 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)
+ | button_to_awt_mods (event->button),
+ (jint)event->x,
+ (jint)event->y,
+ click_count,
+ JNI_FALSE);
+
+ gdk_threads_enter ();
+ }
+ return FALSE;
+}
+
+static gboolean
+component_motion_notify_cb (GtkWidget *widget __attribute__((unused)),
+ GdkEventMotion *event,
+ jobject peer)
+{
+ if (event->state & (GDK_BUTTON1_MASK
+ | GDK_BUTTON2_MASK
+ | GDK_BUTTON3_MASK
+ | GDK_BUTTON4_MASK
+ | GDK_BUTTON5_MASK))
+ {
+ gdk_threads_leave ();
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
+ postMouseEventID,
+ AWT_MOUSE_DRAGGED,
+ (jlong)event->time,
+ state_to_awt_mods_with_button_states (event->state),
+ (jint)event->x,
+ (jint)event->y,
+ 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),
+ (jint)event->x,
+ (jint)event->y,
+ 0,
+ JNI_FALSE);
+
+ gdk_threads_enter ();
+ }
+ return FALSE;
+}
+
+static gboolean
+component_enter_notify_cb (GtkWidget *widget __attribute__((unused)),
+ GdkEventCrossing *event,
+ jobject peer)
+{
+ /* We are not interested in enter events that are due to
+ 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,
+ state_to_awt_mods_with_button_states (event->state),
+ (jint)event->x,
+ (jint)event->y,
+ 0,
+ JNI_FALSE);
+
+ gdk_threads_enter ();
+ }
+ return FALSE;
+}
+
+static gboolean
+component_leave_notify_cb (GtkWidget *widget __attribute__((unused)),
+ GdkEventCrossing *event,
+ jobject peer)
+{
+ /* We are not interested in leave events that are due to
+ 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,
+ (jlong)event->time,
+ state_to_awt_mods_with_button_states (event->state),
+ (jint)event->x,
+ (jint)event->y,
+ 0,
+ JNI_FALSE);
+
+ gdk_threads_enter ();
+ }
+ return FALSE;
+}
+
+static gboolean
+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,
+ (jint)event->area.y,
+ (jint)event->area.width,
+ (jint)event->area.height);
+
+ gdk_threads_enter ();
+
+ return FALSE;
+}
+
+static gboolean
+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;
+}
+
+static gboolean
+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/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c
index 61e1af101..563a0257e 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c
@@ -16,8 +16,8 @@ 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.
+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
@@ -47,10 +47,10 @@ Java_gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer_create
GtkWidget *window;
GtkWidget *fixed;
- NSA_SET_GLOBAL_REF (env, obj);
-
gdk_threads_enter ();
+ NSA_SET_GLOBAL_REF (env, obj);
+
window = gtk_plug_new ((GdkNativeWindow) socket_id);
fixed = gtk_fixed_new ();
@@ -58,9 +58,9 @@ Java_gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer_create
gtk_widget_show (fixed);
- gdk_threads_leave ();
-
NSA_SET_PTR (env, obj, window);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -69,10 +69,10 @@ Java_gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer_construct
{
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
if (GTK_WIDGET_REALIZED (GTK_WIDGET (ptr)))
g_printerr ("ERROR: GtkPlug is already realized\n");
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
deleted file mode 100644
index 8d3dda93a..000000000
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
+++ /dev/null
@@ -1,1176 +0,0 @@
-/* gtkevents.c -- GDK/GTK event handlers
- Copyright (C) 1998, 1999, 2002, 2004 Free Software Foundation, Inc.
-
-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 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. */
-
-
-#include "gtkpeer.h"
-#include <X11/Xlib.h>
-#include <gdk/gdkkeysyms.h>
-#include <stdarg.h>
-#include <assert.h>
-
-/* A widget can be composed of multipled windows, so we need to hook
- events on all of them. */
-struct event_hook_info
-{
- jobject *peer_obj;
- int nwindows;
- /* array of pointers to (GdkWindow *) */
- GdkWindow ***windows;
-};
-
-static jint
-button_to_awt_mods (int button)
-{
- switch (button)
- {
- case 1:
- return AWT_BUTTON1_MASK;
- case 2:
- return AWT_BUTTON2_MASK;
- case 3:
- return AWT_BUTTON3_MASK;
- }
-
- return 0;
-}
-
-static jint
-state_to_awt_mods (guint state)
-{
- jint result = 0;
-
- if (state & GDK_SHIFT_MASK)
- result |= AWT_SHIFT_DOWN_MASK;
- if (state & GDK_CONTROL_MASK)
- result |= AWT_CTRL_DOWN_MASK;
- if (state & GDK_MOD1_MASK)
- result |= AWT_ALT_DOWN_MASK;
-
- return result;
-}
-
-static jint
-state_to_awt_mods_with_button_states (guint state)
-{
- jint result = 0;
-
- if (state & GDK_SHIFT_MASK)
- result |= AWT_SHIFT_DOWN_MASK;
- if (state & GDK_CONTROL_MASK)
- result |= AWT_CTRL_DOWN_MASK;
- if (state & GDK_MOD1_MASK)
- result |= AWT_ALT_DOWN_MASK;
- if (state & GDK_BUTTON1_MASK)
- result |= AWT_BUTTON1_DOWN_MASK;
- if (state & GDK_BUTTON2_MASK)
- result |= AWT_BUTTON2_DOWN_MASK;
- if (state & GDK_BUTTON3_MASK)
- result |= AWT_BUTTON3_DOWN_MASK;
-
- return result;
-}
-
-/* Modifier key events need special treatment. In Sun's peer
- implementation, when a modifier key is pressed, the KEY_PRESSED
- event has that modifier in its modifiers list. The corresponding
- KEY_RELEASED event's modifier list does not contain the modifier.
- For example, pressing and releasing the shift key will produce a
- key press event with modifiers=Shift, and a key release event with
- no modifiers. GDK's key events behave in the exact opposite way,
- so this translation code is needed. */
-jint
-keyevent_state_to_awt_mods (GdkEvent *event)
-{
- jint result = 0;
- guint state;
-
- if (event->type == GDK_KEY_PRESS)
- {
- state = event->key.state;
-
- if (event->key.keyval == GDK_Shift_L
- || event->key.keyval == GDK_Shift_R)
- result |= AWT_SHIFT_DOWN_MASK;
- else
- {
- if (state & GDK_SHIFT_MASK)
- result |= AWT_SHIFT_DOWN_MASK;
- }
-
- if (event->key.keyval == GDK_Control_L
- || event->key.keyval == GDK_Control_R)
- result |= AWT_CTRL_DOWN_MASK;
- else
- {
- if (state & GDK_CONTROL_MASK)
- result |= AWT_CTRL_DOWN_MASK;
- }
-
- if (event->key.keyval == GDK_Alt_L
- || event->key.keyval == GDK_Alt_R)
- result |= AWT_ALT_DOWN_MASK;
- else
- {
- if (state & GDK_MOD1_MASK)
- result |= AWT_ALT_DOWN_MASK;
- }
- }
- else if (event->type == GDK_KEY_RELEASE)
- {
- state = event->key.state;
-
- if (event->key.keyval != GDK_Shift_L
- && event->key.keyval != GDK_Shift_R)
- {
- if (state & GDK_SHIFT_MASK)
- result |= AWT_SHIFT_DOWN_MASK;
- }
- if (event->key.keyval != GDK_Control_L
- && event->key.keyval != GDK_Control_R)
- {
- if (state & GDK_CONTROL_MASK)
- result |= AWT_CTRL_DOWN_MASK;
- }
-
- if (event->key.keyval != GDK_Alt_L
- && event->key.keyval != GDK_Alt_R)
- {
- if (state & GDK_MOD1_MASK)
- result |= AWT_ALT_DOWN_MASK;
- }
- }
-
- return result;
-}
-
-/* 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
-get_first_keyval_from_keymap (GdkEvent *event)
-{
- guint keyval;
- guint *keyvals;
- gint n_entries;
-
- if (!gdk_keymap_get_entries_for_keycode (NULL,
- event->key.hardware_keycode,
- NULL,
- &keyvals,
- &n_entries))
- {
- g_warning ("No keyval found for hardware keycode %d\n",
- event->key.hardware_keycode);
- /* Try to recover by using the keyval in the event structure. */
- keyvals = &(event->key.keyval);
- }
- keyval = keyvals[0];
- g_free (keyvals);
-
- return gdk_keyval_to_upper (keyval);
-}
-
-#ifdef __GNUC__
-__inline
-#endif
-static jint
-keysym_to_awt_keycode (GdkEvent *event)
-{
- guint ukeyval;
- guint state;
-
- ukeyval = get_first_keyval_from_keymap (event);
- state = event->key.state;
-
- /* VK_A through VK_Z */
- if (ukeyval >= GDK_A && ukeyval <= GDK_Z)
- return ukeyval;
-
- /* VK_0 through VK_9 */
- if (ukeyval >= GDK_0 && ukeyval <= GDK_9)
- return ukeyval;
-
- switch (ukeyval)
- {
- case GDK_Return:
- case GDK_KP_Enter:
- return VK_ENTER;
- case GDK_BackSpace:
- return VK_BACK_SPACE;
- case GDK_Tab:
- return VK_TAB;
- case GDK_Cancel:
- return VK_CANCEL;
- case GDK_Clear:
- return VK_CLEAR;
- case GDK_Shift_L:
- case GDK_Shift_R:
- return VK_SHIFT;
- case GDK_Control_L:
- case GDK_Control_R:
- return VK_CONTROL;
- case GDK_Alt_L:
- case GDK_Alt_R:
- return VK_ALT;
- case GDK_Pause:
- return VK_PAUSE;
- case GDK_Caps_Lock:
- return VK_CAPS_LOCK;
- case GDK_Escape:
- return VK_ESCAPE;
- case GDK_space:
- return VK_SPACE;
- case GDK_KP_Page_Up:
- /* For keys on the numeric keypad, the JVM produces one of two
- virtual keys, depending on the num lock state. */
- if (state & GDK_MOD2_MASK)
- return VK_NUMPAD9;
- else
- return VK_PAGE_UP;
- case GDK_Page_Up:
- return VK_PAGE_UP;
- case GDK_KP_Page_Down:
- if (state & GDK_MOD2_MASK)
- return VK_NUMPAD3;
- else
- return VK_PAGE_DOWN;
- case GDK_Page_Down:
- return VK_PAGE_DOWN;
- case GDK_KP_End:
- if (state & GDK_MOD2_MASK)
- return VK_NUMPAD1;
- else
- return VK_END;
- case GDK_End:
- return VK_END;
- case GDK_KP_Home:
- if (state & GDK_MOD2_MASK)
- return VK_NUMPAD7;
- else
- return VK_HOME;
- case GDK_Home:
- return VK_HOME;
- case GDK_KP_Begin:
- if (state & GDK_MOD2_MASK)
- return VK_NUMPAD5;
- else
- return VK_UNDEFINED;
- case GDK_Left:
- return VK_LEFT;
- case GDK_Up:
- return VK_UP;
- case GDK_Right:
- return VK_RIGHT;
- case GDK_Down:
- return VK_DOWN;
- case GDK_comma:
- return VK_COMMA;
- case GDK_minus:
- return VK_MINUS;
- case GDK_period:
- return VK_PERIOD;
- case GDK_slash:
- return VK_SLASH;
- /*
- return VK_0;
- return VK_1;
- return VK_2;
- return VK_3;
- return VK_4;
- return VK_5;
- return VK_6;
- return VK_7;
- return VK_8;
- return VK_9;
- */
- case GDK_semicolon:
- return VK_SEMICOLON;
- case GDK_equal:
- return VK_EQUALS;
- /*
- return VK_A;
- return VK_B;
- return VK_C;
- return VK_D;
- return VK_E;
- return VK_F;
- return VK_G;
- return VK_H;
- return VK_I;
- return VK_J;
- return VK_K;
- return VK_L;
- return VK_M;
- return VK_N;
- return VK_O;
- return VK_P;
- return VK_Q;
- return VK_R;
- return VK_S;
- return VK_T;
- return VK_U;
- return VK_V;
- return VK_W;
- return VK_X;
- return VK_Y;
- return VK_Z;
- */
- case GDK_bracketleft:
- return VK_OPEN_BRACKET;
- case GDK_backslash:
- return VK_BACK_SLASH;
- case GDK_bracketright:
- return VK_CLOSE_BRACKET;
- case GDK_KP_0:
- return VK_NUMPAD0;
- case GDK_KP_1:
- return VK_NUMPAD1;
- case GDK_KP_2:
- return VK_NUMPAD2;
- case GDK_KP_3:
- return VK_NUMPAD3;
- case GDK_KP_4:
- return VK_NUMPAD4;
- case GDK_KP_5:
- return VK_NUMPAD5;
- case GDK_KP_6:
- return VK_NUMPAD6;
- case GDK_KP_7:
- return VK_NUMPAD7;
- case GDK_KP_8:
- return VK_NUMPAD8;
- case GDK_KP_9:
- return VK_NUMPAD9;
- case GDK_KP_Multiply:
- return VK_MULTIPLY;
- case GDK_KP_Add:
- return VK_ADD;
- /*
- return VK_SEPARATER;
- */
- case GDK_KP_Separator:
- return VK_SEPARATOR;
- case GDK_KP_Subtract:
- return VK_SUBTRACT;
- case GDK_KP_Decimal:
- return VK_DECIMAL;
- case GDK_KP_Divide:
- return VK_DIVIDE;
- case GDK_KP_Delete:
- if (state & GDK_MOD2_MASK)
- return VK_DECIMAL;
- else
- return VK_DELETE;
- case GDK_Delete:
- return VK_DELETE;
- case GDK_Num_Lock:
- return VK_NUM_LOCK;
- case GDK_Scroll_Lock:
- return VK_SCROLL_LOCK;
- case GDK_F1:
- return VK_F1;
- case GDK_F2:
- return VK_F2;
- case GDK_F3:
- return VK_F3;
- case GDK_F4:
- return VK_F4;
- case GDK_F5:
- return VK_F5;
- case GDK_F6:
- return VK_F6;
- case GDK_F7:
- return VK_F7;
- case GDK_F8:
- return VK_F8;
- case GDK_F9:
- return VK_F9;
- case GDK_F10:
- return VK_F10;
- case GDK_F11:
- return VK_F11;
- case GDK_F12:
- return VK_F12;
- case GDK_F13:
- return VK_F13;
- case GDK_F14:
- return VK_F14;
- case GDK_F15:
- return VK_F15;
- case GDK_F16:
- return VK_F16;
- case GDK_F17:
- return VK_F17;
- case GDK_F18:
- return VK_F18;
- case GDK_F19:
- return VK_F19;
- case GDK_F20:
- return VK_F20;
- case GDK_F21:
- return VK_F21;
- case GDK_F22:
- return VK_F22;
- case GDK_F23:
- return VK_F23;
- case GDK_F24:
- return VK_F24;
- case GDK_Print:
- return VK_PRINTSCREEN;
- case GDK_KP_Insert:
- if (state & GDK_MOD2_MASK)
- return VK_NUMPAD0;
- else
- return VK_INSERT;
- case GDK_Insert:
- return VK_INSERT;
- case GDK_Help:
- return VK_HELP;
- case GDK_Meta_L:
- case GDK_Meta_R:
- return VK_META;
- case GDK_grave:
- return VK_BACK_QUOTE;
- case GDK_apostrophe:
- return VK_QUOTE;
- case GDK_KP_Up:
- if (state & GDK_MOD2_MASK)
- return VK_NUMPAD8;
- else
- return VK_KP_UP;
- case GDK_KP_Down:
- if (state & GDK_MOD2_MASK)
- return VK_NUMPAD2;
- else
- return VK_KP_DOWN;
- case GDK_KP_Left:
- if (state & GDK_MOD2_MASK)
- return VK_NUMPAD4;
- else
- return VK_KP_LEFT;
- case GDK_KP_Right:
- if (state & GDK_MOD2_MASK)
- return VK_NUMPAD6;
- else
- return VK_KP_RIGHT;
- case GDK_dead_grave:
- return VK_DEAD_GRAVE;
- case GDK_dead_acute:
- return VK_DEAD_ACUTE;
- case GDK_dead_circumflex:
- return VK_DEAD_CIRCUMFLEX;
- case GDK_dead_tilde:
- return VK_DEAD_TILDE;
- case GDK_dead_macron:
- return VK_DEAD_MACRON;
- case GDK_dead_breve:
- return VK_DEAD_BREVE;
- case GDK_dead_abovedot:
- return VK_DEAD_ABOVEDOT;
- case GDK_dead_diaeresis:
- return VK_DEAD_DIAERESIS;
- case GDK_dead_abovering:
- return VK_DEAD_ABOVERING;
- case GDK_dead_doubleacute:
- return VK_DEAD_DOUBLEACUTE;
- case GDK_dead_caron:
- return VK_DEAD_CARON;
- case GDK_dead_cedilla:
- return VK_DEAD_CEDILLA;
- case GDK_dead_ogonek:
- return VK_DEAD_OGONEK;
- case GDK_dead_iota:
- return VK_DEAD_IOTA;
- case GDK_dead_voiced_sound:
- return VK_DEAD_VOICED_SOUND;
- case GDK_dead_semivoiced_sound:
- return VK_DEAD_SEMIVOICED_SOUND;
- case GDK_ampersand:
- return VK_AMPERSAND;
- case GDK_asterisk:
- return VK_ASTERISK;
- case GDK_quotedbl:
- return VK_QUOTEDBL;
- case GDK_less:
- return VK_LESS;
- case GDK_greater:
- return VK_GREATER;
- case GDK_braceleft:
- return VK_BRACELEFT;
- case GDK_braceright:
- return VK_BRACERIGHT;
- case GDK_at:
- return VK_AT;
- case GDK_colon:
- return VK_COLON;
- case GDK_asciicircum:
- return VK_CIRCUMFLEX;
- case GDK_dollar:
- return VK_DOLLAR;
- case GDK_EuroSign:
- return VK_EURO_SIGN;
- case GDK_exclam:
- return VK_EXCLAMATION_MARK;
- case GDK_exclamdown:
- return VK_INVERTED_EXCLAMATION_MARK;
- case GDK_parenleft:
- return VK_LEFT_PARENTHESIS;
- case GDK_numbersign:
- return VK_NUMBER_SIGN;
- case GDK_plus:
- return VK_PLUS;
- case GDK_parenright:
- return VK_RIGHT_PARENTHESIS;
- case GDK_underscore:
- return VK_UNDERSCORE;
- /*
- return VK_FINAL;
- return VK_CONVERT;
- return VK_NONCONVERT;
- return VK_ACCEPT;
- */
- case GDK_Mode_switch:
- return VK_MODECHANGE;
- /*
- return VK_KANA;
- */
- case GDK_Kanji:
- return VK_KANJI;
- /*
- return VK_ALPHANUMERIC;
- */
- case GDK_Katakana:
- return VK_KATAKANA;
- case GDK_Hiragana:
- return VK_HIRAGANA;
- /*
- return VK_FULL_WIDTH;
- return VK_HALF_WIDTH;
- return VK_ROMAN_CHARACTERS;
- return VK_ALL_CANDIDATES;
- */
- case GDK_PreviousCandidate:
- return VK_PREVIOUS_CANDIDATE;
- case GDK_Codeinput:
- return VK_CODE_INPUT;
- /*
- return VK_JAPANESE_KATAKANA;
- return VK_JAPANESE_HIRAGANA;
- return VK_JAPANESE_ROMAN;
- */
- case GDK_Kana_Lock:
- return VK_KANA_LOCK;
- /*
- return VK_INPUT_METHOD_ON_OFF;
- return VK_CUT;
- return VK_COPY;
- return VK_PASTE;
- return VK_UNDO;
- return VK_AGAIN;
- return VK_FIND;
- return VK_PROPS;
- return VK_STOP;
- return VK_COMPOSE;
- return VK_ALT_GRAPH;
- */
- default:
- return VK_UNDEFINED;
- }
-}
-
-static jint
-keysym_to_awt_keylocation (GdkEvent *event)
-{
- guint ukeyval;
-
- ukeyval = get_first_keyval_from_keymap (event);
-
- /* VK_A through VK_Z */
- if (ukeyval >= GDK_A && ukeyval <= GDK_Z)
- return AWT_KEY_LOCATION_STANDARD;
-
- /* VK_0 through VK_9 */
- if (ukeyval >= GDK_0 && ukeyval <= GDK_9)
- return AWT_KEY_LOCATION_STANDARD;
-
- switch (ukeyval)
- {
- case GDK_Shift_L:
- case GDK_Control_L:
- case GDK_Alt_L:
- case GDK_Meta_L:
- return AWT_KEY_LOCATION_LEFT;
-
- case GDK_Shift_R:
- case GDK_Control_R:
- case GDK_Alt_R:
- case GDK_Meta_R:
- return AWT_KEY_LOCATION_RIGHT;
-
- case GDK_Return:
- case GDK_BackSpace:
- case GDK_Tab:
- case GDK_Cancel:
- case GDK_Clear:
- case GDK_Pause:
- case GDK_Caps_Lock:
- case GDK_Escape:
- case GDK_space:
- case GDK_Page_Up:
- case GDK_Page_Down:
- case GDK_End:
- case GDK_Home:
- case GDK_Left:
- case GDK_Up:
- case GDK_Right:
- case GDK_Down:
- case GDK_comma:
- case GDK_minus:
- case GDK_period:
- case GDK_slash:
- case GDK_semicolon:
- case GDK_equal:
- case GDK_bracketleft:
- case GDK_backslash:
- case GDK_bracketright:
- case GDK_Delete:
- case GDK_Scroll_Lock:
- case GDK_F1:
- case GDK_F2:
- case GDK_F3:
- case GDK_F4:
- case GDK_F5:
- case GDK_F6:
- case GDK_F7:
- case GDK_F8:
- case GDK_F9:
- case GDK_F10:
- case GDK_F11:
- case GDK_F12:
- case GDK_F13:
- case GDK_F14:
- case GDK_F15:
- case GDK_F16:
- case GDK_F17:
- case GDK_F18:
- case GDK_F19:
- case GDK_F20:
- case GDK_F21:
- case GDK_F22:
- case GDK_F23:
- case GDK_F24:
- case GDK_Print:
- case GDK_Insert:
- case GDK_Help:
- case GDK_grave:
- case GDK_apostrophe:
- case GDK_dead_grave:
- case GDK_dead_acute:
- case GDK_dead_circumflex:
- case GDK_dead_tilde:
- case GDK_dead_macron:
- case GDK_dead_breve:
- case GDK_dead_abovedot:
- case GDK_dead_diaeresis:
- case GDK_dead_abovering:
- case GDK_dead_doubleacute:
- case GDK_dead_caron:
- case GDK_dead_cedilla:
- case GDK_dead_ogonek:
- case GDK_dead_iota:
- case GDK_dead_voiced_sound:
- case GDK_dead_semivoiced_sound:
- case GDK_ampersand:
- case GDK_asterisk:
- case GDK_quotedbl:
- case GDK_less:
- case GDK_greater:
- case GDK_braceleft:
- case GDK_braceright:
- case GDK_at:
- case GDK_colon:
- case GDK_asciicircum:
- case GDK_dollar:
- case GDK_EuroSign:
- case GDK_exclam:
- case GDK_exclamdown:
- case GDK_parenleft:
- case GDK_numbersign:
- case GDK_plus:
- case GDK_parenright:
- case GDK_underscore:
- case GDK_Mode_switch:
- case GDK_Kanji:
- case GDK_Katakana:
- case GDK_Hiragana:
- case GDK_PreviousCandidate:
- case GDK_Codeinput:
- case GDK_Kana_Lock:
- return AWT_KEY_LOCATION_STANDARD;
-
- case GDK_KP_Enter:
- case GDK_KP_Page_Up:
- case GDK_KP_Page_Down:
- case GDK_KP_End:
- case GDK_KP_Home:
- case GDK_KP_Begin:
- case GDK_KP_0:
- case GDK_KP_1:
- case GDK_KP_2:
- case GDK_KP_3:
- case GDK_KP_4:
- case GDK_KP_5:
- case GDK_KP_6:
- case GDK_KP_7:
- case GDK_KP_8:
- case GDK_KP_9:
- case GDK_KP_Multiply:
- case GDK_KP_Add:
- case GDK_KP_Separator:
- case GDK_KP_Subtract:
- case GDK_KP_Decimal:
- case GDK_KP_Divide:
- case GDK_KP_Delete:
- case GDK_Num_Lock:
- case GDK_KP_Insert:
- case GDK_KP_Up:
- case GDK_KP_Down:
- case GDK_KP_Left:
- case GDK_KP_Right:
- return AWT_KEY_LOCATION_NUMPAD;
-
- default:
- return AWT_KEY_LOCATION_UNKNOWN;
- }
-}
-
-static jchar
-keyevent_to_awt_keychar (GdkEvent *event)
-{
- if (event->key.length > 0)
- {
- /* Translate GDK carriage return to Java linefeed. */
- if (event->key.string[0] == 13)
- return VK_ENTER;
- else
- return event->key.string[0];
- }
- else
- {
- switch (event->key.keyval)
- {
- case GDK_BackSpace:
- return VK_BACK_SPACE;
- case GDK_Tab:
- return VK_TAB;
- case GDK_Delete:
- case GDK_KP_Delete:
- return VK_DELETE;
- default:
- return AWT_KEY_CHAR_UNDEFINED;
- }
- }
-}
-
-void
-awt_event_handler (GdkEvent *event)
-{
- /* keep synthetic AWT events from being processed recursively */
- if (event->type & SYNTHETIC_EVENT_MASK && event->type != GDK_NOTHING)
- {
- event->type ^= SYNTHETIC_EVENT_MASK;
- }
-
- gtk_main_do_event (event);
-}
-
-gboolean
-pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer)
-{
- GtkWidget *event_widget;
- static guint32 button_click_time = 0;
- static GdkWindow *button_window = NULL;
- static guint button_number = -1;
- static jint click_count = 1;
- static int hasBeenDragged;
- union widget_union w;
-
- /* If it is not a focus change event, the widget must be realized already.
- If not, ignore the event (Gtk+ will do the same). */
- if (!(event->type == GDK_FOCUS_CHANGE || GTK_WIDGET_REALIZED(widget)))
- return FALSE;
-
- /* Do not handle propagated events. AWT has its own propagation rules */
- w.widget = &event_widget;
- gdk_window_get_user_data (event->any.window, w.void_widget);
- if (event_widget != widget)
- return FALSE;
-
- /* We only care about input events */
- if (!(event->type == GDK_BUTTON_PRESS
- || event->type == GDK_BUTTON_RELEASE
- || event->type == GDK_ENTER_NOTIFY
- || event->type == GDK_LEAVE_NOTIFY
- || event->type == GDK_CONFIGURE
- || event->type == GDK_EXPOSE
- || event->type == GDK_KEY_PRESS
- || event->type == GDK_KEY_RELEASE
- || event->type == GDK_FOCUS_CHANGE
- || event->type == GDK_MOTION_NOTIFY))
- {
- return FALSE;
- }
- /* g_print("event %u widget %s peer %p\n",
- event->type, gtk_widget_get_name (widget), peer); */
-
- /* If it has no jobject associated we can send no AWT event */
- if (!peer)
- return FALSE;
-
- /* for all input events, which have a window with a jobject attached,
- send the AWT input event corresponding to the Gtk event off to Java */
-
- /* keep track of clickCount ourselves, since the AWT allows more
- than a triple click to occur */
- if (event->type == GDK_BUTTON_PRESS)
- {
- if ((event->button.time < (button_click_time + MULTI_CLICK_TIME))
- && (event->button.window == button_window)
- && (event->button.button == button_number))
- click_count++;
- else
- click_count = 1;
-
- button_click_time = event->button.time;
- button_window = event->button.window;
- button_number = event->button.button;
- }
-
- switch (event->type)
- {
- case GDK_BUTTON_PRESS:
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postMouseEventID,
- AWT_MOUSE_PRESSED,
- (jlong)event->button.time,
- state_to_awt_mods (event->button.state)
- | button_to_awt_mods (event->button.button),
- (jint)event->button.x,
- (jint)event->button.y,
- click_count,
- (event->button.button == 3) ? JNI_TRUE :
- JNI_FALSE);
- gdk_threads_enter ();
- hasBeenDragged = FALSE;
- break;
- case GDK_BUTTON_RELEASE:
- {
- int width, height;
-
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postMouseEventID,
- AWT_MOUSE_RELEASED,
- (jlong)event->button.time,
- state_to_awt_mods (event->button.state)
- | button_to_awt_mods (event->button.button),
- (jint)event->button.x,
- (jint)event->button.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. */
- gdk_window_get_size (event->any.window, &width, &height);
- if (! hasBeenDragged
- && event->button.x >= 0
- && event->button.y >= 0
- && event->button.x <= width
- && event->button.y <= height)
- {
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postMouseEventID,
- AWT_MOUSE_CLICKED,
- (jlong)event->button.time,
- state_to_awt_mods (event->button.state)
- | button_to_awt_mods (event->button.button),
- (jint)event->button.x,
- (jint)event->button.y,
- click_count,
- JNI_FALSE);
- gdk_threads_enter ();
- }
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (event->motion.state & (GDK_BUTTON1_MASK
- | GDK_BUTTON2_MASK
- | GDK_BUTTON3_MASK
- | GDK_BUTTON4_MASK
- | GDK_BUTTON5_MASK))
- {
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postMouseEventID,
- AWT_MOUSE_DRAGGED,
- (jlong)event->motion.time,
- state_to_awt_mods_with_button_states (event->motion.state),
- (jint)event->motion.x,
- (jint)event->motion.y,
- 0,
- JNI_FALSE);
- gdk_threads_enter ();
- hasBeenDragged = TRUE;
- }
- else
- {
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer, postMouseEventID,
- AWT_MOUSE_MOVED,
- (jlong)event->motion.time,
- state_to_awt_mods (event->motion.state),
- (jint)event->motion.x,
- (jint)event->motion.y,
- 0,
- JNI_FALSE);
- gdk_threads_enter ();
- }
-
- break;
- case GDK_ENTER_NOTIFY:
- /* We are not interested in enter events that are due to
- grab/ungrab and not to actually crossing boundaries */
- if (event->crossing.mode == GDK_CROSSING_NORMAL)
- {
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer, postMouseEventID,
- AWT_MOUSE_ENTERED,
- (jlong)event->crossing.time,
- state_to_awt_mods_with_button_states (event->crossing.state),
- (jint)event->crossing.x,
- (jint)event->crossing.y,
- 0,
- JNI_FALSE);
- gdk_threads_enter ();
- }
- break;
- case GDK_LEAVE_NOTIFY:
- /* We are not interested in leave events that are due to
- grab/ungrab and not to actually crossing boundaries */
- if (event->crossing.mode == GDK_CROSSING_NORMAL)
- {
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postMouseEventID,
- AWT_MOUSE_EXITED,
- (jlong)event->crossing.time,
- state_to_awt_mods_with_button_states (event->crossing.state),
- (jint)event->crossing.x,
- (jint)event->crossing.y,
- 0,
- JNI_FALSE);
- gdk_threads_enter ();
- }
- break;
- case GDK_CONFIGURE:
- {
- /* Only send configure events to visible top-level windows. */
- if (widget && GTK_WIDGET_TOPLEVEL (widget)
- && GTK_WIDGET_VISIBLE (widget))
- {
- /* Configure events are not posted to the AWT event
- queue, and as such, the gdk/gtk peer functions will
- be called back before postConfigureEvent
- returns. */
- gdk_threads_leave ();
-
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postConfigureEventID,
- (jint) event->configure.x,
- (jint) event->configure.y,
- (jint) event->configure.width,
- (jint) event->configure.height);
- gdk_threads_enter ();
- }
- }
- break;
- case GDK_EXPOSE:
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postExposeEventID,
- (jint)event->expose.area.x,
- (jint)event->expose.area.y,
- (jint)event->expose.area.width,
- (jint)event->expose.area.height);
- gdk_threads_enter ();
- break;
-
- case GDK_FOCUS_CHANGE:
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postFocusEventID,
- (jint) (event->focus_change.in) ?
- AWT_FOCUS_GAINED : AWT_FOCUS_LOST,
- JNI_FALSE);
- gdk_threads_enter ();
- break;
- case GDK_KEY_PRESS:
- if (GTK_IS_WINDOW (widget))
- {
- /* GdkEventKey *keyevent = (GdkEventKey *) event; */
- /* g_printerr ("key press event: sent: %d time: %d state: %d keyval: %d length: %d string: %s hardware_keycode: %d group: %d\n", keyevent->send_event, keyevent->time, keyevent->state, keyevent->keyval, keyevent->length, keyevent->string, keyevent->hardware_keycode, keyevent->group); */
-
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postKeyEventID,
- (jint) AWT_KEY_PRESSED,
- (jlong) event->key.time,
- keyevent_state_to_awt_mods (event),
- keysym_to_awt_keycode (event),
- keyevent_to_awt_keychar (event),
- keysym_to_awt_keylocation (event));
- gdk_threads_enter ();
- /* FIXME: generation of key typed events needs to be moved
- to GtkComponentPeer.postKeyEvent. If the key in a key
- press event is not an "action" key
- (KeyEvent.isActionKey) and is not a modifier key, then
- it should generate a key typed event. */
- return TRUE;
- }
- else
- return FALSE;
- break;
- case GDK_KEY_RELEASE:
- if (GTK_IS_WINDOW (widget))
- {
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postKeyEventID,
- (jint) AWT_KEY_RELEASED,
- (jlong) event->key.time,
- keyevent_state_to_awt_mods (event),
- keysym_to_awt_keycode (event),
- keyevent_to_awt_keychar (event),
- keysym_to_awt_keylocation (event));
- gdk_threads_enter ();
- return TRUE;
- }
- else
- return FALSE;
- break;
- default:
- break;
- }
-
- return FALSE;
-}
-
-static void
-attach_jobject (GdkWindow *window, jobject *obj)
-{
- GdkAtom addr_atom = gdk_atom_intern ("_GNU_GTKAWT_ADDR", FALSE);
- GdkAtom type_atom = gdk_atom_intern ("CARDINAL", FALSE);
-
- gdk_window_set_events (window,
- gdk_window_get_events (window)
- | GDK_POINTER_MOTION_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_KEY_PRESS_MASK
- | GDK_KEY_RELEASE_MASK
- | GDK_ENTER_NOTIFY_MASK
- | GDK_LEAVE_NOTIFY_MASK
- | GDK_STRUCTURE_MASK
- | GDK_KEY_PRESS_MASK
- | GDK_FOCUS_CHANGE_MASK);
-
- gdk_property_change (window,
- addr_atom,
- type_atom,
- 8,
- GDK_PROP_MODE_REPLACE,
- (guchar *)obj,
- sizeof (jobject));
-}
-
-void
-connect_awt_hook (JNIEnv *env, jobject peer_obj, int nwindows, ...)
-{
- va_list ap;
- jobject *obj;
-
- obj = NSA_GET_GLOBAL_REF (env, peer_obj);
- g_assert (obj);
-
- va_start (ap, nwindows);
- {
- int i;
- for (i = 0; i < nwindows; i++)
- {
- GdkWindow* attach = (va_arg (ap, GdkWindow *));
- attach_jobject(attach, obj);
- }
- }
- va_end (ap);
-}
-
-/*
- * Attach a Java object that is backed by widget. This callback is
- * called after the widget's window has been realized. That way, we
- * can be sure that widget->window is non-NULL, and so can have data
- * connected to it.
- */
-void connect_awt_hook_cb (GtkWidget *widget __attribute__((unused)),
- jobject peer)
-{
- void *ptr;
-
- ptr = NSA_GET_PTR (gdk_env(), peer);
-
- connect_awt_hook (gdk_env(), peer, 1, GTK_WIDGET (ptr)->window);
-
- gdk_threads_leave ();
-
- (*gdk_env())->CallVoidMethod (gdk_env(), peer, setCursorID);
-
- gdk_threads_enter ();
-}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
index 791916174..48478d3b9 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -40,9 +40,9 @@ exception statement from your version. */
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
#include "gnu_java_awt_peer_gtk_GtkFileDialogPeer.h"
-static void handle_response (GtkDialog *dialog,
- gint responseId,
- jobject peer_obj);
+static void handle_response_cb (GtkDialog *dialog,
+ gint responseId,
+ jobject peer_obj);
/*
* Make a new file selection dialog
@@ -55,13 +55,13 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_create
void *parentp;
gpointer widget;
+ gdk_threads_enter ();
+
/* Create global reference and save it for future use */
NSA_SET_GLOBAL_REF (env, obj);
parentp = NSA_GET_PTR(env, parent);
- gdk_threads_enter ();
-
/* 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 */
@@ -79,31 +79,34 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_create
/* We must add this window to the group so input in the others are
disable while it is being shown */
- gtk_window_group_add_window (global_gtk_window_group, GTK_WINDOW (widget));
-
- gdk_threads_leave ();
+ gtk_window_group_add_window (cp_gtk_global_window_group,
+ GTK_WINDOW (widget));
NSA_SET_PTR (env, obj, widget);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_connectSignals
(JNIEnv *env, jobject obj)
{
- void *ptr = NSA_GET_PTR (env, obj);
- jobject *gref = NSA_GET_GLOBAL_REF (env, obj);
- g_assert (gref);
+ void *ptr = NULL;
+ jobject *gref = NULL;
gdk_threads_enter ();
- g_signal_connect (G_OBJECT (GTK_DIALOG (ptr)),
- "response",
- GTK_SIGNAL_FUNC (handle_response), *gref);
+ ptr = NSA_GET_PTR (env, obj);
+ gref = NSA_GET_GLOBAL_REF (env, obj);
- gdk_threads_leave ();
+ /* FileDialog signals */
+ g_signal_connect (G_OBJECT (ptr), "response",
+ G_CALLBACK (handle_response_cb), *gref);
+
+ /* Component signals */
+ cp_gtk_component_connect_signals (G_OBJECT (ptr), gref);
- /* Connect the superclass signals. */
- Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env, obj);
+ gdk_threads_leave ();
}
JNIEXPORT jstring JNICALL
@@ -113,10 +116,10 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeGetDirectory
void *ptr;
const char *str;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
str = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER(ptr));
gdk_threads_leave ();
@@ -137,14 +140,16 @@ static gboolean filenameFilterCallback (const GtkFileFilterInfo *filter_info,
jstring *filename;
gboolean accepted;
- cx = (*gdk_env())->GetObjectClass (gdk_env(), (jobject) obj);
- id = (*gdk_env())->GetMethodID (gdk_env(), cx, "filenameFilterCallback",
+ 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 = (*gdk_env())->NewStringUTF(gdk_env(), filter_info->filename);
+ filename = (*cp_gtk_gdk_env())->NewStringUTF(cp_gtk_gdk_env(), filter_info->filename);
gdk_threads_leave();
- accepted = (*gdk_env())->CallBooleanMethod(gdk_env(), obj, id, filename);
+
+ accepted = (*cp_gtk_gdk_env())->CallBooleanMethod(cp_gtk_gdk_env(), obj, id, filename);
+
gdk_threads_enter();
return accepted;
@@ -157,10 +162,10 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeSetFilenameFilter
void *ptr;
GtkFileFilter *filter;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
filter = gtk_file_filter_new();
gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME,
filenameFilterCallback, obj, NULL);
@@ -177,15 +182,17 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeSetDirectory
void *ptr;
const char *str;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
str = (*env)->GetStringUTFChars (env, directory, 0);
- gdk_threads_enter ();
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(ptr), str);
- gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, directory, str);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -195,21 +202,23 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeSetFile
void *ptr;
const char *str;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
str = (*env)->GetStringUTFChars (env, filename, 0);
- gdk_threads_enter ();
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (ptr), str);
- gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, filename, str);
+
+ gdk_threads_leave ();
}
static void
-handle_response (GtkDialog *dialog __attribute__((unused)),
- gint responseId,
- jobject peer_obj)
+handle_response_cb (GtkDialog *dialog __attribute__((unused)),
+ gint responseId,
+ jobject peer_obj)
{
static int isDisposeIDSet = 0;
static int isIDSet = 0;
@@ -227,47 +236,45 @@ handle_response (GtkDialog *dialog __attribute__((unused)),
&& responseId != GTK_RESPONSE_CANCEL)
return;
- ptr = NSA_GET_PTR (gdk_env(), peer_obj);
+ ptr = NSA_GET_PTR (cp_gtk_gdk_env(), peer_obj);
if (responseId == GTK_RESPONSE_DELETE_EVENT)
{
if (!isDisposeIDSet)
{
- jclass cx = (*gdk_env())->GetObjectClass (gdk_env(), peer_obj);
- disposeID = (*gdk_env())->GetMethodID (gdk_env(), cx, "gtkDisposeFileDialog", "()V");
+ 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;
}
-
- gdk_threads_leave ();
/* We can dispose of the dialog now (and unblock show) */
- (*gdk_env())->CallVoidMethod (gdk_env(), peer_obj, disposeID);
-
+ gdk_threads_leave ();
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, disposeID);
gdk_threads_enter ();
+
return;
}
if (responseId == GTK_RESPONSE_ACCEPT) {
fileName = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (GTK_WIDGET (ptr)));
- str_fileName = (*gdk_env())->NewStringUTF (gdk_env(), fileName);
+ str_fileName = (*cp_gtk_gdk_env())->NewStringUTF (cp_gtk_gdk_env(), fileName);
}
if (!isIDSet)
{
- jclass cx = (*gdk_env())->GetObjectClass (gdk_env(), peer_obj);
- hideID = (*gdk_env())->GetMethodID (gdk_env(), cx, "gtkHideFileDialog", "()V");
- gtkSetFilenameID = (*gdk_env())->GetMethodID (gdk_env(), cx,
+ 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;
}
-
- gdk_threads_leave ();
-
+
/* Set the Java object field 'file' with this value. */
- (*gdk_env())->CallVoidMethod (gdk_env(), peer_obj, gtkSetFilenameID, str_fileName);
+ gdk_threads_leave ();
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, gtkSetFilenameID, str_fileName);
/* We can hide the dialog now (and unblock show) */
- (*gdk_env())->CallVoidMethod (gdk_env(), peer_obj, hideID);
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, hideID);
gdk_threads_enter ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
index 6671a0526..41dfcea67 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
@@ -15,8 +15,8 @@
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.
+ 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
@@ -38,10 +38,6 @@
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkFramePeer.h"
-/* lives in GtkImage.c */
-GdkPixbuf *gnu_java_awt_peer_gtk_GtkImage_getPixbuf(JNIEnv *env, jobject obj);
-jboolean gnu_java_awt_peer_gtk_GtkImage_isOffScreen(JNIEnv *env, jobject obj);
-
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkFramePeer_removeMenuBarPeer
(JNIEnv *env, jobject obj)
@@ -51,10 +47,10 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_removeMenuBarPeer
void *fixed;
GList* children;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
fixed = gtk_container_get_children (GTK_CONTAINER (ptr))->data;
children = gtk_container_get_children (GTK_CONTAINER (fixed));
@@ -86,11 +82,11 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarPeer
void *mptr;
void *fixed;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
mptr = NSA_GET_PTR (env, menubar);
- gdk_threads_enter ();
-
fixed = gtk_container_get_children (GTK_CONTAINER (ptr))->data;
gtk_fixed_put (GTK_FIXED (fixed), mptr, 0, 0);
gtk_widget_show (mptr);
@@ -105,10 +101,10 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_getMenuBarHeight
GtkWidget *ptr;
GtkRequisition requisition;
- ptr = NSA_GET_PTR (env, menubar);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, menubar);
+
gtk_widget_size_request (ptr, &requisition);
gdk_threads_leave ();
@@ -123,10 +119,10 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidth
GtkWidget *ptr;
GtkRequisition natural_req;
- ptr = NSA_GET_PTR (env, menubar);
-
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);
@@ -145,10 +141,10 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_gtkFixedSetVisible
void *ptr;
void *fixed;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
fixed = gtk_container_get_children (GTK_CONTAINER (ptr))->data;
if (visible)
@@ -164,22 +160,21 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImage
(JNIEnv *env, jobject obj, jobject gtkimage)
{
void *ptr;
- GdkPixbuf *pixbuf = gnu_java_awt_peer_gtk_GtkImage_getPixbuf(env, gtkimage);
+ GdkPixbuf *pixbuf = NULL;
+ gdk_threads_enter ();
+
+ pixbuf = cp_gtk_image_get_pixbuf (env, gtkimage);
g_assert (pixbuf != NULL);
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
-
gtk_window_set_icon (GTK_WINDOW (ptr), pixbuf);
/* if the GtkImage is offscreen, this is a temporary pixbuf which should
be thrown out. */
- if(gnu_java_awt_peer_gtk_GtkImage_isOffScreen(env, gtkimage) == JNI_TRUE)
+ if(cp_gtk_image_is_offscreen (env, gtkimage) == JNI_TRUE)
gdk_pixbuf_unref (pixbuf);
gdk_threads_leave ();
}
-
-
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c
index 49ccffcf6..0fae1da42 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -45,20 +45,20 @@ Java_gnu_java_awt_peer_gtk_GtkGenericPeer_dispose
{
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
/* For now the native state for any object must be a widget.
However, a subclass could override dispose() if required. */
gtk_widget_destroy (GTK_WIDGET (ptr));
- gdk_threads_leave ();
-
/* Remove entries from state tables */
NSA_DEL_GLOBAL_REF (env, obj);
NSA_DEL_PTR (env, obj);
+ gdk_threads_leave ();
+
/*
* Wake up the main thread, to make sure it re-checks the window
* destruction condition.
@@ -75,14 +75,15 @@ Java_gnu_java_awt_peer_gtk_GtkGenericPeer_gtkWidgetModifyFont
void *ptr;
PangoFontDescription *font_desc;
+ gdk_threads_enter();
+
ptr = NSA_GET_PTR (env, obj);
font_name = (*env)->GetStringUTFChars (env, name, NULL);
- gdk_threads_enter();
-
font_desc = pango_font_description_from_string (font_name);
- pango_font_description_set_size (font_desc, size * dpi_conversion_factor);
+ pango_font_description_set_size (font_desc,
+ size * cp_gtk_dpi_conversion_factor);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
@@ -94,7 +95,7 @@ Java_gnu_java_awt_peer_gtk_GtkGenericPeer_gtkWidgetModifyFont
pango_font_description_free (font_desc);
- gdk_threads_leave();
-
(*env)->ReleaseStringUTFChars (env, name, font_name);
+
+ gdk_threads_leave();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
index df76adb49..31b9f08d4 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -46,11 +46,6 @@ exception statement from your version. */
#define SCALE_REPLICATE 8
#define SCALE_AREA_AVERAGING 16
-/* functions used by other gtk peer native routines */
-GdkPixbuf *gnu_java_awt_peer_gtk_GtkImage_getPixbuf(JNIEnv *env, jobject obj);
-GdkPixmap *gnu_java_awt_peer_gtk_GtkImage_getPixmap(JNIEnv *env, jobject obj);
-jboolean gnu_java_awt_peer_gtk_GtkImage_isOffScreen(JNIEnv *env, jobject obj);
-
/* local stuff */
static GdkInterpType mapHints(jint hints);
static jboolean offScreen (JNIEnv * env, jobject obj);
@@ -69,30 +64,35 @@ Java_gnu_java_awt_peer_gtk_GtkImage_loadPixbuf
int width, height;
GdkPixbuf *pixbuf;
+ gdk_threads_enter ();
+
/* Don't use the JCL convert function because it throws an exception
on failure */
filename = (*env)->GetStringUTFChars (env, name, 0);
if (filename == NULL)
- return JNI_FALSE;
-
- gdk_threads_enter ();
+ {
+ gdk_threads_leave ();
+ return JNI_FALSE;
+ }
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
if (pixbuf == NULL)
{
- gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, name, filename);
+ gdk_threads_leave ();
return JNI_FALSE;
}
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
- gdk_threads_leave ();
createRawData (env, obj, pixbuf);
setWidthHeight(env, obj, width, height);
(*env)->ReleaseStringUTFChars (env, name, filename);
+
+ gdk_threads_leave ();
+
return JNI_TRUE;
}
@@ -107,33 +107,60 @@ Java_gnu_java_awt_peer_gtk_GtkImage_getPixels(JNIEnv *env, jobject obj)
guchar *pixeldata;
jintArray result_array;
jint *result_array_iter, *dst;
- int i;
+ int i,j;
gdk_threads_enter ();
- pixbuf = gnu_java_awt_peer_gtk_GtkImage_getPixbuf(env, obj);
+ pixbuf = cp_gtk_image_get_pixbuf (env, obj);
width = gdk_pixbuf_get_width (pixbuf);
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);
+
pixeldata = gdk_pixbuf_get_pixels (pixbuf);
- for(i = 0 ; i < height; i++)
+
+ g_assert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
+
+ if (gdk_pixbuf_get_has_alpha (pixbuf))
{
- memcpy(dst, (void *)pixeldata, width * 4);
- dst += width;
- pixeldata += rowstride;
+ for(i = 0 ; i < height; i++)
+ {
+ memcpy(dst, (void *)pixeldata, width * 4);
+ dst += width;
+ pixeldata += rowstride;
+ }
+ } else {
+ for(i = 0; i < height; i++)
+ {
+ for(j = 0; j < width; j++)
+ dst[j] = 0xFF000000 |
+ (pixeldata[j*3 + 2] & 0xFF) << 16 |
+ (pixeldata[j*3 + 1] & 0xFF) << 8 |
+ (pixeldata[j*3] & 0xFF);
+ dst += width;
+ pixeldata += rowstride;
+ }
}
-
+
if (offScreen (env, obj) == JNI_TRUE)
gdk_pixbuf_unref (pixbuf);
+
+ (*env)->ReleaseIntArrayElements (env, result_array, result_array_iter, 0);
gdk_threads_leave ();
- (*env)->ReleaseIntArrayElements (env, result_array, result_array_iter, 0);
return result_array;
}
@@ -168,9 +195,9 @@ Java_gnu_java_awt_peer_gtk_GtkImage_setPixels(JNIEnv *env, jobject obj,
pixeldata += rowstride;
}
- gdk_threads_leave ();
-
(*env)->ReleaseIntArrayElements (env, pixels, src_array_iter, 0);
+
+ gdk_threads_leave ();
}
/**
@@ -183,6 +210,8 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createPixmap(JNIEnv *env, jobject obj)
jclass cls;
jfieldID field;
+ gdk_threads_enter ();
+
cls = (*env)->GetObjectClass (env, obj);
field = (*env)->GetFieldID (env, cls, "width", "I");
g_assert (field != 0);
@@ -192,7 +221,6 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createPixmap(JNIEnv *env, jobject obj)
g_assert (field != 0);
height = (*env)->GetIntField (env, obj, field);
- gdk_threads_enter ();
if (offScreen (env, obj) == JNI_FALSE)
createRawData (env, obj, gdk_pixbuf_new (GDK_COLORSPACE_RGB,
TRUE,
@@ -238,6 +266,8 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createScaledPixmap(JNIEnv *env,
GdkPixbuf *pixbuf;
+ gdk_threads_enter ();
+
cls = (*env)->GetObjectClass (env, destination);
field = (*env)->GetFieldID (env, cls, "width", "I");
g_assert (field != 0);
@@ -247,9 +277,7 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createScaledPixmap(JNIEnv *env,
g_assert (field != 0);
height = (*env)->GetIntField (env, destination, field);
- gdk_threads_enter ();
-
- pixbuf = gnu_java_awt_peer_gtk_GtkImage_getPixbuf(env, source);
+ pixbuf = cp_gtk_image_get_pixbuf (env, source);
dst = gdk_pixbuf_scale_simple(pixbuf,
width, height,
@@ -258,9 +286,9 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createScaledPixmap(JNIEnv *env,
if (offScreen (env, source) == JNI_TRUE)
gdk_pixbuf_unref (pixbuf);
- gdk_threads_leave ();
-
createRawData (env, destination, (void *)dst);
+
+ gdk_threads_leave ();
}
/**
@@ -277,12 +305,12 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled
struct graphics *g;
guint32 bgColor;
+ gdk_threads_enter ();
+
bgColor = ((bg_red & 0xFF) << 16) |
((bg_green & 0xFF) << 8) | (bg_blue & 0xFF);
- gdk_threads_enter ();
-
- 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))
{
@@ -350,12 +378,12 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped
struct graphics *g;
guint32 bgColor;
+ gdk_threads_enter ();
+
bgColor = ((bg_red & 0xFF) << 16) |
((bg_green & 0xFF) << 8) | (bg_blue & 0xFF);
- gdk_threads_enter ();
-
- 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))
{
@@ -433,13 +461,14 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped
GDK_RGB_DITHER_NORMAL, 0, 0);
gdk_pixbuf_unref (dst);
+
gdk_threads_leave ();
}
/**
* Used by GtkFramePeer
*/
-GdkPixbuf *gnu_java_awt_peer_gtk_GtkImage_getPixbuf(JNIEnv *env, jobject obj)
+GdkPixbuf *cp_gtk_image_get_pixbuf (JNIEnv *env, jobject obj)
{
int width, height;
GdkPixbuf *pixbuf;
@@ -473,14 +502,14 @@ GdkPixbuf *gnu_java_awt_peer_gtk_GtkImage_getPixbuf(JNIEnv *env, jobject obj)
/**
* Used by GdkGraphics
*/
-GdkPixmap *gnu_java_awt_peer_gtk_GtkImage_getPixmap(JNIEnv *env, jobject obj)
+GdkPixmap *cp_gtk_image_get_pixmap (JNIEnv *env, jobject obj)
{
if (offScreen (env, obj) == JNI_FALSE)
return NULL;
return (GdkPixmap *)getData (env, obj);
}
-jboolean gnu_java_awt_peer_gtk_GtkImage_isOffScreen(JNIEnv *env, jobject obj)
+jboolean cp_gtk_image_is_offscreen (JNIEnv *env, jobject obj)
{
return offScreen(env, obj);
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
index 25c895546..7968ca773 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -47,23 +47,23 @@ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_create
GtkWidget *eventbox;
const char *str;
+ gdk_threads_enter ();
+
NSA_SET_GLOBAL_REF (env, obj);
str = (*env)->GetStringUTFChars (env, text, 0);
- gdk_threads_enter ();
-
eventbox = gtk_event_box_new ();
label = gtk_label_new (str);
gtk_misc_set_alignment (GTK_MISC (label), xalign, 0.5);
gtk_container_add (GTK_CONTAINER (eventbox), label);
gtk_widget_show (label);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, text, str);
NSA_SET_PTR (env, obj, eventbox);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -75,19 +75,23 @@ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkWidgetModifyFont
GtkWidget *label;
PangoFontDescription *font_desc;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
font_name = (*env)->GetStringUTFChars (env, name, NULL);
- gdk_threads_enter ();
-
label = gtk_bin_get_child (GTK_BIN (ptr));
if (!label)
- return;
+ {
+ gdk_threads_leave ();
+ return;
+ }
font_desc = pango_font_description_from_string (font_name);
- pango_font_description_set_size (font_desc, size * dpi_conversion_factor);
+ pango_font_description_set_size (font_desc,
+ size * cp_gtk_dpi_conversion_factor);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
@@ -99,9 +103,9 @@ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkWidgetModifyFont
pango_font_description_free (font_desc);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, name, font_name);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -112,19 +116,19 @@ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setText
void *ptr;
GtkWidget *label;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
str = (*env)->GetStringUTFChars (env, text, 0);
- gdk_threads_enter ();
-
label = gtk_bin_get_child (GTK_BIN (ptr));
gtk_label_set_label (GTK_LABEL (label), str);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, text, str);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -134,10 +138,10 @@ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_nativeSetAlignment
void *ptr;
GtkWidget *label;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
label = gtk_bin_get_child (GTK_BIN(ptr));
gtk_misc_set_alignment (GTK_MISC (label), xalign, 0.5);
@@ -152,10 +156,10 @@ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setNativeBounds
GtkWidget *widget;
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
widget = GTK_WIDGET (ptr);
/* We assume that -1 is a width or height and not a request for the
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
index 468be06c1..d513176be 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
@@ -15,8 +15,8 @@
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.
+ 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
@@ -38,21 +38,33 @@
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkListPeer.h"
+static jmethodID postListItemEventID;
+
+void
+cp_gtk_list_init_jni (void)
+{
+ jclass gtklistpeer;
+
+ gtklistpeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
+ "gnu/java/awt/peer/gtk/GtkListPeer");
+
+ postListItemEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtklistpeer,
+ "postItemEvent",
+ "(II)V");
+}
+
enum
{
COLUMN_STRING,
N_COLUMNS
};
-gboolean item_highlighted (GtkTreeSelection *selection,
- GtkTreeModel *model,
- GtkTreePath *path,
- gboolean path_currently_selected,
- jobject peer);
-
+static gboolean item_highlighted_cb (GtkTreeSelection *selection,
+ GtkTreeModel *model,
+ GtkTreePath *path,
+ gboolean path_currently_selected,
+ jobject peer);
-#define TREE_VIEW_FROM_SW(obj) \
- (GTK_TREE_VIEW (GTK_SCROLLED_WINDOW (obj)->container.child))
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkListPeer_create
@@ -67,11 +79,11 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_create
GtkRequisition req;
gint i;
+ gdk_threads_enter ();
+
/* Create global reference and save it for future use */
NSA_SET_GLOBAL_REF (env, obj);
- gdk_threads_enter ();
-
list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING);
/* Add the number of rows so that we can calculate the tree view's
size request. */
@@ -111,9 +123,9 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_create
gtk_widget_show (list);
gtk_widget_show (sw);
- gdk_threads_leave ();
-
NSA_SET_PTR (env, obj, sw);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -122,25 +134,22 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_connectSignals
{
void *ptr;
jobject *gref;
- GtkTreeView *list;
+ GtkWidget *list;
GtkTreeSelection *selection;
- ptr = NSA_GET_PTR (env, obj);
- gref = NSA_GET_GLOBAL_REF (env, obj);
-
gdk_threads_enter ();
- g_assert (gref);
-
- list = TREE_VIEW_FROM_SW (ptr);
+ ptr = NSA_GET_PTR (env, obj);
+ gref = NSA_GET_GLOBAL_REF (env, obj);
- g_signal_connect (G_OBJECT (list), "event",
- G_CALLBACK (pre_event_handler), *gref);
+ list = gtk_bin_get_child (GTK_BIN (ptr));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
- gtk_tree_selection_set_select_function (selection, item_highlighted,
+ gtk_tree_selection_set_select_function (selection, item_highlighted_cb,
*gref, NULL);
+ cp_gtk_component_connect_signals (G_OBJECT (list), gref);
+
gdk_threads_leave ();
}
@@ -153,16 +162,17 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_gtkWidgetModifyFont
GtkWidget *list;
PangoFontDescription *font_desc;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter();
- list = GTK_WIDGET (TREE_VIEW_FROM_SW (ptr));
+ ptr = NSA_GET_PTR (env, obj);
+
+ list = gtk_bin_get_child (GTK_BIN (ptr));
font_name = (*env)->GetStringUTFChars (env, name, NULL);
font_desc = pango_font_description_from_string (font_name);
- pango_font_description_set_size (font_desc, size * dpi_conversion_factor);
+ pango_font_description_set_size (font_desc,
+ size * cp_gtk_dpi_conversion_factor);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
@@ -186,11 +196,11 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_gtkWidgetRequestFocus
void *ptr;
GtkWidget *list;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
- list = GTK_WIDGET (TREE_VIEW_FROM_SW (ptr));
+ ptr = NSA_GET_PTR (env, obj);
+
+ list = gtk_bin_get_child (GTK_BIN (ptr));
gtk_widget_grab_focus (list);
gdk_threads_leave ();
@@ -201,20 +211,20 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_append
(JNIEnv *env, jobject obj, jobjectArray items)
{
void *ptr;
- GtkTreeView *list;
+ GtkWidget *list;
GtkTreeIter iter;
GtkTreeModel *list_store;
jint count;
jint i;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
count = (*env)->GetArrayLength (env, items);
- gdk_threads_enter ();
-
- list = TREE_VIEW_FROM_SW (ptr);
- list_store = gtk_tree_view_get_model (list);
+ list = gtk_bin_get_child (GTK_BIN (ptr));
+ list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (list));
for (i = 0; i < count; i++)
{
@@ -240,17 +250,17 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_add
{
void *ptr;
const char *str;
- GtkTreeView *list;
+ GtkWidget *list;
GtkTreeIter iter;
GtkTreeModel *list_store;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
str = (*env)->GetStringUTFChars (env, text, NULL);
- gdk_threads_enter ();
-
- list = TREE_VIEW_FROM_SW (ptr);
- list_store = gtk_tree_view_get_model (list);
+ list = gtk_bin_get_child (GTK_BIN (ptr));
+ list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (list));
if (index == -1)
gtk_list_store_append (GTK_LIST_STORE (list_store), &iter);
@@ -260,9 +270,9 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_add
gtk_list_store_set (GTK_LIST_STORE (list_store), &iter,
COLUMN_STRING, str, -1);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, text, str);
+
+ gdk_threads_leave ();
}
@@ -271,18 +281,18 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_delItems
(JNIEnv *env, jobject obj, jint start, jint end)
{
void *ptr;
- GtkTreeView *list;
+ GtkWidget *list;
GtkTreeIter iter;
GtkTreeModel *list_store;
jint i;
jint num_items;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
- list = TREE_VIEW_FROM_SW (ptr);
- list_store = gtk_tree_view_get_model (list);
+ ptr = NSA_GET_PTR (env, obj);
+
+ list = gtk_bin_get_child (GTK_BIN (ptr));
+ list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (list));
/* Special case: remove all rows. */
if (end == -1)
@@ -307,16 +317,16 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_select
(JNIEnv *env, jobject obj, jint index)
{
void *ptr;
- GtkTreeView *list;
+ GtkWidget *list;
GtkTreePath *path;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
- list = TREE_VIEW_FROM_SW (ptr);
+ ptr = NSA_GET_PTR (env, obj);
+
+ list = gtk_bin_get_child (GTK_BIN (ptr));
path = gtk_tree_path_new_from_indices (index, -1);
- gtk_tree_view_set_cursor (list, path, NULL, FALSE);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (list), path, NULL, FALSE);
gdk_threads_leave ();
}
@@ -326,16 +336,16 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_deselect
(JNIEnv *env, jobject obj, jint index)
{
void *ptr;
- GtkTreeView *list;
+ GtkWidget *list;
GtkTreeSelection *selection;
GtkTreePath *path;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
- list = TREE_VIEW_FROM_SW (ptr);
- selection = gtk_tree_view_get_selection (list);
+ ptr = NSA_GET_PTR (env, obj);
+
+ list = gtk_bin_get_child (GTK_BIN (ptr));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
path = gtk_tree_path_new_from_indices (index, -1);
gtk_tree_selection_unselect_path (selection, path);
@@ -351,13 +361,13 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_getSize
GtkRequisition current_req;
GtkRequisition natural_req;
+ gdk_threads_enter ();
+
dims = (*env)->GetIntArrayElements (env, jdims, NULL);
dims[0] = dims[1] = 0;
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
-
/* Save the widget's current size request. */
gtk_widget_size_request (GTK_WIDGET (ptr), &current_req);
@@ -381,9 +391,9 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_getSize
else
dims[1] = natural_req.height / visible_rows * rows;
- gdk_threads_leave ();
-
(*env)->ReleaseIntArrayElements (env, jdims, dims, 0);
+
+ gdk_threads_leave ();
}
@@ -392,7 +402,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_getSelectedIndexes
(JNIEnv *env, jobject obj)
{
void *ptr;
- GtkTreeView *list;
+ GtkWidget *list;
GtkTreeSelection *selection;
jintArray result_array;
jint *result_array_iter;
@@ -402,18 +412,23 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_getSelectedIndexes
jint count;
jint i;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
- list = TREE_VIEW_FROM_SW (ptr);
- selection = gtk_tree_view_get_selection (list);
+ ptr = NSA_GET_PTR (env, obj);
+
+ list = gtk_bin_get_child (GTK_BIN (ptr));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
count = gtk_tree_selection_count_selected_rows (selection);
if (count > 0)
{
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++)
@@ -429,16 +444,14 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_getSelectedIndexes
g_list_free (rows);
}
- gdk_threads_leave ();
-
(*env)->ReleaseIntArrayElements (env, result_array, result_array_iter, 0);
-
- return result_array;
}
else
- gdk_threads_leave ();
+ result_array = NULL;
- return (jintArray) NULL;
+ gdk_threads_leave ();
+
+ return result_array;
}
JNIEXPORT void JNICALL
@@ -446,16 +459,17 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_makeVisible
(JNIEnv *env, jobject obj, jint index)
{
void *ptr;
- GtkTreeView *list;
+ GtkWidget *list;
GtkTreePath *path;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
- list = TREE_VIEW_FROM_SW (ptr);
+ ptr = NSA_GET_PTR (env, obj);
+
+ list = gtk_bin_get_child (GTK_BIN (ptr));
path = gtk_tree_path_new_from_indices (index, -1);
- gtk_tree_view_scroll_to_cell (list, path, NULL, FALSE, 0.0, 0.0);
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (list), path,
+ NULL, FALSE, 0.0, 0.0);
gdk_threads_leave ();
}
@@ -465,15 +479,15 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_setMultipleMode
(JNIEnv *env, jobject obj, jboolean mode)
{
void *ptr;
- GtkTreeView *list;
+ GtkWidget *list;
GtkTreeSelection *selection;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
- list = TREE_VIEW_FROM_SW (ptr);
- selection = gtk_tree_view_get_selection (list);
+ ptr = NSA_GET_PTR (env, obj);
+
+ list = gtk_bin_get_child (GTK_BIN (ptr));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
gtk_tree_selection_set_mode (selection,
mode ? GTK_SELECTION_MULTIPLE
: GTK_SELECTION_SINGLE);
@@ -481,12 +495,12 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_setMultipleMode
gdk_threads_leave ();
}
-gboolean
-item_highlighted (GtkTreeSelection *selection __attribute__((unused)),
- GtkTreeModel *model,
- GtkTreePath *path,
- gboolean path_currently_selected,
- jobject peer)
+static gboolean
+item_highlighted_cb (GtkTreeSelection *selection __attribute__((unused)),
+ GtkTreeModel *model,
+ GtkTreePath *path,
+ gboolean path_currently_selected,
+ jobject peer)
{
GtkTreeIter iter;
jint row;
@@ -498,15 +512,27 @@ item_highlighted (GtkTreeSelection *selection __attribute__((unused)),
row = indices ? indices[0] : -1;
if (!path_currently_selected)
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
- postListItemEventID,
- row,
- (jint) AWT_ITEM_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_env())->CallVoidMethod (gdk_env(), peer,
- postListItemEventID,
- row,
- (jint) AWT_ITEM_DESELECTED);
+ {
+ gdk_threads_leave ();
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
+ postListItemEventID,
+ row,
+ (jint) AWT_ITEM_DESELECTED);
+
+ gdk_threads_enter ();
+ }
}
return TRUE;
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c
index 563bf4810..3e21a0402 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -45,16 +45,16 @@ Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_create
{
GtkWidget *widget;
- NSA_SET_GLOBAL_REF (env, obj);
-
gdk_threads_enter ();
+ NSA_SET_GLOBAL_REF (env, obj);
+
widget = gtk_menu_bar_new ();
gtk_widget_show (widget);
- gdk_threads_leave ();
-
NSA_SET_PTR (env, obj, widget);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -63,11 +63,13 @@ Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_addMenu
{
void *mbar, *menu;
+ gdk_threads_enter ();
+
mbar = NSA_GET_PTR (env, obj);
menu = NSA_GET_PTR (env, menupeer);
- gdk_threads_enter ();
gtk_menu_shell_append (GTK_MENU_SHELL (mbar), GTK_WIDGET (menu));
+
gdk_threads_leave ();
}
@@ -79,10 +81,11 @@ Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_nativeSetHelpMenu
void *mbar, *menu;
GList *list;
+ gdk_threads_enter ();
+
mbar = NSA_GET_PTR (env, obj);
menu = NSA_GET_PTR (env, menupeer);
- gdk_threads_enter ();
if (helpmenu != NULL)
{
list = gtk_container_children (GTK_CONTAINER (mbar));
@@ -92,6 +95,7 @@ Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_nativeSetHelpMenu
gtk_container_remove (GTK_CONTAINER (mbar), GTK_WIDGET (list->data));
}
helpmenu = menu;
+
gdk_threads_leave ();
}
@@ -102,11 +106,13 @@ Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_delMenu
void *ptr;
GList *list;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
list = gtk_container_children (GTK_CONTAINER (ptr));
list = g_list_nth (list, index);
gtk_container_remove (GTK_CONTAINER (ptr), GTK_WIDGET (list->data));
+
gdk_threads_leave ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c
index c30ac29c9..01b74e46c 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c
index 1fe18f9f0..2746f1e4a 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -40,8 +40,24 @@ exception statement from your version. */
#include "gnu_java_awt_peer_gtk_GtkMenuItemPeer.h"
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
-static void item_activate (GtkMenuItem *item __attribute__((unused)),
- jobject peer_obj);
+static jmethodID postMenuActionEventID;
+
+void
+cp_gtk_menuitem_init_jni (void)
+{
+ jclass gtkmenuitempeer;
+
+ gtkmenuitempeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
+ "gnu/java/awt/peer/gtk/GtkMenuItemPeer");
+
+ postMenuActionEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
+ gtkmenuitempeer,
+ "postMenuActionEvent",
+ "()V");
+}
+
+static void item_activate_cb (GtkMenuItem *item __attribute__((unused)),
+ jobject peer_obj);
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_create
@@ -50,12 +66,12 @@ Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_create
GtkWidget *widget;
const char *str;
+ gdk_threads_enter ();
+
NSA_SET_GLOBAL_REF (env, obj);
str = (*env)->GetStringUTFChars (env, label, NULL);
- gdk_threads_enter ();
-
/* "-" signals that we need a separator. */
if (strcmp (str, "-") == 0)
widget = gtk_menu_item_new ();
@@ -64,25 +80,27 @@ Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_create
gtk_widget_show (widget);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, label, str);
NSA_SET_PTR (env, obj, widget);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_connectSignals
(JNIEnv *env, jobject obj)
{
- void *ptr = NSA_GET_PTR (env, obj);
- jobject *gref = NSA_GET_GLOBAL_REF (env, obj);
- g_assert (gref);
+ void *ptr;
+ jobject *gref;
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+ gref = NSA_GET_GLOBAL_REF (env, obj);
+
g_signal_connect (G_OBJECT (ptr), "activate",
- G_CALLBACK (item_activate), *gref);
+ G_CALLBACK (item_activate_cb), *gref);
gdk_threads_leave ();
}
@@ -96,18 +114,19 @@ Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_gtkWidgetModifyFont
GtkWidget *label;
PangoFontDescription *font_desc;
+ gdk_threads_enter();
+
ptr = NSA_GET_PTR (env, obj);
font_name = (*env)->GetStringUTFChars (env, name, NULL);
- gdk_threads_enter();
-
label = gtk_bin_get_child (GTK_BIN (ptr));
if (label)
{
font_desc = pango_font_description_from_string (font_name);
- pango_font_description_set_size (font_desc, size * dpi_conversion_factor);
+ pango_font_description_set_size (font_desc,
+ size * cp_gtk_dpi_conversion_factor);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
@@ -120,9 +139,9 @@ Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_gtkWidgetModifyFont
pango_font_description_free (font_desc);
}
- gdk_threads_leave();
-
(*env)->ReleaseStringUTFChars (env, name, font_name);
+
+ gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -131,10 +150,12 @@ Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_setEnabled
{
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
gtk_widget_set_sensitive (GTK_WIDGET (ptr), enabled);
+
gdk_threads_leave ();
}
@@ -146,25 +167,27 @@ Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_setLabel
const char *str;
GtkAccelLabel *accel_label;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
str = (*env)->GetStringUTFChars (env, label, NULL);
- gdk_threads_enter ();
-
accel_label = GTK_ACCEL_LABEL (GTK_BIN (ptr)->child);
gtk_label_set_text (GTK_LABEL (accel_label), str);
gtk_accel_label_refetch (accel_label);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, label, str);
+
+ gdk_threads_leave ();
}
static void
-item_activate (GtkMenuItem *item __attribute__((unused)), jobject peer_obj)
+item_activate_cb (GtkMenuItem *item __attribute__((unused)), jobject peer_obj)
{
- (*gdk_env())->CallVoidMethod (gdk_env(), peer_obj,
- postMenuActionEventID);
+ gdk_threads_leave ();
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj,
+ postMenuActionEventID);
+ gdk_threads_enter ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
index dd5511cf6..16018f001 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -45,9 +45,10 @@ Java_gnu_java_awt_peer_gtk_GtkMenuPeer_setupAccelGroup
{
void *ptr1, *ptr2;
+ gdk_threads_enter ();
+
ptr1 = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
if (!parent)
{
gtk_menu_set_accel_group (GTK_MENU (GTK_MENU_ITEM (ptr1)->submenu),
@@ -75,12 +76,12 @@ Java_gnu_java_awt_peer_gtk_GtkMenuPeer_create
GtkWidget *menu_title, *menu, *toplevel;
const char *str;
+ gdk_threads_enter ();
+
NSA_SET_GLOBAL_REF (env, obj);
str = (*env)->GetStringUTFChars (env, label, NULL);
- gdk_threads_enter ();
-
menu = gtk_menu_new ();
if (str != NULL)
@@ -94,7 +95,7 @@ Java_gnu_java_awt_peer_gtk_GtkMenuPeer_create
toplevel = gtk_widget_get_toplevel (menu);
if (GTK_IS_WINDOW (toplevel))
{
- gtk_window_group_add_window (global_gtk_window_group,
+ gtk_window_group_add_window (cp_gtk_global_window_group,
GTK_WINDOW(toplevel));
}
@@ -102,9 +103,9 @@ Java_gnu_java_awt_peer_gtk_GtkMenuPeer_create
NSA_SET_PTR (env, obj, menu_title);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, label, str);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -114,10 +115,10 @@ Java_gnu_java_awt_peer_gtk_GtkMenuPeer_addTearOff
void *ptr1;
GtkWidget *menu, *item;
- ptr1 = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr1 = NSA_GET_PTR (env, obj);
+
menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (ptr1));
item = gtk_tearoff_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
@@ -133,11 +134,11 @@ Java_gnu_java_awt_peer_gtk_GtkMenuPeer_addItem
void *ptr1, *ptr2;
GtkWidget *menu;
+ gdk_threads_enter ();
+
ptr1 = NSA_GET_PTR (env, obj);
ptr2 = NSA_GET_PTR (env, menuitempeer);
- gdk_threads_enter ();
-
menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(ptr1));
gtk_menu_shell_append (GTK_MENU_SHELL(menu), GTK_WIDGET (ptr2));
@@ -160,13 +161,13 @@ Java_gnu_java_awt_peer_gtk_GtkMenuPeer_delItem
void *ptr;
GList *list;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
list = gtk_container_children (GTK_CONTAINER (ptr));
list = g_list_nth (list, index);
gtk_container_remove (GTK_CONTAINER (ptr), GTK_WIDGET (list->data));
+
gdk_threads_leave ();
}
-
-
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c
index f432baf0c..8a130e1a4 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -40,23 +40,73 @@ exception statement from your version. */
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
#include "gnu_java_awt_peer_gtk_GtkPanelPeer.h"
+static gboolean panel_focus_in_cb (GtkWidget * widget,
+ GdkEventFocus *event,
+ jobject peer);
+static gboolean panel_focus_out_cb (GtkWidget * widget,
+ GdkEventFocus *event,
+ jobject peer);
+
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkPanelPeer_create
(JNIEnv *env, jobject obj)
{
GtkWidget *widget;
+ gdk_threads_enter ();
+
NSA_SET_GLOBAL_REF (env, obj);
- gdk_threads_enter ();
-
widget = gtk_fixed_new ();
gtk_fixed_set_has_window (GTK_FIXED (widget), TRUE);
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ NSA_SET_PTR (env, obj, widget);
+
gdk_threads_leave ();
+}
- NSA_SET_PTR (env, obj, widget);
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkPanelPeer_connectSignals
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ jobject *gref;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+ gref = NSA_GET_GLOBAL_REF (env, obj);
+
+ /* Panel signals. These callbacks prevent expose events being
+ delivered to the panel when it is focused. */
+ g_signal_connect (G_OBJECT (ptr), "focus-in-event",
+ G_CALLBACK (panel_focus_in_cb), *gref);
+
+ g_signal_connect (G_OBJECT (ptr), "focus-out-event",
+ G_CALLBACK (panel_focus_out_cb), *gref);
+
+ /* Component signals. Exclude focus signals. */
+ cp_gtk_component_connect_expose_signals (ptr, gref);
+ cp_gtk_component_connect_mouse_signals (ptr, gref);
+
+ gdk_threads_leave ();
+}
+
+static gboolean
+panel_focus_in_cb (GtkWidget * widget __attribute__((unused)),
+ GdkEventFocus *event __attribute__((unused)),
+ jobject peer __attribute__((unused)))
+{
+ return TRUE;
+}
+
+static gboolean
+panel_focus_out_cb (GtkWidget * widget __attribute__((unused)),
+ GdkEventFocus *event __attribute__((unused)),
+ jobject peer __attribute__((unused)))
+{
+ return TRUE;
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c
index 6cfe25497..e684a090f 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -65,18 +65,20 @@ Java_gnu_java_awt_peer_gtk_GtkPopupMenuPeer_show
void *ptr;
struct pos *p;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
p = g_malloc (sizeof (struct pos));
p->x = x;
p->y = y;
- gdk_threads_enter ();
gtk_menu_popup (GTK_MENU (GTK_MENU_ITEM (ptr)->submenu),
NULL, NULL, menu_pos, p, 0, time);
- gdk_threads_leave ();
g_free (p);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -86,10 +88,11 @@ Java_gnu_java_awt_peer_gtk_GtkPopupMenuPeer_setupAccelGroup
void *ptr1, *ptr2;
GtkMenu *menu;
+ gdk_threads_enter ();
+
ptr1 = NSA_GET_PTR (env, obj);
ptr2 = NSA_GET_PTR (env, parent);
- gdk_threads_enter ();
menu = GTK_MENU (GTK_MENU_ITEM (ptr1)->submenu);
gtk_menu_set_accel_group (menu, gtk_accel_group_new ());
/* FIXME: update this to use GTK-2.4 GtkActions. */
@@ -97,5 +100,6 @@ Java_gnu_java_awt_peer_gtk_GtkPopupMenuPeer_setupAccelGroup
_gtk_accel_group_attach (gtk_menu_get_accel_group (menu),
G_OBJECT (gtk_widget_get_toplevel (ptr2)));
#endif
+
gdk_threads_leave ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c
index 79e5082bb..1445cec55 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -39,24 +39,28 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkScrollPanePeer.h"
+#define AWT_SCROLLPANE_SCROLLBARS_AS_NEEDED 0
+#define AWT_SCROLLPANE_SCROLLBARS_ALWAYS 1
+#define AWT_SCROLLPANE_SCROLLBARS_NEVER 2
+
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_create
(JNIEnv *env, jobject obj, int width, int height)
{
GtkWidget *sw;
+ gdk_threads_enter ();
+
/* Create global reference and save it for future use */
NSA_SET_GLOBAL_REF (env, obj);
- gdk_threads_enter ();
-
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_size_request (sw, width, height);
- gdk_threads_leave ();
-
NSA_SET_PTR (env, obj, sw);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -67,9 +71,10 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_setScrollPosition
GtkScrolledWindow *sw;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
sw = GTK_SCROLLED_WINDOW (ptr);
hadj = gtk_scrolled_window_get_hadjustment (sw);
@@ -77,6 +82,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_setScrollPosition
gtk_adjustment_set_value (hadj, x);
gtk_adjustment_set_value (vadj, y);
+
gdk_threads_leave ();
}
@@ -88,9 +94,10 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_gtkScrolledWindowSetHScrollIncremen
GtkScrolledWindow *sw;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
sw = GTK_SCROLLED_WINDOW(ptr);
hadj = gtk_scrolled_window_get_hadjustment (sw);
@@ -107,9 +114,10 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_gtkScrolledWindowSetVScrollIncremen
GtkScrolledWindow *sw;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
sw = GTK_SCROLLED_WINDOW(ptr);
vadj = gtk_scrolled_window_get_hadjustment (sw);
@@ -128,9 +136,10 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_getHScrollbarHeight
jint height = 0;
jint spacing = 0;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
sw = GTK_SCROLLED_WINDOW (ptr);
gtk_widget_size_request (sw->hscrollbar, &requisition);
@@ -152,9 +161,10 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_getVScrollbarWidth
jint width = 0;
jint spacing = 0;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
sw = GTK_SCROLLED_WINDOW (ptr);
gtk_widget_size_request (sw->vscrollbar, &requisition);
@@ -172,6 +182,8 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_setPolicy
{
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
switch (policy)
@@ -187,7 +199,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_setPolicy
break;
}
- gdk_threads_enter ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ptr), policy, policy);
+
gdk_threads_leave ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c
index 10e53d43c..396862710 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -41,10 +41,37 @@ exception statement from your version. */
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
#include "gnu_java_awt_peer_gtk_GtkScrollbarPeer.h"
+#define AWT_ADJUSTMENT_UNIT_INCREMENT 1
+#define AWT_ADJUSTMENT_UNIT_DECREMENT 2
+#define AWT_ADJUSTMENT_BLOCK_DECREMENT 3
+#define AWT_ADJUSTMENT_BLOCK_INCREMENT 4
+#define AWT_ADJUSTMENT_TRACK 5
+
+static jmethodID postAdjustmentEventID;
+
+void
+cp_gtk_scrollbar_init_jni (void)
+{
+ jclass gtkscrollbarpeer;
+
+ gtkscrollbarpeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
+ "gnu/java/awt/peer/gtk/GtkScrollbarPeer");
+
+ postAdjustmentEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
+ gtkscrollbarpeer,
+ "postAdjustmentEvent",
+ "(II)V");
+}
+
+#if GTK_MINOR_VERSION > 4
static gboolean slider_moved_cb (GtkRange *range,
GtkScrollType scroll,
gdouble value,
jobject obj);
+#else
+static void post_change_event_cb (GtkRange *range,
+ jobject peer);
+#endif
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_create
@@ -92,13 +119,19 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_connectSignals
gdk_threads_enter ();
+ /* Scrollbar signals */
+#if GTK_MINOR_VERSION > 4
g_signal_connect (G_OBJECT (ptr), "change-value",
- GTK_SIGNAL_FUNC (slider_moved_cb), *gref);
+ G_CALLBACK (slider_moved_cb), *gref);
+#else
+ g_signal_connect (G_OBJECT (ptr), "value-changed",
+ G_CALLBACK (post_change_event_cb), *gref);
+#endif
- gdk_threads_leave ();
+ /* Component signals */
+ cp_gtk_component_connect_signals (G_OBJECT (ptr), gref);
- /* Connect the superclass signals. */
- Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env, obj);
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -157,6 +190,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setValues
gdk_threads_leave ();
}
+#if GTK_MINOR_VERSION > 4
static gboolean
slider_moved_cb (GtkRange *range,
GtkScrollType scroll,
@@ -184,31 +218,41 @@ slider_moved_cb (GtkRange *range,
switch (scroll)
{
case GTK_SCROLL_STEP_BACKWARD:
- (*gdk_env())->CallVoidMethod (gdk_env(), obj, postAdjustmentEventID,
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), obj, postAdjustmentEventID,
AWT_ADJUSTMENT_UNIT_DECREMENT,
(jint) value);
break;
case GTK_SCROLL_STEP_FORWARD:
- (*gdk_env())->CallVoidMethod (gdk_env(), obj, postAdjustmentEventID,
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), obj, postAdjustmentEventID,
AWT_ADJUSTMENT_UNIT_INCREMENT,
(jint) value);
break;
case GTK_SCROLL_PAGE_BACKWARD:
- (*gdk_env())->CallVoidMethod (gdk_env(), obj, postAdjustmentEventID,
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), obj, postAdjustmentEventID,
AWT_ADJUSTMENT_BLOCK_DECREMENT,
(jint) value);
break;
case GTK_SCROLL_PAGE_FORWARD:
- (*gdk_env())->CallVoidMethod (gdk_env(), obj, postAdjustmentEventID,
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), obj, postAdjustmentEventID,
AWT_ADJUSTMENT_BLOCK_INCREMENT,
(jint) value);
break;
default:
/* GTK_SCROLL_JUMP: */
- (*gdk_env())->CallVoidMethod (gdk_env(), obj, postAdjustmentEventID,
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), obj, postAdjustmentEventID,
AWT_ADJUSTMENT_TRACK,
(jint) value);
break;
}
return FALSE;
}
+#else
+static void
+post_change_event_cb (GtkRange *range, jobject peer)
+{
+ GtkAdjustment *adj;
+ adj = gtk_range_get_adjustment (range);
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postAdjustmentEventID,
+ AWT_ADJUSTMENT_TRACK, (jint) adj->value);
+}
+#endif
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
index 4b7f5dcca..9af88a026 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -39,7 +39,10 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkTextAreaPeer.h"
-#define TEXT_FROM_SW(obj) (GTK_TEXT_VIEW(GTK_SCROLLED_WINDOW (obj)->container.child))
+#define AWT_TEXTAREA_SCROLLBARS_BOTH 0
+#define AWT_TEXTAREA_SCROLLBARS_VERTICAL_ONLY 1
+#define AWT_TEXTAREA_SCROLLBARS_HORIZONTAL_ONLY 2
+
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create
(JNIEnv *env, jobject obj,
@@ -47,11 +50,11 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create
{
GtkWidget *text, *sw;
+ gdk_threads_enter ();
+
/* Create global reference and save it for future use */
NSA_SET_GLOBAL_REF (env, obj);
- gdk_threads_enter ();
-
text = gtk_text_view_new ();
gtk_widget_set_size_request (text, textview_width, textview_height);
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW (text), TRUE);
@@ -76,9 +79,37 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create
|| scroll == AWT_TEXTAREA_SCROLLBARS_HORIZONTAL_ONLY)
? GTK_WRAP_NONE : GTK_WRAP_WORD);
+ NSA_SET_PTR (env, obj, sw);
+
gdk_threads_leave ();
+}
- NSA_SET_PTR (env, obj, sw);
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_connectSignals
+ (JNIEnv *env, jobject obj)
+{
+ GtkWidget *text = NULL;
+ GtkTextBuffer *buf;
+ void *ptr;
+ jobject *gref;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+ gref = NSA_GET_GLOBAL_REF (env, obj);
+
+ /* Unwrap the text view from the scrolled window */
+ text = gtk_bin_get_child (GTK_BIN (ptr));
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+
+ /* TextComponent signals */
+ cp_gtk_textcomponent_connect_signals (G_OBJECT (buf), gref);
+
+ /* Component signals */
+ cp_gtk_component_connect_signals (G_OBJECT (text), gref);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -90,22 +121,21 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_insert
GtkWidget *text;
void *ptr;
const char *str;
- int pos=position;
+
+ gdk_threads_enter ();
ptr = NSA_GET_PTR (env, obj);
str = (*env)->GetStringUTFChars (env, contents, NULL);
- gdk_threads_enter ();
-
- text = GTK_WIDGET (TEXT_FROM_SW (ptr));
+ text = gtk_bin_get_child (GTK_BIN (ptr));
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
- gtk_text_buffer_get_iter_at_offset (buf, &iter, pos);
+ gtk_text_buffer_get_iter_at_offset (buf, &iter, position);
gtk_text_buffer_insert (buf, &iter, str, strlen (str));
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, contents, str);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -120,12 +150,12 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_replaceRange
int mystart = start;
int myend = end;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
str = (*env)->GetStringUTFChars (env, contents, NULL);
- gdk_threads_enter ();
-
- text = GTK_WIDGET (TEXT_FROM_SW (ptr));
+ text = gtk_bin_get_child (GTK_BIN (ptr));
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
@@ -136,8 +166,9 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_replaceRange
gtk_text_buffer_get_iter_at_offset (buf, &iter, mystart);
gtk_text_buffer_insert(buf, &iter, str, strlen (str));
- gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, contents, str);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -149,16 +180,17 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkWidgetModifyFont
GtkWidget *text;
PangoFontDescription *font_desc;
+ gdk_threads_enter();
+
ptr = NSA_GET_PTR (env, obj);
- text = GTK_WIDGET (TEXT_FROM_SW (ptr));
+ text = gtk_bin_get_child (GTK_BIN (ptr));
font_name = (*env)->GetStringUTFChars (env, name, NULL);
- gdk_threads_enter();
-
font_desc = pango_font_description_from_string (font_name);
- pango_font_description_set_size (font_desc, size * dpi_conversion_factor);
+ pango_font_description_set_size (font_desc,
+ size * cp_gtk_dpi_conversion_factor);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
@@ -170,9 +202,9 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkWidgetModifyFont
pango_font_description_free (font_desc);
- gdk_threads_leave();
-
(*env)->ReleaseStringUTFChars (env, name, font_name);
+
+ gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -182,11 +214,11 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkWidgetRequestFocus
void *ptr;
GtkWidget *text;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
- text = GTK_WIDGET (TEXT_FROM_SW (ptr));
+ ptr = NSA_GET_PTR (env, obj);
+
+ text = gtk_bin_get_child (GTK_BIN (ptr));
gtk_widget_grab_focus (text);
@@ -203,9 +235,10 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getHScrollbarHeight
jint height = 0;
jint spacing = 0;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
sw = GTK_SCROLLED_WINDOW (ptr);
if (sw)
@@ -230,9 +263,10 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getVScrollbarWidth
jint width = 0;
jint spacing = 0;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
- gdk_threads_enter ();
sw = GTK_SCROLLED_WINDOW (ptr);
if (sw)
@@ -246,3 +280,243 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getVScrollbarWidth
return width;
}
+
+JNIEXPORT jint JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getCaretPosition
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ int pos = 0;
+ GtkWidget *text = NULL;
+ GtkTextBuffer *buf;
+ GtkTextMark *mark;
+ GtkTextIter iter;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ text = gtk_bin_get_child (GTK_BIN (ptr));
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+ mark = gtk_text_buffer_get_insert (buf);
+ gtk_text_buffer_get_iter_at_mark (buf, &iter, mark);
+ pos = gtk_text_iter_get_offset (&iter);
+
+ gdk_threads_leave ();
+
+ return pos;
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_setCaretPosition
+ (JNIEnv *env, jobject obj, jint pos)
+{
+ void *ptr;
+ GtkWidget *text = NULL;
+ GtkTextBuffer *buf;
+ GtkTextIter iter;
+ GtkTextMark *oldmark;
+ GtkTextIter olditer;
+ int oldpos;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ text = gtk_bin_get_child (GTK_BIN (ptr));
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+
+ /* Save old position. */
+ oldmark = gtk_text_buffer_get_insert (buf);
+ gtk_text_buffer_get_iter_at_mark (buf, &olditer, oldmark);
+ oldpos = gtk_text_iter_get_offset (&olditer);
+
+ /* Move to new position. */
+ gtk_text_buffer_get_iter_at_offset (buf, &iter, pos);
+ gtk_text_buffer_place_cursor (buf, &iter);
+
+ /* Scroll to new position. Alignment is determined
+ comparing the new position to the old position. */
+ if (oldpos > pos)
+ gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (text),
+ &iter, 0, TRUE, 0, 0);
+ else if (oldpos < pos)
+ gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (text),
+ &iter, 0, TRUE, 1, 1);
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getSelectionStart
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ int pos = 0;
+ GtkWidget *text = NULL;
+ GtkTextBuffer *buf;
+ GtkTextIter start;
+ GtkTextIter end;
+ GtkTextMark *mark;
+ GtkTextIter iter;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ text = gtk_bin_get_child (GTK_BIN (ptr));
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+
+ if (gtk_text_buffer_get_selection_bounds (buf, &start, &end))
+ {
+ pos = gtk_text_iter_get_offset (&start);
+ }
+ else
+ {
+ mark = gtk_text_buffer_get_insert (buf);
+ gtk_text_buffer_get_iter_at_mark (buf, &iter, mark);
+ pos = gtk_text_iter_get_offset (&iter);
+ }
+
+ gdk_threads_leave ();
+
+ return pos;
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getSelectionEnd
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ int pos = 0;
+ GtkWidget *text = NULL;
+ GtkTextBuffer *buf;
+ GtkTextIter start;
+ GtkTextIter end;
+ GtkTextMark *mark;
+ GtkTextIter iter;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ text = gtk_bin_get_child (GTK_BIN (ptr));
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+
+ if (gtk_text_buffer_get_selection_bounds (buf, &start, &end))
+ {
+ pos = gtk_text_iter_get_offset (&end);
+ }
+ else
+ {
+ mark = gtk_text_buffer_get_insert (buf);
+ gtk_text_buffer_get_iter_at_mark (buf, &iter, mark);
+ pos = gtk_text_iter_get_offset (&iter);
+ }
+
+ gdk_threads_leave ();
+
+ return pos;
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_select
+ (JNIEnv *env, jobject obj, jint start, jint end)
+{
+ void *ptr;
+ GtkWidget *text = NULL;
+ GtkTextBuffer *buf;
+ GtkTextIter iter;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ text = gtk_bin_get_child (GTK_BIN (ptr));
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+ gtk_text_buffer_get_iter_at_offset (buf, &iter, start);
+ /* quickly move both 'insert' and 'selection_bound' to the
+ same position */
+ gtk_text_buffer_place_cursor (buf, &iter);
+ gtk_text_buffer_get_iter_at_offset (buf, &iter, end);
+ gtk_text_buffer_move_mark_by_name (buf, "selection_bound", &iter);
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_setEditable
+ (JNIEnv *env, jobject obj, jboolean state)
+{
+ void *ptr;
+ GtkWidget *text = NULL;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ text = gtk_bin_get_child (GTK_BIN (ptr));
+
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (text), state);
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT jstring JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getText
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ char *contents = NULL;
+ jstring jcontents;
+ GtkWidget *text = NULL;
+ GtkTextBuffer *buf;
+ GtkTextIter start, end;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ text = gtk_bin_get_child (GTK_BIN (ptr));
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+ gtk_text_buffer_get_start_iter (buf, &start);
+ gtk_text_buffer_get_end_iter (buf, &end);
+ contents = gtk_text_buffer_get_text (buf, &start, &end, FALSE);
+
+ jcontents = (*env)->NewStringUTF (env, contents);
+ g_free (contents);
+
+ gdk_threads_leave ();
+
+ return jcontents;
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_setText
+ (JNIEnv *env, jobject obj, jstring contents)
+{
+ void *ptr;
+ const char *str;
+ GtkWidget *text = NULL;
+ GtkTextBuffer *buf;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+ str = (*env)->GetStringUTFChars (env, contents, NULL);
+
+ text = gtk_bin_get_child (GTK_BIN (ptr));
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
+ gtk_text_buffer_set_text (buf, str, strlen (str));
+
+ (*env)->ReleaseStringUTFChars (env, contents, str);
+
+ gdk_threads_leave ();
+}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c
deleted file mode 100644
index 6eb06e073..000000000
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c
+++ /dev/null
@@ -1,498 +0,0 @@
-/* gtktextcomponentpeer.c -- Native implementation of GtkTextComponentPeer
- Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
-
-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 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. */
-
-
-#include "gtkpeer.h"
-#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
-#include "gnu_java_awt_peer_gtk_GtkTextComponentPeer.h"
-
-static void textcomponent_changed_cb (GtkEditable *editable,
- jobject peer);
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_connectSignals
- (JNIEnv *env, jobject obj)
-{
- GtkTextView *text = NULL;
- GtkTextBuffer *buf;
- void *ptr = NSA_GET_PTR (env, obj);
- jobject *gref = NSA_GET_GLOBAL_REF (env, obj);
- g_assert (gref);
-
- gdk_threads_enter ();
-
- if (GTK_IS_ENTRY(ptr))
- {
- g_signal_connect (GTK_EDITABLE (ptr), "changed",
- G_CALLBACK (textcomponent_changed_cb), *gref);
-
- gdk_threads_leave ();
-
- /* Connect the superclass signals. */
- Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env, *gref);
- }
- else
- {
- if (GTK_IS_SCROLLED_WINDOW (ptr))
- {
- text = GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child);
- }
- else if (GTK_IS_TEXT_VIEW (ptr))
- {
- text = GTK_TEXT_VIEW (ptr);
- }
-
- if (text)
- {
- buf = gtk_text_view_get_buffer (text);
- if (buf)
- g_signal_connect (buf, "changed",
- G_CALLBACK (textcomponent_changed_cb), *gref);
-
- /* Connect the superclass signals. */
- /* FIXME: Cannot do that here or it will get the sw and not the list.
- We must a generic way of doing this. */
- /* Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env,
- obj); */
- g_signal_connect (GTK_OBJECT (text), "event",
- G_CALLBACK (pre_event_handler), *gref);
-
- gdk_threads_leave ();
- }
- }
-}
-
-JNIEXPORT jint JNICALL
-Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getCaretPosition
- (JNIEnv *env, jobject obj)
-{
- void *ptr;
- int pos = 0;
- GtkEditable *editable;
- GtkWidget *text = NULL;
- GtkTextBuffer *buf;
- GtkTextMark *mark;
- GtkTextIter iter;
-
- ptr = NSA_GET_PTR (env, obj);
-
- gdk_threads_enter ();
-
- if (GTK_IS_EDITABLE (ptr))
- {
- editable = GTK_EDITABLE (ptr);
- pos = gtk_editable_get_position (editable);
- }
- else
- {
- if (GTK_IS_SCROLLED_WINDOW (ptr))
- {
- text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
- }
- else if (GTK_IS_TEXT_VIEW (ptr))
- {
- text = GTK_WIDGET (ptr);
- }
-
- if (text)
- {
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
- mark = gtk_text_buffer_get_insert (buf);
- gtk_text_buffer_get_iter_at_mark (buf, &iter, mark);
- pos = gtk_text_iter_get_offset (&iter);
- }
- }
-
- gdk_threads_leave ();
-
- return pos;
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setCaretPosition
- (JNIEnv *env, jobject obj, jint pos)
-{
- void *ptr;
- GtkEditable *editable;
- GtkWidget *text = NULL;
- GtkTextBuffer *buf;
- GtkTextIter iter;
- GtkTextMark *oldmark;
- GtkTextIter olditer;
- int oldpos;
-
- ptr = NSA_GET_PTR (env, obj);
-
- gdk_threads_enter ();
- if (GTK_IS_EDITABLE (ptr))
- {
- editable = GTK_EDITABLE (ptr);
- gtk_editable_set_position (editable, pos);
- }
- else
- {
- if (GTK_IS_SCROLLED_WINDOW (ptr))
- {
- text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
- }
- else if (GTK_IS_TEXT_VIEW (ptr))
- {
- text = GTK_WIDGET (ptr);
- }
-
- if (text)
- {
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
-
- /* Save old position. */
- oldmark = gtk_text_buffer_get_insert (buf);
- gtk_text_buffer_get_iter_at_mark (buf, &olditer, oldmark);
- oldpos = gtk_text_iter_get_offset (&olditer);
-
- /* Move to new position. */
- gtk_text_buffer_get_iter_at_offset (buf, &iter, pos);
- gtk_text_buffer_place_cursor (buf, &iter);
-
- /* Scroll to new position. Alignment is determined
- comparing the new position to the old position. */
- if (oldpos > pos)
- gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (text),
- &iter, 0, TRUE, 0, 0);
- else if (oldpos < pos)
- gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (text),
- &iter, 0, TRUE, 1, 1);
- }
- }
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT jint JNICALL
-Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getSelectionStart
- (JNIEnv *env, jobject obj)
-{
- void *ptr;
- int pos = 0;
- GtkEditable *editable;
- GtkWidget *text = NULL;
- GtkTextBuffer *buf;
- GtkTextIter start;
- GtkTextIter end;
- int starti, endi;
- GtkTextMark *mark;
- GtkTextIter iter;
-
- ptr = NSA_GET_PTR (env, obj);
-
- gdk_threads_enter ();
-
- if (GTK_IS_EDITABLE (ptr))
- {
- editable = GTK_EDITABLE (ptr);
- if (gtk_editable_get_selection_bounds (editable, &starti, &endi))
- pos = starti;
- else
- pos = gtk_editable_get_position (editable);
- }
- else
- {
- if (GTK_IS_SCROLLED_WINDOW (ptr))
- {
- text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
- }
- else if (GTK_IS_TEXT_VIEW (ptr))
- {
- text = GTK_WIDGET (ptr);
- }
-
- if (text)
- {
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
- if (gtk_text_buffer_get_selection_bounds(buf, &start, &end))
- pos = gtk_text_iter_get_offset (&start);
- else
- {
- mark = gtk_text_buffer_get_insert (buf);
- gtk_text_buffer_get_iter_at_mark (buf, &iter, mark);
- pos = gtk_text_iter_get_offset (&iter);
- }
- }
- }
-
- gdk_threads_leave ();
-
- return pos;
-}
-
-JNIEXPORT jint JNICALL
-Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getSelectionEnd
- (JNIEnv *env, jobject obj)
-{
- void *ptr;
- int pos = 0;
- GtkEditable *editable;
- GtkWidget *text = NULL;
- GtkTextBuffer *buf;
- GtkTextIter start;
- GtkTextIter end;
- int starti, endi;
- GtkTextMark *mark;
- GtkTextIter iter;
-
- ptr = NSA_GET_PTR (env, obj);
-
- gdk_threads_enter ();
-
- if (GTK_IS_EDITABLE (ptr))
- {
- editable = GTK_EDITABLE (ptr);
- if (gtk_editable_get_selection_bounds (editable, &starti, &endi))
- pos = endi;
- else
- pos = gtk_editable_get_position (editable);
- }
- else
- {
- if (GTK_IS_SCROLLED_WINDOW (ptr))
- {
- text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
- }
- else if (GTK_IS_TEXT_VIEW (ptr))
- {
- text = GTK_WIDGET (ptr);
- }
-
- if (text)
- {
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
- if (gtk_text_buffer_get_selection_bounds(buf, &start, &end))
- pos = gtk_text_iter_get_offset (&end);
- else
- {
- mark = gtk_text_buffer_get_insert (buf);
- gtk_text_buffer_get_iter_at_mark (buf, &iter, mark);
- pos = gtk_text_iter_get_offset (&iter);
- }
- }
- }
-
- gdk_threads_leave ();
-
- return pos;
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_select
- (JNIEnv *env, jobject obj, jint start, jint end)
-{
- void *ptr;
- GtkEditable *editable;
- GtkWidget *text = NULL;
- GtkTextBuffer *buf;
- GtkTextIter iter;
-
- ptr = NSA_GET_PTR (env, obj);
-
- gdk_threads_enter ();
-
-
- if (GTK_IS_EDITABLE (ptr))
- {
- editable = GTK_EDITABLE (ptr);
- gtk_editable_select_region (editable, start, end);
- }
- else
- {
- if (GTK_IS_SCROLLED_WINDOW (ptr))
- {
- text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
- }
- else if (GTK_IS_TEXT_VIEW (ptr))
- {
- text = GTK_WIDGET (ptr);
- }
-
- if (text)
- {
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
- gtk_text_buffer_get_iter_at_offset (buf, &iter, start);
- /* quickly move both 'insert' and 'selection_bound' to the
- same position */
- gtk_text_buffer_place_cursor (buf, &iter);
- gtk_text_buffer_get_iter_at_offset (buf, &iter, end);
- gtk_text_buffer_move_mark_by_name (buf, "selection_bound", &iter);
- }
- }
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setEditable
- (JNIEnv *env, jobject obj, jboolean state)
-{
- void *ptr;
- GtkEditable *editable;
- GtkWidget *text = NULL;
-
- ptr = NSA_GET_PTR (env, obj);
-
- gdk_threads_enter ();
-
- if (GTK_IS_EDITABLE (ptr))
- {
- editable = GTK_EDITABLE (ptr);
- gtk_editable_set_editable (editable, state);
- }
- else
- {
- if (GTK_IS_SCROLLED_WINDOW (ptr))
- {
- text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
- }
- else if (GTK_IS_TEXT_VIEW (ptr))
- {
- text = GTK_WIDGET (ptr);
- }
-
- if (text)
- {
- gtk_text_view_set_editable (GTK_TEXT_VIEW (text), state);
- }
- }
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT jstring JNICALL
-Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getText
- (JNIEnv *env, jobject obj)
-{
- void *ptr;
- char *contents = NULL;
- jstring jcontents;
- GtkEditable *editable;
- GtkWidget *text = NULL;
- GtkTextBuffer *buf;
- GtkTextIter start, end;
-
- ptr = NSA_GET_PTR (env, obj);
-
- gdk_threads_enter ();
-
- if (GTK_IS_EDITABLE (ptr))
- {
- editable = GTK_EDITABLE (ptr);
- contents = gtk_editable_get_chars (editable, 0, -1);
- }
- else
- {
- if (GTK_IS_SCROLLED_WINDOW (ptr))
- {
- text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
- }
- else if (GTK_IS_TEXT_VIEW (ptr))
- {
- text = GTK_WIDGET (ptr);
- }
-
- if (text)
- {
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
- gtk_text_buffer_get_start_iter (buf, &start);
- gtk_text_buffer_get_end_iter (buf, &end);
- contents = gtk_text_buffer_get_text (buf, &start, &end, FALSE);
- }
- }
-
- gdk_threads_leave ();
-
- jcontents = (*env)->NewStringUTF (env, contents);
- g_free (contents);
-
- return jcontents;
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setText
- (JNIEnv *env, jobject obj, jstring contents)
-{
- void *ptr;
- const char *str;
- GtkWidget *text = NULL;
- GtkTextBuffer *buf;
-
- ptr = NSA_GET_PTR (env, obj);
- str = (*env)->GetStringUTFChars (env, contents, NULL);
-
- gdk_threads_enter ();
-
- if (GTK_IS_EDITABLE (ptr))
- {
- gtk_entry_set_text (GTK_ENTRY (ptr), str);
- }
- else
- {
- if (GTK_IS_SCROLLED_WINDOW (ptr))
- {
- text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
- }
- else if (GTK_IS_TEXT_VIEW (ptr))
- {
- text = GTK_WIDGET (ptr);
- }
-
- if (text)
- {
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
- gtk_text_buffer_set_text (buf, str, strlen (str));
- }
- }
-
- gdk_threads_leave ();
-
- (*env)->ReleaseStringUTFChars (env, contents, str);
-}
-
-static void
-textcomponent_changed_cb (GtkEditable *editable __attribute__((unused)),
- jobject peer)
-{
- gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer, postTextEventID);
- gdk_threads_enter ();
-}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
index a7b0a4778..eb658339d 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -39,8 +39,30 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkTextFieldPeer.h"
-static jint
-get_border_width (GtkWidget *entry);
+/* the color used for highlighting when the foreground is black,
+ since black highlights aren't a Good Idea. */
+#define BB_RED 16962
+#define BB_GREEN 26985
+#define BB_BLUE 31611
+
+static jmethodID postTextEventID;
+
+void
+cp_gtk_textcomponent_init_jni (void)
+{
+ jclass gtkcomponentpeer;
+
+ gtkcomponentpeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
+ "gnu/java/awt/peer/gtk/GtkComponentPeer");
+
+ postTextEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcomponentpeer,
+ "postTextEvent",
+ "()V");
+}
+
+static void textcomponent_changed_cb (GtkEditable *editable, jobject peer);
+
+static jint get_border_width (GtkWidget *entry);
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_create
@@ -48,18 +70,39 @@ Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_create
{
GtkWidget *entry;
+ gdk_threads_enter ();
+
/* Create global reference and save it for future use */
NSA_SET_GLOBAL_REF (env, obj);
- gdk_threads_enter ();
-
entry = gtk_entry_new ();
gtk_widget_set_size_request (entry,
text_width + 2 * get_border_width (entry), -1);
+ NSA_SET_PTR (env, obj, entry);
+
gdk_threads_leave ();
+}
- NSA_SET_PTR (env, obj, entry);
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_connectSignals
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ jobject *gref;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+ gref = NSA_GET_GLOBAL_REF (env, obj);
+
+ /* TextComponent signals */
+ cp_gtk_textcomponent_connect_signals (G_OBJECT (ptr), gref);
+
+ /* Component signals */
+ cp_gtk_component_connect_signals (G_OBJECT (ptr), gref);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -69,14 +112,14 @@ Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkWidgetSetBackground
GdkColor color;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
color.red = (red / 255.0) * 65535;
color.green = (green / 255.0) * 65535;
color.blue = (blue / 255.0) * 65535;
- gdk_threads_enter ();
-
gtk_widget_modify_base (GTK_WIDGET (ptr), GTK_STATE_NORMAL, &color);
gdk_threads_leave ();
@@ -89,15 +132,22 @@ Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkWidgetSetForeground
GdkColor color;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
color.red = (red / 255.0) * 65535;
color.green = (green / 255.0) * 65535;
color.blue = (blue / 255.0) * 65535;
-
- gdk_threads_enter ();
-
+
gtk_widget_modify_text (GTK_WIDGET (ptr), GTK_STATE_NORMAL, &color);
+
+ if ( red == 0 && green == 0 && blue == 0)
+ {
+ color.red = BB_RED;
+ color.green = BB_GREEN;
+ color.blue = BB_BLUE;
+ }
gtk_widget_modify_base (GTK_WIDGET (ptr), GTK_STATE_SELECTED, &color);
gdk_threads_leave ();
@@ -110,10 +160,10 @@ Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkEntryGetBorderWidth
void *ptr;
int border_width = 0;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
border_width = get_border_width (GTK_WIDGET (ptr));
gdk_threads_leave ();
@@ -155,10 +205,10 @@ Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_setEchoChar
void *ptr;
GtkEntry *entry;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
entry = GTK_ENTRY (ptr);
if (c != 0)
@@ -180,18 +230,17 @@ Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkWidgetModifyFont
{
const char *font_name;
void *ptr;
- GtkWidget *entry;
PangoFontDescription *font_desc;
+ gdk_threads_enter();
+
ptr = NSA_GET_PTR (env, obj);
- entry = GTK_WIDGET (ptr);
font_name = (*env)->GetStringUTFChars (env, name, NULL);
- gdk_threads_enter();
-
font_desc = pango_font_description_from_string (font_name);
- pango_font_description_set_size (font_desc, size * dpi_conversion_factor);
+ pango_font_description_set_size (font_desc,
+ size * cp_gtk_dpi_conversion_factor);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
@@ -199,11 +248,176 @@ Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkWidgetModifyFont
if (style & AWT_STYLE_ITALIC)
pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE);
- gtk_widget_modify_font (GTK_WIDGET(entry), font_desc);
+ gtk_widget_modify_font (GTK_WIDGET (ptr), font_desc);
pango_font_description_free (font_desc);
+ (*env)->ReleaseStringUTFChars (env, name, font_name);
+
gdk_threads_leave();
+}
- (*env)->ReleaseStringUTFChars (env, name, font_name);
+JNIEXPORT jint JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_getCaretPosition
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ int pos = 0;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ pos = gtk_editable_get_position (GTK_EDITABLE (ptr));
+
+ gdk_threads_leave ();
+
+ return pos;
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_setCaretPosition
+ (JNIEnv *env, jobject obj, jint pos)
+{
+ void *ptr;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ gtk_editable_set_position (GTK_EDITABLE (ptr), pos);
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_getSelectionStart
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ int pos = 0;
+ int starti, endi;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ if (gtk_editable_get_selection_bounds (GTK_EDITABLE (ptr), &starti, &endi))
+ pos = starti;
+ else
+ pos = gtk_editable_get_position (GTK_EDITABLE (ptr));
+
+ gdk_threads_leave ();
+
+ return pos;
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_getSelectionEnd
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ int pos = 0;
+ int starti, endi;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ if (gtk_editable_get_selection_bounds (GTK_EDITABLE (ptr), &starti, &endi))
+ pos = endi;
+ else
+ pos = gtk_editable_get_position (GTK_EDITABLE (ptr));
+
+ gdk_threads_leave ();
+
+ return pos;
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_select
+ (JNIEnv *env, jobject obj, jint start, jint end)
+{
+ void *ptr;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ gtk_editable_select_region (GTK_EDITABLE (ptr), start, end);
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_setEditable
+ (JNIEnv *env, jobject obj, jboolean state)
+{
+ void *ptr;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ gtk_editable_set_editable (GTK_EDITABLE (ptr), state);
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT jstring JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_getText
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ char *contents = NULL;
+ jstring jcontents;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ contents = gtk_editable_get_chars (GTK_EDITABLE (ptr), 0, -1);
+
+ jcontents = (*env)->NewStringUTF (env, contents);
+
+ g_free (contents);
+
+ gdk_threads_leave ();
+
+ return jcontents;
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_setText
+ (JNIEnv *env, jobject obj, jstring contents)
+{
+ void *ptr;
+ const char *str;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+ str = (*env)->GetStringUTFChars (env, contents, NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (ptr), str);
+
+ (*env)->ReleaseStringUTFChars (env, contents, str);
+
+ gdk_threads_leave ();
+}
+
+void
+cp_gtk_textcomponent_connect_signals (GObject *ptr, jobject *gref)
+{
+ g_signal_connect (G_OBJECT(ptr), "changed",
+ G_CALLBACK (textcomponent_changed_cb), *gref);
+}
+
+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/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
index f9fb4d63a..a8e1957ee 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -39,43 +39,47 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkToolkit.h"
#include "gthread-jni.h"
+#include "jcl.h"
#include <sys/time.h>
-#ifdef JVM_SUN
- struct state_table *native_state_table;
- struct state_table *native_global_ref_table;
-#endif
-
-jmethodID setBoundsCallbackID;
-
-jmethodID postActionEventID;
-jmethodID postMenuActionEventID;
-jmethodID postMouseEventID;
-jmethodID postConfigureEventID;
-jmethodID postExposeEventID;
-jmethodID postKeyEventID;
-jmethodID postFocusEventID;
-jmethodID postAdjustmentEventID;
-jmethodID postItemEventID;
-jmethodID choicePostItemEventID;
-jmethodID postListItemEventID;
-jmethodID postTextEventID;
-jmethodID postWindowEventID;
-jmethodID postInsetsChangedEventID;
-jmethodID windowGetWidthID;
-jmethodID windowGetHeightID;
-
-jmethodID beginNativeRepaintID;
-jmethodID endNativeRepaintID;
-
-jmethodID initComponentGraphicsID;
-#ifdef GTK_CAIRO
-jmethodID initComponentGraphics2DID;
-#endif
-jmethodID setCursorID;
-
-JavaVM *java_vm;
+#define RC_FILE ".classpath-gtkrc"
+
+/* From java.awt.SystemColor */
+#define AWT_DESKTOP 0
+#define AWT_ACTIVE_CAPTION 1
+#define AWT_ACTIVE_CAPTION_TEXT 2
+#define AWT_ACTIVE_CAPTION_BORDER 3
+#define AWT_INACTIVE_CAPTION 4
+#define AWT_INACTIVE_CAPTION_TEXT 5
+#define AWT_INACTIVE_CAPTION_BORDER 6
+#define AWT_WINDOW 7
+#define AWT_WINDOW_BORDER 8
+#define AWT_WINDOW_TEXT 9
+#define AWT_MENU 10
+#define AWT_MENU_TEXT 11
+#define AWT_TEXT 12
+#define AWT_TEXT_TEXT 13
+#define AWT_TEXT_HIGHLIGHT 14
+#define AWT_TEXT_HIGHLIGHT_TEXT 15
+#define AWT_TEXT_INACTIVE_TEXT 16
+#define AWT_CONTROL 17
+#define AWT_CONTROL_TEXT 18
+#define AWT_CONTROL_HIGHLIGHT 19
+#define AWT_CONTROL_LT_HIGHLIGHT 20
+#define AWT_CONTROL_SHADOW 21
+#define AWT_CONTROL_DK_SHADOW 22
+#define AWT_SCROLLBAR 23
+#define AWT_INFO 24
+#define AWT_INFO_TEXT 25
+#define AWT_NUM_COLORS 26
+
+struct state_table *cp_gtk_native_state_table;
+struct state_table *cp_gtk_native_global_ref_table;
+
+static jclass gtkgenericpeer;
+static JavaVM *java_vm;
+static jmethodID printCurrentThreadID;
union env_union
{
@@ -84,7 +88,7 @@ union env_union
};
JNIEnv *
-gdk_env()
+cp_gtk_gdk_env()
{
union env_union tmp;
g_assert((*java_vm)->GetEnv(java_vm, &tmp.void_env, JNI_VERSION_1_2) == JNI_OK);
@@ -92,16 +96,23 @@ gdk_env()
}
-GtkWindowGroup *global_gtk_window_group;
+GtkWindowGroup *cp_gtk_global_window_group;
+double cp_gtk_dpi_conversion_factor;
static void init_glib_threads(JNIEnv *, jint);
-double dpi_conversion_factor;
-
static void init_dpi_conversion_factor (void);
static void dpi_changed_cb (GtkSettings *settings,
GParamSpec *pspec);
+#if GTK_MINOR_VERSION > 4
+static GLogFunc old_glog_func;
+static void glog_func (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data);
+#endif
+
/*
* Call gtk_init. It is very important that this happen before any other
* gtk calls.
@@ -123,29 +134,20 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env,
char **argv;
char *homedir, *rcpath = NULL;
- jclass gtkgenericpeer, gtkcomponentpeer, gtkchoicepeer, gtkwindowpeer, gtkscrollbarpeer, gtklistpeer,
- gtkmenuitempeer, gtktextcomponentpeer, window, gdkgraphics;
-#ifdef GTK_CAIRO
- jclass gdkgraphics2d;
-#endif
-
gtkgenericpeer = (*env)->FindClass(env, "gnu/java/awt/peer/gtk/GtkGenericPeer");
+ printCurrentThreadID = (*env)->GetStaticMethodID (env, gtkgenericpeer,
+ "printCurrentThread", "()V");
+
NSA_INIT (env, gtkgenericpeer);
g_assert((*env)->GetJavaVM(env, &java_vm) == 0);
/* GTK requires a program's argc and argv variables, and requires that they
- be valid. Set it up. */
+ be valid. Set it up. */
argv = (char **) g_malloc (sizeof (char *) * 2);
argv[0] = (char *) g_malloc(1);
-#if 1
- strcpy(argv[0], "");
-#else /* The following is a more efficient alternative, but less intuitively
- * expresses what we are trying to do. This code is only run once, so
- * I'm going for intuitive. */
argv[0][0] = '\0';
-#endif
argv[1] = NULL;
init_glib_threads(env, portableNativeSync);
@@ -163,8 +165,6 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env,
we're shutting down. */
atexit (gdk_threads_enter);
- gdk_event_handler_set ((GdkEventFunc)awt_event_handler, NULL, NULL);
-
if ((homedir = getenv ("HOME")))
{
rcpath = (char *) g_malloc (strlen (homedir) + strlen (RC_FILE) + 2);
@@ -177,89 +177,26 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env,
g_free (argv[0]);
g_free (argv);
- /* setup cached IDs for posting GTK events to Java */
-
- window = (*env)->FindClass (env, "java/awt/Window");
-
- gtkcomponentpeer = (*env)->FindClass (env,
- "gnu/java/awt/peer/gtk/GtkComponentPeer");
- gtkchoicepeer = (*env)->FindClass (env,
- "gnu/java/awt/peer/gtk/GtkChoicePeer");
- gtkwindowpeer = (*env)->FindClass (env,
- "gnu/java/awt/peer/gtk/GtkWindowPeer");
- gtkscrollbarpeer = (*env)->FindClass (env,
- "gnu/java/awt/peer/gtk/GtkScrollbarPeer");
- gtklistpeer = (*env)->FindClass (env, "gnu/java/awt/peer/gtk/GtkListPeer");
- gtkmenuitempeer = (*env)->FindClass (env,
- "gnu/java/awt/peer/gtk/GtkMenuItemPeer");
- gtktextcomponentpeer = (*env)->FindClass (env,
- "gnu/java/awt/peer/gtk/GtkTextComponentPeer");
- gdkgraphics = (*env)->FindClass (env,
- "gnu/java/awt/peer/gtk/GdkGraphics");
-#ifdef GTK_CAIRO
- gdkgraphics2d = (*env)->FindClass (env,
- "gnu/java/awt/peer/gtk/GdkGraphics2D");
+ /* On errors or warning print a whole stacktrace. */
+#if GTK_MINOR_VERSION > 4
+ old_glog_func = g_log_set_default_handler (&glog_func, NULL);
#endif
- setBoundsCallbackID = (*env)->GetMethodID (env, window,
- "setBoundsCallback",
- "(IIII)V");
-
- postMenuActionEventID = (*env)->GetMethodID (env, gtkmenuitempeer,
- "postMenuActionEvent",
- "()V");
- postMouseEventID = (*env)->GetMethodID (env, gtkcomponentpeer,
- "postMouseEvent", "(IJIIIIZ)V");
- setCursorID = (*env)->GetMethodID (env, gtkcomponentpeer,
- "setCursor", "()V");
- beginNativeRepaintID = (*env)->GetMethodID (env, gtkcomponentpeer,
- "beginNativeRepaint", "()V");
-
- endNativeRepaintID = (*env)->GetMethodID (env, gtkcomponentpeer,
- "endNativeRepaint", "()V");
-
- postConfigureEventID = (*env)->GetMethodID (env, gtkwindowpeer,
- "postConfigureEvent", "(IIII)V");
- postWindowEventID = (*env)->GetMethodID (env, gtkwindowpeer,
- "postWindowEvent",
- "(ILjava/awt/Window;I)V");
- postInsetsChangedEventID = (*env)->GetMethodID (env, gtkwindowpeer,
- "postInsetsChangedEvent",
- "(IIII)V");
- windowGetWidthID = (*env)->GetMethodID (env, gtkwindowpeer,
- "getWidth", "()I");
- windowGetHeightID = (*env)->GetMethodID (env, gtkwindowpeer,
- "getHeight", "()I");
-
- postExposeEventID = (*env)->GetMethodID (env, gtkcomponentpeer,
- "postExposeEvent", "(IIII)V");
- postKeyEventID = (*env)->GetMethodID (env, gtkcomponentpeer,
- "postKeyEvent", "(IJIICI)V");
- postFocusEventID = (*env)->GetMethodID (env, gtkcomponentpeer,
- "postFocusEvent", "(IZ)V");
- postAdjustmentEventID = (*env)->GetMethodID (env, gtkscrollbarpeer,
- "postAdjustmentEvent",
- "(II)V");
- postItemEventID = (*env)->GetMethodID (env, gtkcomponentpeer,
- "postItemEvent",
- "(Ljava/lang/Object;I)V");
- choicePostItemEventID = (*env)->GetMethodID (env, gtkchoicepeer,
- "choicePostItemEvent",
- "(Ljava/lang/String;I)V");
- postListItemEventID = (*env)->GetMethodID (env, gtklistpeer,
- "postItemEvent",
- "(II)V");
- postTextEventID = (*env)->GetMethodID (env, gtktextcomponentpeer,
- "postTextEvent",
- "()V");
- initComponentGraphicsID = (*env)->GetMethodID (env, gdkgraphics,
- "initComponentGraphics",
- "()V");
-#ifdef GTK_CAIRO
- initComponentGraphics2DID = (*env)->GetMethodID (env, gdkgraphics2d,
- "initComponentGraphics2D",
- "()V");
+
+#if GTK_CAIRO
+ cp_gtk_graphics2d_init_jni ();
#endif
- global_gtk_window_group = gtk_window_group_new ();
+ cp_gtk_graphics_init_jni ();
+ cp_gtk_button_init_jni ();
+ cp_gtk_checkbox_init_jni ();
+ cp_gtk_choice_init_jni ();
+ cp_gtk_component_init_jni ();
+ cp_gtk_list_init_jni ();
+ cp_gtk_menuitem_init_jni ();
+ cp_gtk_scrollbar_init_jni ();
+ cp_gtk_textcomponent_init_jni ();
+ cp_gtk_window_init_jni ();
+
+ cp_gtk_global_window_group = gtk_window_group_new ();
init_dpi_conversion_factor ();
}
@@ -283,11 +220,11 @@ init_glib_threads(JNIEnv *env, jint portableNativeSync)
#endif
}
- (*env)->GetJavaVM( env, &the_vm );
+ (*env)->GetJavaVM( env, &cp_gtk_the_vm );
if (!g_thread_supported ())
{
if (portableNativeSync)
- g_thread_init ( &portable_native_sync_jni_functions );
+ g_thread_init ( &cp_gtk_portable_native_sync_jni_functions );
else
g_thread_init ( NULL );
}
@@ -305,6 +242,11 @@ init_glib_threads(JNIEnv *env, jint portableNativeSync)
/* printf("called gthread init\n"); */
}
+void
+cp_gtk_print_current_thread (void)
+{
+ (*cp_gtk_gdk_env())->CallStaticVoidMethod (cp_gtk_gdk_env(), gtkgenericpeer, printCurrentThreadID);
+}
/* This is a big hack, needed until this pango bug is resolved:
http://bugzilla.gnome.org/show_bug.cgi?id=119081.
@@ -324,16 +266,17 @@ init_dpi_conversion_factor ()
/* If int_dpi == -1 gtk-xft-dpi returns the default value. So we
have to do approximate calculation here. */
if (int_dpi < 0)
- dpi_conversion_factor = PANGO_SCALE * 72.0 / 96.;
+ cp_gtk_dpi_conversion_factor = PANGO_SCALE * 72.0 / 96.;
else
- dpi_conversion_factor = PANGO_SCALE * 72.0 / (int_dpi / PANGO_SCALE);
+ cp_gtk_dpi_conversion_factor =
+ PANGO_SCALE * 72.0 / (int_dpi / PANGO_SCALE);
g_signal_connect (settings, "notify::gtk-xft-dpi",
G_CALLBACK (dpi_changed_cb), NULL);
}
else
/* Approximate. */
- dpi_conversion_factor = PANGO_SCALE * 72.0 / 96.;
+ cp_gtk_dpi_conversion_factor = PANGO_SCALE * 72.0 / 96.;
}
static void
@@ -343,9 +286,10 @@ dpi_changed_cb (GtkSettings *settings,
int int_dpi;
g_object_get (settings, "gtk-xft-dpi", &int_dpi, NULL);
if (int_dpi < 0)
- dpi_conversion_factor = PANGO_SCALE * 72.0 / 96.;
+ cp_gtk_dpi_conversion_factor = PANGO_SCALE * 72.0 / 96.;
else
- dpi_conversion_factor = PANGO_SCALE * 72.0 / (int_dpi / PANGO_SCALE);
+ cp_gtk_dpi_conversion_factor =
+ PANGO_SCALE * 72.0 / (int_dpi / PANGO_SCALE);
}
static int
@@ -362,6 +306,31 @@ within_human_latency_tolerance(struct timeval *init)
return milliseconds_elapsed < 100;
}
+#if GTK_MINOR_VERSION > 4
+static void
+glog_func (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
+{
+ old_glog_func (log_domain, log_level, message, user_data);
+ if (log_level & (G_LOG_LEVEL_ERROR
+ | G_LOG_LEVEL_CRITICAL
+ | G_LOG_LEVEL_WARNING))
+ {
+ JNIEnv *env = cp_gtk_gdk_env ();
+ jthrowable *exc = (*env)->ExceptionOccurred(env);
+ gchar *detail = g_strconcat (log_domain, ": ", message, NULL);
+ JCL_ThrowException (env, "java/lang/InternalError", detail);
+ g_free (detail);
+ (*env)->ExceptionDescribe (env);
+ if (exc != NULL)
+ (*env)->Throw (env, exc);
+ else
+ (*env)->ExceptionClear (env);
+ }
+}
+#endif
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkToolkit_iterateNativeQueue
@@ -418,9 +387,13 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_nativeQueueEmpty
(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)))
{
jboolean empty = FALSE;
+
gdk_threads_enter ();
+
empty = ! gtk_events_pending();
+
gdk_threads_leave ();
+
return empty;
}
@@ -433,7 +406,9 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_beep
(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)))
{
gdk_threads_enter ();
+
gdk_beep ();
+
gdk_threads_leave ();
}
@@ -442,7 +417,9 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_sync
(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)))
{
gdk_threads_enter ();
+
gdk_flush ();
+
gdk_threads_leave ();
}
@@ -474,6 +451,7 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_getScreenResolution
res = gdk_screen_width () / (gdk_screen_width_mm () / 25.4);
gdk_threads_leave ();
+
return res;
}
@@ -488,10 +466,10 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_loadSystemColors
jint *colors;
GtkStyle *style;
- colors = (*env)->GetIntArrayElements (env, jcolors, 0);
-
gdk_threads_enter ();
+ colors = (*env)->GetIntArrayElements (env, jcolors, 0);
+
style = gtk_widget_get_default_style ();
colors[AWT_DESKTOP] = CONVERT (bg, SELECTED);
@@ -521,9 +499,9 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_loadSystemColors
colors[AWT_INFO] = CONVERT (bg, NORMAL);
colors[AWT_INFO_TEXT] = CONVERT (fg, NORMAL);
- gdk_threads_leave ();
-
(*env)->ReleaseIntArrayElements(env, jcolors, colors, 0);
+
+ gdk_threads_leave ();
}
#undef CONVERT
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
index 318b13ad1..650d9b603 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -41,6 +41,971 @@ exception statement from your version. */
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
#include <X11/Xatom.h>
+#include <gdk/gdkkeysyms.h>
+
+#define AWT_WINDOW_OPENED 200
+#define AWT_WINDOW_CLOSING 201
+#define AWT_WINDOW_CLOSED 202
+#define AWT_WINDOW_ICONIFIED 203
+#define AWT_WINDOW_DEICONIFIED 204
+#define AWT_WINDOW_ACTIVATED 205
+#define AWT_WINDOW_DEACTIVATED 206
+#define AWT_WINDOW_GAINED_FOCUS 207
+#define AWT_WINDOW_LOST_FOCUS 208
+#define AWT_WINDOW_STATE_CHANGED 209
+
+/* Virtual Keys */
+/* This list should be kept in the same order as the VK_ field
+ declarations in KeyEvent.java. */
+#define VK_ENTER '\n'
+#define VK_BACK_SPACE '\b'
+#define VK_TAB '\t'
+#define VK_CANCEL 3
+#define VK_CLEAR 12
+#define VK_SHIFT 16
+#define VK_CONTROL 17
+#define VK_ALT 18
+#define VK_PAUSE 19
+#define VK_CAPS_LOCK 20
+#define VK_ESCAPE 27
+#define VK_SPACE ' '
+#define VK_PAGE_UP 33
+#define VK_PAGE_DOWN 34
+#define VK_END 35
+#define VK_HOME 36
+#define VK_LEFT 37
+#define VK_UP 38
+#define VK_RIGHT 39
+#define VK_DOWN 40
+#define VK_COMMA ','
+#define VK_MINUS '-'
+#define VK_PERIOD '.'
+#define VK_SLASH '/'
+#define VK_0 '0'
+#define VK_1 '1'
+#define VK_2 '2'
+#define VK_3 '3'
+#define VK_4 '4'
+#define VK_5 '5'
+#define VK_6 '6'
+#define VK_7 '7'
+#define VK_8 '8'
+#define VK_9 '9'
+#define VK_SEMICOLON ';'
+#define VK_EQUALS '='
+#define VK_A 'A'
+#define VK_B 'B'
+#define VK_C 'C'
+#define VK_D 'D'
+#define VK_E 'E'
+#define VK_F 'F'
+#define VK_G 'G'
+#define VK_H 'H'
+#define VK_I 'I'
+#define VK_J 'J'
+#define VK_K 'K'
+#define VK_L 'L'
+#define VK_M 'M'
+#define VK_N 'N'
+#define VK_O 'O'
+#define VK_P 'P'
+#define VK_Q 'Q'
+#define VK_R 'R'
+#define VK_S 'S'
+#define VK_T 'T'
+#define VK_U 'U'
+#define VK_V 'V'
+#define VK_W 'W'
+#define VK_X 'X'
+#define VK_Y 'Y'
+#define VK_Z 'Z'
+#define VK_OPEN_BRACKET '['
+#define VK_BACK_SLASH '\\'
+#define VK_CLOSE_BRACKET ']'
+/* See gtkpeer.h */
+/* #define VK_NUMPAD0 96 */
+/* #define VK_NUMPAD1 97 */
+/* #define VK_NUMPAD2 98 */
+/* #define VK_NUMPAD3 99 */
+/* #define VK_NUMPAD4 100 */
+/* #define VK_NUMPAD5 101 */
+/* #define VK_NUMPAD6 102 */
+/* #define VK_NUMPAD7 103 */
+/* #define VK_NUMPAD8 104 */
+/* #define VK_NUMPAD9 105 */
+#define VK_MULTIPLY 106
+#define VK_ADD 107
+#define VK_SEPARATER 108
+#define VK_SEPARATOR 108
+#define VK_SUBTRACT 109
+/* See gtkpeer.h */
+/* #define VK_DECIMAL 110 */
+#define VK_DIVIDE 111
+#define VK_DELETE 127
+#define VK_NUM_LOCK 144
+#define VK_SCROLL_LOCK 145
+#define VK_F1 112
+#define VK_F2 113
+#define VK_F3 114
+#define VK_F4 115
+#define VK_F5 116
+#define VK_F6 117
+#define VK_F7 118
+#define VK_F8 119
+#define VK_F9 120
+#define VK_F10 121
+#define VK_F11 122
+#define VK_F12 123
+#define VK_F13 61440
+#define VK_F14 61441
+#define VK_F15 61442
+#define VK_F16 61443
+#define VK_F17 61444
+#define VK_F18 61445
+#define VK_F19 61446
+#define VK_F20 61447
+#define VK_F21 61448
+#define VK_F22 61449
+#define VK_F23 61450
+#define VK_F24 61451
+#define VK_PRINTSCREEN 154
+#define VK_INSERT 155
+#define VK_HELP 156
+#define VK_META 157
+#define VK_BACK_QUOTE 192
+#define VK_QUOTE 222
+#define VK_KP_UP 224
+#define VK_KP_DOWN 225
+#define VK_KP_LEFT 226
+#define VK_KP_RIGHT 227
+#define VK_DEAD_GRAVE 128
+#define VK_DEAD_ACUTE 129
+#define VK_DEAD_CIRCUMFLEX 130
+#define VK_DEAD_TILDE 131
+#define VK_DEAD_MACRON 132
+#define VK_DEAD_BREVE 133
+#define VK_DEAD_ABOVEDOT 134
+#define VK_DEAD_DIAERESIS 135
+#define VK_DEAD_ABOVERING 136
+#define VK_DEAD_DOUBLEACUTE 137
+#define VK_DEAD_CARON 138
+#define VK_DEAD_CEDILLA 139
+#define VK_DEAD_OGONEK 140
+#define VK_DEAD_IOTA 141
+#define VK_DEAD_VOICED_SOUND 142
+#define VK_DEAD_SEMIVOICED_SOUND 143
+#define VK_AMPERSAND 150
+#define VK_ASTERISK 151
+#define VK_QUOTEDBL 152
+#define VK_LESS 153
+#define VK_GREATER 160
+#define VK_BRACELEFT 161
+#define VK_BRACERIGHT 162
+#define VK_AT 512
+#define VK_COLON 513
+#define VK_CIRCUMFLEX 514
+#define VK_DOLLAR 515
+#define VK_EURO_SIGN 516
+#define VK_EXCLAMATION_MARK 517
+#define VK_INVERTED_EXCLAMATION_MARK 518
+#define VK_LEFT_PARENTHESIS 519
+#define VK_NUMBER_SIGN 520
+#define VK_PLUS 521
+#define VK_RIGHT_PARENTHESIS 522
+#define VK_UNDERSCORE 523
+#define VK_FINAL 24
+#define VK_CONVERT 28
+#define VK_NONCONVERT 29
+#define VK_ACCEPT 30
+#define VK_MODECHANGE 31
+#define VK_KANA 21
+#define VK_KANJI 25
+#define VK_ALPHANUMERIC 240
+#define VK_KATAKANA 241
+#define VK_HIRAGANA 242
+#define VK_FULL_WIDTH 243
+#define VK_HALF_WIDTH 244
+#define VK_ROMAN_CHARACTERS 245
+#define VK_ALL_CANDIDATES 256
+#define VK_PREVIOUS_CANDIDATE 257
+#define VK_CODE_INPUT 258
+#define VK_JAPANESE_KATAKANA 259
+#define VK_JAPANESE_HIRAGANA 260
+#define VK_JAPANESE_ROMAN 261
+#define VK_KANA_LOCK 262
+#define VK_INPUT_METHOD_ON_OFF 263
+#define VK_CUT 65489
+#define VK_COPY 65485
+#define VK_PASTE 65487
+#define VK_UNDO 65483
+#define VK_AGAIN 65481
+#define VK_FIND 65488
+#define VK_PROPS 65482
+#define VK_STOP 65480
+#define VK_COMPOSE 65312
+#define VK_ALT_GRAPH 65406
+#define VK_UNDEFINED 0
+
+#define AWT_KEY_CHAR_UNDEFINED 0
+
+#define AWT_FRAME_STATE_NORMAL 0
+#define AWT_FRAME_STATE_ICONIFIED 1
+#define AWT_FRAME_STATE_MAXIMIZED_HORIZ 2
+#define AWT_FRAME_STATE_MAXIMIZED_VERT 4
+#define AWT_FRAME_STATE_MAXIMIZED_BOTH 6
+
+static jmethodID postKeyEventID;
+static jmethodID postWindowEventID;
+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");
+
+ postKeyEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkwindowpeer,
+ "postKeyEvent", "(IJIICI)V");
+
+ postWindowEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkwindowpeer,
+ "postWindowEvent",
+ "(ILjava/awt/Window;I)V");
+
+ postConfigureEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkwindowpeer,
+ "postConfigureEvent", "(IIII)V");
+
+ postInsetsChangedEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkwindowpeer,
+ "postInsetsChangedEvent",
+ "(IIII)V");
+
+ windowGetWidthID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkwindowpeer,
+ "getWidth", "()I");
+
+ windowGetHeightID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkwindowpeer,
+ "getHeight", "()I");
+
+ gtkwindowpeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
+ "gnu/java/awt/peer/gtk/GtkWindowPeer");
+}
+
+/* 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
+get_first_keyval_from_keymap (GdkEventKey *event)
+{
+ guint keyval;
+ guint *keyvals;
+ gint n_entries;
+
+ if (!gdk_keymap_get_entries_for_keycode (NULL,
+ event->hardware_keycode,
+ NULL,
+ &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);
+ }
+ keyval = keyvals[0];
+ g_free (keyvals);
+
+ return gdk_keyval_to_upper (keyval);
+}
+
+#ifdef __GNUC__
+__inline
+#endif
+static jint
+keysym_to_awt_keycode (GdkEventKey *event)
+{
+ guint ukeyval;
+ guint state;
+
+ ukeyval = get_first_keyval_from_keymap (event);
+ state = event->state;
+
+ /* VK_A through VK_Z */
+ if (ukeyval >= GDK_A && ukeyval <= GDK_Z)
+ return ukeyval;
+
+ /* VK_0 through VK_9 */
+ if (ukeyval >= GDK_0 && ukeyval <= GDK_9)
+ return ukeyval;
+
+ switch (ukeyval)
+ {
+ case GDK_Return:
+ case GDK_KP_Enter:
+ return VK_ENTER;
+ case GDK_BackSpace:
+ return VK_BACK_SPACE;
+ case GDK_Tab:
+ return VK_TAB;
+ case GDK_Cancel:
+ return VK_CANCEL;
+ case GDK_Clear:
+ return VK_CLEAR;
+ case GDK_Shift_L:
+ case GDK_Shift_R:
+ return VK_SHIFT;
+ case GDK_Control_L:
+ case GDK_Control_R:
+ return VK_CONTROL;
+ case GDK_Alt_L:
+ case GDK_Alt_R:
+ return VK_ALT;
+ case GDK_Pause:
+ return VK_PAUSE;
+ case GDK_Caps_Lock:
+ return VK_CAPS_LOCK;
+ case GDK_Escape:
+ return VK_ESCAPE;
+ case GDK_space:
+ return VK_SPACE;
+ case GDK_KP_Page_Up:
+ /* For keys on the numeric keypad, the JVM produces one of two
+ virtual keys, depending on the num lock state. */
+ if (state & GDK_MOD2_MASK)
+ return VK_NUMPAD9;
+ else
+ return VK_PAGE_UP;
+ case GDK_Page_Up:
+ return VK_PAGE_UP;
+ case GDK_KP_Page_Down:
+ if (state & GDK_MOD2_MASK)
+ return VK_NUMPAD3;
+ else
+ return VK_PAGE_DOWN;
+ case GDK_Page_Down:
+ return VK_PAGE_DOWN;
+ case GDK_KP_End:
+ if (state & GDK_MOD2_MASK)
+ return VK_NUMPAD1;
+ else
+ return VK_END;
+ case GDK_End:
+ return VK_END;
+ case GDK_KP_Home:
+ if (state & GDK_MOD2_MASK)
+ return VK_NUMPAD7;
+ else
+ return VK_HOME;
+ case GDK_Home:
+ return VK_HOME;
+ case GDK_KP_Begin:
+ if (state & GDK_MOD2_MASK)
+ return VK_NUMPAD5;
+ else
+ return VK_UNDEFINED;
+ case GDK_Left:
+ return VK_LEFT;
+ case GDK_Up:
+ return VK_UP;
+ case GDK_Right:
+ return VK_RIGHT;
+ case GDK_Down:
+ return VK_DOWN;
+ case GDK_comma:
+ return VK_COMMA;
+ case GDK_minus:
+ return VK_MINUS;
+ case GDK_period:
+ return VK_PERIOD;
+ case GDK_slash:
+ return VK_SLASH;
+ /*
+ return VK_0;
+ return VK_1;
+ return VK_2;
+ return VK_3;
+ return VK_4;
+ return VK_5;
+ return VK_6;
+ return VK_7;
+ return VK_8;
+ return VK_9;
+ */
+ case GDK_semicolon:
+ return VK_SEMICOLON;
+ case GDK_equal:
+ return VK_EQUALS;
+ /*
+ return VK_A;
+ return VK_B;
+ return VK_C;
+ return VK_D;
+ return VK_E;
+ return VK_F;
+ return VK_G;
+ return VK_H;
+ return VK_I;
+ return VK_J;
+ return VK_K;
+ return VK_L;
+ return VK_M;
+ return VK_N;
+ return VK_O;
+ return VK_P;
+ return VK_Q;
+ return VK_R;
+ return VK_S;
+ return VK_T;
+ return VK_U;
+ return VK_V;
+ return VK_W;
+ return VK_X;
+ return VK_Y;
+ return VK_Z;
+ */
+ case GDK_bracketleft:
+ return VK_OPEN_BRACKET;
+ case GDK_backslash:
+ return VK_BACK_SLASH;
+ case GDK_bracketright:
+ return VK_CLOSE_BRACKET;
+ case GDK_KP_0:
+ return VK_NUMPAD0;
+ case GDK_KP_1:
+ return VK_NUMPAD1;
+ case GDK_KP_2:
+ return VK_NUMPAD2;
+ case GDK_KP_3:
+ return VK_NUMPAD3;
+ case GDK_KP_4:
+ return VK_NUMPAD4;
+ case GDK_KP_5:
+ return VK_NUMPAD5;
+ case GDK_KP_6:
+ return VK_NUMPAD6;
+ case GDK_KP_7:
+ return VK_NUMPAD7;
+ case GDK_KP_8:
+ return VK_NUMPAD8;
+ case GDK_KP_9:
+ return VK_NUMPAD9;
+ case GDK_KP_Multiply:
+ return VK_MULTIPLY;
+ case GDK_KP_Add:
+ return VK_ADD;
+ /*
+ return VK_SEPARATER;
+ */
+ case GDK_KP_Separator:
+ return VK_SEPARATOR;
+ case GDK_KP_Subtract:
+ return VK_SUBTRACT;
+ case GDK_KP_Decimal:
+ return VK_DECIMAL;
+ case GDK_KP_Divide:
+ return VK_DIVIDE;
+ case GDK_KP_Delete:
+ if (state & GDK_MOD2_MASK)
+ return VK_DECIMAL;
+ else
+ return VK_DELETE;
+ case GDK_Delete:
+ return VK_DELETE;
+ case GDK_Num_Lock:
+ return VK_NUM_LOCK;
+ case GDK_Scroll_Lock:
+ return VK_SCROLL_LOCK;
+ case GDK_F1:
+ return VK_F1;
+ case GDK_F2:
+ return VK_F2;
+ case GDK_F3:
+ return VK_F3;
+ case GDK_F4:
+ return VK_F4;
+ case GDK_F5:
+ return VK_F5;
+ case GDK_F6:
+ return VK_F6;
+ case GDK_F7:
+ return VK_F7;
+ case GDK_F8:
+ return VK_F8;
+ case GDK_F9:
+ return VK_F9;
+ case GDK_F10:
+ return VK_F10;
+ case GDK_F11:
+ return VK_F11;
+ case GDK_F12:
+ return VK_F12;
+ case GDK_F13:
+ return VK_F13;
+ case GDK_F14:
+ return VK_F14;
+ case GDK_F15:
+ return VK_F15;
+ case GDK_F16:
+ return VK_F16;
+ case GDK_F17:
+ return VK_F17;
+ case GDK_F18:
+ return VK_F18;
+ case GDK_F19:
+ return VK_F19;
+ case GDK_F20:
+ return VK_F20;
+ case GDK_F21:
+ return VK_F21;
+ case GDK_F22:
+ return VK_F22;
+ case GDK_F23:
+ return VK_F23;
+ case GDK_F24:
+ return VK_F24;
+ case GDK_Print:
+ return VK_PRINTSCREEN;
+ case GDK_KP_Insert:
+ if (state & GDK_MOD2_MASK)
+ return VK_NUMPAD0;
+ else
+ return VK_INSERT;
+ case GDK_Insert:
+ return VK_INSERT;
+ case GDK_Help:
+ return VK_HELP;
+ case GDK_Meta_L:
+ case GDK_Meta_R:
+ return VK_META;
+ case GDK_grave:
+ return VK_BACK_QUOTE;
+ case GDK_apostrophe:
+ return VK_QUOTE;
+ case GDK_KP_Up:
+ if (state & GDK_MOD2_MASK)
+ return VK_NUMPAD8;
+ else
+ return VK_KP_UP;
+ case GDK_KP_Down:
+ if (state & GDK_MOD2_MASK)
+ return VK_NUMPAD2;
+ else
+ return VK_KP_DOWN;
+ case GDK_KP_Left:
+ if (state & GDK_MOD2_MASK)
+ return VK_NUMPAD4;
+ else
+ return VK_KP_LEFT;
+ case GDK_KP_Right:
+ if (state & GDK_MOD2_MASK)
+ return VK_NUMPAD6;
+ else
+ return VK_KP_RIGHT;
+ case GDK_dead_grave:
+ return VK_DEAD_GRAVE;
+ case GDK_dead_acute:
+ return VK_DEAD_ACUTE;
+ case GDK_dead_circumflex:
+ return VK_DEAD_CIRCUMFLEX;
+ case GDK_dead_tilde:
+ return VK_DEAD_TILDE;
+ case GDK_dead_macron:
+ return VK_DEAD_MACRON;
+ case GDK_dead_breve:
+ return VK_DEAD_BREVE;
+ case GDK_dead_abovedot:
+ return VK_DEAD_ABOVEDOT;
+ case GDK_dead_diaeresis:
+ return VK_DEAD_DIAERESIS;
+ case GDK_dead_abovering:
+ return VK_DEAD_ABOVERING;
+ case GDK_dead_doubleacute:
+ return VK_DEAD_DOUBLEACUTE;
+ case GDK_dead_caron:
+ return VK_DEAD_CARON;
+ case GDK_dead_cedilla:
+ return VK_DEAD_CEDILLA;
+ case GDK_dead_ogonek:
+ return VK_DEAD_OGONEK;
+ case GDK_dead_iota:
+ return VK_DEAD_IOTA;
+ case GDK_dead_voiced_sound:
+ return VK_DEAD_VOICED_SOUND;
+ case GDK_dead_semivoiced_sound:
+ return VK_DEAD_SEMIVOICED_SOUND;
+ case GDK_ampersand:
+ return VK_AMPERSAND;
+ case GDK_asterisk:
+ return VK_ASTERISK;
+ case GDK_quotedbl:
+ return VK_QUOTEDBL;
+ case GDK_less:
+ return VK_LESS;
+ case GDK_greater:
+ return VK_GREATER;
+ case GDK_braceleft:
+ return VK_BRACELEFT;
+ case GDK_braceright:
+ return VK_BRACERIGHT;
+ case GDK_at:
+ return VK_AT;
+ case GDK_colon:
+ return VK_COLON;
+ case GDK_asciicircum:
+ return VK_CIRCUMFLEX;
+ case GDK_dollar:
+ return VK_DOLLAR;
+ case GDK_EuroSign:
+ return VK_EURO_SIGN;
+ case GDK_exclam:
+ return VK_EXCLAMATION_MARK;
+ case GDK_exclamdown:
+ return VK_INVERTED_EXCLAMATION_MARK;
+ case GDK_parenleft:
+ return VK_LEFT_PARENTHESIS;
+ case GDK_numbersign:
+ return VK_NUMBER_SIGN;
+ case GDK_plus:
+ return VK_PLUS;
+ case GDK_parenright:
+ return VK_RIGHT_PARENTHESIS;
+ case GDK_underscore:
+ return VK_UNDERSCORE;
+ /*
+ return VK_FINAL;
+ return VK_CONVERT;
+ return VK_NONCONVERT;
+ return VK_ACCEPT;
+ */
+ case GDK_Mode_switch:
+ return VK_MODECHANGE;
+ /*
+ return VK_KANA;
+ */
+ case GDK_Kanji:
+ return VK_KANJI;
+ /*
+ return VK_ALPHANUMERIC;
+ */
+ case GDK_Katakana:
+ return VK_KATAKANA;
+ case GDK_Hiragana:
+ return VK_HIRAGANA;
+ /*
+ return VK_FULL_WIDTH;
+ return VK_HALF_WIDTH;
+ return VK_ROMAN_CHARACTERS;
+ return VK_ALL_CANDIDATES;
+ */
+ case GDK_PreviousCandidate:
+ return VK_PREVIOUS_CANDIDATE;
+ case GDK_Codeinput:
+ return VK_CODE_INPUT;
+ /*
+ return VK_JAPANESE_KATAKANA;
+ return VK_JAPANESE_HIRAGANA;
+ return VK_JAPANESE_ROMAN;
+ */
+ case GDK_Kana_Lock:
+ return VK_KANA_LOCK;
+ /*
+ return VK_INPUT_METHOD_ON_OFF;
+ return VK_CUT;
+ return VK_COPY;
+ return VK_PASTE;
+ return VK_UNDO;
+ return VK_AGAIN;
+ return VK_FIND;
+ return VK_PROPS;
+ return VK_STOP;
+ return VK_COMPOSE;
+ return VK_ALT_GRAPH;
+ */
+ default:
+ return VK_UNDEFINED;
+ }
+}
+
+static jint
+keysym_to_awt_keylocation (GdkEventKey *event)
+{
+ guint ukeyval;
+
+ ukeyval = get_first_keyval_from_keymap (event);
+
+ /* VK_A through VK_Z */
+ if (ukeyval >= GDK_A && ukeyval <= GDK_Z)
+ return AWT_KEY_LOCATION_STANDARD;
+
+ /* VK_0 through VK_9 */
+ if (ukeyval >= GDK_0 && ukeyval <= GDK_9)
+ return AWT_KEY_LOCATION_STANDARD;
+
+ switch (ukeyval)
+ {
+ case GDK_Shift_L:
+ case GDK_Control_L:
+ case GDK_Alt_L:
+ case GDK_Meta_L:
+ return AWT_KEY_LOCATION_LEFT;
+
+ case GDK_Shift_R:
+ case GDK_Control_R:
+ case GDK_Alt_R:
+ case GDK_Meta_R:
+ return AWT_KEY_LOCATION_RIGHT;
+
+ case GDK_Return:
+ case GDK_BackSpace:
+ case GDK_Tab:
+ case GDK_Cancel:
+ case GDK_Clear:
+ case GDK_Pause:
+ case GDK_Caps_Lock:
+ case GDK_Escape:
+ case GDK_space:
+ case GDK_Page_Up:
+ case GDK_Page_Down:
+ case GDK_End:
+ case GDK_Home:
+ case GDK_Left:
+ case GDK_Up:
+ case GDK_Right:
+ case GDK_Down:
+ case GDK_comma:
+ case GDK_minus:
+ case GDK_period:
+ case GDK_slash:
+ case GDK_semicolon:
+ case GDK_equal:
+ case GDK_bracketleft:
+ case GDK_backslash:
+ case GDK_bracketright:
+ case GDK_Delete:
+ case GDK_Scroll_Lock:
+ case GDK_F1:
+ case GDK_F2:
+ case GDK_F3:
+ case GDK_F4:
+ case GDK_F5:
+ case GDK_F6:
+ case GDK_F7:
+ case GDK_F8:
+ case GDK_F9:
+ case GDK_F10:
+ case GDK_F11:
+ case GDK_F12:
+ case GDK_F13:
+ case GDK_F14:
+ case GDK_F15:
+ case GDK_F16:
+ case GDK_F17:
+ case GDK_F18:
+ case GDK_F19:
+ case GDK_F20:
+ case GDK_F21:
+ case GDK_F22:
+ case GDK_F23:
+ case GDK_F24:
+ case GDK_Print:
+ case GDK_Insert:
+ case GDK_Help:
+ case GDK_grave:
+ case GDK_apostrophe:
+ case GDK_dead_grave:
+ case GDK_dead_acute:
+ case GDK_dead_circumflex:
+ case GDK_dead_tilde:
+ case GDK_dead_macron:
+ case GDK_dead_breve:
+ case GDK_dead_abovedot:
+ case GDK_dead_diaeresis:
+ case GDK_dead_abovering:
+ case GDK_dead_doubleacute:
+ case GDK_dead_caron:
+ case GDK_dead_cedilla:
+ case GDK_dead_ogonek:
+ case GDK_dead_iota:
+ case GDK_dead_voiced_sound:
+ case GDK_dead_semivoiced_sound:
+ case GDK_ampersand:
+ case GDK_asterisk:
+ case GDK_quotedbl:
+ case GDK_less:
+ case GDK_greater:
+ case GDK_braceleft:
+ case GDK_braceright:
+ case GDK_at:
+ case GDK_colon:
+ case GDK_asciicircum:
+ case GDK_dollar:
+ case GDK_EuroSign:
+ case GDK_exclam:
+ case GDK_exclamdown:
+ case GDK_parenleft:
+ case GDK_numbersign:
+ case GDK_plus:
+ case GDK_parenright:
+ case GDK_underscore:
+ case GDK_Mode_switch:
+ case GDK_Kanji:
+ case GDK_Katakana:
+ case GDK_Hiragana:
+ case GDK_PreviousCandidate:
+ case GDK_Codeinput:
+ case GDK_Kana_Lock:
+ return AWT_KEY_LOCATION_STANDARD;
+
+ case GDK_KP_Enter:
+ case GDK_KP_Page_Up:
+ case GDK_KP_Page_Down:
+ case GDK_KP_End:
+ case GDK_KP_Home:
+ case GDK_KP_Begin:
+ case GDK_KP_0:
+ case GDK_KP_1:
+ case GDK_KP_2:
+ case GDK_KP_3:
+ case GDK_KP_4:
+ case GDK_KP_5:
+ case GDK_KP_6:
+ case GDK_KP_7:
+ case GDK_KP_8:
+ case GDK_KP_9:
+ case GDK_KP_Multiply:
+ case GDK_KP_Add:
+ case GDK_KP_Separator:
+ case GDK_KP_Subtract:
+ case GDK_KP_Decimal:
+ case GDK_KP_Divide:
+ case GDK_KP_Delete:
+ case GDK_Num_Lock:
+ case GDK_KP_Insert:
+ case GDK_KP_Up:
+ case GDK_KP_Down:
+ case GDK_KP_Left:
+ case GDK_KP_Right:
+ return AWT_KEY_LOCATION_NUMPAD;
+
+ default:
+ return AWT_KEY_LOCATION_UNKNOWN;
+ }
+}
+
+static jchar
+keyevent_to_awt_keychar (GdkEventKey *event)
+{
+ if (event->length > 0)
+ {
+ /* Translate GDK carriage return to Java linefeed. */
+ if (event->string[0] == 13)
+ return VK_ENTER;
+ else
+ return event->string[0];
+ }
+ else
+ {
+ switch (event->keyval)
+ {
+ case GDK_BackSpace:
+ return VK_BACK_SPACE;
+ case GDK_Tab:
+ return VK_TAB;
+ case GDK_Delete:
+ case GDK_KP_Delete:
+ return VK_DELETE;
+ default:
+ return AWT_KEY_CHAR_UNDEFINED;
+ }
+ }
+}
+
+/* Modifier key events need special treatment. In Sun's peer
+ implementation, when a modifier key is pressed, the KEY_PRESSED
+ event has that modifier in its modifiers list. The corresponding
+ KEY_RELEASED event's modifier list does not contain the modifier.
+ For example, pressing and releasing the shift key will produce a
+ key press event with modifiers=Shift, and a key release event with
+ no modifiers. GDK's key events behave in the exact opposite way,
+ so this translation code is needed. */
+static jint
+keyevent_state_to_awt_mods (GdkEventKey *event)
+{
+ jint result = 0;
+ guint state;
+
+ if (event->type == GDK_KEY_PRESS)
+ {
+ state = event->state;
+
+ if (event->keyval == GDK_Shift_L
+ || event->keyval == GDK_Shift_R)
+ result |= AWT_SHIFT_DOWN_MASK;
+ else
+ {
+ if (state & GDK_SHIFT_MASK)
+ result |= AWT_SHIFT_DOWN_MASK;
+ }
+
+ if (event->keyval == GDK_Control_L
+ || event->keyval == GDK_Control_R)
+ result |= AWT_CTRL_DOWN_MASK;
+ else
+ {
+ if (state & GDK_CONTROL_MASK)
+ result |= AWT_CTRL_DOWN_MASK;
+ }
+
+ if (event->keyval == GDK_Alt_L
+ || event->keyval == GDK_Alt_R)
+ result |= AWT_ALT_DOWN_MASK;
+ else
+ {
+ if (state & GDK_MOD1_MASK)
+ result |= AWT_ALT_DOWN_MASK;
+ }
+ }
+ else if (event->type == GDK_KEY_RELEASE)
+ {
+ state = event->state;
+
+ if (event->keyval != GDK_Shift_L
+ && event->keyval != GDK_Shift_R)
+ {
+ if (state & GDK_SHIFT_MASK)
+ result |= AWT_SHIFT_DOWN_MASK;
+ }
+ if (event->keyval != GDK_Control_L
+ && event->keyval != GDK_Control_R)
+ {
+ if (state & GDK_CONTROL_MASK)
+ result |= AWT_CTRL_DOWN_MASK;
+ }
+
+ if (event->keyval != GDK_Alt_L
+ && event->keyval != GDK_Alt_R)
+ {
+ if (state & GDK_MOD1_MASK)
+ result |= AWT_ALT_DOWN_MASK;
+ }
+ }
+
+ return result;
+}
+
+static gboolean window_configure_cb (GtkWidget *widget,
+ GdkEventConfigure *event,
+ jobject peer);
/* FIXME: we're currently seeing the double-activation that occurs
with metacity and GTK. See
@@ -82,6 +1047,73 @@ static gboolean window_property_changed_cb (GtkWidget *widget,
jobject peer);
static void realize_cb (GtkWidget *widget, jobject peer);
+static gboolean
+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,
+ (jint) event->y,
+ (jint) event->width,
+ (jint) event->height);
+
+ gdk_threads_enter ();
+
+ return FALSE;
+}
+
+static gboolean
+key_press_cb (GtkWidget *widget __attribute__((unused)),
+ GdkEventKey *event,
+ jobject peer)
+{
+ gdk_threads_leave ();
+
+ (*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),
+ keyevent_to_awt_keychar (event),
+ keysym_to_awt_keylocation (event));
+
+ gdk_threads_enter ();
+
+ /* FIXME: generation of key typed events needs to be moved
+ to GtkComponentPeer.postKeyEvent. If the key in a key
+ press event is not an "action" key
+ (KeyEvent.isActionKey) and is not a modifier key, then
+ it should generate a key typed event. */
+ return TRUE;
+}
+
+
+static gboolean
+key_release_cb (GtkWidget *widget __attribute__((unused)),
+ GdkEventKey *event,
+ jobject peer)
+{
+ gdk_threads_leave ();
+
+ (*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),
+ keyevent_to_awt_keychar (event),
+ keysym_to_awt_keylocation (event));
+
+ gdk_threads_enter ();
+
+ return TRUE;
+}
+
/* Union used for type punning. */
union extents_union
{
@@ -104,10 +1136,10 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_create
void *window_parent;
GtkWidget *fixed;
- NSA_SET_GLOBAL_REF (env, obj);
-
gdk_threads_enter ();
+ NSA_SET_GLOBAL_REF (env, obj);
+
window_widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = GTK_WINDOW (window_widget);
@@ -122,16 +1154,17 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_create
gtk_window_set_type_hint (window, type);
- gtk_window_group_add_window (global_gtk_window_group, window);
+ gtk_window_group_add_window (cp_gtk_global_window_group, window);
fixed = gtk_fixed_new ();
+
gtk_container_add (GTK_CONTAINER (window_widget), fixed);
gtk_widget_show (fixed);
- gdk_threads_leave ();
-
NSA_SET_PTR (env, obj, window_widget);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -141,17 +1174,17 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetTitle
const char *c_title;
void *ptr;
+ gdk_threads_enter ();
+
ptr = NSA_GET_PTR (env, obj);
c_title = (*env)->GetStringUTFChars (env, title, NULL);
- gdk_threads_enter ();
-
gtk_window_set_title (GTK_WINDOW (ptr), c_title);
- gdk_threads_leave ();
-
(*env)->ReleaseStringUTFChars (env, title, c_title);
+
+ gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -160,10 +1193,10 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetResizable
{
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
gtk_window_set_policy (GTK_WINDOW (ptr), resizable, resizable, FALSE);
gdk_threads_leave ();
@@ -175,10 +1208,10 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetModal
{
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
gtk_window_set_modal (GTK_WINDOW (ptr), modal);
gdk_threads_leave ();
@@ -190,10 +1223,10 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisible
{
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
if (visible)
gtk_widget_show (GTK_WIDGET (ptr));
else
@@ -211,13 +1244,10 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectSignals
void *ptr;
jobject *gref;
- ptr = NSA_GET_PTR (env, obj);
- gref = NSA_GET_GLOBAL_REF (env, obj);
-
gdk_threads_enter ();
- g_signal_connect (G_OBJECT (ptr), "event",
- G_CALLBACK (pre_event_handler), *gref);
+ ptr = NSA_GET_PTR (env, obj);
+ gref = NSA_GET_GLOBAL_REF (env, obj);
g_signal_connect (G_OBJECT (ptr), "delete-event",
G_CALLBACK (window_delete_cb), *gref);
@@ -249,14 +1279,38 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectSignals
g_signal_connect_after (G_OBJECT (ptr), "realize",
G_CALLBACK (realize_cb), *gref);
- g_signal_connect_after (G_OBJECT (ptr), "realize",
- G_CALLBACK (connect_awt_hook_cb), *gref);
+ g_signal_connect (G_OBJECT (ptr), "key-press-event",
+ G_CALLBACK (key_press_cb), *gref);
+
+ g_signal_connect (G_OBJECT (ptr), "key-release-event",
+ G_CALLBACK (key_release_cb), *gref);
+ g_signal_connect_after (G_OBJECT (ptr), "window-state-event",
+ G_CALLBACK (window_window_state_cb), *gref);
+
+ g_signal_connect (G_OBJECT (ptr), "configure-event",
+ G_CALLBACK (window_configure_cb), *gref);
+
+ cp_gtk_component_connect_expose_signals (ptr, gref);
+ cp_gtk_component_connect_mouse_signals (ptr, gref);
+
+ /* FIXME: override focus signals here to prevent child fixed repaint? */
+
+ gdk_threads_leave ();
+}
+
+/* Realize the window here so that its frame extents are known now.
+ That way Window.pack can operate with the accurate insets returned
+ by the window manager rather than the default estimates. */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkWindowPeer_realize (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
- /* Realize the window here so that its frame extents are known now.
- That way Window.pack can operate with the accurate insets
- returned by the window manager rather than the default
- estimates. */
gtk_widget_realize (GTK_WIDGET (ptr));
gdk_threads_leave ();
@@ -267,10 +1321,11 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_toBack (JNIEnv *env,
jobject obj)
{
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
+
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
gdk_window_lower (GTK_WIDGET (ptr)->window);
gdk_flush ();
@@ -282,10 +1337,11 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_toFront (JNIEnv *env,
jobject obj)
{
void *ptr;
- ptr = NSA_GET_PTR (env, obj);
-
+
gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+
gdk_window_raise (GTK_WIDGET (ptr)->window);
gdk_flush ();
@@ -299,7 +1355,7 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setBoundsCallback
{
/* Circumvent package-private access to call Window's
setBoundsCallback method. */
- (*gdk_env())->CallVoidMethod (gdk_env(), window, setBoundsCallbackID,
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), window, setBoundsCallbackID,
x, y, width, height);
}
@@ -307,14 +1363,16 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setSize
(JNIEnv *env, jobject obj, jint width, jint height)
{
- void *ptr = NSA_GET_PTR (env, obj);
+ void *ptr;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
/* Avoid GTK runtime assertion failures. */
width = (width < 1) ? 1 : width;
height = (height < 1) ? 1 : height;
- gdk_threads_enter ();
-
gtk_widget_set_size_request (GTK_WIDGET(ptr), width, height);
gdk_threads_leave ();
@@ -324,14 +1382,16 @@ 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 = NSA_GET_PTR (env, obj);
+ void *ptr;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
/* Avoid GTK runtime assertion failures. */
width = (width < 1) ? 1 : width;
height = (height < 1) ? 1 : height;
- gdk_threads_enter ();
-
gtk_window_move (GTK_WINDOW(ptr), x, y);
/* The call to gdk_window_move is needed in addition to the call to
gtk_window_move. If gdk_window_move isn't called, then the
@@ -354,6 +1414,7 @@ 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 ();
}
@@ -471,10 +1532,12 @@ window_delete_cb (GtkWidget *widget __attribute__((unused)),
jobject peer)
{
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+
+ (*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"
@@ -490,10 +1553,12 @@ window_destroy_cb (GtkWidget *widget __attribute__((unused)),
jobject peer)
{
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_CLOSED,
(jobject) NULL, (jint) 0);
+
gdk_threads_enter ();
}
@@ -502,10 +1567,12 @@ window_show_cb (GtkWidget *widget __attribute__((unused)),
jobject peer)
{
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_OPENED,
(jobject) NULL, (jint) 0);
+
gdk_threads_enter ();
}
@@ -518,16 +1585,18 @@ window_active_state_change_cb (GtkWidget *widget __attribute__((unused)),
/* Remove the unused attributes if you fix the below. */
#if 0
gdk_threads_leave ();
+
if (GTK_WINDOW (widget)->is_active)
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_GAINED_FOCUS,
(jobject) NULL, (jint) 0);
else
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_DEACTIVATED,
(jobject) NULL, (jint) 0);
+
gdk_threads_enter ();
#endif
}
@@ -538,16 +1607,18 @@ window_focus_state_change_cb (GtkWidget *widget,
jobject peer)
{
gdk_threads_leave ();
+
if (GTK_WINDOW (widget)->has_toplevel_focus)
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_ACTIVATED,
(jobject) NULL, (jint) 0);
else
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_DEACTIVATED,
(jobject) NULL, (jint) 0);
+
gdk_threads_enter ();
}
@@ -557,13 +1628,14 @@ window_focus_in_cb (GtkWidget * widget __attribute__((unused)),
jobject peer)
{
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_GAINED_FOCUS,
(jobject) NULL, (jint) 0);
- /* FIXME: somewhere after this is handled, the child window is
- getting an expose event. */
+
gdk_threads_enter ();
+
return FALSE;
}
@@ -573,13 +1645,14 @@ window_focus_out_cb (GtkWidget * widget __attribute__((unused)),
jobject peer)
{
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_LOST_FOCUS,
(jobject) NULL, (jint) 0);
- /* FIXME: somewhere after this is handled, the child window is
- getting an expose event. */
+
gdk_threads_enter ();
+
return FALSE;
}
@@ -598,20 +1671,24 @@ window_window_state_cb (GtkWidget *widget,
{
/* We've been iconified. */
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+
+ (*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 ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_DEICONIFIED,
(jobject) NULL, (jint) 0);
+
gdk_threads_enter ();
}
}
@@ -626,11 +1703,14 @@ window_window_state_cb (GtkWidget *widget,
new_state |= window_get_new_state (widget);
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+
+ (*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;
}
@@ -697,12 +1777,14 @@ window_property_changed_cb (GtkWidget *widget __attribute__((unused)),
gu_ex.gu_extents))
{
gdk_threads_leave ();
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+
+ (*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 ();
}
@@ -720,12 +1802,12 @@ realize_cb (GtkWidget *widget, jobject peer)
jint width = 0;
jint height = 0;
- width = (*gdk_env())->CallIntMethod (gdk_env(), peer, windowGetWidthID);
- height = (*gdk_env())->CallIntMethod (gdk_env(), peer, windowGetHeightID);
+ width = (*cp_gtk_gdk_env())->CallIntMethod (cp_gtk_gdk_env(), peer, windowGetWidthID);
+ height = (*cp_gtk_gdk_env())->CallIntMethod (cp_gtk_gdk_env(), peer, windowGetHeightID);
window_get_frame_extents (widget, &top, &left, &bottom, &right);
- (*gdk_env())->CallVoidMethod (gdk_env(), peer,
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postInsetsChangedEventID,
top, left, bottom, right);
@@ -742,3 +1824,358 @@ realize_cb (GtkWidget *widget, jobject peer)
MAX (1, width - left - right),
MAX (1, height - top - bottom));
}
+
+/*
+ * This method returns a GDK keyval that corresponds to one of the
+ * keysyms in the X keymap table. The return value is only used to
+ * determine the keyval's corresponding hardware keycode, and doesn't
+ * reflect an accurate translation of a Java virtual key value to a
+ * GDK keyval.
+ */
+#ifdef __GNUC__
+__inline
+#endif
+guint
+cp_gtk_awt_keycode_to_keysym (jint keyCode, jint keyLocation)
+{
+ /* GDK_A through GDK_Z */
+ if (keyCode >= VK_A && keyCode <= VK_Z)
+ return gdk_keyval_to_lower (keyCode);
+
+ /* GDK_0 through GDK_9 */
+ if (keyCode >= VK_0 && keyCode <= VK_9)
+ return keyCode;
+
+ switch (keyCode)
+ {
+ case VK_ENTER:
+ return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Enter : GDK_Return;
+ case VK_BACK_SPACE:
+ return GDK_BackSpace;
+ case VK_TAB:
+ return GDK_Tab;
+ case VK_CANCEL:
+ return GDK_Cancel;
+ case VK_CLEAR:
+ return GDK_Clear;
+ case VK_SHIFT:
+ return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Shift_L : GDK_Shift_R;
+ case VK_CONTROL:
+ return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Control_L : GDK_Control_R;
+ case VK_ALT:
+ return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Alt_L : GDK_Alt_R;
+ case VK_PAUSE:
+ return GDK_Pause;
+ case VK_CAPS_LOCK:
+ return GDK_Caps_Lock;
+ case VK_ESCAPE:
+ return GDK_Escape;
+ case VK_SPACE:
+ return GDK_space;
+ case VK_PAGE_UP:
+ return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Page_Up : GDK_Page_Up;
+ case VK_PAGE_DOWN:
+ return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Page_Down : GDK_Page_Down;
+ case VK_END:
+ return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_End : GDK_End;
+ case VK_HOME:
+ return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Home : GDK_Home;
+ case VK_LEFT:
+ return GDK_Left;
+ case VK_UP:
+ return GDK_Up;
+ case VK_RIGHT:
+ return GDK_Right;
+ case VK_DOWN:
+ return GDK_Down;
+ case VK_COMMA:
+ return GDK_comma;
+ case VK_MINUS:
+ return GDK_minus;
+ case VK_PERIOD:
+ return GDK_period;
+ case VK_SLASH:
+ return GDK_slash;
+ /*
+ case VK_0:
+ case VK_1:
+ case VK_2:
+ case VK_3:
+ case VK_4:
+ case VK_5:
+ case VK_6:
+ case VK_7:
+ case VK_8:
+ case VK_9:
+ */
+ case VK_SEMICOLON:
+ return GDK_semicolon;
+ case VK_EQUALS:
+ return GDK_equal;
+ /*
+ case VK_A:
+ case VK_B:
+ case VK_C:
+ case VK_D:
+ case VK_E:
+ case VK_F:
+ case VK_G:
+ case VK_H:
+ case VK_I:
+ case VK_J:
+ case VK_K:
+ case VK_L:
+ case VK_M:
+ case VK_N:
+ case VK_O:
+ case VK_P:
+ case VK_Q:
+ case VK_R:
+ case VK_S:
+ case VK_T:
+ case VK_U:
+ case VK_V:
+ case VK_W:
+ case VK_X:
+ case VK_Y:
+ case VK_Z:
+ */
+ case VK_OPEN_BRACKET:
+ return GDK_bracketleft;
+ case VK_BACK_SLASH:
+ return GDK_backslash;
+ case VK_CLOSE_BRACKET:
+ return GDK_bracketright;
+ case VK_NUMPAD0:
+ return GDK_KP_0;
+ case VK_NUMPAD1:
+ return GDK_KP_1;
+ case VK_NUMPAD2:
+ return GDK_KP_2;
+ case VK_NUMPAD3:
+ return GDK_KP_3;
+ case VK_NUMPAD4:
+ return GDK_KP_4;
+ case VK_NUMPAD5:
+ return GDK_KP_5;
+ case VK_NUMPAD6:
+ return GDK_KP_6;
+ case VK_NUMPAD7:
+ return GDK_KP_7;
+ case VK_NUMPAD8:
+ return GDK_KP_8;
+ case VK_NUMPAD9:
+ return GDK_KP_9;
+ case VK_MULTIPLY:
+ return GDK_KP_Multiply;
+ case VK_ADD:
+ return GDK_KP_Add;
+ /*
+ case VK_SEPARATER:
+ */
+ case VK_SEPARATOR:
+ return GDK_KP_Separator;
+ case VK_SUBTRACT:
+ return GDK_KP_Subtract;
+ case VK_DECIMAL:
+ return GDK_KP_Decimal;
+ case VK_DIVIDE:
+ return GDK_KP_Divide;
+ case VK_DELETE:
+ return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Delete : GDK_Delete;
+ case VK_NUM_LOCK:
+ return GDK_Num_Lock;
+ case VK_SCROLL_LOCK:
+ return GDK_Scroll_Lock;
+ case VK_F1:
+ return GDK_F1;
+ case VK_F2:
+ return GDK_F2;
+ case VK_F3:
+ return GDK_F3;
+ case VK_F4:
+ return GDK_F4;
+ case VK_F5:
+ return GDK_F5;
+ case VK_F6:
+ return GDK_F6;
+ case VK_F7:
+ return GDK_F7;
+ case VK_F8:
+ return GDK_F8;
+ case VK_F9:
+ return GDK_F9;
+ case VK_F10:
+ return GDK_F10;
+ case VK_F11:
+ return GDK_F11;
+ case VK_F12:
+ return GDK_F12;
+ case VK_F13:
+ return GDK_F13;
+ case VK_F14:
+ return GDK_F14;
+ case VK_F15:
+ return GDK_F15;
+ case VK_F16:
+ return GDK_F16;
+ case VK_F17:
+ return GDK_F17;
+ case VK_F18:
+ return GDK_F18;
+ case VK_F19:
+ return GDK_F19;
+ case VK_F20:
+ return GDK_F20;
+ case VK_F21:
+ return GDK_F21;
+ case VK_F22:
+ return GDK_F22;
+ case VK_F23:
+ return GDK_F23;
+ case VK_F24:
+ return GDK_F24;
+ case VK_PRINTSCREEN:
+ return GDK_Print;
+ case VK_INSERT:
+ return keyLocation == AWT_KEY_LOCATION_NUMPAD ? GDK_KP_Insert : GDK_Insert;
+ case VK_HELP:
+ return GDK_Help;
+ case VK_META:
+ return keyLocation == AWT_KEY_LOCATION_LEFT ? GDK_Meta_L : GDK_Meta_R;
+ case VK_BACK_QUOTE:
+ return GDK_grave;
+ case VK_QUOTE:
+ return GDK_apostrophe;
+ case VK_KP_UP:
+ return GDK_KP_Up;
+ case VK_KP_DOWN:
+ return GDK_KP_Down;
+ case VK_KP_LEFT:
+ return GDK_KP_Left;
+ case VK_KP_RIGHT:
+ return GDK_KP_Right;
+ case VK_DEAD_GRAVE:
+ return GDK_dead_grave;
+ case VK_DEAD_ACUTE:
+ return GDK_dead_acute;
+ case VK_DEAD_CIRCUMFLEX:
+ return GDK_dead_circumflex;
+ case VK_DEAD_TILDE:
+ return GDK_dead_tilde;
+ case VK_DEAD_MACRON:
+ return GDK_dead_macron;
+ case VK_DEAD_BREVE:
+ return GDK_dead_breve;
+ case VK_DEAD_ABOVEDOT:
+ return GDK_dead_abovedot;
+ case VK_DEAD_DIAERESIS:
+ return GDK_dead_diaeresis;
+ case VK_DEAD_ABOVERING:
+ return GDK_dead_abovering;
+ case VK_DEAD_DOUBLEACUTE:
+ return GDK_dead_doubleacute;
+ case VK_DEAD_CARON:
+ return GDK_dead_caron;
+ case VK_DEAD_CEDILLA:
+ return GDK_dead_cedilla;
+ case VK_DEAD_OGONEK:
+ return GDK_dead_ogonek;
+ case VK_DEAD_IOTA:
+ return GDK_dead_iota;
+ case VK_DEAD_VOICED_SOUND:
+ return GDK_dead_voiced_sound;
+ case VK_DEAD_SEMIVOICED_SOUND:
+ return GDK_dead_semivoiced_sound;
+ case VK_AMPERSAND:
+ return GDK_ampersand;
+ case VK_ASTERISK:
+ return GDK_asterisk;
+ case VK_QUOTEDBL:
+ return GDK_quotedbl;
+ case VK_LESS:
+ return GDK_less;
+ case VK_GREATER:
+ return GDK_greater;
+ case VK_BRACELEFT:
+ return GDK_braceleft;
+ case VK_BRACERIGHT:
+ return GDK_braceright;
+ case VK_AT:
+ return GDK_at;
+ case VK_COLON:
+ return GDK_colon;
+ case VK_CIRCUMFLEX:
+ return GDK_asciicircum;
+ case VK_DOLLAR:
+ return GDK_dollar;
+ case VK_EURO_SIGN:
+ return GDK_EuroSign;
+ case VK_EXCLAMATION_MARK:
+ return GDK_exclam;
+ case VK_INVERTED_EXCLAMATION_MARK:
+ return GDK_exclamdown;
+ case VK_LEFT_PARENTHESIS:
+ return GDK_parenleft;
+ case VK_NUMBER_SIGN:
+ return GDK_numbersign;
+ case VK_PLUS:
+ return GDK_plus;
+ case VK_RIGHT_PARENTHESIS:
+ return GDK_parenright;
+ case VK_UNDERSCORE:
+ return GDK_underscore;
+ /*
+ case VK_FINAL:
+ case VK_CONVERT:
+ case VK_NONCONVERT:
+ case VK_ACCEPT:
+ */
+ case VK_MODECHANGE:
+ return GDK_Mode_switch;
+ /*
+ case VK_KANA:
+ */
+ case VK_KANJI:
+ return GDK_Kanji;
+ /*
+ case VK_ALPHANUMERIC:
+ */
+ case VK_KATAKANA:
+ return GDK_Katakana;
+ case VK_HIRAGANA:
+ return GDK_Hiragana;
+ /*
+ case VK_FULL_WIDTH:
+ case VK_HALF_WIDTH:
+ case VK_ROMAN_CHARACTERS:
+ case VK_ALL_CANDIDATES:
+ */
+ case VK_PREVIOUS_CANDIDATE:
+ return GDK_PreviousCandidate;
+ case VK_CODE_INPUT:
+ return GDK_Codeinput;
+ /*
+ case VK_JAPANESE_KATAKANA:
+ case VK_JAPANESE_HIRAGANA:
+ case VK_JAPANESE_ROMAN:
+ */
+ case VK_KANA_LOCK:
+ return GDK_Kana_Lock;
+ /*
+ case VK_INPUT_METHOD_ON_OFF:
+ case VK_CUT:
+ case VK_COPY:
+ case VK_PASTE:
+ case VK_UNDO:
+ case VK_AGAIN:
+ case VK_FIND:
+ case VK_PROPS:
+ case VK_STOP:
+ case VK_COMPOSE:
+ case VK_ALT_GRAPH:
+ */
+ default:
+ return GDK_VoidSymbol;
+ }
+}
diff --git a/native/jni/gtk-peer/gthread-jni.c b/native/jni/gtk-peer/gthread-jni.c
index d66c5a080..e673de07d 100644
--- a/native/jni/gtk-peer/gthread-jni.c
+++ b/native/jni/gtk-peer/gthread-jni.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -245,7 +245,7 @@ exception statement from your version. */
/* The VM handle. This is set in
Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit */
-JavaVM *the_vm;
+JavaVM *cp_gtk_the_vm;
/* Unions used for type punning. */
union env_union
@@ -403,8 +403,8 @@ tracing (const char fmt[], ...)
/* Cached info for Exception-wrapping */
-jclass runtimeException_class; /* java.lang.RuntimeException */
-jmethodID runtimeException_ctor; /* constructor for it */
+static jclass runtimeException_class; /* java.lang.RuntimeException */
+static jmethodID runtimeException_ctor; /* constructor for it */
/* Throw a new RuntimeException. It may wrap around an existing exception.
@@ -1456,7 +1456,7 @@ mutex_new_jni_impl (void)
tracing ("mutex_new_jni_impl()");
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
{
@@ -1488,7 +1488,7 @@ mutex_lock_jni_impl (GMutex * mutex)
assert (mutexObj);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
@@ -1526,7 +1526,7 @@ mutex_trylock_jni_impl (GMutex * gmutex)
assert (mutexObj);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
HIDE_OLD_TROUBLE (env);
@@ -1597,7 +1597,7 @@ mutex_unlock_jni_impl (GMutex * gmutex)
tracing ("mutex_unlock_jni_impl(mutexObj=%p)", mutexObj);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
HIDE_OLD_TROUBLE (env);
@@ -1629,7 +1629,7 @@ mutex_free_jni_impl (GMutex * mutex)
union env_union e;
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (TRACE_API_CALLS)
tracing ("mutex_free_jni_impl(%p)", mutexObj);
@@ -1659,7 +1659,7 @@ cond_new_jni_impl (void)
tracing ("mutex_free_jni_impl()");
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
condObj = allocatePlainObject (env);
@@ -1683,7 +1683,7 @@ cond_signal_jni_impl (GCond * gcond)
tracing ("cond_signal_jni_impl(condObj = %p)", condObj);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
HIDE_OLD_TROUBLE (env);
@@ -1725,7 +1725,7 @@ cond_broadcast_jni_impl (GCond * gcond)
tracing ("cond_broadcast_jni_impl(condObj=%p)", condObj);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
HIDE_OLD_TROUBLE (env);
@@ -1772,7 +1772,7 @@ cond_wait_jni_impl (GCond * gcond, GMutex * gmutex)
condObj, mutexObj);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
HIDE_OLD_TROUBLE (env);
@@ -1851,7 +1851,7 @@ cond_timed_wait_jni_impl (GCond * gcond, GMutex * gmutex, GTimeVal * end_time)
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
HIDE_OLD_TROUBLE (env);
@@ -1942,7 +1942,7 @@ cond_free_jni_impl (GCond * cond)
if (TRACE_API_CALLS)
tracing ("cond_free_jni_impl(condObj = %p)", condObj);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
freeObject (env, condObj);
@@ -1974,7 +1974,7 @@ private_new_jni_impl (GDestroyNotify notify __attribute__ ((unused)))
tracing ("private_new_jni_impl()");
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
HIDE_OLD_TROUBLE (env);
@@ -2023,7 +2023,7 @@ private_get_jni_impl (GPrivate * gkey)
tracing ("private_get_jni_impl(keyObj=%p)", keyObj);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
HIDE_OLD_TROUBLE (env);
@@ -2079,7 +2079,7 @@ private_set_jni_impl (GPrivate * gkey, gpointer thread_specific_data)
keyObj, thread_specific_data);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
HIDE_OLD_TROUBLE (env);
@@ -2173,7 +2173,7 @@ thread_create_jni_impl (GThreadFunc func,
}
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
{
/* The failed call to setup the cache is certainly not recoverable;
@@ -2247,7 +2247,7 @@ thread_yield_jni_impl (void)
tracing ("thread_yield_jni_impl()");
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
HIDE_OLD_TROUBLE (env);
@@ -2275,7 +2275,7 @@ thread_join_jni_impl (gpointer threadID)
tracing ("thread_join_jni_impl(threadID=%p) ", threadID);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
HIDE_OLD_TROUBLE (env);
@@ -2323,7 +2323,7 @@ thread_exit_jni_impl (void)
tracing ("thread_exit_jni_impl() ");
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
@@ -2412,7 +2412,7 @@ thread_set_priority_jni_impl (gpointer gThreadID, GThreadPriority gpriority)
gThreadID, gpriority);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
goto done;
@@ -2469,7 +2469,7 @@ thread_self_jni_impl (/* Another confusing glib prototype. This is
tracing ("thread_self_jni_impl(my_thread_IDp=%p)", my_thread_IDp);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
return;
@@ -2514,7 +2514,7 @@ thread_equal_jni_impl (gpointer thread1, gpointer thread2)
threadID1, threadID2);
e.jni_env = &env;
- (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1);
+ (*cp_gtk_the_vm)->GetEnv (cp_gtk_the_vm, e.void_env, JNI_VERSION_1_1);
if (setup_cache (env) < 0)
{
ret = FALSE; /* what is safer? We really don't ever want
@@ -2556,7 +2556,7 @@ done:
/************************************************************************/
/* set of function pointers to give to glib. */
-GThreadFunctions portable_native_sync_jni_functions = {
+GThreadFunctions cp_gtk_portable_native_sync_jni_functions = {
mutex_new_jni_impl, /* mutex_new */
mutex_lock_jni_impl, /* mutex_lock */
mutex_trylock_jni_impl, /* mutex_trylock */
diff --git a/native/jni/gtk-peer/gthread-jni.h b/native/jni/gtk-peer/gthread-jni.h
index 90a252fa5..3d052dc10 100644
--- a/native/jni/gtk-peer/gthread-jni.h
+++ b/native/jni/gtk-peer/gthread-jni.h
@@ -15,8 +15,8 @@ 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.
+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
@@ -42,7 +42,7 @@ exception statement from your version. */
#include <glib.h>
#include "gtkpeer.h"
-extern GThreadFunctions portable_native_sync_jni_functions;
-extern JavaVM *the_vm;
+extern GThreadFunctions cp_gtk_portable_native_sync_jni_functions;
+extern JavaVM *cp_gtk_the_vm;
#endif /* __GTHREADJNI_H__ */
diff --git a/native/jni/gtk-peer/gtkcairopeer.h b/native/jni/gtk-peer/gtkcairopeer.h
index 85834cadb..dee843c8a 100644
--- a/native/jni/gtk-peer/gtkcairopeer.h
+++ b/native/jni/gtk-peer/gtkcairopeer.h
@@ -18,8 +18,8 @@ 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.
+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
@@ -86,6 +86,7 @@ struct graphics2d
jintArray jarray;
jint width, height;
jint *javabuf;
+ jint *javabuf_copy;
jboolean isCopy;
};
diff --git a/native/jni/gtk-peer/gtkpeer.h b/native/jni/gtk-peer/gtkpeer.h
index 02613c4e3..dba79673c 100644
--- a/native/jni/gtk-peer/gtkpeer.h
+++ b/native/jni/gtk-peer/gtkpeer.h
@@ -1,5 +1,5 @@
/* gtkpeer.h -- Some global variables and #defines
- Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ 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.
+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
@@ -45,12 +45,6 @@ exception statement from your version. */
#include <jni.h>
-#define RC_FILE ".classpath-gtkrc"
-#define JVM_SUN
-/*
- #define JVM_JAPHAR
-*/
-
#ifndef __GTKPEER_H__
#define __GTKPEER_H__
@@ -58,54 +52,50 @@ exception statement from your version. */
#define __attribute__(x) /* nothing */
#endif
-#ifdef JVM_SUN
-
-extern struct state_table *native_state_table;
-extern struct state_table *native_global_ref_table;
+extern struct state_table *cp_gtk_native_state_table;
+extern struct state_table *cp_gtk_native_global_ref_table;
#define NSA_INIT(env, clazz) \
- do {native_state_table = init_state_table (env, clazz); \
- native_global_ref_table = init_state_table (env, clazz);} while (0)
+ do {cp_gtk_native_state_table = cp_gtk_init_state_table (env, clazz); \
+ cp_gtk_native_global_ref_table = cp_gtk_init_state_table (env, clazz);} while (0)
#define NSA_GET_PTR(env, obj) \
- get_state (env, obj, native_state_table)
+ cp_gtk_get_state (env, obj, cp_gtk_native_state_table)
#define NSA_SET_PTR(env, obj, ptr) \
- set_state (env, obj, native_state_table, (void *)ptr)
+ cp_gtk_set_state (env, obj, cp_gtk_native_state_table, (void *)ptr)
#define NSA_DEL_PTR(env, obj) \
- remove_state_slot (env, obj, native_state_table)
+ cp_gtk_remove_state_slot (env, obj, cp_gtk_native_state_table)
#define NSA_GET_GLOBAL_REF(env, obj) \
- get_state (env, obj, native_global_ref_table)
+ cp_gtk_get_state (env, obj, cp_gtk_native_global_ref_table)
#define NSA_SET_GLOBAL_REF(env, obj) \
do {jobject *globRefPtr; \
globRefPtr = (jobject *) malloc (sizeof (jobject)); \
*globRefPtr = (*env)->NewGlobalRef (env, obj); \
- set_state (env, obj, native_global_ref_table, (void *)globRefPtr);} while (0)
+ cp_gtk_set_state (env, obj, cp_gtk_native_global_ref_table, (void *)globRefPtr);} while (0)
#define NSA_DEL_GLOBAL_REF(env, obj) \
- do {jobject *globRefPtr = get_state (env, obj, native_global_ref_table); \
- remove_state_slot (env, obj, native_global_ref_table); \
+ do {jobject *globRefPtr = cp_gtk_get_state (env, obj, cp_gtk_native_global_ref_table); \
+ cp_gtk_remove_state_slot (env, obj, cp_gtk_native_global_ref_table); \
(*env)->DeleteGlobalRef (env, *globRefPtr); \
free (globRefPtr);} while (0)
-extern struct state_table *native_pixbufdecoder_state_table;
+extern struct state_table *cp_gtk_native_graphics_state_table;
-#define NSA_PB_INIT(env, clazz) \
- native_pixbufdecoder_state_table = init_state_table (env, clazz)
+#define NSA_G_INIT(env, clazz) \
+ cp_gtk_native_graphics_state_table = cp_gtk_init_state_table (env, clazz)
-#define NSA_GET_PB_PTR(env, obj) \
- get_state (env, obj, native_pixbufdecoder_state_table)
+#define NSA_GET_G_PTR(env, obj) \
+ cp_gtk_get_state (env, obj, cp_gtk_native_graphics_state_table)
-#define NSA_SET_PB_PTR(env, obj, ptr) \
- set_state (env, obj, native_pixbufdecoder_state_table, (void *)ptr)
+#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_PB_PTR(env, obj) \
- remove_state_slot (env, obj, native_pixbufdecoder_state_table)
-
-#endif /* JVM_SUN */
+#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))
@@ -121,65 +111,15 @@ struct graphics
jint x_offset, y_offset;
};
-#define AWT_DEFAULT_CURSOR 0
-#define AWT_CROSSHAIR_CURSOR 1
-#define AWT_TEXT_CURSOR 2
-#define AWT_WAIT_CURSOR 3
-#define AWT_SW_RESIZE_CURSOR 4
-#define AWT_SE_RESIZE_CURSOR 5
-#define AWT_NW_RESIZE_CURSOR 6
-#define AWT_NE_RESIZE_CURSOR 7
-#define AWT_N_RESIZE_CURSOR 8
-#define AWT_S_RESIZE_CURSOR 9
-#define AWT_W_RESIZE_CURSOR 10
-#define AWT_E_RESIZE_CURSOR 11
-#define AWT_HAND_CURSOR 12
-#define AWT_MOVE_CURSOR 13
-
-#define SYNTHETIC_EVENT_MASK (1 << 10)
-
#define AWT_SHIFT_DOWN_MASK (1 << 6)
#define AWT_CTRL_DOWN_MASK (1 << 7)
#define AWT_META_DOWN_MASK (1 << 8)
#define AWT_ALT_DOWN_MASK (1 << 9)
-#define AWT_BUTTON1_DOWN_MASK (1 << 10)
-#define AWT_BUTTON2_DOWN_MASK (1 << 11)
-#define AWT_BUTTON3_DOWN_MASK (1 << 12)
-
#define AWT_BUTTON1_MASK (1 << 4)
#define AWT_BUTTON2_MASK (1 << 3)
#define AWT_BUTTON3_MASK (1 << 2)
-#define MULTI_CLICK_TIME 250
-/* as opposed to a MULTI_PASS_TIME :) */
-
-#define AWT_MOUSE_CLICKED 500
-#define AWT_MOUSE_PRESSED 501
-#define AWT_MOUSE_RELEASED 502
-#define AWT_MOUSE_MOVED 503
-#define AWT_MOUSE_ENTERED 504
-#define AWT_MOUSE_EXITED 505
-#define AWT_MOUSE_DRAGGED 506
-
-#define AWT_ADJUSTMENT_UNIT_INCREMENT 1
-#define AWT_ADJUSTMENT_UNIT_DECREMENT 2
-#define AWT_ADJUSTMENT_BLOCK_DECREMENT 3
-#define AWT_ADJUSTMENT_BLOCK_INCREMENT 4
-#define AWT_ADJUSTMENT_TRACK 5
-
-#define AWT_SCROLLPANE_SCROLLBARS_AS_NEEDED 0
-#define AWT_SCROLLPANE_SCROLLBARS_ALWAYS 1
-#define AWT_SCROLLPANE_SCROLLBARS_NEVER 2
-
-#define AWT_LABEL_LEFT 0
-#define AWT_LABEL_CENTER 1
-#define AWT_LABEL_RIGHT 2
-
-#define AWT_TEXTAREA_SCROLLBARS_BOTH 0
-#define AWT_TEXTAREA_SCROLLBARS_VERTICAL_ONLY 1
-#define AWT_TEXTAREA_SCROLLBARS_HORIZONTAL_ONLY 2
-
#define AWT_ITEM_SELECTED 1
#define AWT_ITEM_DESELECTED 2
@@ -187,82 +127,17 @@ struct graphics
#define AWT_KEY_PRESSED 401
#define AWT_KEY_RELEASED 402
-#define AWT_KEY_CHAR_UNDEFINED 0
-
#define AWT_KEY_LOCATION_UNKNOWN 0
#define AWT_KEY_LOCATION_STANDARD 1
#define AWT_KEY_LOCATION_LEFT 2
#define AWT_KEY_LOCATION_RIGHT 3
#define AWT_KEY_LOCATION_NUMPAD 4
-/* Virtual Keys */
-/* This list should be kept in the same order as the VK_ field
- declarations in KeyEvent.java. */
-#define VK_ENTER '\n'
-#define VK_BACK_SPACE '\b'
-#define VK_TAB '\t'
-#define VK_CANCEL 3
-#define VK_CLEAR 12
-#define VK_SHIFT 16
-#define VK_CONTROL 17
-#define VK_ALT 18
-#define VK_PAUSE 19
-#define VK_CAPS_LOCK 20
-#define VK_ESCAPE 27
-#define VK_SPACE ' '
-#define VK_PAGE_UP 33
-#define VK_PAGE_DOWN 34
-#define VK_END 35
-#define VK_HOME 36
-#define VK_LEFT 37
-#define VK_UP 38
-#define VK_RIGHT 39
-#define VK_DOWN 40
-#define VK_COMMA ','
-#define VK_MINUS '-'
-#define VK_PERIOD '.'
-#define VK_SLASH '/'
-#define VK_0 '0'
-#define VK_1 '1'
-#define VK_2 '2'
-#define VK_3 '3'
-#define VK_4 '4'
-#define VK_5 '5'
-#define VK_6 '6'
-#define VK_7 '7'
-#define VK_8 '8'
-#define VK_9 '9'
-#define VK_SEMICOLON ';'
-#define VK_EQUALS '='
-#define VK_A 'A'
-#define VK_B 'B'
-#define VK_C 'C'
-#define VK_D 'D'
-#define VK_E 'E'
-#define VK_F 'F'
-#define VK_G 'G'
-#define VK_H 'H'
-#define VK_I 'I'
-#define VK_J 'J'
-#define VK_K 'K'
-#define VK_L 'L'
-#define VK_M 'M'
-#define VK_N 'N'
-#define VK_O 'O'
-#define VK_P 'P'
-#define VK_Q 'Q'
-#define VK_R 'R'
-#define VK_S 'S'
-#define VK_T 'T'
-#define VK_U 'U'
-#define VK_V 'V'
-#define VK_W 'W'
-#define VK_X 'X'
-#define VK_Y 'Y'
-#define VK_Z 'Z'
-#define VK_OPEN_BRACKET '['
-#define VK_BACK_SLASH '\\'
-#define VK_CLOSE_BRACKET ']'
+#define AWT_STYLE_PLAIN 0
+#define AWT_STYLE_BOLD 1
+#define AWT_STYLE_ITALIC 2
+
+/* Used in GtkComponentPeer and GtkWindowPeer */
#define VK_NUMPAD0 96
#define VK_NUMPAD1 97
#define VK_NUMPAD2 98
@@ -273,229 +148,13 @@ struct graphics
#define VK_NUMPAD7 103
#define VK_NUMPAD8 104
#define VK_NUMPAD9 105
-#define VK_MULTIPLY 106
-#define VK_ADD 107
-#define VK_SEPARATER 108
-#define VK_SEPARATOR 108
-#define VK_SUBTRACT 109
#define VK_DECIMAL 110
-#define VK_DIVIDE 111
-#define VK_DELETE 127
-#define VK_NUM_LOCK 144
-#define VK_SCROLL_LOCK 145
-#define VK_F1 112
-#define VK_F2 113
-#define VK_F3 114
-#define VK_F4 115
-#define VK_F5 116
-#define VK_F6 117
-#define VK_F7 118
-#define VK_F8 119
-#define VK_F9 120
-#define VK_F10 121
-#define VK_F11 122
-#define VK_F12 123
-#define VK_F13 61440
-#define VK_F14 61441
-#define VK_F15 61442
-#define VK_F16 61443
-#define VK_F17 61444
-#define VK_F18 61445
-#define VK_F19 61446
-#define VK_F20 61447
-#define VK_F21 61448
-#define VK_F22 61449
-#define VK_F23 61450
-#define VK_F24 61451
-#define VK_PRINTSCREEN 154
-#define VK_INSERT 155
-#define VK_HELP 156
-#define VK_META 157
-#define VK_BACK_QUOTE 192
-#define VK_QUOTE 222
-#define VK_KP_UP 224
-#define VK_KP_DOWN 225
-#define VK_KP_LEFT 226
-#define VK_KP_RIGHT 227
-#define VK_DEAD_GRAVE 128
-#define VK_DEAD_ACUTE 129
-#define VK_DEAD_CIRCUMFLEX 130
-#define VK_DEAD_TILDE 131
-#define VK_DEAD_MACRON 132
-#define VK_DEAD_BREVE 133
-#define VK_DEAD_ABOVEDOT 134
-#define VK_DEAD_DIAERESIS 135
-#define VK_DEAD_ABOVERING 136
-#define VK_DEAD_DOUBLEACUTE 137
-#define VK_DEAD_CARON 138
-#define VK_DEAD_CEDILLA 139
-#define VK_DEAD_OGONEK 140
-#define VK_DEAD_IOTA 141
-#define VK_DEAD_VOICED_SOUND 142
-#define VK_DEAD_SEMIVOICED_SOUND 143
-#define VK_AMPERSAND 150
-#define VK_ASTERISK 151
-#define VK_QUOTEDBL 152
-#define VK_LESS 153
-#define VK_GREATER 160
-#define VK_BRACELEFT 161
-#define VK_BRACERIGHT 162
-#define VK_AT 512
-#define VK_COLON 513
-#define VK_CIRCUMFLEX 514
-#define VK_DOLLAR 515
-#define VK_EURO_SIGN 516
-#define VK_EXCLAMATION_MARK 517
-#define VK_INVERTED_EXCLAMATION_MARK 518
-#define VK_LEFT_PARENTHESIS 519
-#define VK_NUMBER_SIGN 520
-#define VK_PLUS 521
-#define VK_RIGHT_PARENTHESIS 522
-#define VK_UNDERSCORE 523
-#define VK_FINAL 24
-#define VK_CONVERT 28
-#define VK_NONCONVERT 29
-#define VK_ACCEPT 30
-#define VK_MODECHANGE 31
-#define VK_KANA 21
-#define VK_KANJI 25
-#define VK_ALPHANUMERIC 240
-#define VK_KATAKANA 241
-#define VK_HIRAGANA 242
-#define VK_FULL_WIDTH 243
-#define VK_HALF_WIDTH 244
-#define VK_ROMAN_CHARACTERS 245
-#define VK_ALL_CANDIDATES 256
-#define VK_PREVIOUS_CANDIDATE 257
-#define VK_CODE_INPUT 258
-#define VK_JAPANESE_KATAKANA 259
-#define VK_JAPANESE_HIRAGANA 260
-#define VK_JAPANESE_ROMAN 261
-#define VK_KANA_LOCK 262
-#define VK_INPUT_METHOD_ON_OFF 263
-#define VK_CUT 65489
-#define VK_COPY 65485
-#define VK_PASTE 65487
-#define VK_UNDO 65483
-#define VK_AGAIN 65481
-#define VK_FIND 65488
-#define VK_PROPS 65482
-#define VK_STOP 65480
-#define VK_COMPOSE 65312
-#define VK_ALT_GRAPH 65406
-#define VK_UNDEFINED 0
-
-#define AWT_FOCUS_GAINED 1004
-#define AWT_FOCUS_LOST 1005
-
-#define AWT_WINDOW_OPENED 200
-#define AWT_WINDOW_CLOSING 201
-#define AWT_WINDOW_CLOSED 202
-#define AWT_WINDOW_ICONIFIED 203
-#define AWT_WINDOW_DEICONIFIED 204
-#define AWT_WINDOW_ACTIVATED 205
-#define AWT_WINDOW_DEACTIVATED 206
-#define AWT_WINDOW_GAINED_FOCUS 207
-#define AWT_WINDOW_LOST_FOCUS 208
-#define AWT_WINDOW_STATE_CHANGED 209
-
-#define AWT_FRAME_STATE_NORMAL 0
-#define AWT_FRAME_STATE_ICONIFIED 1
-#define AWT_FRAME_STATE_MAXIMIZED_HORIZ 2
-#define AWT_FRAME_STATE_MAXIMIZED_VERT 4
-#define AWT_FRAME_STATE_MAXIMIZED_BOTH 6
-#define AWT_STYLE_PLAIN 0
-#define AWT_STYLE_BOLD 1
-#define AWT_STYLE_ITALIC 2
+JNIEnv *cp_gtk_gdk_env(void);
-/* From java.awt.SystemColor */
-#define AWT_DESKTOP 0
-#define AWT_ACTIVE_CAPTION 1
-#define AWT_ACTIVE_CAPTION_TEXT 2
-#define AWT_ACTIVE_CAPTION_BORDER 3
-#define AWT_INACTIVE_CAPTION 4
-#define AWT_INACTIVE_CAPTION_TEXT 5
-#define AWT_INACTIVE_CAPTION_BORDER 6
-#define AWT_WINDOW 7
-#define AWT_WINDOW_BORDER 8
-#define AWT_WINDOW_TEXT 9
-#define AWT_MENU 10
-#define AWT_MENU_TEXT 11
-#define AWT_TEXT 12
-#define AWT_TEXT_TEXT 13
-#define AWT_TEXT_HIGHLIGHT 14
-#define AWT_TEXT_HIGHLIGHT_TEXT 15
-#define AWT_TEXT_INACTIVE_TEXT 16
-#define AWT_CONTROL 17
-#define AWT_CONTROL_TEXT 18
-#define AWT_CONTROL_HIGHLIGHT 19
-#define AWT_CONTROL_LT_HIGHLIGHT 20
-#define AWT_CONTROL_SHADOW 21
-#define AWT_CONTROL_DK_SHADOW 22
-#define AWT_SCROLLBAR 23
-#define AWT_INFO 24
-#define AWT_INFO_TEXT 25
-#define AWT_NUM_COLORS 26
-
-extern jmethodID setBoundsCallbackID;
-
-extern jmethodID postActionEventID;
-extern jmethodID postMenuActionEventID;
-extern jmethodID postMouseEventID;
-extern jmethodID postConfigureEventID;
-extern jmethodID postExposeEventID;
-extern jmethodID postKeyEventID;
-extern jmethodID postFocusEventID;
-extern jmethodID postAdjustmentEventID;
-extern jmethodID choicePostItemEventID;
-extern jmethodID postItemEventID;
-extern jmethodID postListItemEventID;
-extern jmethodID postTextEventID;
-extern jmethodID postWindowEventID;
-
-extern jmethodID beginNativeRepaintID;
-extern jmethodID endNativeRepaintID;
-
-extern jmethodID initComponentGraphicsID;
-extern jmethodID initComponentGraphics2DID;
-extern jmethodID setCursorID;
-
-extern jmethodID syncAttrsID;
-extern jclass gdkColor;
-extern jmethodID gdkColorID;
-
-extern jmethodID postInsetsChangedEventID;
-extern jmethodID windowGetWidthID;
-extern jmethodID windowGetHeightID;
-
-JNIEnv *gdk_env(void);
-
-extern double dpi_conversion_factor;
-
-extern GtkWindowGroup *global_gtk_window_group;
-
-void awt_event_handler (GdkEvent *event);
-
-gboolean pre_event_handler (GtkWidget *widget,
- GdkEvent *event,
- jobject peer);
-
-void connect_awt_hook (JNIEnv *env, jobject peer_obj, int nwindows, ...);
-void connect_awt_hook_cb (GtkWidget *widget, jobject peer);
-
-void set_visible (GtkWidget *widget, jboolean visible);
-void set_parent (GtkWidget *widget, GtkContainer *parent);
-
-jint keyevent_state_to_awt_mods (GdkEvent *event);
-
-guint awt_keycode_to_keysym (jint keyCode, jint keyLocation);
-
-struct item_event_hook_info
-{
- jobject peer_obj;
- const char *label;
-};
+/* Global variables */
+extern double cp_gtk_dpi_conversion_factor;
+extern GtkWindowGroup *cp_gtk_global_window_group;
/* Union used for type punning. */
union widget_union
@@ -504,18 +163,57 @@ union widget_union
GtkWidget **widget;
};
+/* Keycode helpers */
+guint cp_gtk_awt_keycode_to_keysym (jint keyCode, jint keyLocation);
+
+/* Image helpers */
+GdkPixbuf *cp_gtk_image_get_pixbuf (JNIEnv *env, jobject obj);
+GdkPixmap *cp_gtk_image_get_pixmap (JNIEnv *env, jobject obj);
+jboolean cp_gtk_image_is_offscreen (JNIEnv *env, jobject obj);
+
+/* JNI initialization functions */
+#if GTK_CAIRO
+void cp_gtk_graphics2d_init_jni (void);
+#endif
+void cp_gtk_graphics_init_jni (void);
+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_list_init_jni (void);
+void cp_gtk_menuitem_init_jni (void);
+void cp_gtk_scrollbar_init_jni (void);
+void cp_gtk_textcomponent_init_jni (void);
+void cp_gtk_window_init_jni (void);
+
+/* Signal connection convience functions */
+void cp_gtk_component_connect_expose_signals (GObject *ptr, jobject *gref);
+void cp_gtk_component_connect_focus_signals (GObject *ptr, jobject *gref);
+void cp_gtk_component_connect_mouse_signals (GObject *ptr, jobject *gref);
+void cp_gtk_component_connect_signals (GObject *ptr, jobject *gref);
+void cp_gtk_textcomponent_connect_signals (GObject *ptr, jobject *gref);
+
+/* Debugging */
+void cp_gtk_print_current_thread (void);
+
#define DEBUG_LOCKING 0
#if DEBUG_LOCKING
-#define gdk_threads_enter() \
-{ \
- g_print ("lock: %s, %d\n", __FILE__, __LINE__); \
- gdk_threads_enter (); \
+#define gdk_threads_enter() \
+{ \
+ g_print ("locking: %s, %d\n", __FILE__, __LINE__); \
+ cp_gtk_print_current_thread (); \
+ gdk_threads_enter (); \
+ g_print ("locked: %s, %d\n", __FILE__, __LINE__); \
+ cp_gtk_print_current_thread (); \
}
-#define gdk_threads_leave() \
-{ \
- g_print ("unlock: %s, %d\n", __FILE__, __LINE__); \
- gdk_threads_leave (); \
+#define gdk_threads_leave() \
+{ \
+ g_print ("unlocking: %s, %d\n", __FILE__, __LINE__); \
+ cp_gtk_print_current_thread (); \
+ gdk_threads_leave (); \
+ g_print ("unlocked: %s, %d\n", __FILE__, __LINE__); \
+ cp_gtk_print_current_thread (); \
}
#endif
diff --git a/native/jni/java-io/java_io_VMFile.c b/native/jni/java-io/java_io_VMFile.c
index d02fbbf01..b32c29477 100644
--- a/native/jni/java-io/java_io_VMFile.c
+++ b/native/jni/java-io/java_io_VMFile.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-io/java_io_VMObjectInputStream.c b/native/jni/java-io/java_io_VMObjectInputStream.c
index 71fa71499..d8d807149 100644
--- a/native/jni/java-io/java_io_VMObjectInputStream.c
+++ b/native/jni/java-io/java_io_VMObjectInputStream.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-io/java_io_VMObjectStreamClass.c b/native/jni/java-io/java_io_VMObjectStreamClass.c
index fee104b50..8c2556bcf 100644
--- a/native/jni/java-io/java_io_VMObjectStreamClass.c
+++ b/native/jni/java-io/java_io_VMObjectStreamClass.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-io/javaio.c b/native/jni/java-io/javaio.c
index b753d07d2..6dc3de8f0 100644
--- a/native/jni/java-io/javaio.c
+++ b/native/jni/java-io/javaio.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-io/javaio.h b/native/jni/java-io/javaio.h
index 0228993ef..2e4a8d103 100644
--- a/native/jni/java-io/javaio.h
+++ b/native/jni/java-io/javaio.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-lang/java_lang_Math.c b/native/jni/java-lang/java_lang_Math.c
index 179d8fda7..b4b88a775 100644
--- a/native/jni/java-lang/java_lang_Math.c
+++ b/native/jni/java-lang/java_lang_Math.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-lang/java_lang_VMDouble.c b/native/jni/java-lang/java_lang_VMDouble.c
index 33246489c..6b4aed42d 100644
--- a/native/jni/java-lang/java_lang_VMDouble.c
+++ b/native/jni/java-lang/java_lang_VMDouble.c
@@ -16,8 +16,8 @@ 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.
+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
diff --git a/native/jni/java-lang/java_lang_VMFloat.c b/native/jni/java-lang/java_lang_VMFloat.c
index 0d9c19152..7bff629fc 100644
--- a/native/jni/java-lang/java_lang_VMFloat.c
+++ b/native/jni/java-lang/java_lang_VMFloat.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-lang/java_lang_VMProcess.c b/native/jni/java-lang/java_lang_VMProcess.c
index 7cd41b440..1c5a11ff9 100644
--- a/native/jni/java-lang/java_lang_VMProcess.c
+++ b/native/jni/java-lang/java_lang_VMProcess.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-lang/java_lang_VMSystem.c b/native/jni/java-lang/java_lang_VMSystem.c
index fd27a06f8..620ae60cb 100644
--- a/native/jni/java-lang/java_lang_VMSystem.c
+++ b/native/jni/java-lang/java_lang_VMSystem.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-lang/java_lang_reflect_Array.c b/native/jni/java-lang/java_lang_reflect_Array.c
index d1dfa5e67..0bd23c16f 100644
--- a/native/jni/java-lang/java_lang_reflect_Array.c
+++ b/native/jni/java-lang/java_lang_reflect_Array.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c b/native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c
index a02cdeb1c..5bc284f64 100644
--- a/native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c
+++ b/native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -207,7 +207,9 @@ Java_gnu_java_net_PlainDatagramSocketImpl_receive0 (JNIEnv * env, jobject obj,
}
arr = (*env)->CallObjectMethod (env, packet, mid);
- if ((arr == NULL) || (*env)->ExceptionOccurred (env))
+ if ((*env)->ExceptionOccurred (env))
+ return;
+ if (arr == NULL)
{
JCL_ThrowException (env, IO_EXCEPTION, "Internal error: call getData");
return;
@@ -223,11 +225,7 @@ Java_gnu_java_net_PlainDatagramSocketImpl_receive0 (JNIEnv * env, jobject obj,
offset = (*env)->CallIntMethod (env, packet, mid);
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION,
- "Internal error: call getOffset");
- return;
- }
+ return;
DBG ("PlainDatagramSocketImpl.receive(): Got the offset\n");
@@ -241,16 +239,15 @@ Java_gnu_java_net_PlainDatagramSocketImpl_receive0 (JNIEnv * env, jobject obj,
maxlen = (*env)->GetIntField (env, packet, fid);
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION, "Internal error: call length");
- return;
- }
+ return;
/* Receive the packet */
/* should we try some sort of validation on the length? */
bytes_read =
_javanet_recvfrom (env, obj, arr, offset, maxlen, &addr, &port);
- if ((bytes_read == -1) || (*env)->ExceptionOccurred (env))
+ if ((*env)->ExceptionOccurred (env))
+ return;
+ if (bytes_read == -1)
{
JCL_ThrowException (env, IO_EXCEPTION, "Internal error: receive");
return;
@@ -292,11 +289,7 @@ Java_gnu_java_net_PlainDatagramSocketImpl_receive0 (JNIEnv * env, jobject obj,
addr_obj = (*env)->CallStaticObjectMethod (env, addr_cls, mid, ip_str_obj);
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION,
- "Internal error: call getByName");
- return;
- }
+ return;
mid = (*env)->GetMethodID (env, cls, "setAddress",
"(Ljava/net/InetAddress;)V");
@@ -308,11 +301,7 @@ Java_gnu_java_net_PlainDatagramSocketImpl_receive0 (JNIEnv * env, jobject obj,
(*env)->CallVoidMethod (env, packet, mid, addr_obj);
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION,
- "Internal error: call setAddress");
- return;
- }
+ return;
DBG ("PlainDatagramSocketImpl.receive(): Stored the address\n");
@@ -326,10 +315,7 @@ Java_gnu_java_net_PlainDatagramSocketImpl_receive0 (JNIEnv * env, jobject obj,
(*env)->CallVoidMethod (env, packet, mid, port);
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION, "Internal error: call setPort");
- return;
- }
+ return;
DBG ("PlainDatagramSocketImpl.receive(): Stored the port\n");
@@ -343,10 +329,7 @@ Java_gnu_java_net_PlainDatagramSocketImpl_receive0 (JNIEnv * env, jobject obj,
(*env)->SetIntField (env, packet, fid, bytes_read);
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION, "Internal error: call length");
- return;
- }
+ return;
DBG ("PlainDatagramSocketImpl.receive(): Stored the length\n");
#else /* not WITHOUT_NETWORK */
@@ -372,20 +355,13 @@ Java_gnu_java_net_PlainDatagramSocketImpl_sendto (JNIEnv * env, jobject obj,
netAddress = _javanet_get_netaddr (env, addr);
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION,
- "Internal error: get network address");
- return;
- }
+ return;
DBG ("PlainDatagramSocketImpl.sendto(): have addr\n");
_javanet_sendto (env, obj, buf, offset, len, netAddress, port);
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION, "Internal error: send data");
- return;
- }
+ return;
DBG ("PlainDatagramSocketImpl.sendto(): finished\n");
#else /* not WITHOUT_NETWORK */
@@ -411,17 +387,11 @@ Java_gnu_java_net_PlainDatagramSocketImpl_join (JNIEnv * env, jobject obj,
netAddress = _javanet_get_netaddr (env, addr);
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION, "Internal error");
- return;
- }
+ return;
fd = _javanet_get_int_field (env, obj, "native_fd");
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION, "Internal error");
- return;
- }
+ return;
DBG ("PlainDatagramSocketImpl.join(): have native fd\n");
@@ -459,17 +429,11 @@ Java_gnu_java_net_PlainDatagramSocketImpl_leave (JNIEnv * env, jobject obj,
netAddress = _javanet_get_netaddr (env, addr);
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION, "Internal error");
- return;
- }
+ return;
fd = _javanet_get_int_field (env, obj, "native_fd");
if ((*env)->ExceptionOccurred (env))
- {
- JCL_ThrowException (env, IO_EXCEPTION, "Internal error");
- return;
- }
+ return;
DBG ("PlainDatagramSocketImpl.leave(): have native fd\n");
diff --git a/native/jni/java-net/gnu_java_net_PlainSocketImpl.c b/native/jni/java-net/gnu_java_net_PlainSocketImpl.c
index 086aeded3..a5261514d 100644
--- a/native/jni/java-net/gnu_java_net_PlainSocketImpl.c
+++ b/native/jni/java-net/gnu_java_net_PlainSocketImpl.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-net/java_net_VMInetAddress.c b/native/jni/java-net/java_net_VMInetAddress.c
index 6247a70ba..d33265cff 100644
--- a/native/jni/java-net/java_net_VMInetAddress.c
+++ b/native/jni/java-net/java_net_VMInetAddress.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-net/java_net_VMNetworkInterface.c b/native/jni/java-net/java_net_VMNetworkInterface.c
index 47ea150b2..71f5e8927 100644
--- a/native/jni/java-net/java_net_VMNetworkInterface.c
+++ b/native/jni/java-net/java_net_VMNetworkInterface.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-net/javanet.c b/native/jni/java-net/javanet.c
index f778af66f..fdc1c22ec 100644
--- a/native/jni/java-net/javanet.c
+++ b/native/jni/java-net/javanet.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -377,6 +377,13 @@ _javanet_get_netaddr (JNIEnv * env, jobject addr)
DBG ("_javanet_get_netaddr(): Entered _javanet_get_netaddr\n");
+ if (addr == NULL)
+ {
+ JCL_ThrowException (env, "java/lang/NullPointerException",
+ "Null address");
+ return 0;
+ }
+
/* Call the getAddress method on the object to retrieve the IP address */
cls = (*env)->GetObjectClass (env, addr);
if (cls == NULL)
@@ -473,6 +480,22 @@ _javanet_create (JNIEnv * env, jobject this, jboolean stream)
else
_javanet_set_int_field (env, this, "gnu/java/net/PlainDatagramSocketImpl",
"native_fd", fd);
+
+ if ((*env)->ExceptionOccurred (env))
+ {
+ /* Try to make sure we close the socket since close() won't work. */
+ do
+ {
+ TARGET_NATIVE_NETWORK_SOCKET_CLOSE (fd, result);
+ if (result != TARGET_NATIVE_OK
+ && (TARGET_NATIVE_LAST_ERROR ()
+ != TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL))
+ return;
+ }
+ while (result != TARGET_NATIVE_OK);
+ return;
+ }
+
#else /* not WITHOUT_NETWORK */
#endif /* not WITHOUT_NETWORK */
}
@@ -489,6 +512,7 @@ _javanet_close (JNIEnv * env, jobject this, int stream)
#ifndef WITHOUT_NETWORK
int fd;
int result;
+ int error = 0;
assert (env != NULL);
assert ((*env) != NULL);
@@ -497,14 +521,27 @@ _javanet_close (JNIEnv * env, jobject this, int stream)
if (fd == -1)
return;
- TARGET_NATIVE_NETWORK_SOCKET_CLOSE (fd, result);
-
if (stream)
_javanet_set_int_field (env, this, "gnu/java/net/PlainSocketImpl",
"native_fd", -1);
else
_javanet_set_int_field (env, this, "gnu/java/net/PlainDatagramSocketImpl",
"native_fd", -1);
+ do
+ {
+ TARGET_NATIVE_NETWORK_SOCKET_CLOSE (fd, result);
+ if (result != TARGET_NATIVE_OK)
+ {
+ /* Only throw an error when a "real" error occurs. */
+ error = TARGET_NATIVE_LAST_ERROR ();
+ if (error != TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL
+ && error != ENOTCONN && error != ECONNRESET && error != EBADF)
+ JCL_ThrowException (env, IO_EXCEPTION,
+ TARGET_NATIVE_LAST_ERROR_STRING ());
+ }
+ }
+ while (error == TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL);
+
#else /* not WITHOUT_NETWORK */
#endif /* not WITHOUT_NETWORK */
}
@@ -548,13 +585,20 @@ _javanet_connect (JNIEnv * env, jobject this, jobject addr, jint port)
DBG ("_javanet_connect(): Got native fd\n");
/* Connect up */
- TARGET_NATIVE_NETWORK_SOCKET_CONNECT (fd, netaddr, port, result);
- if (result != TARGET_NATIVE_OK)
+ do
{
- JCL_ThrowException (env, IO_EXCEPTION,
- TARGET_NATIVE_LAST_ERROR_STRING ());
- return;
+ TARGET_NATIVE_NETWORK_SOCKET_CONNECT (fd, netaddr, port, 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);
+
DBG ("_javanet_connect(): Connected successfully\n");
/* Populate instance variables */
@@ -562,15 +606,17 @@ _javanet_connect (JNIEnv * env, jobject this, jobject addr, jint port)
result);
if (result != TARGET_NATIVE_OK)
{
- TARGET_NATIVE_NETWORK_SOCKET_CLOSE (fd, result);
JCL_ThrowException (env, IO_EXCEPTION,
TARGET_NATIVE_LAST_ERROR_STRING ());
+ /* We don't care whether this succeeds. close() will cleanup later. */
+ TARGET_NATIVE_NETWORK_SOCKET_CLOSE (fd, result);
return;
}
_javanet_create_localfd (env, this);
if ((*env)->ExceptionOccurred (env))
{
+ /* We don't care whether this succeeds. close() will cleanup later. */
TARGET_NATIVE_NETWORK_SOCKET_CLOSE (fd, result);
return;
}
@@ -580,6 +626,7 @@ _javanet_connect (JNIEnv * env, jobject this, jobject addr, jint port)
local_port);
if ((*env)->ExceptionOccurred (env))
{
+ /* We don't care whether this succeeds. close() will cleanup later. */
TARGET_NATIVE_NETWORK_SOCKET_CLOSE (fd, result);
return;
}
@@ -589,9 +636,10 @@ _javanet_connect (JNIEnv * env, jobject this, jobject addr, jint port)
remote_port, result);
if (result != TARGET_NATIVE_OK)
{
- TARGET_NATIVE_NETWORK_SOCKET_CLOSE (fd, result);
JCL_ThrowException (env, IO_EXCEPTION,
TARGET_NATIVE_LAST_ERROR_STRING ());
+ /* We don't care whether this succeeds. close() will cleanup later. */
+ TARGET_NATIVE_NETWORK_SOCKET_CLOSE (fd, result);
return;
}
@@ -605,6 +653,7 @@ _javanet_connect (JNIEnv * env, jobject this, jobject addr, jint port)
}
if ((*env)->ExceptionOccurred (env))
{
+ /* We don't care whether this succeeds. close() will cleanup later. */
TARGET_NATIVE_NETWORK_SOCKET_CLOSE (fd, result);
return;
}
@@ -614,6 +663,7 @@ _javanet_connect (JNIEnv * env, jobject this, jobject addr, jint port)
remote_port);
if ((*env)->ExceptionOccurred (env))
{
+ /* We don't care whether this succeeds. close() will cleanup later. */
TARGET_NATIVE_NETWORK_SOCKET_CLOSE (fd, result);
return;
}
@@ -698,16 +748,19 @@ _javanet_bind (JNIEnv * env, jobject this, jobject addr, jint port,
octets[3], tmpaddr);
TARGET_NATIVE_NETWORK_SOCKET_BIND (fd, tmpaddr, port, result);
- (*env)->ReleaseByteArrayElements (env, arr, octets, 0);
-
if (result != TARGET_NATIVE_OK)
{
+ char *errorstr = TARGET_NATIVE_LAST_ERROR_STRING ();
+ (*env)->ReleaseByteArrayElements (env, arr, octets, 0);
+
JCL_ThrowException (env, BIND_EXCEPTION,
- TARGET_NATIVE_LAST_ERROR_STRING ());
+ errorstr);
return;
}
DBG ("_javanet_bind(): Past bind\n");
+ (*env)->ReleaseByteArrayElements (env, arr, octets, 0);
+
/* Update instance variables, specifically the local port number */
TARGET_NATIVE_NETWORK_SOCKET_GET_LOCAL_INFO (fd, local_address, local_port,
result);
@@ -816,7 +869,16 @@ _javanet_accept (JNIEnv * env, jobject this, jobject impl)
if ((*env)->ExceptionOccurred (env))
{
- TARGET_NATIVE_NETWORK_SOCKET_CLOSE (newfd, result);
+ /* Try to make sure we close the socket since close() won't work. */
+ do
+ {
+ TARGET_NATIVE_NETWORK_SOCKET_CLOSE (newfd, result);
+ if (result != TARGET_NATIVE_OK
+ && (TARGET_NATIVE_LAST_ERROR ()
+ != TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL))
+ return;
+ }
+ while (result != TARGET_NATIVE_OK);
return;
}
@@ -824,6 +886,7 @@ _javanet_accept (JNIEnv * env, jobject this, jobject impl)
local_port, result);
if (result != TARGET_NATIVE_OK)
{
+ /* We don't care whether this succeeds. close() will cleanup later. */
TARGET_NATIVE_NETWORK_SOCKET_CLOSE (newfd, result);
JCL_ThrowException (env, IO_EXCEPTION,
TARGET_NATIVE_LAST_ERROR_STRING ());
@@ -833,6 +896,7 @@ _javanet_accept (JNIEnv * env, jobject this, jobject impl)
_javanet_create_localfd (env, impl);
if ((*env)->ExceptionOccurred (env))
{
+ /* We don't care whether this succeeds. close() will cleanup later. */
TARGET_NATIVE_NETWORK_SOCKET_CLOSE (newfd, result);
return;
}
@@ -841,6 +905,7 @@ _javanet_accept (JNIEnv * env, jobject this, jobject impl)
local_port);
if ((*env)->ExceptionOccurred (env))
{
+ /* We don't care whether this succeeds. close() will cleanup later. */
TARGET_NATIVE_NETWORK_SOCKET_CLOSE (newfd, result);
return;
}
@@ -849,15 +914,17 @@ _javanet_accept (JNIEnv * env, jobject this, jobject impl)
remote_port, result);
if (result != TARGET_NATIVE_OK)
{
- TARGET_NATIVE_NETWORK_SOCKET_CLOSE (newfd, result);
JCL_ThrowException (env, IO_EXCEPTION,
TARGET_NATIVE_LAST_ERROR_STRING ());
+ /* We don't care whether this succeeds. close() will cleanup later. */
+ TARGET_NATIVE_NETWORK_SOCKET_CLOSE (newfd, result);
return;
}
_javanet_set_remhost (env, impl, remote_address);
if ((*env)->ExceptionOccurred (env))
{
+ /* We don't care whether this succeeds. close() will cleanup later. */
TARGET_NATIVE_NETWORK_SOCKET_CLOSE (newfd, result);
return;
}
@@ -866,6 +933,7 @@ _javanet_accept (JNIEnv * env, jobject this, jobject impl)
remote_port);
if ((*env)->ExceptionOccurred (env))
{
+ /* We don't care whether this succeeds. close() will cleanup later. */
TARGET_NATIVE_NETWORK_SOCKET_CLOSE (newfd, result);
return;
}
@@ -945,15 +1013,21 @@ _javanet_recvfrom (JNIEnv * env, jobject this, jarray buf, int offset,
(TARGET_NATIVE_LAST_ERROR () ==
TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL));
- (*env)->ReleaseByteArrayElements (env, buf, p, 0);
-
if (received_bytes == -1)
{
- JCL_ThrowException (env, IO_EXCEPTION,
- TARGET_NATIVE_LAST_ERROR_STRING ());
+ if (TARGET_NATIVE_LAST_ERROR () == EAGAIN)
+ JCL_ThrowException (env, "java/net/SocketTimeoutException", "Timeout");
+ else
+ JCL_ThrowException (env, IO_EXCEPTION,
+ TARGET_NATIVE_LAST_ERROR_STRING ());
+
+ /* Cleanup and return. */
+ (*env)->ReleaseByteArrayElements (env, buf, p, 0);
return 0;
}
+ (*env)->ReleaseByteArrayElements (env, buf, p, 0);
+
/* Handle return addr case */
if (addr != NULL)
{
@@ -1004,29 +1078,42 @@ _javanet_sendto (JNIEnv * env, jobject this, jarray buf, int offset, int len,
if (p == NULL)
return;
- /* Send the data */
- if (addr == 0)
+ /* We must send all the data, so repeat till done. */
+ while (len > 0)
{
- DBG ("_javanet_sendto(): Sending....\n");
- TARGET_NATIVE_NETWORK_SOCKET_SEND (fd, p + offset, len, bytes_sent);
- }
- else
- {
- DBG ("_javanet_sendto(): Sending....\n");
- TARGET_NATIVE_NETWORK_SOCKET_SEND_WITH_ADDRESS_PORT (fd, p + offset,
- len, addr, port,
- bytes_sent);
+ /* Send the data */
+ if (addr == 0)
+ {
+ DBG ("_javanet_sendto(): Sending....\n");
+ TARGET_NATIVE_NETWORK_SOCKET_SEND (fd, p + offset, len, bytes_sent);
+ }
+ else
+ {
+ DBG ("_javanet_sendto(): Sending....\n");
+ TARGET_NATIVE_NETWORK_SOCKET_SEND_WITH_ADDRESS_PORT (fd, p + offset,
+ len, addr, port,
+ bytes_sent);
+ }
+
+ if (bytes_sent < 0)
+ {
+ if (TARGET_NATIVE_LAST_ERROR ()
+ != TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION,
+ TARGET_NATIVE_LAST_ERROR_STRING ());
+ break;
+ }
+ }
+ else
+ {
+ len -= bytes_sent;
+ addr += bytes_sent;
+ }
}
(*env)->ReleaseByteArrayElements (env, buf, p, 0);
- /***** Do we need to check EINTR? */
- if (bytes_sent < 0)
- {
- JCL_ThrowException (env, IO_EXCEPTION,
- TARGET_NATIVE_LAST_ERROR_STRING ());
- return;
- }
#else /* not WITHOUT_NETWORK */
#endif /* not WITHOUT_NETWORK */
}
@@ -1139,9 +1226,9 @@ _javanet_set_option (JNIEnv * env, jobject this, jint option_id, jobject val)
return;
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT (fd, optval, result);
-#endif
- /* ignore errors and do not throw an exception. */
+#else
result = TARGET_NATIVE_OK;
+#endif
break;
case SOCKOPT_SO_SNDBUF:
@@ -1326,7 +1413,6 @@ _javanet_get_option (JNIEnv * env, jobject this, jint option_id)
TARGET_NATIVE_LAST_ERROR_STRING ());
return (0);
}
-
return (_javanet_create_integer (env, optval));
#else
JCL_ThrowException (env, SOCKET_EXCEPTION,
diff --git a/native/jni/java-net/javanet.h b/native/jni/java-net/javanet.h
index dc28bbf60..7c77ea77f 100644
--- a/native/jni/java-net/javanet.h
+++ b/native/jni/java-net/javanet.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-nio/gnu_java_nio_VMPipe.c b/native/jni/java-nio/gnu_java_nio_VMPipe.c
index ded68907a..369c5a3d6 100644
--- a/native/jni/java-nio/gnu_java_nio_VMPipe.c
+++ b/native/jni/java-nio/gnu_java_nio_VMPipe.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-nio/gnu_java_nio_VMSelector.c b/native/jni/java-nio/gnu_java_nio_VMSelector.c
index 912523bf1..f8a40aa7a 100644
--- a/native/jni/java-nio/gnu_java_nio_VMSelector.c
+++ b/native/jni/java-nio/gnu_java_nio_VMSelector.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c b/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
index c43e8df17..9232ea49c 100644
--- a/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
+++ b/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
@@ -1,5 +1,5 @@
/* gnu_java_nio_channels_FileChannelImpl.c -
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ 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.
+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
@@ -52,6 +52,14 @@ exception statement from your version. */
#include "gnu_java_nio_channels_FileChannelImpl.h"
+#ifdef HAVE_FCNTL_H
+#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
@@ -87,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;
@@ -101,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");
@@ -124,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
}
/*
@@ -214,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;
}
@@ -241,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);
}
/*
@@ -263,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);
@@ -499,13 +507,125 @@ 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;
+ jclass RawData_class;
+ jmethodID MappedByteBufferImpl_init = NULL;
+ jmethodID RawData_init = NULL;
+ jobject RawData_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,
+ "can't determine memory page size");
+ return NULL;
+#endif /* HAVE_GETPAGESIZE/HAVE_SYSCONF */
+
+#if (SIZEOF_VOID_P == 4)
+ RawData_class = (*env)->FindClass (env, "gnu/classpath/RawData32");
+ if (RawData_class != NULL)
+ {
+ RawData_init = (*env)->GetMethodID (env, RawData_class,
+ "<init>", "(I)V");
+ }
+#elif (SIZEOF_VOID_P == 8)
+ RawData_class = (*env)->FindClass (env, "gnu/classpath/RawData64");
+ if (RawData_class != NULL)
+ {
+ RawData_init = (*env)->GetMethodID (env, RawData_class,
+ "<init>", "(J)V");
+ }
+#else
JCL_ThrowException (env, IO_EXCEPTION,
- "java.nio.FileChannelImpl.nio_mmap_file(): not implemented");
+ "pointer size not supported");
+ return NULL;
+#endif /* SIZEOF_VOID_P */
+
+ if ((*env)->ExceptionOccurred (env))
+ {
+ return NULL;
+ }
+ if (RawData_init == NULL)
+ {
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "could not get RawData constructor");
+ 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));
+
+#if (SIZEOF_VOID_P == 4)
+ RawData_instance = (*env)->NewObject (env, RawData_class,
+ RawData_init, (jint) address);
+#elif (SIZEOF_VOID_P == 8)
+ RawData_instance = (*env)->NewObject (env, RawData_class,
+ RawData_init, (jlong) address);
+#endif /* SIZEOF_VOID_P */
+
+ MappedByteBufferImpl_class = (*env)->FindClass (env,
+ "java/nio/MappedByteBufferImpl");
+ if (MappedByteBufferImpl_class != NULL)
+ {
+ MappedByteBufferImpl_init =
+ (*env)->GetMethodID (env, MappedByteBufferImpl_class,
+ "<init>", "(Lgnu/classpath/RawData;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, RawData_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 */
}
/*
@@ -539,7 +659,7 @@ Java_gnu_java_nio_channels_FileChannelImpl_read__ (JNIEnv * env, jobject obj)
return (-1);
}
}
- while (bytes_read != 1);
+ while (result != TARGET_NATIVE_OK);
return ((jint) (data & 0xFF));
}
@@ -567,6 +687,12 @@ Java_gnu_java_nio_channels_FileChannelImpl_read___3BII (JNIEnv * env,
if (length == 0)
return 0;
+ if (offset < 0)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, "negative offset");
+ return -1;
+ }
+
bufptr = (*env)->GetByteArrayElements (env, buffer, 0);
if (!bufptr)
{
@@ -574,6 +700,13 @@ Java_gnu_java_nio_channels_FileChannelImpl_read___3BII (JNIEnv * env,
return (-1);
}
+ if (length + offset > (*env)->GetArrayLength (env, buffer))
+ {
+ JCL_ThrowException (env, IO_EXCEPTION,
+ "length + offset > buffer.length");
+ return -1;
+ }
+
bytes_read = 0;
do
{
@@ -596,7 +729,8 @@ Java_gnu_java_nio_channels_FileChannelImpl_read___3BII (JNIEnv * env,
(*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0);
return -1;
}
- bytes_read += n;
+ if (result == TARGET_NATIVE_OK)
+ bytes_read += n;
}
while (bytes_read < 1);
@@ -630,12 +764,29 @@ Java_gnu_java_nio_channels_FileChannelImpl_write__I (JNIEnv * env,
{
JCL_ThrowException (env, IO_EXCEPTION,
TARGET_NATIVE_LAST_ERROR_STRING ());
+ return;
}
}
while (result != TARGET_NATIVE_OK);
}
/*
+ * Copies all parts of a file to disk.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_channels_FileChannelImpl_force (JNIEnv * env,
+ jobject obj)
+{
+ int native_fd;
+ int result;
+ native_fd = get_native_fd (env, obj);
+ TARGET_NATIVE_FILE_FSYNC (native_fd, result);
+ if (result != TARGET_NATIVE_OK)
+ JCL_ThrowException (env, IO_EXCEPTION,
+ TARGET_NATIVE_LAST_ERROR_STRING ());
+}
+
+/*
* Writes a byte buffer to the specified file descriptor
* Return status code, exception on error
*/
@@ -679,35 +830,80 @@ Java_gnu_java_nio_channels_FileChannelImpl_write___3BII (JNIEnv * env,
(*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0);
return;
}
- bytes_written += n;
+ if (result == TARGET_NATIVE_OK)
+ bytes_written += n;
}
(*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0);
}
JNIEXPORT jboolean JNICALL
-Java_gnu_java_nio_channels_FileChannelImpl_lock (JNIEnv * env,
- jobject obj
- __attribute__ ((__unused__)),
- jlong position
- __attribute__ ((__unused__)),
- jlong size
- __attribute__ ((__unused__)),
- jboolean shared
- __attribute__ ((__unused__)),
- jboolean wait
- __attribute__ ((__unused__)))
+Java_gnu_java_nio_channels_FileChannelImpl_lock (JNIEnv *env, jobject obj,
+ jlong position, jlong size,
+ jboolean shared, jboolean wait)
{
- JCL_ThrowException (env, IO_EXCEPTION,
- "java.nio.FileChannelImpl.lock(): not implemented");
- return 0;
+#ifdef HAVE_FCNTL
+ int fd = get_native_fd (env, obj);
+ int cmd = wait ? F_SETLKW : F_SETLK;
+ struct flock flock;
+ int ret;
+
+ 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;
+
+ ret = fcntl (fd, cmd, &flock);
+ 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. */
+ if (errno != EACCES && errno != EAGAIN)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ }
+ return JNI_FALSE;
+ }
+ return JNI_TRUE;
+#else
+ (void) obj;
+ (void) position;
+ (void) size;
+ (void) shared;
+ (void) wait;
+ JCL_ThrowException (env, "java/lang/UnsupportedOperationException",
+ "file locks not implemented on this platform");
+ return JNI_FALSE;
+#endif /* HAVE_FCNTL */
}
JNIEXPORT void JNICALL
-Java_gnu_java_nio_channels_FileChannelImpl_unlock (JNIEnv * env,
- jobject obj
- __attribute__ ((__unused__)), jlong position __attribute__ ((__unused__)), jlong length __attribute__ ((__unused__)))
+Java_gnu_java_nio_channels_FileChannelImpl_unlock (JNIEnv *env,
+ jobject obj,
+ jlong position,
+ jlong length)
{
- JCL_ThrowException (env, IO_EXCEPTION,
- "java.nio.FileChannelImpl.unlock(): not implemented");
+#ifdef HAVE_FCNTL
+ int fd = get_native_fd (env, obj);
+ struct flock flock;
+ int ret;
+
+ flock.l_type = F_UNLCK;
+ flock.l_whence = SEEK_SET;
+ flock.l_start = (off_t) position;
+ flock.l_len = (off_t) length;
+
+ ret = fcntl (fd, F_SETLK, &flock);
+ if (ret)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ }
+#else
+ (void) obj;
+ (void) position;
+ (void) length;
+ JCL_ThrowException (env, "java/lang/UnsupportedOperationException",
+ "file locks not implemented on this platform");
+#endif /* HAVE_FCNTL */
}
diff --git a/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c b/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c
index 54138f92f..8c3f83acc 100644
--- a/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c
+++ b/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c b/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c
index f3980af72..cd5d48656 100644
--- a/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c
+++ b/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-nio/java_nio.c b/native/jni/java-nio/java_nio.c
index 33b7de43d..a25f38a6d 100644
--- a/native/jni/java-nio/java_nio.c
+++ b/native/jni/java-nio/java_nio.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/java-nio/java_nio_MappedByteBufferImpl.c b/native/jni/java-nio/java_nio_MappedByteBufferImpl.c
index a12592e42..9e23bb2ee 100644
--- a/native/jni/java-nio/java_nio_MappedByteBufferImpl.c
+++ b/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.
@@ -15,8 +15,8 @@ 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.
+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
@@ -43,41 +43,215 @@ 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) ((p) - ((p) % (s)))
+#define ALIGN_UP(p,s) ((p) + ((s) - ((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;
+ jfieldID RawData_data;
+ 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/RawData;");
+ /* '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;
+ }
+
+#if (SIZEOF_VOID_P == 4)
+ RawData_data =
+ (*env)->GetFieldID (env, (*env)->GetObjectClass (env, MappedByteBufferImpl_address_value),
+ "data", "I");
+ *address = (void *)
+ ALIGN_DOWN ((*env)->GetIntField (env, MappedByteBufferImpl_address_value,
+ RawData_data), pagesize);
+#elif (SIZEOF_VOID_P == 8)
+ RawData_data =
+ (*env)->GetFieldID (env, (*env)->GetObjectClass (env, MappedByteBufferImpl_address_value),
+ "data", "J");
+ *address = (void *)
+ ALIGN_DOWN ((*env)->GetLongField (env, MappedByteBufferImpl_address_value,
+ RawData_data), pagesize);
+#endif /* SIZEOF_VOID_P */
+
+ *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/native/jni/java-nio/java_nio_VMDirectByteBuffer.c b/native/jni/java-nio/java_nio_VMDirectByteBuffer.c
index 08b05660f..fec431cdc 100644
--- a/native/jni/java-nio/java_nio_VMDirectByteBuffer.c
+++ b/native/jni/java-nio/java_nio_VMDirectByteBuffer.c
@@ -15,8 +15,8 @@ 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.
+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
@@ -179,7 +179,7 @@ Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_RawData_2I
}
JNIEXPORT void JNICALL
-Java_java_nio_VMDirectByteBuffer_put
+Java_java_nio_VMDirectByteBuffer_put__Lgnu_classpath_RawData_2IB
(JNIEnv * env, jclass clazz __attribute__ ((__unused__)),
jobject address, jint index, jbyte value)
{
@@ -193,8 +193,20 @@ Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_RawData_2I_3BII
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 *_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_RawData_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 *) NIOGetPointer (env, address) + index;
+ (*env)->ReleaseByteArrayElements (env, src, _src, 0);
+ memcpy (dst, _src, src_len);
}
JNIEXPORT void JNICALL
diff --git a/native/jni/java-util/java_util_VMTimeZone.c b/native/jni/java-util/java_util_VMTimeZone.c
index fc0f534e0..a3a986d36 100644
--- a/native/jni/java-util/java_util_VMTimeZone.c
+++ b/native/jni/java-util/java_util_VMTimeZone.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_dom.c b/native/jni/xmlj/xmlj_dom.c
index 86c7d4c50..b9bd372b1 100644
--- a/native/jni/xmlj/xmlj_dom.c
+++ b/native/jni/xmlj/xmlj_dom.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_dom.h b/native/jni/xmlj/xmlj_dom.h
index e8e2e73a5..d4a1dff42 100644
--- a/native/jni/xmlj/xmlj_dom.h
+++ b/native/jni/xmlj/xmlj_dom.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_error.c b/native/jni/xmlj/xmlj_error.c
index 5a75c48e9..5dd90552c 100644
--- a/native/jni/xmlj/xmlj_error.c
+++ b/native/jni/xmlj/xmlj_error.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_error.h b/native/jni/xmlj/xmlj_error.h
index f31ffc45f..a0c9fcc80 100644
--- a/native/jni/xmlj/xmlj_error.h
+++ b/native/jni/xmlj/xmlj_error.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_io.c b/native/jni/xmlj/xmlj_io.c
index 1cb6c7e19..aa2964dc3 100644
--- a/native/jni/xmlj/xmlj_io.c
+++ b/native/jni/xmlj/xmlj_io.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_io.h b/native/jni/xmlj/xmlj_io.h
index 878fa92dc..871859aca 100644
--- a/native/jni/xmlj/xmlj_io.h
+++ b/native/jni/xmlj/xmlj_io.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_node.c b/native/jni/xmlj/xmlj_node.c
index a5f6af201..20832678a 100644
--- a/native/jni/xmlj/xmlj_node.c
+++ b/native/jni/xmlj/xmlj_node.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_node.h b/native/jni/xmlj/xmlj_node.h
index bd5afbbb9..11f5e308b 100644
--- a/native/jni/xmlj/xmlj_node.h
+++ b/native/jni/xmlj/xmlj_node.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_sax.c b/native/jni/xmlj/xmlj_sax.c
index d6beb1fda..78991bdad 100644
--- a/native/jni/xmlj/xmlj_sax.c
+++ b/native/jni/xmlj/xmlj_sax.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_sax.h b/native/jni/xmlj/xmlj_sax.h
index f63606c97..249929ce0 100644
--- a/native/jni/xmlj/xmlj_sax.h
+++ b/native/jni/xmlj/xmlj_sax.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_transform.c b/native/jni/xmlj/xmlj_transform.c
index af8acd8dd..075409ad1 100644
--- a/native/jni/xmlj/xmlj_transform.c
+++ b/native/jni/xmlj/xmlj_transform.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_util.c b/native/jni/xmlj/xmlj_util.c
index 2c9f05d08..498cb7092 100644
--- a/native/jni/xmlj/xmlj_util.c
+++ b/native/jni/xmlj/xmlj_util.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_util.h b/native/jni/xmlj/xmlj_util.h
index ad3dd1f99..7bbe78b8e 100644
--- a/native/jni/xmlj/xmlj_util.h
+++ b/native/jni/xmlj/xmlj_util.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/jni/xmlj/xmlj_xpath.c b/native/jni/xmlj/xmlj_xpath.c
index ca31b8cd4..6d014cefc 100644
--- a/native/jni/xmlj/xmlj_xpath.c
+++ b/native/jni/xmlj/xmlj_xpath.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/Linux/target_native.h b/native/target/Linux/target_native.h
index 3192b016e..4e1d5136d 100644
--- a/native/target/Linux/target_native.h
+++ b/native/target/Linux/target_native.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/Linux/target_native_file.h b/native/target/Linux/target_native_file.h
index f066c5a67..0c40b4471 100644
--- a/native/target/Linux/target_native_file.h
+++ b/native/target/Linux/target_native_file.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/Linux/target_native_io.h b/native/target/Linux/target_native_io.h
index dec0c803d..03f43adf5 100644
--- a/native/target/Linux/target_native_io.h
+++ b/native/target/Linux/target_native_io.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/Linux/target_native_math_float.h b/native/target/Linux/target_native_math_float.h
index 6b9e18ea6..0f3455d2a 100644
--- a/native/target/Linux/target_native_math_float.h
+++ b/native/target/Linux/target_native_math_float.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/Linux/target_native_math_int.h b/native/target/Linux/target_native_math_int.h
index e21c5aa64..4c5fc671d 100644
--- a/native/target/Linux/target_native_math_int.h
+++ b/native/target/Linux/target_native_math_int.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/Linux/target_native_misc.h b/native/target/Linux/target_native_misc.h
index a6ff2a705..00bc7ac8d 100644
--- a/native/target/Linux/target_native_misc.h
+++ b/native/target/Linux/target_native_misc.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/Linux/target_native_network.h b/native/target/Linux/target_native_network.h
index 9698b5f47..23f9d0a62 100644
--- a/native/target/Linux/target_native_network.h
+++ b/native/target/Linux/target_native_network.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/generic/target_generic.h b/native/target/generic/target_generic.h
index d767985c4..e4ddf5c3b 100644
--- a/native/target/generic/target_generic.h
+++ b/native/target/generic/target_generic.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/generic/target_generic_file.h b/native/target/generic/target_generic_file.h
index 811548455..cd90e733c 100644
--- a/native/target/generic/target_generic_file.h
+++ b/native/target/generic/target_generic_file.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/generic/target_generic_io.h b/native/target/generic/target_generic_io.h
index 46450604f..cc24915ab 100644
--- a/native/target/generic/target_generic_io.h
+++ b/native/target/generic/target_generic_io.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/generic/target_generic_math_float.h b/native/target/generic/target_generic_math_float.h
index 23316a068..e2085e080 100644
--- a/native/target/generic/target_generic_math_float.h
+++ b/native/target/generic/target_generic_math_float.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/generic/target_generic_math_int.h b/native/target/generic/target_generic_math_int.h
index f88de7579..c6861487e 100644
--- a/native/target/generic/target_generic_math_int.h
+++ b/native/target/generic/target_generic_math_int.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/generic/target_generic_misc.h b/native/target/generic/target_generic_misc.h
index e3a4de6e5..1174aa83c 100644
--- a/native/target/generic/target_generic_misc.h
+++ b/native/target/generic/target_generic_misc.h
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/target/generic/target_generic_network.h b/native/target/generic/target_generic_network.h
index 57fcc2520..4488ea876 100644
--- a/native/target/generic/target_generic_network.h
+++ b/native/target/generic/target_generic_network.h
@@ -1,5 +1,5 @@
/* target_generic_network.h - Native methods for network operations.
- Copyright (C) 1998, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ 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.
+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
@@ -666,11 +666,22 @@ Systems : all
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT
#include <sys/types.h>
#include <sys/socket.h>
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT(socketDescriptor,flag,result) \
do { \
- int __value; \
+ struct timeval __value; \
\
- __value=flag; \
+ __value.tv_sec = flag / 1000; \
+ __value.tv_usec = (flag % 1000) * 1000; \
result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_TIMEOUT,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
@@ -682,7 +693,7 @@ Systems : all
* size - size of send buffer
* Output : result - TARGET_NATIVE_OK if no error occurred,
* TARGET_NATIVE_ERROR otherwise
-* Return : -
+* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
@@ -989,7 +1000,7 @@ Systems : all
#include <sys/socket.h>
#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT(socketDescriptor,flag,result) \
do { \
- int __value; \
+ struct timeval __value; \
socklen_t __len; \
\
flag=0; \
@@ -998,7 +1009,7 @@ Systems : all
result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_TIMEOUT,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
if (result==TARGET_NATIVE_OK) \
{ \
- flag=__value; \
+ flag = (__value.tv_sec * 1000LL) + (__value.tv_usec / 1000LL); \
} \
} while (0)
#endif
diff --git a/native/testsuite/guile-jvm.c b/native/testsuite/guile-jvm.c
index c5beb688a..c372f75f2 100644
--- a/native/testsuite/guile-jvm.c
+++ b/native/testsuite/guile-jvm.c
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
diff --git a/native/vmi/vmi.c b/native/vmi/vmi.c
index 07eef82f9..6022bedfd 100755
--- a/native/vmi/vmi.c
+++ b/native/vmi/vmi.c
@@ -15,8 +15,8 @@ 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.
+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
diff --git a/native/vmi/vmi.h b/native/vmi/vmi.h
index ea4f51783..1a8e26a81 100755
--- a/native/vmi/vmi.h
+++ b/native/vmi/vmi.h
@@ -15,8 +15,8 @@ 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.
+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