diff options
Diffstat (limited to 'libjava/jni')
15 files changed, 466 insertions, 476 deletions
diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c index a52f54ce35f..bce87371202 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c @@ -37,9 +37,11 @@ exception statement from your version. */ #include "gtkpeer.h" +#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" #include "gnu_java_awt_peer_gtk_GtkButtonPeer.h" -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_create +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkButtonPeer_create (JNIEnv *env, jobject obj) { GtkWidget *button; @@ -51,6 +53,33 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_create NSA_SET_PTR (env, obj, button); } +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkButtonPeer_connectJObject + (JNIEnv *env, jobject obj) +{ + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + gdk_threads_enter (); + + gtk_widget_realize (GTK_WIDGET (ptr)); + + connect_awt_hook (env, obj, 1, GTK_BUTTON(ptr)->event_window); + + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkButtonPeer_connectSignals + (JNIEnv *env, jobject obj) +{ + void *ptr = NSA_GET_PTR (env, obj); + + /* Connect the superclass signals. */ + Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env, obj); +} + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkSetFont (JNIEnv *env, jobject obj, jstring name, jint style, jint size) diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c index d0d95f9fab7..9789569ddad 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c @@ -104,25 +104,20 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeCreate } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_connectHooks +Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_connectSignals (JNIEnv *env, jobject obj) { void *ptr = NSA_GET_PTR (env, obj); - jobject peer; gdk_threads_enter (); - peer = (*env)->NewGlobalRef (env, obj); - - /* FIXME: when the widget goes away, we should get rid of the global - reference. */ - gtk_signal_connect (GTK_OBJECT (ptr), "toggled", - GTK_SIGNAL_FUNC (item_toggled), peer); + g_signal_connect (G_OBJECT (ptr), "toggled", + GTK_SIGNAL_FUNC (item_toggled), obj); gdk_threads_leave (); - /* Connect the superclass hooks. */ - Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectHooks (env, obj); + /* Connect the superclass signals. */ + Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env, obj); } JNIEXPORT void JNICALL diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c index b0130408c6b..7e915c876ba 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c @@ -200,6 +200,6 @@ connect_choice_item_selectable_hook (JNIEnv *env, jobject peer_obj, ie->peer_obj = (*env)->NewGlobalRef (env, peer_obj); ie->item_obj = (*env)->NewGlobalRef (env, item_obj); - gtk_signal_connect (GTK_OBJECT (item), "activate", + g_signal_connect (G_OBJECT (item), "activate", GTK_SIGNAL_FUNC (item_activate), ie); } diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c index cf197115aa5..a1327400335 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c @@ -75,16 +75,16 @@ Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env, gdk_threads_enter (); clipboard = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_signal_connect (GTK_OBJECT(clipboard), "selection_received", + g_signal_connect (G_OBJECT(clipboard), "selection_received", GTK_SIGNAL_FUNC (selection_received), NULL); - gtk_signal_connect (GTK_OBJECT(clipboard), "selection_clear_event", + g_signal_connect (G_OBJECT(clipboard), "selection_clear_event", GTK_SIGNAL_FUNC (selection_clear), NULL); gtk_selection_add_target (clipboard, GDK_SELECTION_PRIMARY, GDK_TARGET_STRING, 0); - gtk_signal_connect (GTK_OBJECT(clipboard), "selection_get", + g_signal_connect (G_OBJECT(clipboard), "selection_get", GTK_SIGNAL_FUNC (selection_get), NULL); gdk_threads_leave (); diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c index 70aabf0cad9..ee44ccc11fc 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c @@ -531,7 +531,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2Ljava_lang_O (*env)->ReleaseStringUTFChars (env, jname, name); } -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectHooks +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectJObject (JNIEnv *env, jobject obj) { void *ptr; @@ -539,12 +539,36 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectHooks ptr = NSA_GET_PTR (env, obj); gdk_threads_enter (); + gtk_widget_realize (GTK_WIDGET (ptr)); - if(GTK_IS_BUTTON(ptr)) - connect_awt_hook (env, obj, 1, GTK_BUTTON(ptr)->event_window); - else - connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window); + connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window); + + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals + (JNIEnv *env, jobject peer_obj) +{ + void *ptr; + + ptr = NSA_GET_PTR (env, peer_obj); + + gdk_threads_enter (); + + gtk_widget_realize (GTK_WIDGET (ptr)); + + /* FIXME: We could check here if this is a scrolled window with a + single child that does not have an associated jobject. This + means that it is one of our wrapped widgets like List or TextArea + and thus we could connect the signal to the child without having + to specialize this method. */ + + /* Connect EVENT signal, which happens _before_ any specific signal. */ + + g_signal_connect (GTK_OBJECT (ptr), "event", + G_CALLBACK (pre_event_handler), peer_obj); + gdk_threads_leave (); } diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c index 0411352c7ca..3a7ad6277b7 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c @@ -813,21 +813,35 @@ generates_key_typed_event (GdkEvent *event, GtkWidget *source) void awt_event_handler (GdkEvent *event) { - jobject *event_obj_ptr = NULL; - static guint32 button_click_time = 0; - static GdkWindow *button_window = NULL; - static guint button_number = -1; - static jint click_count = 1; - /* 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); - return; } - /* If it is not an input event, let the main loop handle it */ + 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; + + /* 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 */ + gdk_window_get_user_data (event->any.window, (void **) &event_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 @@ -839,12 +853,18 @@ awt_event_handler (GdkEvent *event) || event->type == GDK_FOCUS_CHANGE || event->type == GDK_MOTION_NOTIFY)) { - gtk_main_do_event (event); - return; + 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 */ - /* Handle input events */ - /* keep track of clickCount ourselves, since the AWT allows more than a triple click to occur */ if (event->type == GDK_BUTTON_PRESS) @@ -861,376 +881,247 @@ awt_event_handler (GdkEvent *event) button_number = event->button.button; } - /* for all input events, which have a window with a jobject attached, - send the input event off to Java before GTK has a chance to process - the event. Note that the jobject may be in the parent for widgets - that are always inside a scrolled window, like List */ - if (!gdk_property_get (event->any.window, - gdk_atom_intern ("_GNU_GTKAWT_ADDR", FALSE), - gdk_atom_intern ("CARDINAL", FALSE), - 0, - sizeof (jobject), - FALSE, - NULL, - NULL, - NULL, - (guchar **)&event_obj_ptr)) + switch (event->type) { - /* See if is contained in a scrolled pane */ - GtkWidget *widget; - gdk_window_get_user_data (event->any.window, (void **) &widget); - - if ((gtk_widget_get_parent (widget) != NULL) - && (gtk_widget_get_parent (widget)->window != NULL)) - { - GtkWidget *parent = gtk_widget_get_parent (widget); - - if (GTK_IS_SCROLLED_WINDOW (parent)) - gdk_property_get (gtk_widget_get_parent (widget)->window, - gdk_atom_intern ("_GNU_GTKAWT_ADDR", FALSE), - gdk_atom_intern ("CARDINAL", FALSE), - 0, - sizeof (jobject), - FALSE, - NULL, - NULL, - NULL, - (guchar **)&event_obj_ptr); - } - } - - if (event_obj_ptr) - { - GtkWidget *event_widget; - GtkWidget *grab_widget; - jobject *grab_obj_ptr = NULL; - void *ptr; - - /* Implement modality using GTK grabs. */ - g_assert (global_gtk_window_group); - if (global_gtk_window_group->grabs) - { - grab_widget = global_gtk_window_group->grabs->data; - g_assert (grab_widget); - - ptr = NSA_GET_PTR (gdk_env, *event_obj_ptr); - event_widget = GTK_WIDGET(ptr); - - /* Don't need to do this if it is the same widget as we - * already got the jobject above. - * Also, don't do it for the BUTTON_PRESS as the focus may be - * changing and the event widget is the one that must - * receive it (again, we have the jobject already) - */ - if ((event_widget != grab_widget) - && (event->type != GDK_BUTTON_PRESS)) - { - /* If the grab widget is an ancestor of the event widget - * then we send the event to the original event widget. - * This is the key to implementing modality. - * Unless the widget is disabled, in this case the grab - * widget still gets the event. - * XXX: But the grab widget may not be an ancestor!!! - */ - if (!GTK_WIDGET_IS_SENSITIVE (event_widget) - || !gtk_widget_is_ancestor (event_widget, grab_widget)) - { - gdk_property_get (grab_widget->window, - gdk_atom_intern ("_GNU_GTKAWT_ADDR", FALSE), - gdk_atom_intern ("CARDINAL", FALSE), - 0, - sizeof (jobject), - FALSE, - NULL, - NULL, - NULL, - (guchar **)&grab_obj_ptr); - - } - } - } - - if (!grab_obj_ptr) - grab_obj_ptr = event_obj_ptr; - else - g_free (event_obj_ptr); - - switch (event->type) - { - case GDK_BUTTON_PRESS: - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, 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); - - /* grab_counter++; - gdk_pointer_grab (event->any.window, - FALSE, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_MOTION_MASK | - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK, - NULL, - NULL, - event->button.time);*/ - break; - case GDK_BUTTON_RELEASE: - { - int width, height; - - /* only ungrab if no other buttons are pressed down */ - /* if (--grab_counter == 0) - gdk_pointer_ungrab (event->button.time); - */ - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, - postMouseEventID, - AWT_MOUSE_RELEASED, - (jlong)event->button.time, + case GDK_BUTTON_PRESS: + (*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); + break; + case GDK_BUTTON_RELEASE: + { + int width, height; + + (*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); - - /* check to see if the release occured in the window it was pressed - in, and if so, generate an AWT click event */ - gdk_window_get_size (event->any.window, &width, &height); - if (event->button.x >= 0 - && event->button.y >= 0 - && event->button.x <= width - && event->button.y <= height) - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, - 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); - - } - break; - case GDK_MOTION_NOTIFY: - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, postMouseEventID, - AWT_MOUSE_MOVED, + (jint)event->button.x, + (jint)event->button.y, + click_count, + JNI_FALSE); + + /* check to see if the release occured in the window it was pressed + in, and if so, generate an AWT click event */ + gdk_window_get_size (event->any.window, &width, &height); + if (event->button.x >= 0 + && event->button.y >= 0 + && event->button.x <= width + && event->button.y <= height) + { + (*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); + } + } + break; + case GDK_MOTION_NOTIFY: + (*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); + + if (event->motion.state & (GDK_BUTTON1_MASK + | GDK_BUTTON2_MASK + | GDK_BUTTON3_MASK + | GDK_BUTTON4_MASK + | GDK_BUTTON5_MASK)) + { + (*gdk_env)->CallVoidMethod (gdk_env, peer, + postMouseEventID, + AWT_MOUSE_DRAGGED, (jlong)event->motion.time, state_to_awt_mods (event->motion.state), (jint)event->motion.x, (jint)event->motion.y, - 0, JNI_FALSE); - - if (event->motion.state & (GDK_BUTTON1_MASK - | GDK_BUTTON2_MASK - | GDK_BUTTON3_MASK - | GDK_BUTTON4_MASK - | GDK_BUTTON5_MASK)) - { - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, - postMouseEventID, - AWT_MOUSE_DRAGGED, - (jlong)event->motion.time, - state_to_awt_mods (event->motion.state), - (jint)event->motion.x, - (jint)event->motion.y, - 0, JNI_FALSE); - } - break; - case GDK_ENTER_NOTIFY: - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, postMouseEventID, - AWT_MOUSE_ENTERED, - (jlong)event->crossing.time, - state_to_awt_mods (event->crossing.state), - (jint)event->crossing.x, - (jint)event->crossing.y, - 0, JNI_FALSE); - break; - case GDK_LEAVE_NOTIFY: - if (event->crossing.mode == GDK_CROSSING_NORMAL) - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, - postMouseEventID, - AWT_MOUSE_EXITED, - (jlong)event->crossing.time, + 0, + JNI_FALSE); + } + break; + case GDK_ENTER_NOTIFY: + (*gdk_env)->CallVoidMethod (gdk_env, peer, postMouseEventID, + AWT_MOUSE_ENTERED, + (jlong)event->crossing.time, + state_to_awt_mods (event->crossing.state), + (jint)event->crossing.x, + (jint)event->crossing.y, + 0, + JNI_FALSE); + break; + case GDK_LEAVE_NOTIFY: + if (event->crossing.mode == GDK_CROSSING_NORMAL) + (*gdk_env)->CallVoidMethod (gdk_env, peer, + postMouseEventID, + AWT_MOUSE_EXITED, + (jlong)event->crossing.time, state_to_awt_mods (event->crossing.state), - (jint)event->crossing.x, - (jint)event->crossing.y, - 0, JNI_FALSE); - break; - case GDK_CONFIGURE: - { - GtkWidget *widget; - - gdk_window_get_user_data (event->any.window, (void **) &widget); + (jint)event->crossing.x, + (jint)event->crossing.y, + 0, + JNI_FALSE); + break; + case GDK_CONFIGURE: + { + /* GtkWidget *widget; + + gdk_window_get_user_data (event->any.window, (void **) &widget); */ - if (widget && GTK_WIDGET_TOPLEVEL (widget)) - { - gint top, left, right, bottom; - - /* 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 (); - - /* FIXME: hard-code these values for now. */ - top = 20; - left = 6; - bottom = 6; - right = 6; - - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, - postConfigureEventID, - (jint) event->configure.x, - (jint) event->configure.y, - (jint) event->configure.width, - (jint) event->configure.height, - (jint) top, - (jint) left, - (jint) bottom, - (jint) right); - gdk_threads_enter (); - } - } - break; - case GDK_EXPOSE: + if (widget && GTK_WIDGET_TOPLEVEL (widget)) { - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, - postExposeEventID, - (jint)event->expose.area.x, - (jint)event->expose.area.y, - (jint)event->expose.area.width, - (jint)event->expose.area.height); + gint top, left, right, bottom; + + /* 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 (); + + /* FIXME: hard-code these values for now. */ + top = 20; + left = 6; + bottom = 6; + right = 6; + + (*gdk_env)->CallVoidMethod (gdk_env, peer, + postConfigureEventID, + (jint) event->configure.x, + (jint) event->configure.y, + (jint) event->configure.width, + (jint) event->configure.height, + (jint) top, + (jint) left, + (jint) bottom, + (jint) right); + gdk_threads_enter (); } - break; - - case GDK_KEY_PRESS: + } + break; + case GDK_EXPOSE: + { + (*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); + } + break; + case GDK_FOCUS_CHANGE: + (*gdk_env)->CallVoidMethod (gdk_env, peer, + postFocusEventID, + (jint) (event->focus_change.in) ? + AWT_FOCUS_GAINED : AWT_FOCUS_LOST, + JNI_FALSE); + break; + case GDK_KEY_PRESS: + case GDK_KEY_RELEASE: + { + GtkWindow *window; + GdkWindow *obj_window; + jobject *focus_obj_ptr = NULL; + + /* A widget with a grab will get key events */ + if (!GTK_IS_WINDOW (widget)) + *focus_obj_ptr = peer; + else { - GtkWidget *widget; - GtkWindow *window; - /* The window to which the Java peer is attached. */ - GdkWindow *obj_window; - - gdk_window_get_user_data (event->any.window, (void **) &widget); - - window = GTK_WINDOW (gtk_widget_get_ancestor (widget, - GTK_TYPE_WINDOW)); - if (window - && GTK_WIDGET_IS_SENSITIVE (window) - && window->focus_widget - && GTK_WIDGET_IS_SENSITIVE (window->focus_widget) - && window->focus_widget->window) - { - gtk_widget_activate (window->focus_widget); - - /* TextArea peers are attached to the scrolled window - that contains the GtkTextView, not to the text view - itself. */ - if (GTK_IS_TEXT_VIEW (window->focus_widget) - || GTK_IS_CLIST (window->focus_widget)) - obj_window = gtk_widget_get_parent (window->focus_widget)->window; - else - obj_window = window->focus_widget->window; - - gdk_property_get (obj_window, - gdk_atom_intern ("_GNU_GTKAWT_ADDR", FALSE), - gdk_atom_intern ("CARDINAL", FALSE), - 0, - sizeof (jobject), - FALSE, - NULL, - NULL, - NULL, - (guchar **)&grab_obj_ptr); - - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, - 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)); - - if (generates_key_typed_event (event, window->focus_widget)) - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, - postKeyEventID, - (jint) AWT_KEY_TYPED, - (jlong) event->key.time, - state_to_awt_mods (event->key.state), - VK_UNDEFINED, - keyevent_to_awt_keychar (event), - AWT_KEY_LOCATION_UNKNOWN); - } - } - break; - case GDK_KEY_RELEASE: + /* Check if we have an enabled focused widget in this window. + If not don't handle the event. */ + window = GTK_WINDOW (widget); + if (!window->focus_widget + || !GTK_WIDGET_IS_SENSITIVE (window->focus_widget) + || !window->focus_widget->window) + return FALSE; + + /* TextArea peers are attached to the scrolled window + that contains the GtkTextView, not to the text view + itself. Same for List. */ + if (GTK_IS_TEXT_VIEW (window->focus_widget) + || GTK_IS_CLIST (window->focus_widget)) + { + obj_window = gtk_widget_get_parent (window->focus_widget)->window; + } + else + obj_window = window->focus_widget->window; + + gdk_property_get (obj_window, + gdk_atom_intern ("_GNU_GTKAWT_ADDR", FALSE), + gdk_atom_intern ("CARDINAL", FALSE), + 0, + sizeof (jobject), + FALSE, + NULL, + NULL, + NULL, + (guchar **)&focus_obj_ptr); + + /* If the window has no jobject attached we can't send anything */ + if (!focus_obj_ptr) + return FALSE; + } + + if (event->type == GDK_KEY_PRESS) { - GtkWidget *widget; - GtkWindow *window; - GdkWindow *obj_window; - - gdk_window_get_user_data (event->any.window, (void **) &widget); - - window = GTK_WINDOW (gtk_widget_get_ancestor (widget, - GTK_TYPE_WINDOW)); - if (window - && GTK_WIDGET_IS_SENSITIVE (window) - && window->focus_widget - && GTK_WIDGET_IS_SENSITIVE (window->focus_widget) - && window->focus_widget->window) - { - gtk_widget_activate (window->focus_widget); - - if (GTK_IS_TEXT_VIEW (window->focus_widget) - || GTK_IS_CLIST (window->focus_widget)) - obj_window = gtk_widget_get_parent (window->focus_widget)->window; - else - obj_window = window->focus_widget->window; - - gdk_property_get (obj_window, - gdk_atom_intern ("_GNU_GTKAWT_ADDR", FALSE), - gdk_atom_intern ("CARDINAL", FALSE), - 0, - sizeof (jobject), - FALSE, - NULL, - NULL, - NULL, - (guchar **)&grab_obj_ptr); - - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, - 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_env)->CallVoidMethod (gdk_env, *focus_obj_ptr, + 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)); + + if (generates_key_typed_event (event, window->focus_widget)) + { + (*gdk_env)->CallVoidMethod (gdk_env, *focus_obj_ptr, + postKeyEventID, + (jint) AWT_KEY_TYPED, + (jlong) event->key.time, + state_to_awt_mods (event->key.state), + VK_UNDEFINED, + keyevent_to_awt_keychar (event), + AWT_KEY_LOCATION_UNKNOWN); } } - break; - case GDK_FOCUS_CHANGE: - (*gdk_env)->CallVoidMethod (gdk_env, *grab_obj_ptr, - postFocusEventID, - (jint) (event->focus_change.in) ? - AWT_FOCUS_GAINED : AWT_FOCUS_LOST, - JNI_FALSE); - break; - default: - break; - } - g_free (grab_obj_ptr); + else /* GDK_KEY_RELEASE */ + { + (*gdk_env)->CallVoidMethod (gdk_env, *focus_obj_ptr, + 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)); + } + } + break; + default: + break; } - - gtk_main_do_event (event); + + return FALSE; } static void @@ -1285,3 +1176,4 @@ connect_awt_hook (JNIEnv *env, jobject peer_obj, int nwindows, ...) } va_end (ap); } + diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c index 2308d1100ed..cb065d51894 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c @@ -57,15 +57,15 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_create } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_connectHooks +Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_connectJObject (JNIEnv *env, jobject obj) { void *ptr = NSA_GET_PTR (env, obj); gdk_threads_enter (); - /* NOTE: we don't call the superclass connect method here. */ gtk_widget_realize (GTK_WIDGET (ptr)); + connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window); gdk_threads_leave (); diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c index 94c303e0cdd..7bc4c6dabb1 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c @@ -37,10 +37,18 @@ exception statement from your version. */ #include "gtkpeer.h" +#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" #include "gnu_java_awt_peer_gtk_GtkListPeer.h" -static void -connect_selectable_hook (JNIEnv *env, jobject peer_obj, GtkCList *list); +static void item_select (GtkCList *list __attribute__((unused)), + int row, int col __attribute__((unused)), + GdkEventButton *event __attribute__((unused)), + jobject peer_obj); +static void item_unselect (GtkCList *list __attribute__((unused)), + int row, + int col __attribute__((unused)), + GdkEventButton *event __attribute__((unused)), + jobject peer_obj); #define CLIST_FROM_SW(obj) (GTK_CLIST(GTK_SCROLLED_WINDOW (obj)->container.child)) @@ -64,7 +72,7 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_create } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_connectHooks +Java_gnu_java_awt_peer_gtk_GtkListPeer_connectJObject (JNIEnv *env, jobject obj) { void *ptr; @@ -72,76 +80,61 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_connectHooks ptr = NSA_GET_PTR (env, obj); gdk_threads_enter (); + gtk_widget_realize (GTK_WIDGET (ptr)); - connect_selectable_hook (env, obj, CLIST_FROM_SW (ptr)); + connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window); + gdk_threads_leave (); } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_append - (JNIEnv *env, jobject obj, jobjectArray items) +Java_gnu_java_awt_peer_gtk_GtkListPeer_connectSignals + (JNIEnv *env, jobject peer_obj) { - void *ptr; GtkCList *list; - jint count, i; - - ptr = NSA_GET_PTR (env, obj); + void *ptr; - count = (*env)->GetArrayLength (env, items); + ptr = NSA_GET_PTR (env, peer_obj); gdk_threads_enter (); + + gtk_widget_realize (GTK_WIDGET (ptr)); + + /* connect selectable hook */ + list = CLIST_FROM_SW (ptr); - for (i = 0; i < count; i++) - { - const char *text; - jobject item; - item = (*env)->GetObjectArrayElement (env, items, i); + g_signal_connect (G_OBJECT (list), "select_row", + GTK_SIGNAL_FUNC (item_select), peer_obj); - text = (*env)->GetStringUTFChars (env, item, NULL); - gtk_clist_append (list, (char **)&text); - (*env)->ReleaseStringUTFChars (env, item, text); - } + g_signal_connect (G_OBJECT (list), "unselect_row", + GTK_SIGNAL_FUNC (item_unselect), peer_obj); + + /* 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, peer_obj); */ + g_signal_connect (GTK_OBJECT (list), "event", + G_CALLBACK (pre_event_handler), peer_obj); - gtk_clist_columns_autosize (list); gdk_threads_leave (); } - JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_old_create - (JNIEnv *env, jobject obj, jobject parent_obj, - jobjectArray items, jboolean mode) +Java_gnu_java_awt_peer_gtk_GtkListPeer_append + (JNIEnv *env, jobject obj, jobjectArray items) { - GtkWidget *list, *sw, *parent; - jsize count, i; + void *ptr; + GtkCList *list; + jint count, i; - parent = NSA_GET_PTR (env, parent_obj); + ptr = NSA_GET_PTR (env, obj); count = (*env)->GetArrayLength (env, items); gdk_threads_enter (); - - list = gtk_clist_new (1); - gtk_widget_show (list); - - sw = gtk_scrolled_window_new (NULL, NULL); - set_parent (sw, GTK_CONTAINER (parent)); - gtk_widget_realize (sw); - - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (sw), list); - - connect_selectable_hook (env, obj, GTK_CLIST (list)); - connect_awt_hook (env, obj, 1, list->window); - - gtk_clist_set_selection_mode (GTK_CLIST (list), - mode ? GTK_SELECTION_MULTIPLE : - GTK_SELECTION_SINGLE); - + list = CLIST_FROM_SW (ptr); for (i = 0; i < count; i++) { const char *text; @@ -150,14 +143,12 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_old_create item = (*env)->GetObjectArrayElement (env, items, i); text = (*env)->GetStringUTFChars (env, item, NULL); - gtk_clist_append (GTK_CLIST (list), (char **)&text); + gtk_clist_append (list, (char **)&text); (*env)->ReleaseStringUTFChars (env, item, text); } - gtk_clist_columns_autosize (GTK_CLIST (list)); + gtk_clist_columns_autosize (list); gdk_threads_leave (); - - NSA_SET_PTR (env, obj, sw); } JNIEXPORT void JNICALL @@ -326,9 +317,9 @@ static void item_select (GtkCList *list __attribute__((unused)), int row, int col __attribute__((unused)), GdkEventButton *event __attribute__((unused)), - jobject *peer_obj) + jobject peer_obj) { - (*gdk_env)->CallVoidMethod (gdk_env, *peer_obj, + (*gdk_env)->CallVoidMethod (gdk_env, peer_obj, postListItemEventID, row, (jint) AWT_ITEM_SELECTED); @@ -339,25 +330,11 @@ item_unselect (GtkCList *list __attribute__((unused)), int row, int col __attribute__((unused)), GdkEventButton *event __attribute__((unused)), - jobject *peer_obj) + jobject peer_obj) { - (*gdk_env)->CallVoidMethod (gdk_env, *peer_obj, + (*gdk_env)->CallVoidMethod (gdk_env, peer_obj, postListItemEventID, row, (jint) AWT_ITEM_DESELECTED); } -static void -connect_selectable_hook (JNIEnv *env, jobject peer_obj, GtkCList *list) -{ - jobject *obj; - - obj = (jobject *) malloc (sizeof (jobject)); - *obj = (*env)->NewGlobalRef (env, peer_obj); - - gtk_signal_connect (GTK_OBJECT (list), "select_row", - GTK_SIGNAL_FUNC (item_select), obj); - - gtk_signal_connect (GTK_OBJECT (list), "unselect_row", - GTK_SIGNAL_FUNC (item_unselect), obj); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c index 10c9e4cab74..f7c704110b7 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c @@ -109,6 +109,6 @@ connect_activate_hook (JNIEnv *env, jobject peer_obj, GtkMenuItem *item) obj = (jobject *) malloc (sizeof (jobject)); *obj = (*env)->NewGlobalRef (env, peer_obj); - gtk_signal_connect (GTK_OBJECT (item), "activate", + g_signal_connect (G_OBJECT (item), "activate", GTK_SIGNAL_FUNC (item_activate), obj); } diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c index e8cd78cb11d..3de02d54f85 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c @@ -66,7 +66,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_setupAccelGroup if (GTK_WIDGET_REALIZED (GTK_WIDGET (ptr1))) accel_attach (GTK_MENU_ITEM (ptr1), NULL); else - gtk_signal_connect (GTK_OBJECT (ptr1), + g_signal_connect (G_OBJECT (ptr1), "realize", GTK_SIGNAL_FUNC (accel_attach), NULL); diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c index 5d389895456..72a96c61736 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c @@ -37,6 +37,7 @@ exception statement from your version. */ #include "gtkpeer.h" +#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" #include "gnu_java_awt_peer_gtk_GtkPanelPeer.h" JNIEXPORT void JNICALL @@ -61,7 +62,7 @@ struct _GtkLayoutChild { }; JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkPanelPeer_connectHooks +Java_gnu_java_awt_peer_gtk_GtkPanelPeer_connectJObject (JNIEnv *env, jobject obj) { void *ptr; @@ -72,9 +73,26 @@ Java_gnu_java_awt_peer_gtk_GtkPanelPeer_connectHooks gtk_widget_realize (GTK_WIDGET (ptr)); connect_awt_hook (env, obj, 1, GTK_LAYOUT (ptr)->bin_window); -/* gtk_signal_connect (GTK_OBJECT (ptr), "size_request", GTK_SIGNAL_FUNC (sr), */ + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkPanelPeer_connectSignals + (JNIEnv *env, jobject obj) +{ + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + gdk_threads_enter (); + gtk_widget_realize (GTK_WIDGET (ptr)); + +/* g_signal_connect (G_OBJECT (ptr), "size_request", GTK_SIGNAL_FUNC (sr), */ /* NULL); */ gdk_threads_leave (); + + /* Connect the superclass signals. */ + Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env, obj); } /* diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c index 2bd3df8cf35..1b56d08317f 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c @@ -37,6 +37,7 @@ exception statement from your version. */ #include "gtkpeer.h" +#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" #include "gnu_java_awt_peer_gtk_GtkScrollbarPeer.h" struct range_scrollbar @@ -120,7 +121,24 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_create } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_connectHooks +Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_connectJObject + (JNIEnv *env, jobject obj) +{ + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + gdk_threads_enter (); + + gtk_widget_realize (GTK_WIDGET (ptr)); + + connect_awt_hook (env, obj, 1, GTK_SCROLLBAR (ptr)->range); + + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_connectSignals (JNIEnv *env, jobject obj) { void *ptr; @@ -136,17 +154,19 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_connectHooks rs->range = GTK_RANGE (ptr); rs->scrollbar = (jobject *) malloc (sizeof (jobject)); *(rs->scrollbar) = (*env)->NewGlobalRef (env, obj); - gtk_signal_connect (GTK_OBJECT (GTK_RANGE (ptr)), + + g_signal_connect (G_OBJECT (GTK_RANGE (ptr)), "move-slider", GTK_SIGNAL_FUNC (post_adjustment_event), rs); - gtk_signal_connect (GTK_OBJECT (GTK_RANGE (ptr)), + g_signal_connect (G_OBJECT (GTK_RANGE (ptr)), "value-changed", GTK_SIGNAL_FUNC (post_change_event), rs); - - connect_awt_hook (env, obj, 1, GTK_SCROLLBAR (ptr)->range); gdk_threads_leave (); + + /* Connect the superclass signals. */ + Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env, obj); } diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c index b4a00e1288d..69e8b0abc49 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c @@ -48,7 +48,7 @@ static void textcomponent_changed_cb (GtkEditable *editable, jobject peer); JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_connectHooks +Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_connectSignals (JNIEnv *env, jobject obj) { void *ptr; @@ -66,6 +66,11 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_connectHooks g_signal_connect (GTK_EDITABLE (ptr), "changed", G_CALLBACK (textcomponent_changed_cb), obj); + + gdk_threads_leave (); + + /* Connect the superclass signals. */ + Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env, obj); } else { @@ -87,13 +92,18 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_connectHooks if (buf) g_signal_connect (buf, "changed", G_CALLBACK (textcomponent_changed_cb), obj); - } - } - gdk_threads_leave (); + /* 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, + peer_obj); */ + g_signal_connect (GTK_OBJECT (text), "event", + G_CALLBACK (pre_event_handler), obj); - /* Connect the superclass hooks. */ - Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectHooks (env, obj); + gdk_threads_leave (); + } + } } JNIEXPORT jint JNICALL diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c index d71f36a4298..3986a1fd22c 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c @@ -37,6 +37,7 @@ exception statement from your version. */ #include "gtkpeer.h" +#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" #include "gnu_java_awt_peer_gtk_GtkWindowPeer.h" #include "gnu_java_awt_peer_gtk_GtkFramePeer.h" #include <gdk/gdkprivate.h> @@ -116,7 +117,8 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_create NSA_SET_PTR (env, obj, window_widget); } -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisible +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisible (JNIEnv *env, jobject obj, jboolean visible) { void *ptr; @@ -135,7 +137,8 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisible gdk_threads_leave (); } -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectHooks +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectJObject (JNIEnv *env, jobject obj) { void *ptr; @@ -169,6 +172,21 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectHooks connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window); + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectSignals + (JNIEnv *env, jobject obj) +{ + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + gdk_threads_enter (); + + gtk_widget_realize (ptr); + /* Connect signals for window event support. */ g_signal_connect (G_OBJECT (ptr), "delete-event", G_CALLBACK (window_delete_cb), obj); @@ -189,6 +207,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectHooks G_CALLBACK (window_window_state_cb), obj); gdk_threads_leave (); + + /* Connect the superclass signals. */ + Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (env, obj); } /* diff --git a/libjava/jni/gtk-peer/gtkpeer.h b/libjava/jni/gtk-peer/gtkpeer.h index 8f8ec40c08c..55d5e3dce21 100644 --- a/libjava/jni/gtk-peer/gtkpeer.h +++ b/libjava/jni/gtk-peer/gtkpeer.h @@ -392,6 +392,10 @@ 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 set_visible (GtkWidget *widget, jboolean visible); |