Yeah it's definitely related to this. I found out that using the
recursive lock instead of the GTK lock helps already. Not sure how to
solve this yet, had no time to dig this.
Currently testing a fix...
Cool. Keep me updated.
Committing the attached patch, which resolves the deadlock... the same
"unlocked" pattern has been used for a number of other GTK methods, and
seems appropriate here too.
Unfortunately, graphics still don't seem to work - mouse events don't
seem to register (clicking on buttons in the Swing demo has no effect,
for example)...
2007-08-23 Francis Kung <[EMAIL PROTECTED]>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java:
(getLocationOnScreen): Check for GTK main thread.
(gtkWidgetGetLocationOnScreenUnlocked): New native method.
(gtkWindowGetLocationOnScreenUnlocked): New native method.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c:
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWindowGetLocationOnScreen):
Delegate to unlocked function.
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWindowGetLocationOnScreenUnlocked):
New function.
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen):
Delegate to unlocked function.
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreenUnlocked):
New function.
Index: gnu/java/awt/peer/gtk/GtkComponentPeer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java,v
retrieving revision 1.128
diff -u -r1.128 GtkComponentPeer.java
--- gnu/java/awt/peer/gtk/GtkComponentPeer.java 25 Jun 2007 11:25:52 -0000 1.128
+++ gnu/java/awt/peer/gtk/GtkComponentPeer.java 23 Aug 2007 20:02:37 -0000
@@ -106,7 +106,9 @@
native void gtkWidgetGetDimensions (int[] dim);
native void gtkWidgetGetPreferredDimensions (int[] dim);
native void gtkWindowGetLocationOnScreen (int[] point);
+ native void gtkWindowGetLocationOnScreenUnlocked (int[] point);
native void gtkWidgetGetLocationOnScreen (int[] point);
+ native void gtkWidgetGetLocationOnScreenUnlocked (int[] point);
native void gtkWidgetSetCursor (int type, GtkImage image, int x, int y);
native void gtkWidgetSetCursorUnlocked (int type, GtkImage image,
int x, int y);
@@ -252,9 +254,19 @@
{
int point[] = new int[2];
if( this instanceof WindowPeer )
- gtkWindowGetLocationOnScreen (point);
+ {
+ if (Thread.currentThread() == GtkMainThread.mainThread)
+ gtkWindowGetLocationOnScreenUnlocked (point);
+ else
+ gtkWindowGetLocationOnScreen (point);
+ }
else
- gtkWidgetGetLocationOnScreen (point);
+ {
+ if (Thread.currentThread() == GtkMainThread.mainThread)
+ gtkWidgetGetLocationOnScreenUnlocked (point);
+ else
+ gtkWidgetGetLocationOnScreen (point);
+ }
return new Point (point[0], point[1]);
}
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c,v
retrieving revision 1.67
diff -u -r1.67 gnu_java_awt_peer_gtk_GtkComponentPeer.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c 25 Apr 2007 14:53:04 -0000 1.67
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c 23 Aug 2007 20:02:37 -0000
@@ -517,19 +517,27 @@
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWindowGetLocationOnScreen
(JNIEnv * env, jobject obj, jintArray jpoint)
{
+ gdk_threads_enter();
+
+ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWindowGetLocationOnScreenUnlocked
+ (env, obj, jpoint);
+
+ gdk_threads_leave();
+
+}
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWindowGetLocationOnScreenUnlocked
+ (JNIEnv * env, jobject obj, jintArray jpoint)
+{
void *ptr;
jint *point;
- gdk_threads_enter ();
-
ptr = gtkpeer_get_widget (env, obj);
point = (*env)->GetIntArrayElements (env, jpoint, 0);
gdk_window_get_root_origin (get_widget(GTK_WIDGET (ptr))->window, point, point+1);
(*env)->ReleaseIntArrayElements(env, jpoint, point, 0);
-
- gdk_threads_leave ();
}
/*
@@ -539,12 +547,22 @@
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen
(JNIEnv * env, jobject obj, jintArray jpoint)
{
+ gdk_threads_enter();
+
+ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreenUnlocked
+ (env, obj, jpoint);
+
+ gdk_threads_leave();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreenUnlocked
+ (JNIEnv * env, jobject obj, jintArray jpoint)
+{
void *ptr;
jint *point;
GtkWidget *widget;
- gdk_threads_enter ();
-
ptr = gtkpeer_get_widget (env, obj);
point = (*env)->GetIntArrayElements (env, jpoint, 0);
@@ -557,8 +575,6 @@
*(point+1) += GTK_WIDGET(ptr)->allocation.y;
(*env)->ReleaseIntArrayElements(env, jpoint, point, 0);
-
- gdk_threads_leave ();
}
/*