diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-03-26 20:08:09 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-03-26 20:08:09 +0000 |
commit | c7fc43440df4ee0406f8483ff717949056f81845 (patch) | |
tree | d1933cdedc07bb3dea4f9e8becfa47c46c928a7e /native/jni | |
parent | 7afa402d5269bad9cf422c4c2369c51ef76ded8b (diff) | |
download | classpath-c7fc43440df4ee0406f8483ff717949056f81845.tar.gz |
2006-03-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge from Classpath HEAD --> generics for the period
2005/03/07 to the branch tag generics_merge_20050326.
Diffstat (limited to 'native/jni')
27 files changed, 638 insertions, 325 deletions
diff --git a/native/jni/gtk-peer/Makefile.am b/native/jni/gtk-peer/Makefile.am index 81de38b95..9c373cb4d 100644 --- a/native/jni/gtk-peer/Makefile.am +++ b/native/jni/gtk-peer/Makefile.am @@ -1,4 +1,4 @@ -nativelib_LTLIBRARIES = libgtkpeer.la +nativeexeclib_LTLIBRARIES = libgtkpeer.la # Gtk/Cairo JNI sources. if GTK_CAIRO 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 30f2d5e24..8910bf3ec 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 @@ -239,6 +239,17 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_getFontMetrics struct peerfont *pfont = NULL; jdouble *native_metrics = NULL; PangoFontMetrics *pango_metrics = NULL; + PangoLayout* layout = NULL; + PangoRectangle ink_rect; + PangoRectangle logical_rect; + PangoLayoutIter* iter = NULL; + int pango_ascent = 0; + int pango_descent = 0; + int pango_ink_ascent = 0; + int pango_ink_descent = 0; + int baseline = 0; + int java_ascent = 0; + int java_descent = 0; gdk_threads_enter(); @@ -254,21 +265,52 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_getFontMetrics g_assert (native_metrics != NULL); - native_metrics[FONT_METRICS_ASCENT] - = PANGO_PIXELS (pango_font_metrics_get_ascent (pango_metrics)); + pango_ascent = PANGO_PIXELS (pango_font_metrics_get_ascent (pango_metrics)); + pango_descent = PANGO_PIXELS (pango_font_metrics_get_descent (pango_metrics)); - native_metrics[FONT_METRICS_MAX_ASCENT] - = native_metrics[FONT_METRICS_ASCENT]; + layout = pango_layout_new (pfont->ctx); - native_metrics[FONT_METRICS_DESCENT] - = PANGO_PIXELS (pango_font_metrics_get_descent (pango_metrics)); + /* Pango seems to produce ascent and descent values larger than + those that Sun produces for the same-sized font. It turns out + that an average of the "ink ascent" and "logical ascent" closely + approximates Sun's ascent values. Likewise for descent values. + This is expensive but we cache GdkFontMetrics so this should only + run once per Font instance. */ + pango_layout_set_text (layout, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL" + "MNOPQRSTUVWXYZ0123456789", -1); + pango_layout_set_font_description (layout, pfont->desc); - if (native_metrics[FONT_METRICS_DESCENT] < 0) - native_metrics[FONT_METRICS_DESCENT] - = - native_metrics[FONT_METRICS_DESCENT]; + pango_layout_get_pixel_extents (layout, &ink_rect, &logical_rect); - native_metrics[FONT_METRICS_MAX_DESCENT] - = native_metrics[FONT_METRICS_DESCENT]; + iter = pango_layout_get_iter (layout); + + baseline = PANGO_PIXELS (pango_layout_iter_get_baseline (iter)); + + pango_ink_ascent = baseline - ink_rect.y; + pango_ink_descent = ink_rect.y + ink_rect.height - baseline; + + java_ascent = (pango_ascent + pango_ink_ascent) >> 1; + java_descent = (pango_descent + pango_ink_descent) >> 1; + + java_ascent = MAX(0, java_ascent); + java_descent = MAX(0, java_descent); + + pango_ascent = MAX(0, pango_ascent); + pango_descent = MAX(0, pango_descent); + + /* Pango monospaced fonts have smaller ascent metrics than Sun's so + we return the logical ascent for monospaced fonts. */ + if (!strcmp (pango_font_description_get_family (pfont->desc), + "Courier")) + native_metrics[FONT_METRICS_ASCENT] = pango_ascent; + else + native_metrics[FONT_METRICS_ASCENT] = java_ascent; + + native_metrics[FONT_METRICS_MAX_ASCENT] = pango_ascent; + + native_metrics[FONT_METRICS_DESCENT] = java_descent; + + native_metrics[FONT_METRICS_MAX_DESCENT] = pango_descent; native_metrics[FONT_METRICS_MAX_ADVANCE] = PANGO_PIXELS (pango_font_metrics_get_approximate_char_width 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 f6e0e6bda..d23d7edc6 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 @@ -43,6 +43,46 @@ exception statement from your version. */ static jmethodID initComponentGraphicsUnlockedID; +/* + * AWT applications may call Graphics methods from threads other than + * the GDK main thread, so we must call XFlush after each batch of + * drawing operations, otherwise animations flicker. Flushing after + * every graphics operation is excessive and negatively affects + * performance (PR 26486). We set the maximum frequency to 50 times + * per second, or a minimum period of 20 milliseconds between calls to + * XFlush. See gnu.classpath.examples.awt.AnimationApplet for an + * example applet that requires these XFlush calls. + */ + +static short flush_scheduled = 0; + +static gboolean flush (gpointer data __attribute__((unused))) +{ + gdk_threads_enter (); + + XFlush (GDK_DISPLAY ()); + flush_scheduled = 0; + + gdk_threads_leave (); + + return FALSE; +} + +/* The minimum time period between calls to XFlush, in + milliseconds. */ +#define MINIMUM_FLUSH_PERIOD 20 + +/* schedule_flush must be called with the GDK lock held. */ +static void +schedule_flush () +{ + if (!flush_scheduled) + { + g_timeout_add (MINIMUM_FLUSH_PERIOD, flush, NULL); + flush_scheduled = 1; + } +} + void cp_gtk_graphics_init_jni (void) { @@ -343,7 +383,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString pango_layout_iter_free (iter); pango_layout_set_text (pfont->layout, "", -1); - gdk_flush (); + schedule_flush (); (*env)->ReleaseStringUTFChars (env, str, cstr); @@ -363,7 +403,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawLine 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 (); + schedule_flush (); gdk_threads_leave (); } @@ -380,7 +420,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_fillRect gdk_draw_rectangle (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, width, height); - gdk_flush (); + schedule_flush (); gdk_threads_leave (); } @@ -397,7 +437,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawRect gdk_draw_rectangle (g->drawable, g->gc, FALSE, x + g->x_offset, y + g->y_offset, width, height); - gdk_flush (); + schedule_flush (); gdk_threads_leave (); } @@ -419,7 +459,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea x + g->x_offset, y + g->y_offset, x + g->x_offset + dx, y + g->y_offset + dy, width, height); - gdk_flush (); + schedule_flush (); gdk_threads_leave (); } @@ -461,7 +501,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect gdk_gc_set_foreground (g->gc, &(saved.foreground)); } - gdk_flush (); + schedule_flush (); gdk_threads_leave (); } @@ -517,7 +557,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawArc gdk_draw_arc (g->drawable, g->gc, FALSE, x + g->x_offset, y + g->y_offset, width, height, angle1 << 6, angle2 << 6); - gdk_flush (); + schedule_flush (); gdk_threads_leave (); } @@ -564,7 +604,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolyline g->x_offset, g->y_offset); gdk_draw_lines (g->drawable, g->gc, points, npoints); - gdk_flush (); + schedule_flush (); g_free (points); @@ -591,7 +631,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolygon points[npoints++] = points[0]; gdk_draw_lines (g->drawable, g->gc, points, npoints); - gdk_flush (); + schedule_flush (); g_free (points); @@ -612,7 +652,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_fillPolygon points = translate_points (env, xpoints, ypoints, npoints, g->x_offset, g->y_offset); gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints); - gdk_flush (); + schedule_flush (); g_free (points); @@ -633,7 +673,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_fillArc gdk_draw_arc (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, width, height, angle1 << 6, angle2 << 6); - gdk_flush (); + schedule_flush (); gdk_threads_leave (); } @@ -651,7 +691,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawOval gdk_draw_arc (g->drawable, g->gc, FALSE, x + g->x_offset, y + g->y_offset, width, height, 0, 23040); - gdk_flush (); + schedule_flush (); gdk_threads_leave (); } @@ -669,7 +709,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_fillOval gdk_draw_arc (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, width, height, 0, 23040); - gdk_flush (); + schedule_flush (); gdk_threads_leave (); } 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 c95ea614b..b42f649a1 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 @@ -1992,6 +1992,10 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); g_assert (gr != NULL); + + if (gr->pattern == NULL) + return; + if (gr->debug) printf ("cairo_pattern_set_filter %d\n", filter); switch ((enum java_awt_rendering_hints_filter) filter) { 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 4d6169b85..eba00fb68 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, 2005 Free Software Foundation, Inc. + Copyright (C) 1999, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -191,8 +191,6 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_initState GdkPixbufLoader *loader = NULL; jobject *decoder = NULL; - gdk_threads_enter (); - decoder = (jobject *) g_malloc (sizeof (jobject)); g_assert (decoder != NULL); *decoder = (*env)->NewGlobalRef (env, obj); @@ -204,8 +202,6 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_initState g_signal_connect (loader, "closed", G_CALLBACK (closed_cb), decoder); NSA_SET_PB_PTR (env, obj, loader); - - gdk_threads_leave (); } static void @@ -317,8 +313,6 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_finish { GdkPixbufLoader *loader = NULL; - gdk_threads_enter (); - loader = (GdkPixbufLoader *)NSA_DEL_PB_PTR (env, obj); if (loader == NULL) return; @@ -326,8 +320,6 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_finish if (needs_close) gdk_pixbuf_loader_close (loader, NULL); g_object_unref (loader); - - gdk_threads_leave (); } JNIEXPORT void JNICALL @@ -337,8 +329,6 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_pumpDone GError *err = NULL; GdkPixbufLoader *loader = NULL; - gdk_threads_enter (); - loader = (GdkPixbufLoader *)NSA_GET_PB_PTR (env, obj); g_assert (loader != NULL); @@ -349,8 +339,6 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_pumpDone JCL_ThrowException (env, "java/io/IOException", err->message); g_error_free (err); } - - gdk_threads_leave (); } struct stream_save_request @@ -370,6 +358,9 @@ save_to_stream(const gchar *buf, jbyteArray jbuf; jbyte *cbuf; + /* FIXME. Don't call user code directly on this thread. + Store bytes and signal a "pump" thread to deliver to user code. + Then we don't have to drop/acquire any locks. */ gdk_threads_leave (); jbuf = (*(ssr->env))->NewByteArray ((ssr->env), count); @@ -400,8 +391,6 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_streamImage int i; struct stream_save_request ssr; - gdk_threads_enter (); - ssr.stream = &stream; ssr.env = env; @@ -465,8 +454,6 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_streamImage (*env)->ReleaseStringUTFChars (env, jenctype, enctype); (*env)->ReleaseIntArrayElements (env, jarr, ints, 0); - - gdk_threads_leave (); } @@ -478,8 +465,6 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_pumpBytes jbyte *bytes = NULL; GError *err = NULL; - gdk_threads_enter (); - g_assert (len >= 1); g_assert (jarr != NULL); @@ -497,6 +482,4 @@ Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_pumpBytes 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_GtkCheckboxGroupPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c index 5ba300b7e..16ef43c40 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 @@ -39,6 +39,8 @@ exception statement from your version. */ #include "gtkpeer.h" #include "gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.h" +static GtkWidget *comboboxgroup_get_widget (GtkWidget *widget); + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_dispose (JNIEnv *env, jobject obj) @@ -59,7 +61,7 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_remove gdk_threads_enter (); ptr = NSA_GET_PTR (env, checkbox); - button = GTK_RADIO_BUTTON (ptr); + button = GTK_RADIO_BUTTON (comboboxgroup_get_widget (GTK_WIDGET (ptr))); /* Update the group to point to some other widget in the group. We have to do this because Gtk doesn't have a separate object to @@ -75,3 +77,11 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_remove gdk_threads_leave (); } + +static GtkWidget * +comboboxgroup_get_widget (GtkWidget *widget) +{ + if (GTK_IS_EVENT_BOX (widget)) + return gtk_bin_get_child (GTK_BIN(widget)); + return widget; +} 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 297b4f853..191cdda8f 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 @@ -42,6 +42,7 @@ exception statement from your version. */ #include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" static jmethodID postItemEventID; +static GtkWidget *combobox_get_widget (GtkWidget *widget); void cp_gtk_checkbox_init_jni (void) @@ -63,26 +64,35 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_create (JNIEnv *env, jobject obj, jobject group) { GtkWidget *button; + GtkWidget *eventbox; gdk_threads_enter (); NSA_SET_GLOBAL_REF (env, obj); - + eventbox = gtk_event_box_new (); + if (group == NULL) + { button = gtk_check_button_new_with_label (""); + gtk_container_add (GTK_CONTAINER (eventbox), button); + gtk_widget_show (button); + } else { void *native_group = NSA_GET_PTR (env, group); button = gtk_radio_button_new_with_label_from_widget (native_group, ""); + gtk_container_add (GTK_CONTAINER (eventbox), button); + gtk_widget_show (button); + if (native_group == NULL) - { - /* Set the native group so we can use the correct value the - next time around. FIXME: this doesn't work! */ - NSA_SET_PTR (env, group, button); - } + { + /* Set the native group so we can use the correct value the + next time around. FIXME: this doesn't work! */ + NSA_SET_PTR (env, group, button); + } } - NSA_SET_PTR (env, obj, button); + NSA_SET_PTR (env, obj, eventbox); gdk_threads_leave (); } @@ -93,18 +103,20 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_connectSignals { void *ptr = NULL; jobject *gref = NULL; + GtkWidget *bin; gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); gref = NSA_GET_GLOBAL_REF (env, obj); + bin = combobox_get_widget (GTK_WIDGET (ptr)); /* Checkbox signals */ - g_signal_connect (G_OBJECT (ptr), "toggled", + g_signal_connect (G_OBJECT (bin), "toggled", G_CALLBACK (item_toggled_cb), *gref); /* Component signals */ - cp_gtk_component_connect_signals (G_OBJECT (ptr), gref); + cp_gtk_component_connect_signals (G_OBJECT (bin), gref); gdk_threads_leave (); } @@ -115,16 +127,18 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup { GtkRadioButton *button; void *native_group, *ptr; + GtkWidget *bin; gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - + bin = combobox_get_widget (GTK_WIDGET (ptr)); + /* FIXME: we can't yet switch between a checkbutton and a radiobutton. However, AWT requires this. For now we just crash. */ - button = GTK_RADIO_BUTTON (ptr); + button = GTK_RADIO_BUTTON (bin); native_group = NSA_GET_PTR (env, group); if (native_group == NULL) @@ -152,12 +166,14 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkToggleButtonSetActive (JNIEnv *env, jobject obj, jboolean is_active) { void *ptr; + GtkWidget *bin; gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ptr), is_active); + bin = combobox_get_widget (GTK_WIDGET (ptr)); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bin), is_active); gdk_threads_leave (); } @@ -176,7 +192,7 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkWidgetModifyFont ptr = NSA_GET_PTR (env, obj); - button = GTK_WIDGET (ptr); + button = combobox_get_widget (GTK_WIDGET (ptr)); label = gtk_bin_get_child (GTK_BIN(button)); if (!label) @@ -217,7 +233,7 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkButtonSetLabel c_label = (*env)->GetStringUTFChars (env, label, NULL); - label_widget = gtk_bin_get_child (GTK_BIN (ptr)); + label_widget = gtk_bin_get_child (GTK_BIN (combobox_get_widget (GTK_WIDGET (ptr)))); gtk_label_set_text (GTK_LABEL (label_widget), c_label); (*env)->ReleaseStringUTFChars (env, label, c_label); @@ -233,3 +249,15 @@ item_toggled_cb (GtkToggleButton *item, jobject peer) peer, item->active); } + +static GtkWidget * +combobox_get_widget (GtkWidget *widget) +{ + GtkWidget *wid; + + g_assert (GTK_IS_EVENT_BOX (widget)); + wid = gtk_bin_get_child (GTK_BIN(widget)); + + return wid; +} + 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 e9a0f693e..46949d99a 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 @@ -40,6 +40,7 @@ exception statement from your version. */ #include "gnu_java_awt_peer_gtk_GtkChoicePeer.h" static jmethodID postChoiceItemEventID; +static GtkWidget *choice_get_widget (GtkWidget *widget); void cp_gtk_choice_init_jni (void) @@ -61,16 +62,20 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_create (JNIEnv *env, jobject obj) { GtkWidget *combobox; + GtkWidget *eventbox; jobject *gref; gdk_threads_enter (); NSA_SET_GLOBAL_REF (env, obj); gref = NSA_GET_GLOBAL_REF (env, obj); - + + eventbox = gtk_event_box_new (); combobox = gtk_combo_box_new_text (); + gtk_container_add (GTK_CONTAINER (eventbox), combobox); + gtk_widget_show (combobox); - NSA_SET_PTR (env, obj, combobox); + NSA_SET_PTR (env, obj, eventbox); gdk_threads_leave (); } @@ -81,18 +86,21 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_connectSignals { void *ptr = NULL; jobject *gref = NULL; + GtkWidget *bin; gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); gref = NSA_GET_GLOBAL_REF (env, obj); + bin = choice_get_widget (GTK_WIDGET (ptr)); + /* Choice signals */ - g_signal_connect (G_OBJECT (ptr), "changed", + g_signal_connect (G_OBJECT (bin), "changed", G_CALLBACK (selection_changed_cb), *gref); /* Component signals */ - cp_gtk_component_connect_signals (G_OBJECT (ptr), gref); + cp_gtk_component_connect_signals (G_OBJECT (bin), gref); gdk_threads_leave (); } @@ -103,11 +111,13 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_append { gpointer ptr; jsize count, i; + GtkWidget *bin; gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - + bin = choice_get_widget (GTK_WIDGET (ptr)); + count = (*env)->GetArrayLength (env, items); for (i = 0; i < count; i++) @@ -118,7 +128,7 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_append item = (*env)->GetObjectArrayElement (env, items, i); label = (*env)->GetStringUTFChars (env, item, NULL); - gtk_combo_box_append_text (GTK_COMBO_BOX (ptr), label); + gtk_combo_box_append_text (GTK_COMBO_BOX (bin), label); (*env)->ReleaseStringUTFChars (env, item, label); (*env)->DeleteLocalRef(env, item); @@ -133,14 +143,16 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeAdd { void *ptr; const char *label; + GtkWidget *bin; gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - + bin = choice_get_widget (GTK_WIDGET (ptr)); + label = (*env)->GetStringUTFChars (env, item, 0); - gtk_combo_box_insert_text (GTK_COMBO_BOX (ptr), index, label); + gtk_combo_box_insert_text (GTK_COMBO_BOX (bin), index, label); (*env)->ReleaseStringUTFChars (env, item, label); @@ -152,12 +164,14 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeRemove (JNIEnv *env, jobject obj, jint index) { void *ptr; - + GtkWidget *bin; + gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - - gtk_combo_box_remove_text (GTK_COMBO_BOX (ptr), index); + bin = choice_get_widget (GTK_WIDGET (ptr)); + + gtk_combo_box_remove_text (GTK_COMBO_BOX (bin), index); gdk_threads_leave (); } @@ -168,20 +182,22 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeRemoveAll { void *ptr; GtkTreeModel *model; + GtkWidget *bin; gint count, i; gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (ptr)); + bin = choice_get_widget (GTK_WIDGET (ptr)); + + model = gtk_combo_box_get_model (GTK_COMBO_BOX (bin)); count = gtk_tree_model_iter_n_children (model, NULL); /* First, unselect everything, to avoid problems when removing items. */ - gtk_combo_box_set_active (GTK_COMBO_BOX (ptr), -1); + gtk_combo_box_set_active (GTK_COMBO_BOX (bin), -1); for (i = count - 1; i >= 0; i--) { - gtk_combo_box_remove_text (GTK_COMBO_BOX (ptr), i); + gtk_combo_box_remove_text (GTK_COMBO_BOX (bin), i); } gdk_threads_leave (); @@ -204,10 +220,12 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_selectNativeUnlocked (JNIEnv *env, jobject obj, jint index) { void *ptr; - + GtkWidget *bin; + ptr = NSA_GET_PTR (env, obj); - - gtk_combo_box_set_active (GTK_COMBO_BOX (ptr), index); + bin = choice_get_widget (GTK_WIDGET (ptr)); + + gtk_combo_box_set_active (GTK_COMBO_BOX (bin), index); } JNIEXPORT jint JNICALL @@ -216,12 +234,14 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeGetSelected { void *ptr; int index; + GtkWidget *bin; gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - - index = gtk_combo_box_get_active (GTK_COMBO_BOX (ptr)); + bin = choice_get_widget (GTK_WIDGET (ptr)); + + index = gtk_combo_box_get_active (GTK_COMBO_BOX (bin)); gdk_threads_leave (); @@ -252,3 +272,14 @@ selection_changed_cb (GtkComboBox *combobox, jobject peer) (jint) AWT_ITEM_SELECTED); } } + +static GtkWidget * +choice_get_widget (GtkWidget *widget) +{ + GtkWidget *wid; + + g_assert (GTK_IS_EVENT_BOX (widget)); + wid = gtk_bin_get_child (GTK_BIN(widget)); + + return wid; +} 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 3b62dc335..cb2c87238 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 @@ -1,5 +1,5 @@ /* gtkclipboard.c - Copyright (C) 1998, 1999, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,23 +45,21 @@ exception statement from your version. */ #define IMAGE_TARGET 3 #define URI_TARGET 4 -/* The clipboard and standard (string targets) shared with GtkSelection. */ +/* The clipboard and selection plus corresponding GtkClipboard objects. */ GtkClipboard *cp_gtk_clipboard; +GtkClipboard *cp_gtk_selection; +jobject cp_gtk_clipboard_instance; +jobject cp_gtk_selection_instance; + +/* Standard (string targets) shared with GtkSelection. */ jstring cp_gtk_stringTarget; jstring cp_gtk_imageTarget; jstring cp_gtk_filesTarget; -/* Simple id to keep track of the selection we are currently managing. */ -static gint current_selection = 0; - -/* Whether we "own" the clipboard. And may clear it. */ -static int owner = 0; - static jclass gtk_clipboard_class; -static jmethodID setSystemContentsID; -static jobject gtk_clipboard_instance = NULL; +static jmethodID setSystemContentsID; static jmethodID provideContentID; static jmethodID provideTextID; static jmethodID provideImageID; @@ -70,22 +68,26 @@ static jmethodID provideURIsID; /* Called when clipboard owner changes. Used to update available targets. */ #if GTK_MINOR_VERSION > 4 static void -clipboard_owner_change_cb (GtkClipboard *clipboard __attribute__((unused)), +clipboard_owner_change_cb (GtkClipboard *clipboard, GdkEvent *event __attribute__((unused)), gpointer user_data __attribute__((unused))) { - /* These are only interesting when we are not the owner. Otherwise - we will have the set and clear functions doing the updating. */ JNIEnv *env = cp_gtk_gdk_env (); - if (!owner) - (*env)->CallStaticVoidMethod (env, gtk_clipboard_class, - setSystemContentsID); + if (clipboard == cp_gtk_clipboard) + (*env)->CallVoidMethod (env, cp_gtk_clipboard_instance, + setSystemContentsID, JNI_FALSE); + else + (*env)->CallVoidMethod (env, cp_gtk_selection_instance, + setSystemContentsID, JNI_FALSE); + } #endif JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env, - jclass gtkclipboard, + jclass clz, + jobject gtkclipboard, + jobject gtkselection, jstring string, jstring image, jstring files) @@ -93,19 +95,47 @@ Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env, GdkDisplay* display; jboolean can_cache; - gtk_clipboard_class = gtkclipboard; - setSystemContentsID = (*env)->GetStaticMethodID (env, gtk_clipboard_class, - "setSystemContents", - "()V"); + gtk_clipboard_class = clz; + setSystemContentsID = (*env)->GetMethodID (env, gtk_clipboard_class, + "setSystemContents", + "(Z)V"); if (setSystemContentsID == NULL) return JNI_FALSE; + provideContentID = (*env)->GetMethodID (env, gtk_clipboard_class, + "provideContent", + "(Ljava/lang/String;)[B"); + if (provideContentID == NULL) + return JNI_FALSE; + + provideTextID = (*env)->GetMethodID (env, gtk_clipboard_class, + "provideText", + "()Ljava/lang/String;"); + if (provideTextID == NULL) + return JNI_FALSE; + + provideImageID = (*env)->GetMethodID (env, gtk_clipboard_class, + "provideImage", + "()Lgnu/java/awt/peer/gtk/GtkImage;"); + if (provideImageID == NULL) + return JNI_FALSE; + + provideURIsID = (*env)->GetMethodID (env, gtk_clipboard_class, + "provideURIs", + "()[Ljava/lang/String;"); + if (provideURIsID == NULL) + return JNI_FALSE; + + cp_gtk_clipboard_instance = (*env)->NewGlobalRef(env, gtkclipboard); + cp_gtk_selection_instance = (*env)->NewGlobalRef(env, gtkselection); + cp_gtk_stringTarget = (*env)->NewGlobalRef(env, string); cp_gtk_imageTarget = (*env)->NewGlobalRef(env, image); cp_gtk_filesTarget = (*env)->NewGlobalRef(env, files); gdk_threads_enter (); cp_gtk_clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); + cp_gtk_selection = gtk_clipboard_get (GDK_SELECTION_PRIMARY); display = gtk_clipboard_get_display (cp_gtk_clipboard); /* Check for support for clipboard owner changes. */ @@ -114,26 +144,37 @@ Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env, { g_signal_connect (cp_gtk_clipboard, "owner-change", G_CALLBACK (clipboard_owner_change_cb), NULL); + g_signal_connect (cp_gtk_selection, "owner-change", + G_CALLBACK (clipboard_owner_change_cb), NULL); gdk_display_request_selection_notification (display, GDK_SELECTION_CLIPBOARD); + gdk_display_request_selection_notification (display, + GDK_SELECTION_PRIMARY); can_cache = JNI_TRUE; } else #endif can_cache = JNI_FALSE; + gdk_threads_leave (); return can_cache; } static void -clipboard_get_func (GtkClipboard *clipboard __attribute__((unused)), +clipboard_get_func (GtkClipboard *clipboard, GtkSelectionData *selection, guint info, gpointer user_data __attribute__((unused))) { + jobject gtk_clipboard_instance; JNIEnv *env = cp_gtk_gdk_env (); + if (clipboard == cp_gtk_clipboard) + gtk_clipboard_instance = cp_gtk_clipboard_instance; + else + gtk_clipboard_instance = cp_gtk_selection_instance; + if (info == OBJECT_TARGET) { const gchar *target_name; @@ -258,16 +299,17 @@ clipboard_get_func (GtkClipboard *clipboard __attribute__((unused)), } static void -clipboard_clear_func (GtkClipboard *clipboard __attribute__((unused)), - gpointer user_data) +clipboard_clear_func (GtkClipboard *clipboard, + gpointer user_data __attribute__((unused))) { - if (owner && GPOINTER_TO_INT(user_data) == current_selection) - { - JNIEnv *env = cp_gtk_gdk_env(); - owner = 0; - (*env)->CallStaticVoidMethod (env, gtk_clipboard_class, - setSystemContentsID); - } + JNIEnv *env = cp_gtk_gdk_env(); + if (clipboard == cp_gtk_clipboard) + (*env)->CallVoidMethod (env, cp_gtk_clipboard_instance, + setSystemContentsID, JNI_TRUE); + else + (*env)->CallVoidMethod (env, cp_gtk_selection_instance, + setSystemContentsID, JNI_TRUE); + } JNIEXPORT void JNICALL @@ -347,65 +389,35 @@ Java_gnu_java_awt_peer_gtk_GtkClipboard_advertiseContent /* Set the targets plus callback functions and ask for the clipboard to be stored when the application exists if supported. */ - current_selection++; - if (gtk_clipboard_set_with_data (cp_gtk_clipboard, targets, n, - clipboard_get_func, - clipboard_clear_func, - GINT_TO_POINTER(current_selection))) + if ((*env)->IsSameObject(env, instance, cp_gtk_clipboard_instance)) { - owner = 1; - if (gtk_clipboard_instance == NULL) + if (gtk_clipboard_set_with_data (cp_gtk_clipboard, targets, n, + clipboard_get_func, + clipboard_clear_func, + NULL)) { - JNIEnv *env = cp_gtk_gdk_env (); - gtk_clipboard_instance = (*env)->NewGlobalRef(env, instance); - - provideContentID - = (*env)->GetMethodID (env, gtk_clipboard_class, - "provideContent", - "(Ljava/lang/String;)[B"); - if (provideContentID == NULL) - return; - - provideTextID - = (*env)->GetMethodID (env, gtk_clipboard_class, - "provideText", "()Ljava/lang/String;"); - if (provideTextID == NULL) - return; - - provideImageID - = (*env)->GetMethodID (env, gtk_clipboard_class, - "provideImage", - "()Lgnu/java/awt/peer/gtk/GtkImage;"); - if (provideImageID == NULL) - return; - - provideURIsID - = (*env)->GetMethodID (env, gtk_clipboard_class, - "provideURIs", - "()[Ljava/lang/String;"); - if (provideURIsID == NULL) - return; - } #if GTK_MINOR_VERSION > 4 - gtk_clipboard_set_can_store (cp_gtk_clipboard, NULL, 0); + gtk_clipboard_set_can_store (cp_gtk_clipboard, NULL, 0); #endif + } } else { - owner = 0; - (*env)->CallStaticVoidMethod (env, gtk_clipboard_class, - setSystemContentsID); + if (gtk_clipboard_set_with_data (cp_gtk_selection, targets, n, + clipboard_get_func, + clipboard_clear_func, + NULL)) + { +#if GTK_MINOR_VERSION > 4 + gtk_clipboard_set_can_store (cp_gtk_selection, NULL, 0); +#endif + } } for (i = 0; i < n; i++) g_free (targets[i].target); g_free (targets); } - else if (owner) - { - gtk_clipboard_clear (cp_gtk_clipboard); - owner = 0; - } gtk_target_list_unref (target_list); gdk_threads_leave (); 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 6de7b61b8..fc6002255 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 @@ -1,5 +1,5 @@ /* gtkcomponentpeer.c -- Native implementation of GtkComponentPeer - Copyright (C) 1998, 1999, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2002, 2004, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -67,14 +67,19 @@ exception statement from your version. */ #define AWT_MOUSE_ENTERED 504 #define AWT_MOUSE_EXITED 505 #define AWT_MOUSE_DRAGGED 506 +#define AWT_MOUSE_WHEEL 507 + +#define AWT_WHEEL_UNIT_SCROLL 0 #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 GtkWidget *get_widget (GtkWidget *widget); static jmethodID postMouseEventID; +static jmethodID postMouseWheelEventID; static jmethodID setCursorID; static jmethodID postExposeEventID; static jmethodID postFocusEventID; @@ -90,6 +95,11 @@ cp_gtk_component_init_jni (void) postMouseEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcomponentpeer, "postMouseEvent", "(IJIIIIZ)V"); + postMouseWheelEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), + gtkcomponentpeer, + "postMouseWheelEvent", + "(IJIIIIZIII)V"); + setCursorID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcomponentpeer, "setCursor", "()V"); @@ -109,6 +119,9 @@ static gboolean component_button_release_cb (GtkWidget *widget, static gboolean component_motion_notify_cb (GtkWidget *widget, GdkEventMotion *event, jobject peer); +static gboolean component_scroll_cb (GtkWidget *widget, + GdkEventScroll *event, + jobject peer); static gboolean component_enter_notify_cb (GtkWidget *widget, GdkEventCrossing *event, jobject peer); @@ -179,19 +192,19 @@ state_to_awt_mods_with_button_states (guint state) JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor - (JNIEnv *env, jobject obj, jint type) + (JNIEnv *env, jobject obj, jint type, jobject image, jint x, jint y) { gdk_threads_enter (); Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked - (env, obj, type); + (env, obj, type, image, x, y); gdk_threads_leave (); } JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked - (JNIEnv *env, jobject obj, jint type) + (JNIEnv *env, jobject obj, jint type, jobject image, jint x, jint y) { void *ptr; GtkWidget *widget; @@ -245,9 +258,16 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked gdk_cursor_type = GDK_LEFT_PTR; } - widget = GTK_WIDGET(ptr); + widget = get_widget(GTK_WIDGET(ptr)); + + if (image == NULL) + gdk_cursor = gdk_cursor_new (gdk_cursor_type); + else + gdk_cursor + = gdk_cursor_new_from_pixbuf (gdk_drawable_get_display (widget->window), + cp_gtk_image_get_pixbuf (env, image), + x, y); - gdk_cursor = gdk_cursor_new (gdk_cursor_type); gdk_window_set_cursor (widget->window, gdk_cursor); gdk_cursor_unref (gdk_cursor); } @@ -265,9 +285,9 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetParent ptr = NSA_GET_PTR (env, obj); parent_ptr = NSA_GET_PTR (env, parent); - + widget = GTK_WIDGET (ptr); - parent_widget = GTK_WIDGET (parent_ptr); + parent_widget = get_widget(GTK_WIDGET (parent_ptr)); if (widget->parent == NULL) { @@ -310,7 +330,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetSensitive ptr = NSA_GET_PTR (env, obj); - gtk_widget_set_sensitive (GTK_WIDGET (ptr), sensitive); + gtk_widget_set_sensitive (get_widget(GTK_WIDGET (ptr)), sensitive); gdk_threads_leave (); } @@ -325,7 +345,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetRequestFocus ptr = NSA_GET_PTR (env, obj); - gtk_widget_grab_focus (GTK_WIDGET (ptr)); + gtk_widget_grab_focus (get_widget(GTK_WIDGET (ptr))); gdk_threads_leave (); } @@ -361,11 +381,11 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetDispatchKeyEvent } if (GTK_IS_BUTTON (ptr)) - event->key.window = GTK_BUTTON (ptr)->event_window; - else if (GTK_IS_SCROLLED_WINDOW (ptr)) - event->key.window = GTK_WIDGET (GTK_SCROLLED_WINDOW (ptr)->container.child)->window; + event->key.window = GTK_BUTTON (get_widget(GTK_WIDGET (ptr)))->event_window; + else if (GTK_IS_SCROLLED_WINDOW (get_widget(GTK_WIDGET (ptr)))) + event->key.window = GTK_WIDGET (GTK_SCROLLED_WINDOW (get_widget(GTK_WIDGET (ptr)))->container.child)->window; else - event->key.window = GTK_WIDGET (ptr)->window; + event->key.window = get_widget(GTK_WIDGET (ptr))->window; event->key.send_event = 0; event->key.time = (guint32) when; @@ -441,10 +461,10 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetDispatchKeyEvent so we don't want to resend it. */ if (!GTK_IS_WINDOW (ptr)) { - if (GTK_IS_SCROLLED_WINDOW (ptr)) - gtk_widget_event (GTK_WIDGET (GTK_SCROLLED_WINDOW (ptr)->container.child), event); + if (GTK_IS_SCROLLED_WINDOW (get_widget(GTK_WIDGET (ptr)))) + gtk_widget_event (GTK_WIDGET (GTK_SCROLLED_WINDOW (get_widget(GTK_WIDGET (ptr)))->container.child), event); else - gtk_widget_event (GTK_WIDGET (ptr), event); + gtk_widget_event (get_widget(GTK_WIDGET (ptr)), event); } gdk_threads_leave (); @@ -465,7 +485,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWindowGetLocationOnScreen ptr = NSA_GET_PTR (env, obj); point = (*env)->GetIntArrayElements (env, jpoint, 0); - gdk_window_get_root_origin (GTK_WIDGET (ptr)->window, point, point+1); + gdk_window_get_root_origin (get_widget(GTK_WIDGET (ptr))->window, point, point+1); (*env)->ReleaseIntArrayElements(env, jpoint, point, 0); @@ -488,7 +508,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen ptr = NSA_GET_PTR (env, obj); point = (*env)->GetIntArrayElements (env, jpoint, 0); - widget = GTK_WIDGET(ptr); + widget = get_widget(GTK_WIDGET (ptr)); while(gtk_widget_get_parent(widget) != NULL) widget = gtk_widget_get_parent(widget); gdk_window_get_position (GTK_WIDGET(widget)->window, point, point+1); @@ -519,7 +539,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetDimensions dims = (*env)->GetIntArrayElements (env, jdims, 0); dims[0] = dims[1] = 0; - gtk_widget_size_request (GTK_WIDGET (ptr), &requisition); + gtk_widget_size_request (get_widget(GTK_WIDGET (ptr)), &requisition); dims[0] = requisition.width; dims[1] = requisition.height; @@ -551,10 +571,10 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetPreferredDimensions /* 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. */ - if (GTK_IS_WINDOW (ptr)) + if (GTK_IS_WINDOW (get_widget(GTK_WIDGET (ptr)))) { gint width, height; - gtk_window_get_default_size (GTK_WINDOW (ptr), &width, &height); + gtk_window_get_default_size (GTK_WINDOW (get_widget(GTK_WIDGET (ptr))), &width, &height); dims[0] = width; dims[1] = height; @@ -562,14 +582,14 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetPreferredDimensions else { /* Save the widget's current size request. */ - gtk_widget_size_request (GTK_WIDGET (ptr), ¤t_req); + gtk_widget_size_request (get_widget(GTK_WIDGET (ptr)), ¤t_req); /* Get the widget's "natural" size request. */ - gtk_widget_set_size_request (GTK_WIDGET (ptr), -1, -1); - gtk_widget_size_request (GTK_WIDGET (ptr), &natural_req); + gtk_widget_set_size_request (get_widget(GTK_WIDGET (ptr)), -1, -1); + gtk_widget_size_request (get_widget(GTK_WIDGET (ptr)), &natural_req); /* Reset the widget's size request. */ - gtk_widget_set_size_request (GTK_WIDGET (ptr), + gtk_widget_set_size_request (get_widget(GTK_WIDGET (ptr)), current_req.width, current_req.height); dims[0] = natural_req.width; @@ -656,7 +676,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetForeground ptr = NSA_GET_PTR (env, obj); - fg = GTK_WIDGET (ptr)->style->fg[GTK_STATE_NORMAL]; + fg = get_widget(GTK_WIDGET (ptr))->style->fg[GTK_STATE_NORMAL]; array = (*env)->NewIntArray (env, 3); @@ -766,7 +786,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isEnabled ptr = NSA_GET_PTR (env, obj); - ret_val = GTK_WIDGET_IS_SENSITIVE (GTK_WIDGET (ptr)); + ret_val = GTK_WIDGET_IS_SENSITIVE (get_widget(GTK_WIDGET (ptr))); gdk_threads_leave (); @@ -790,7 +810,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isRealized return FALSE; } - ret_val = GTK_WIDGET_REALIZED (GTK_WIDGET (ptr)); + ret_val = GTK_WIDGET_REALIZED (get_widget(GTK_WIDGET (ptr))); gdk_threads_leave (); @@ -841,7 +861,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeEventMask ptr = NSA_GET_PTR (env, obj); - gtk_widget_add_events (GTK_WIDGET (ptr), + gtk_widget_add_events (get_widget(GTK_WIDGET (ptr)), GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK @@ -857,6 +877,19 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeEventMask gdk_threads_leave (); } +static GtkWidget * +get_widget (GtkWidget *widget) +{ + GtkWidget *w; + + if (GTK_IS_EVENT_BOX (widget)) + w = gtk_bin_get_child (GTK_BIN(widget)); + else + w = widget; + + return w; +} + /* FIXME: these functions should be implemented by overridding the appropriate GtkComponentPeer methods. */ static GtkWidget * @@ -918,6 +951,9 @@ cp_gtk_component_connect_mouse_signals (GObject *ptr, jobject *gref) g_signal_connect (G_OBJECT (ptr), "motion-notify-event", G_CALLBACK (component_motion_notify_cb), *gref); + + g_signal_connect (G_OBJECT (ptr), "scroll-event", + G_CALLBACK (component_scroll_cb), *gref); } void @@ -930,11 +966,11 @@ cp_gtk_component_connect_signals (GObject *ptr, jobject *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. */ + more-than-triple clicks. Also used for keeping track of scroll events.*/ static jint click_count = 1; static guint32 button_click_time = 0; static GdkWindow *button_window = NULL; -static guint button_number = -1; +static guint button_number_direction = -1; static int hasBeenDragged; static gboolean @@ -949,14 +985,14 @@ component_button_press_cb (GtkWidget *widget __attribute__((unused)), if ((event->time < (button_click_time + MULTI_CLICK_TIME)) && (event->window == button_window) - && (event->button == button_number)) + && (event->button == button_number_direction)) click_count++; else click_count = 1; button_click_time = event->time; button_window = event->window; - button_number = event->button; + button_number_direction = event->button; (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postMouseEventID, @@ -1055,6 +1091,45 @@ component_motion_notify_cb (GtkWidget *widget __attribute__((unused)), } static gboolean +component_scroll_cb (GtkWidget *widget __attribute__((unused)), + GdkEventScroll *event, + jobject peer) +{ + int rotation; + /** Record click count for specific direction. */ + if ((event->time < (button_click_time + MULTI_CLICK_TIME)) + && (event->window == button_window) + && (event->direction == button_number_direction)) + click_count++; + else + click_count = 1; + + button_click_time = event->time; + button_window = event->window; + button_number_direction = event->direction; + + if (event->direction == GDK_SCROLL_UP + || event->direction == GDK_SCROLL_LEFT) + rotation = -1; + else + rotation = 1; + + (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, + postMouseWheelEventID, + AWT_MOUSE_WHEEL, + (jlong)event->time, + cp_gtk_state_to_awt_mods (event->state), + (jint)event->x, + (jint)event->y, + click_count, + JNI_FALSE, + AWT_WHEEL_UNIT_SCROLL, + 1 /* amount */, + rotation); + return FALSE; +} + +static gboolean component_enter_notify_cb (GtkWidget *widget __attribute__((unused)), GdkEventCrossing *event, jobject peer) 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 ae0657636..92bc09edd 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 @@ -1,5 +1,5 @@ /* gtkimage.c - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -65,23 +65,17 @@ 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) - { - gdk_threads_leave (); - return JNI_FALSE; - } + return JNI_FALSE; pixbuf = gdk_pixbuf_new_from_file (filename, NULL); if (pixbuf == NULL) { (*env)->ReleaseStringUTFChars (env, name, filename); - gdk_threads_leave (); return JNI_FALSE; } @@ -92,8 +86,6 @@ Java_gnu_java_awt_peer_gtk_GtkImage_loadPixbuf setWidthHeight(env, obj, width, height); (*env)->ReleaseStringUTFChars (env, name, filename); - gdk_threads_leave (); - return JNI_TRUE; } @@ -111,8 +103,6 @@ Java_gnu_java_awt_peer_gtk_GtkImage_loadImageFromData int width; int height; - gdk_threads_enter (); - src = (*env)->GetByteArrayElements (env, data, NULL); len = (*env)->GetArrayLength (env, data); @@ -128,9 +118,6 @@ Java_gnu_java_awt_peer_gtk_GtkImage_loadImageFromData if (pixbuf == NULL) { createRawData (env, obj, NULL); - - gdk_threads_leave (); - return JNI_FALSE; } @@ -140,8 +127,6 @@ Java_gnu_java_awt_peer_gtk_GtkImage_loadImageFromData createRawData (env, obj, pixbuf); setWidthHeight(env, obj, width, height); - gdk_threads_leave (); - return JNI_TRUE; } @@ -151,10 +136,8 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createFromPixbuf { int width, heigth; GdkPixbuf *pixbuf = (GdkPixbuf *) getData (env, obj); - gdk_threads_enter (); width = gdk_pixbuf_get_width (pixbuf); heigth = gdk_pixbuf_get_height (pixbuf); - gdk_threads_leave (); setWidthHeight(env, obj, width, heigth); } @@ -171,8 +154,6 @@ Java_gnu_java_awt_peer_gtk_GtkImage_getPixels(JNIEnv *env, jobject obj) jint *result_array_iter, *dst; int i,j; - gdk_threads_enter (); - pixbuf = cp_gtk_image_get_pixbuf (env, obj); width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); @@ -214,8 +195,6 @@ Java_gnu_java_awt_peer_gtk_GtkImage_getPixels(JNIEnv *env, jobject obj) (*env)->ReleaseIntArrayElements (env, result_array, result_array_iter, 0); - gdk_threads_leave (); - return result_array; } @@ -233,8 +212,6 @@ Java_gnu_java_awt_peer_gtk_GtkImage_setPixels(JNIEnv *env, jobject obj, jint *src_array_iter, *src; int i; - gdk_threads_enter (); - width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); rowstride = gdk_pixbuf_get_rowstride (pixbuf); @@ -251,8 +228,6 @@ Java_gnu_java_awt_peer_gtk_GtkImage_setPixels(JNIEnv *env, jobject obj, } (*env)->ReleaseIntArrayElements (env, pixels, src_array_iter, 0); - - gdk_threads_leave (); } /** @@ -265,8 +240,6 @@ 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); @@ -285,8 +258,6 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createPixmap(JNIEnv *env, jobject obj) else createRawData (env, obj, gdk_pixmap_new (NULL, width, height, gdk_rgb_get_visual ()->depth)); - - gdk_threads_leave (); } /** @@ -295,13 +266,10 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createPixmap(JNIEnv *env, jobject obj) JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_freePixmap(JNIEnv *env, jobject obj) { - gdk_threads_enter (); if (offScreen (env, obj) == JNI_FALSE) gdk_pixbuf_unref ((GdkPixbuf *)getData (env, obj)); else g_object_unref ((GdkPixmap *)getData (env, obj)); - - gdk_threads_leave (); } /** @@ -321,8 +289,6 @@ 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); @@ -342,8 +308,6 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createScaledPixmap(JNIEnv *env, gdk_pixbuf_unref (pixbuf); createRawData (env, destination, (void *)dst); - - gdk_threads_leave (); } /** 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 6da42cec6..54ef31a4f 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 @@ -39,6 +39,7 @@ #include "gnu_java_awt_peer_gtk_GtkListPeer.h" static jmethodID postListItemEventID; +static GtkWidget *list_get_widget (GtkWidget *widget); void cp_gtk_list_init_jni (void) @@ -72,6 +73,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_create { GtkWidget *sw; GtkWidget *list; + GtkWidget *eventbox; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkListStore *list_store; @@ -102,11 +104,13 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_create COLUMN_STRING, NULL); + eventbox = gtk_event_box_new (); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - + gtk_container_add (GTK_CONTAINER (eventbox), sw); + gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (list), FALSE); @@ -123,7 +127,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_create gtk_widget_show (list); gtk_widget_show (sw); - NSA_SET_PTR (env, obj, sw); + NSA_SET_PTR (env, obj, eventbox); gdk_threads_leave (); } @@ -142,7 +146,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_connectSignals ptr = NSA_GET_PTR (env, obj); gref = NSA_GET_GLOBAL_REF (env, obj); - list = gtk_bin_get_child (GTK_BIN (ptr)); + list = list_get_widget (GTK_WIDGET (ptr)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list)); gtk_tree_selection_set_select_function (selection, item_highlighted_cb, @@ -166,7 +170,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_gtkWidgetModifyFont ptr = NSA_GET_PTR (env, obj); - list = gtk_bin_get_child (GTK_BIN (ptr)); + list = list_get_widget (GTK_WIDGET (ptr)); font_name = (*env)->GetStringUTFChars (env, name, NULL); @@ -200,7 +204,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_gtkWidgetRequestFocus ptr = NSA_GET_PTR (env, obj); - list = gtk_bin_get_child (GTK_BIN (ptr)); + list = list_get_widget (GTK_WIDGET (ptr)); gtk_widget_grab_focus (list); gdk_threads_leave (); @@ -223,7 +227,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_append count = (*env)->GetArrayLength (env, items); - list = gtk_bin_get_child (GTK_BIN (ptr)); + list = list_get_widget (GTK_WIDGET (ptr)); list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (list)); for (i = 0; i < count; i++) @@ -260,7 +264,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_add ptr = NSA_GET_PTR (env, obj); str = (*env)->GetStringUTFChars (env, text, NULL); - list = gtk_bin_get_child (GTK_BIN (ptr)); + list = list_get_widget (GTK_WIDGET (ptr)); list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (list)); if (index == -1) @@ -292,7 +296,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_delItems ptr = NSA_GET_PTR (env, obj); - list = gtk_bin_get_child (GTK_BIN (ptr)); + list = list_get_widget (GTK_WIDGET (ptr)); list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (list)); /* Special case: remove all rows. */ @@ -325,7 +329,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_select ptr = NSA_GET_PTR (env, obj); - list = gtk_bin_get_child (GTK_BIN (ptr)); + list = list_get_widget (GTK_WIDGET (ptr)); path = gtk_tree_path_new_from_indices (index, -1); gtk_tree_view_set_cursor (GTK_TREE_VIEW (list), path, NULL, FALSE); @@ -345,7 +349,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_deselect ptr = NSA_GET_PTR (env, obj); - list = gtk_bin_get_child (GTK_BIN (ptr)); + list = list_get_widget (GTK_WIDGET (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); @@ -361,6 +365,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_getSize jint *dims; GtkRequisition current_req; GtkRequisition natural_req; + GtkWidget* bin; gdk_threads_enter (); @@ -368,16 +373,17 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_getSize dims[0] = dims[1] = 0; ptr = NSA_GET_PTR (env, obj); - + bin = list_get_widget (GTK_WIDGET (ptr)); + /* Save the widget's current size request. */ - gtk_widget_size_request (GTK_WIDGET (ptr), ¤t_req); + gtk_widget_size_request (bin, ¤t_req); /* Get the widget's "natural" size request. */ gtk_widget_set_size_request (GTK_WIDGET (ptr), -1, -1); - gtk_widget_size_request (GTK_WIDGET (ptr), &natural_req); + gtk_widget_size_request (bin, &natural_req); /* Reset the widget's size request. */ - gtk_widget_set_size_request (GTK_WIDGET (ptr), + gtk_widget_set_size_request (bin, current_req.width, current_req.height); dims[0] = natural_req.width; @@ -417,7 +423,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_getSelectedIndexes ptr = NSA_GET_PTR (env, obj); - list = gtk_bin_get_child (GTK_BIN (ptr)); + list = list_get_widget (GTK_WIDGET (ptr)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list)); count = gtk_tree_selection_count_selected_rows (selection); if (count > 0) @@ -463,7 +469,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_makeVisible ptr = NSA_GET_PTR (env, obj); - list = gtk_bin_get_child (GTK_BIN (ptr)); + list = list_get_widget (GTK_WIDGET (ptr)); path = gtk_tree_path_new_from_indices (index, -1); gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (list), path, NULL, FALSE, 0.0, 0.0); @@ -483,7 +489,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_setMultipleMode ptr = NSA_GET_PTR (env, obj); - list = gtk_bin_get_child (GTK_BIN (ptr)); + list = list_get_widget (GTK_WIDGET (ptr)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list)); gtk_tree_selection_set_mode (selection, mode ? GTK_SELECTION_MULTIPLE @@ -526,3 +532,18 @@ item_highlighted_cb (GtkTreeSelection *selection __attribute__((unused)), return TRUE; } + +static GtkWidget * +list_get_widget (GtkWidget *widget) +{ + GtkWidget *wid; + g_assert (GTK_IS_EVENT_BOX (widget)); + + wid = gtk_bin_get_child (GTK_BIN (widget)); + g_assert (GTK_IS_SCROLLED_WINDOW (wid)); + + wid = gtk_bin_get_child (GTK_BIN (wid)); + + return wid; +} + 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 1445cec55..a4690deed 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 @@ -43,22 +43,27 @@ exception statement from your version. */ #define AWT_SCROLLPANE_SCROLLBARS_ALWAYS 1 #define AWT_SCROLLPANE_SCROLLBARS_NEVER 2 +static GtkWidget *scrollpane_get_widget (GtkWidget *widget); + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_create (JNIEnv *env, jobject obj, int width, int height) { GtkWidget *sw; - + GtkWidget *eventbox; + gdk_threads_enter (); /* Create global reference and save it for future use */ NSA_SET_GLOBAL_REF (env, obj); sw = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_set_size_request (sw, width, height); + eventbox = gtk_event_box_new (); + gtk_container_add (GTK_CONTAINER (eventbox), sw); + gtk_widget_show (sw); - NSA_SET_PTR (env, obj, sw); + NSA_SET_PTR (env, obj, eventbox); gdk_threads_leave (); } @@ -75,7 +80,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_setScrollPosition ptr = NSA_GET_PTR (env, obj); - sw = GTK_SCROLLED_WINDOW (ptr); + sw = GTK_SCROLLED_WINDOW (scrollpane_get_widget (GTK_WIDGET (ptr))); hadj = gtk_scrolled_window_get_hadjustment (sw); vadj = gtk_scrolled_window_get_vadjustment (sw); @@ -98,7 +103,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_gtkScrolledWindowSetHScrollIncremen ptr = NSA_GET_PTR (env, obj); - sw = GTK_SCROLLED_WINDOW(ptr); + sw = GTK_SCROLLED_WINDOW (scrollpane_get_widget (GTK_WIDGET (ptr))); hadj = gtk_scrolled_window_get_hadjustment (sw); hadj->step_increment = u; @@ -118,7 +123,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_gtkScrolledWindowSetVScrollIncremen ptr = NSA_GET_PTR (env, obj); - sw = GTK_SCROLLED_WINDOW(ptr); + sw = GTK_SCROLLED_WINDOW (scrollpane_get_widget (GTK_WIDGET (ptr))); vadj = gtk_scrolled_window_get_hadjustment (sw); vadj->step_increment = u; @@ -140,7 +145,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_getHScrollbarHeight ptr = NSA_GET_PTR (env, obj); - sw = GTK_SCROLLED_WINDOW (ptr); + sw = GTK_SCROLLED_WINDOW (scrollpane_get_widget (GTK_WIDGET (ptr))); gtk_widget_size_request (sw->hscrollbar, &requisition); gtk_widget_style_get (GTK_WIDGET (sw), "scrollbar_spacing", &spacing, NULL); @@ -165,7 +170,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_getVScrollbarWidth ptr = NSA_GET_PTR (env, obj); - sw = GTK_SCROLLED_WINDOW (ptr); + sw = GTK_SCROLLED_WINDOW (scrollpane_get_widget (GTK_WIDGET (ptr))); gtk_widget_size_request (sw->vscrollbar, &requisition); gtk_widget_style_get (GTK_WIDGET (sw), "scrollbar_spacing", &spacing, NULL); @@ -181,7 +186,8 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_setPolicy (JNIEnv *env, jobject obj, jint policy) { void *ptr; - + GtkWidget *sw; + gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); @@ -199,7 +205,18 @@ Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_setPolicy break; } - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ptr), policy, policy); + sw = scrollpane_get_widget (GTK_WIDGET (ptr)); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), policy, policy); gdk_threads_leave (); } + +static GtkWidget * +scrollpane_get_widget (GtkWidget *widget) +{ + GtkWidget *wid; + g_assert (GTK_IS_EVENT_BOX (widget)); + wid = gtk_bin_get_child (GTK_BIN(widget)); + + return wid; +} 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 bec1e63c4..a90501968 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 @@ -48,6 +48,7 @@ exception statement from your version. */ #define AWT_ADJUSTMENT_TRACK 5 static jmethodID postAdjustmentEventID; +static GtkWidget *scrollbar_get_widget (GtkWidget *widget); void cp_gtk_scrollbar_init_jni (void) @@ -79,6 +80,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_create jint min, jint max, jint step_incr, jint page_incr, jint visible_amount) { GtkWidget *scrollbar; + GtkWidget *eventbox; GtkObject *adj; /* Create global reference and save it for future use */ @@ -104,7 +106,10 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_create scrollbar = orientation ? gtk_vscrollbar_new (GTK_ADJUSTMENT (adj)) : gtk_hscrollbar_new (GTK_ADJUSTMENT (adj)); - + eventbox = gtk_event_box_new (); + gtk_container_add (GTK_CONTAINER (eventbox), scrollbar); + gtk_widget_show (scrollbar); + GTK_RANGE (scrollbar)->round_digits = 0; /* These calls seem redundant but they are not. They clamp values so that the slider's entirety is always between the two @@ -114,7 +119,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_create gdk_threads_leave (); - NSA_SET_PTR (env, obj, scrollbar); + NSA_SET_PTR (env, obj, eventbox); } JNIEXPORT void JNICALL @@ -122,6 +127,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_connectSignals (JNIEnv *env, jobject obj) { void *ptr = NSA_GET_PTR (env, obj); + GtkWidget *wid = scrollbar_get_widget (GTK_WIDGET (ptr)); jobject *gref = NSA_GET_GLOBAL_REF (env, obj); g_assert (gref); @@ -129,15 +135,15 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_connectSignals /* Scrollbar signals */ #if GTK_MINOR_VERSION > 4 - g_signal_connect (G_OBJECT (ptr), "change-value", + g_signal_connect (G_OBJECT (wid), "change-value", G_CALLBACK (slider_moved_cb), *gref); #else - g_signal_connect (G_OBJECT (ptr), "value-changed", + g_signal_connect (G_OBJECT (wid), "value-changed", G_CALLBACK (post_change_event_cb), *gref); #endif /* Component signals */ - cp_gtk_component_connect_signals (G_OBJECT (ptr), gref); + cp_gtk_component_connect_signals (G_OBJECT (wid), gref); gdk_threads_leave (); } @@ -148,12 +154,14 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setLineIncrement { void *ptr; GtkAdjustment *adj; + GtkWidget *wid; ptr = NSA_GET_PTR (env, obj); - + wid = scrollbar_get_widget (GTK_WIDGET (ptr)); + gdk_threads_enter (); - adj = gtk_range_get_adjustment (GTK_RANGE (ptr)); + adj = gtk_range_get_adjustment (GTK_RANGE (wid)); adj->step_increment = (gdouble) amount; gtk_adjustment_changed (adj); @@ -166,12 +174,14 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setPageIncrement { void *ptr; GtkAdjustment *adj; - + GtkWidget *wid; + ptr = NSA_GET_PTR (env, obj); - + wid = scrollbar_get_widget (GTK_WIDGET (ptr)); + gdk_threads_enter (); - adj = gtk_range_get_adjustment (GTK_RANGE (ptr)); + adj = gtk_range_get_adjustment (GTK_RANGE (wid)); adj->page_increment = (gdouble) amount; gtk_adjustment_changed (adj); @@ -184,9 +194,11 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setBarValues { void *ptr; GtkAdjustment *adj; - + GtkWidget *wid; + ptr = NSA_GET_PTR (env, obj); - + wid = scrollbar_get_widget (GTK_WIDGET (ptr)); + gdk_threads_enter (); /* A little hack because gtk_range_set_range() doesn't allow min == max. */ @@ -197,11 +209,11 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setBarValues max++; } - adj = gtk_range_get_adjustment (GTK_RANGE (ptr)); + adj = gtk_range_get_adjustment (GTK_RANGE (wid)); adj->page_size = (gdouble) visible; - gtk_range_set_range (GTK_RANGE (ptr), (gdouble) min, (gdouble) max); - gtk_range_set_value (GTK_RANGE (ptr), (gdouble) value); + gtk_range_set_range (GTK_RANGE (wid), (gdouble) min, (gdouble) max); + gtk_range_set_value (GTK_RANGE (wid), (gdouble) value); gdk_threads_leave (); } @@ -214,7 +226,7 @@ slider_moved_cb (GtkRange *range, jobject obj) { GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (range)); - + value = CLAMP (value, adj->lower, (adj->upper - adj->page_size)); @@ -272,3 +284,13 @@ post_change_event_cb (GtkRange *range, jobject peer) AWT_ADJUSTMENT_TRACK, (jint) adj->value); } #endif + +static GtkWidget * +scrollbar_get_widget (GtkWidget *widget) +{ + GtkWidget *wid; + g_assert (GTK_IS_EVENT_BOX (widget)); + wid = gtk_bin_get_child (GTK_BIN(widget)); + + return wid; +} diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkSelection.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkSelection.c index 3244d2364..be03c4525 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkSelection.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkSelection.c @@ -1,5 +1,5 @@ /* gtkselection.c -- Native C functions for GtkSelection class using gtk+. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -149,9 +149,10 @@ clipboard_targets_received (GtkClipboard *clipboard JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkSelection_requestMimeTypes -(JNIEnv *env, jobject selection) +(JNIEnv *env, jobject selection, jboolean clipboard) { jobject selection_obj; + GtkClipboard *gtk_clipboard; selection_obj = (*env)->NewGlobalRef(env, selection); if (selection_obj == NULL) return; @@ -167,13 +168,18 @@ Java_gnu_java_awt_peer_gtk_GtkSelection_requestMimeTypes return; } + if (clipboard) + gtk_clipboard = cp_gtk_clipboard; + else + gtk_clipboard = cp_gtk_selection; + /* We would have liked to call gtk_clipboard_request_targets () since that is more general. But the result of that, an array of GdkAtoms, cannot be used with the gtk_selection_data_targets_include_<x> functions (despite what the name suggests). */ gdk_threads_enter (); - gtk_clipboard_request_contents (cp_gtk_clipboard, + gtk_clipboard_request_contents (gtk_clipboard, gdk_atom_intern ("TARGETS", FALSE), clipboard_targets_received, (gpointer) selection_obj); @@ -210,9 +216,10 @@ clipboard_text_received (GtkClipboard *clipboard JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkSelection_requestText -(JNIEnv *env, jobject selection) +(JNIEnv *env, jobject selection, jboolean clipboard) { jobject selection_obj; + GtkClipboard *gtk_clipboard; selection_obj = (*env)->NewGlobalRef(env, selection); if (selection_obj == NULL) return; @@ -228,8 +235,13 @@ Java_gnu_java_awt_peer_gtk_GtkSelection_requestText return; } + if (clipboard) + gtk_clipboard = cp_gtk_clipboard; + else + gtk_clipboard = cp_gtk_selection; + gdk_threads_enter (); - gtk_clipboard_request_text (cp_gtk_clipboard, + gtk_clipboard_request_text (gtk_clipboard, clipboard_text_received, (gpointer) selection_obj); gdk_threads_leave (); @@ -260,9 +272,12 @@ clipboard_image_received (GtkClipboard *clipboard } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkSelection_requestImage (JNIEnv *env, jobject obj) +Java_gnu_java_awt_peer_gtk_GtkSelection_requestImage (JNIEnv *env, + jobject obj, + jboolean clipboard) { jobject selection_obj; + GtkClipboard *gtk_clipboard; selection_obj = (*env)->NewGlobalRef(env, obj); if (selection_obj == NULL) return; @@ -278,14 +293,19 @@ Java_gnu_java_awt_peer_gtk_GtkSelection_requestImage (JNIEnv *env, jobject obj) return; } + if (clipboard) + gtk_clipboard = cp_gtk_clipboard; + else + gtk_clipboard = cp_gtk_selection; + #if GTK_MINOR_VERSION > 4 gdk_threads_enter (); - gtk_clipboard_request_image (cp_gtk_clipboard, + gtk_clipboard_request_image (gtk_clipboard, clipboard_image_received, (gpointer) selection_obj); gdk_threads_leave (); #else - clipboard_image_received (cp_gtk_clipboard, NULL, (gpointer) selection_obj); + clipboard_image_received (gtk_clipboard, NULL, (gpointer) selection_obj); #endif } @@ -342,12 +362,15 @@ clipboard_uris_received (GtkClipboard *clipboard } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkSelection_requestURIs (JNIEnv *env, jobject obj) +Java_gnu_java_awt_peer_gtk_GtkSelection_requestURIs (JNIEnv *env, + jobject obj, + jboolean clipboard) { #if GTK_MINOR_VERSION > 4 GdkAtom uri_atom; #endif jobject selection_obj; + GtkClipboard *gtk_clipboard; selection_obj = (*env)->NewGlobalRef(env, obj); if (selection_obj == NULL) return; @@ -363,17 +386,22 @@ Java_gnu_java_awt_peer_gtk_GtkSelection_requestURIs (JNIEnv *env, jobject obj) return; } + if (clipboard) + gtk_clipboard = cp_gtk_clipboard; + else + gtk_clipboard = cp_gtk_selection; + #if GTK_MINOR_VERSION > 4 /* There is no real request_uris so we have to make one ourselves. */ gdk_threads_enter (); uri_atom = gdk_atom_intern ("text/uri-list", FALSE); - gtk_clipboard_request_contents (cp_gtk_clipboard, + gtk_clipboard_request_contents (gtk_clipboard, uri_atom, clipboard_uris_received, (gpointer) selection_obj); gdk_threads_leave (); #else - clipboard_uris_received (cp_gtk_clipboard, NULL, (gpointer) selection_obj); + clipboard_uris_received (gtk_clipboard, NULL, (gpointer) selection_obj); #endif } @@ -406,12 +434,14 @@ clipboard_bytes_received (GtkClipboard *clipboard JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkSelection_requestBytes (JNIEnv *env, jobject obj, + jboolean clipboard, jstring target_string) { int len; const gchar *target_text; GdkAtom target_atom; jobject selection_obj; + GtkClipboard *gtk_clipboard; selection_obj = (*env)->NewGlobalRef(env, obj); if (selection_obj == NULL) return; @@ -434,9 +464,14 @@ Java_gnu_java_awt_peer_gtk_GtkSelection_requestBytes (JNIEnv *env, if (target_text == NULL) return; + if (clipboard) + gtk_clipboard = cp_gtk_clipboard; + else + gtk_clipboard = cp_gtk_selection; + gdk_threads_enter (); target_atom = gdk_atom_intern (target_text, FALSE); - gtk_clipboard_request_contents (cp_gtk_clipboard, + gtk_clipboard_request_contents (gtk_clipboard, target_atom, clipboard_bytes_received, (gpointer) selection_obj); 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 9af88a026..bd6e14d76 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 @@ -43,12 +43,16 @@ exception statement from your version. */ #define AWT_TEXTAREA_SCROLLBARS_VERTICAL_ONLY 1 #define AWT_TEXTAREA_SCROLLBARS_HORIZONTAL_ONLY 2 +static GtkWidget *textarea_get_widget (GtkWidget *widget); + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create (JNIEnv *env, jobject obj, jint textview_width, jint textview_height, jint scroll) { - GtkWidget *text, *sw; + GtkWidget *text; + GtkWidget *sw; + GtkWidget *eventbox; gdk_threads_enter (); @@ -61,9 +65,12 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create gtk_widget_show (text); + eventbox = gtk_event_box_new (); sw = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (sw), text); - + gtk_container_add (GTK_CONTAINER (eventbox), sw); + gtk_widget_show (sw); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), /* horizontal scrollbar */ (scroll == AWT_TEXTAREA_SCROLLBARS_BOTH @@ -79,7 +86,7 @@ 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); + NSA_SET_PTR (env, obj, eventbox); gdk_threads_leave (); } @@ -99,7 +106,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_connectSignals gref = NSA_GET_GLOBAL_REF (env, obj); /* Unwrap the text view from the scrolled window */ - text = gtk_bin_get_child (GTK_BIN (ptr)); + text = textarea_get_widget (GTK_WIDGET (ptr)); buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); @@ -127,7 +134,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_insert ptr = NSA_GET_PTR (env, obj); str = (*env)->GetStringUTFChars (env, contents, NULL); - text = gtk_bin_get_child (GTK_BIN (ptr)); + text = textarea_get_widget (GTK_WIDGET (ptr)); buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); gtk_text_buffer_get_iter_at_offset (buf, &iter, position); @@ -155,8 +162,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_replaceRange ptr = NSA_GET_PTR (env, obj); str = (*env)->GetStringUTFChars (env, contents, NULL); - text = gtk_bin_get_child (GTK_BIN (ptr)); - + text = textarea_get_widget (GTK_WIDGET (ptr)); + buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); gtk_text_buffer_get_iter_at_offset (buf, &startIter, mystart); @@ -183,8 +190,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkWidgetModifyFont gdk_threads_enter(); ptr = NSA_GET_PTR (env, obj); - - text = gtk_bin_get_child (GTK_BIN (ptr)); + + text = textarea_get_widget (GTK_WIDGET (ptr)); font_name = (*env)->GetStringUTFChars (env, name, NULL); @@ -218,7 +225,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkWidgetRequestFocus ptr = NSA_GET_PTR (env, obj); - text = gtk_bin_get_child (GTK_BIN (ptr)); + text = textarea_get_widget (GTK_WIDGET (ptr)); gtk_widget_grab_focus (text); @@ -230,6 +237,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getHScrollbarHeight (JNIEnv *env, jobject obj) { void *ptr; + GtkWidget *bin; GtkScrolledWindow *sw; GtkRequisition requisition; jint height = 0; @@ -239,7 +247,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getHScrollbarHeight ptr = NSA_GET_PTR (env, obj); - sw = GTK_SCROLLED_WINDOW (ptr); + bin = gtk_bin_get_child (GTK_BIN (ptr)); + sw = GTK_SCROLLED_WINDOW (bin); if (sw) { @@ -258,6 +267,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getVScrollbarWidth (JNIEnv *env, jobject obj) { void *ptr; + GtkWidget *bin; GtkScrolledWindow *sw; GtkRequisition requisition; jint width = 0; @@ -266,8 +276,9 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getVScrollbarWidth gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - - sw = GTK_SCROLLED_WINDOW (ptr); + + bin = gtk_bin_get_child (GTK_BIN (ptr)); + sw = GTK_SCROLLED_WINDOW (bin); if (sw) { @@ -295,8 +306,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getCaretPosition gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - - text = gtk_bin_get_child (GTK_BIN (ptr)); + + text = textarea_get_widget (GTK_WIDGET (ptr)); buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); mark = gtk_text_buffer_get_insert (buf); @@ -323,8 +334,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_setCaretPosition gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - - text = gtk_bin_get_child (GTK_BIN (ptr)); + + text = textarea_get_widget (GTK_WIDGET (ptr)); buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); @@ -366,7 +377,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getSelectionStart ptr = NSA_GET_PTR (env, obj); - text = gtk_bin_get_child (GTK_BIN (ptr)); + text = textarea_get_widget (GTK_WIDGET (ptr)); buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); @@ -403,7 +414,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getSelectionEnd ptr = NSA_GET_PTR (env, obj); - text = gtk_bin_get_child (GTK_BIN (ptr)); + text = textarea_get_widget (GTK_WIDGET (ptr)); buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); @@ -436,7 +447,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_select ptr = NSA_GET_PTR (env, obj); - text = gtk_bin_get_child (GTK_BIN (ptr)); + text = textarea_get_widget (GTK_WIDGET (ptr)); buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); gtk_text_buffer_get_iter_at_offset (buf, &iter, start); @@ -460,7 +471,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_setEditable ptr = NSA_GET_PTR (env, obj); - text = gtk_bin_get_child (GTK_BIN (ptr)); + text = textarea_get_widget (GTK_WIDGET (ptr)); gtk_text_view_set_editable (GTK_TEXT_VIEW (text), state); @@ -481,8 +492,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_getText gdk_threads_enter (); ptr = NSA_GET_PTR (env, obj); - - text = gtk_bin_get_child (GTK_BIN (ptr)); + + text = textarea_get_widget (GTK_WIDGET (ptr)); buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); gtk_text_buffer_get_start_iter (buf, &start); @@ -505,13 +516,13 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_setText 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)); + text = textarea_get_widget (GTK_WIDGET (ptr)); buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); gtk_text_buffer_set_text (buf, str, strlen (str)); @@ -520,3 +531,17 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_setText gdk_threads_leave (); } + +static GtkWidget * +textarea_get_widget (GtkWidget *widget) +{ + GtkWidget *wid; + g_assert (GTK_IS_EVENT_BOX (widget)); + + wid = gtk_bin_get_child (GTK_BIN (widget)); + g_assert (GTK_IS_SCROLLED_WINDOW (wid)); + + wid = gtk_bin_get_child (GTK_BIN (wid)); + + return wid; +} diff --git a/native/jni/gtk-peer/gtkpeer.h b/native/jni/gtk-peer/gtkpeer.h index f332b62a1..9a1590b81 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, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -167,8 +167,12 @@ JNIEnv *cp_gtk_gdk_env(void); extern double cp_gtk_dpi_conversion_factor; extern GtkWindowGroup *cp_gtk_global_window_group; -/* Shared global clipboard for GtkClipboard and GtkSelection. */ +/* Shared global clipboard and selection for GtkClipboard and GtkSelection. */ extern GtkClipboard *cp_gtk_clipboard; +extern GtkClipboard *cp_gtk_selection; + +extern jobject cp_gtk_clipboard_instance; +extern jobject cp_gtk_selection_instance; /* Standard target (strings) for GtkClipboard and GtkSelection. */ extern jstring cp_gtk_stringTarget; diff --git a/native/jni/java-io/Makefile.am b/native/jni/java-io/Makefile.am index 35afaae50..ac7cf2872 100644 --- a/native/jni/java-io/Makefile.am +++ b/native/jni/java-io/Makefile.am @@ -1,4 +1,4 @@ -nativelib_LTLIBRARIES = libjavaio.la +nativeexeclib_LTLIBRARIES = libjavaio.la libjavaio_la_SOURCES = java_io_VMFile.c \ java_io_VMObjectInputStream.c \ diff --git a/native/jni/java-lang/Makefile.am b/native/jni/java-lang/Makefile.am index db8a3a6a4..06deb62b8 100644 --- a/native/jni/java-lang/Makefile.am +++ b/native/jni/java-lang/Makefile.am @@ -1,4 +1,4 @@ -nativelib_LTLIBRARIES = libjavalang.la libjavalangreflect.la +nativeexeclib_LTLIBRARIES = libjavalang.la libjavalangreflect.la libjavalang_la_SOURCES = java_lang_VMSystem.c \ java_lang_VMFloat.c \ @@ -9,7 +9,7 @@ libjavalang_la_SOURCES = java_lang_VMSystem.c \ libjavalang_la_LIBADD = $(wildcard $(top_builddir)/native/fdlibm/*.lo) \ $(top_builddir)/native/jni/classpath/jcl.lo -libjavalangreflect_la_SOURCES = java_lang_reflect_Array.c +libjavalangreflect_la_SOURCES = java_lang_reflect_VMArray.c AM_LDFLAGS = @CLASSPATH_MODULE@ AM_CPPFLAGS = @CLASSPATH_INCLUDES@ -I$(top_srcdir)/native/fdlibm diff --git a/native/jni/java-lang/java_lang_reflect_Array.c b/native/jni/java-lang/java_lang_reflect_VMArray.c index 64ad202db..2db68ebf9 100644 --- a/native/jni/java-lang/java_lang_reflect_Array.c +++ b/native/jni/java-lang/java_lang_reflect_VMArray.c @@ -45,7 +45,7 @@ exception statement from your version. */ #include <config.h> #include <stddef.h> -#include "java_lang_reflect_Array.h" +#include "java_lang_reflect_VMArray.h" /* * Class: java_lang_reflect_Array @@ -53,7 +53,7 @@ exception statement from your version. */ * Signature: (Ljava/lang/Class;I)Ljava/lang/Object; */ JNIEXPORT jobject JNICALL -Java_java_lang_reflect_Array_createObjectArray +Java_java_lang_reflect_VMArray_createObjectArray (JNIEnv * env, jclass thisClass __attribute__ ((__unused__)), jclass arrayType, jint arrayLength) diff --git a/native/jni/java-net/Makefile.am b/native/jni/java-net/Makefile.am index 4bca9511e..5ad257f5a 100644 --- a/native/jni/java-net/Makefile.am +++ b/native/jni/java-net/Makefile.am @@ -1,4 +1,4 @@ -nativelib_LTLIBRARIES = libjavanet.la +nativeexeclib_LTLIBRARIES = libjavanet.la libjavanet_la_SOURCES = javanet.c \ javanet.h \ diff --git a/native/jni/java-nio/Makefile.am b/native/jni/java-nio/Makefile.am index 8fd5ba3ae..af564373b 100644 --- a/native/jni/java-nio/Makefile.am +++ b/native/jni/java-nio/Makefile.am @@ -1,4 +1,4 @@ -nativelib_LTLIBRARIES = libjavanio.la +nativeexeclib_LTLIBRARIES = libjavanio.la libjavanio_la_SOURCES = gnu_java_nio_VMPipe.c \ gnu_java_nio_VMSelector.c \ diff --git a/native/jni/java-util/Makefile.am b/native/jni/java-util/Makefile.am index 148e9ccbe..f06213f71 100644 --- a/native/jni/java-util/Makefile.am +++ b/native/jni/java-util/Makefile.am @@ -1,4 +1,4 @@ -nativelib_LTLIBRARIES = libjavautil.la +nativeexeclib_LTLIBRARIES = libjavautil.la libjavautil_la_SOURCES = java_util_VMTimeZone.c diff --git a/native/jni/midi-alsa/Makefile.am b/native/jni/midi-alsa/Makefile.am index b6498df2b..e45cb439e 100644 --- a/native/jni/midi-alsa/Makefile.am +++ b/native/jni/midi-alsa/Makefile.am @@ -1,4 +1,4 @@ -nativelib_LTLIBRARIES = libgjsmalsa.la +nativeexeclib_LTLIBRARIES = libgjsmalsa.la libgjsmalsa_la_SOURCES = gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.c \ gnu_javax_sound_midi_alsa_AlsaPortDevice.c \ diff --git a/native/jni/midi-dssi/Makefile.am b/native/jni/midi-dssi/Makefile.am index 6b1ef0407..8a466d61f 100644 --- a/native/jni/midi-dssi/Makefile.am +++ b/native/jni/midi-dssi/Makefile.am @@ -1,4 +1,4 @@ -nativelib_LTLIBRARIES = libgjsmdssi.la +nativeexeclib_LTLIBRARIES = libgjsmdssi.la libgjsmdssi_la_SOURCES = gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c \ gnu_javax_sound_midi_dssi_DSSISynthesizer.c \ diff --git a/native/jni/qt-peer/Makefile.am b/native/jni/qt-peer/Makefile.am index 031d58fee..d39271fe7 100644 --- a/native/jni/qt-peer/Makefile.am +++ b/native/jni/qt-peer/Makefile.am @@ -1,7 +1,7 @@ # Qt AWT backend for Classpath # -nativelib_LTLIBRARIES = libqtpeer.la +nativeexeclib_LTLIBRARIES = libqtpeer.la AM_LDFLAGS = @CLASSPATH_MODULE@ @QT_LIBS@ AM_CPPFLAGS = @CLASSPATH_INCLUDES@ diff --git a/native/jni/xmlj/Makefile.am b/native/jni/xmlj/Makefile.am index a210a59c7..3904dd58c 100644 --- a/native/jni/xmlj/Makefile.am +++ b/native/jni/xmlj/Makefile.am @@ -1,4 +1,4 @@ -nativelib_LTLIBRARIES = libxmlj.la +nativeexeclib_LTLIBRARIES = libxmlj.la libxmlj_la_SOURCES = \ xmlj_dom.c \ |